* [raster] Bound embedded PNG dimensions before decoding hb_raster_paint_image() handed a font's embedded sbix/CBDT PNG to deserialize_from_png(), which allocated and filled the whole image at whatever size the PNG's IHDR declared (up to two buffers at the 1 GiB HB_RASTER_MAX_BUFFER_SIZE cap each), and only charged src_width * src_height against the pixel budget after the decode had finished. A 33 KB sbix font with a blank 16384x16384 1-bit PNG therefore made the raster backend allocate and touch ~2 GiB of memory per painted glyph, independent of the requested output size. Surfaces whose size comes from font data are already clamped to HB_RASTER_MAX_AUTO_DIMENSION (4096 per side); the PNG decoder was not. deserialize_from_png() gains a max_dimension parameter checked right after png_get_IHDR(), before any allocation, and the paint callback passes HB_RASTER_MAX_AUTO_DIMENSION. The public hb_raster_image_deserialize_from_png_or_fail() keeps its INT_MAX behaviour through the default argument, matching the limit's documented intent that explicitly requested sizes are not bounded. With the cap a decode is at most 16M pixels, whose cost fits the 2^26 pixel budget, so the later charge_work() is adequate. Behaviour change: sbix/CBDT PNG glyphs wider or taller than 4096 pixels are no longer painted by the raster backend (the callback returns false, as for any undecodable image). The cairo backend has the same weakness on a different code path and was already fixed separately (#6497). test_image_png_size() in test/api/test-raster.cc paints a 4096- and a 4097-pixel-wide PNG and checks that only the former lands; it fails on the unpatched library. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-ENME4ECM. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * [raster] Charge the scanline sweep to the pixel budget hb_raster_draw_render() walks every active edge once per pixel row it spans, a product (edges times rows) that neither HB_RASTER_MAX_DRAW_EDGES (2^20) nor HB_RASTER_MAX_AUTO_DIMENSION (4096 rows) bounds, and that nothing charged: the outline budget only sees traversal and curve flattening. A 10 KB glyf font of 199,800 full-height straight edges therefore cost tens of seconds of CPU for a single render. PR #6244 added the precharge for the paint path but sized it by the paint *surface*, which comes from the font's declared glyph extents, while the mask rasterizer auto-sizes the mask from the outline itself; a 1x1 ClipBox or empty bounding box slipped the full-height sweep past it. The direct draw path had no check at all. This charges the sweep inside hb_raster_draw_render(), where the extents really rendered are known, estimating it with the existing hb_raster_draw_get_pixel_work() helper, now clamped to those extents (the fixed ones, else the 4096 auto cap) rather than taking them as arguments. The sweep is skipped when the estimate exceeds the per-session pixel allowance raster-paint already uses, max(HB_BUDGET_RASTER_PIXELS, HB_BUDGET_RASTER_PAINT_PASSES * width * height). The two paint callers now use the mask-relative estimate, and hb_raster_paint_attach_clip_rdr() seeds HB_BUDGET_UNLIMITED into the mask rasterizer when the paint policy is unlimited, so opting out of limits still disables the check. hb_raster_draw_get_pixel_work() is HB_INTERNAL, so dropping its two arguments changes no public API/ABI. Behaviour change: an over-budget render returns a blank image of the computed size (documented in the API comment) rather than NULL. Letting HB_BUDGET_UNLIMITED switch the check off matches the paint pixel budget's semantics and keeps the edge and dimension caps active; whether this bound should instead be an unconditional structural cap is a maintainer's choice. Testing: the finding's reproducer flips from BUG to OK, its attack render dropping from ~39 s to 0.05 s of CPU while the control is unchanged; the api suite passes under both the optimized and the ASan/UBSan build. test_budget_sweep in test/api/test-raster.cc covers the direct draw path with auto and fixed extents and the small-surface paint-clip path. Discovered by Anthropic's OSS Scanner, as vulnerability ANT-2026-8PTXE0MD. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
HarfBuzz
HarfBuzz started as a text shaping engine but has grown into a
full font platform — the ffmpeg of text shaping. It primarily
supports OpenType, but also Apple Advanced Typography.
HarfBuzz shapes the majority of text on modern screens.
HarfBuzz is optimized for robustness, correctness, and performance — in that order. Achieve all.
Try it live at harfbuzz-world.cc — an interactive playground for shaping, subsetting, rasterization, vector output, and GPU rendering, all running in your browser.
Here is a quick map of its components:
Core libraries
| Library | Description |
|---|---|
| libharfbuzz | Text shaping, draw API, paint API. Highly configurable (see CONFIG.md). Optional integration backends compiled in: hb-ft (FreeType), hb-coretext (macOS), hb-uniscribe (Windows), hb-directwrite (Windows), hb-gdi (Windows), hb-glib, hb-graphite2. |
| libharfbuzz-subset | Font subsetting and variable-font instancing. |
Auxiliary libraries
| Library | Description |
|---|---|
| libharfbuzz-icu | ICU Unicode integration. |
| libharfbuzz-cairo | Cairo rendering integration. |
| libharfbuzz-gobject | GObject/GI bindings. |
Rendering libraries
| Library | Description |
|---|---|
| libharfbuzz-raster | Glyph rasterization to bitmaps, including color fonts. Uses hb-draw and hb-paint. |
| libharfbuzz-vector | Glyph output to vector formats (currently SVG), including color fonts. Uses hb-draw and hb-paint. |
| libharfbuzz-gpu | Encodes glyph outlines for GPU rasterization (Slug algorithm). Provides shader sources in GLSL, WGSL, MSL, and HLSL. Live demo. |
Notable missing feature: font hinting (including autohinting) is not implemented. For hinted rasterization, use FreeType or Skrifa.
For simplified builds, amalgamated sources are available:
harfbuzz.cc (just libharfbuzz), harfbuzz-subset.cc (just
libharfbuzz-subset), or harfbuzz-world.cc (everything, driven
by a custom hb-features.h). For a live in-browser playground
plus a worked example of the world.cc single-file build, see
harfbuzz-world.cc.
Command-line tools
| Tool | Description |
|---|---|
| hb-shape | Shape text and display glyph output. |
| hb-view | Render shaped text to an image. |
| hb-subset | Subset and optimize fonts. |
| hb-info | Display font metadata. |
| hb-raster | Render glyphs to bitmap images. |
| hb-vector | Render glyphs to vector formats (SVG). |
| hb-gpu | Interactive GPU text rendering. |
The canonical source tree and bug trackers are available on github. Both development and user support discussion around HarfBuzz happen on github as well.
For license information, see COPYING.
API stability
The API that comes with hb.h will not change incompatibly. Other, peripheral,
headers are more likely to go through minor modifications, but again, we do our
best to never change API in an incompatible way. We will never break the ABI.
The API and ABI are stable even across major version number jumps. In fact, current HarfBuzz is API/ABI compatible all the way back to the 0.9.x series. If one day we need to break the API/ABI, that would be called a new library.
As such, we bump the major version number only when we add major new features, the minor version when there is new API, and the micro version when there are bug fixes.
Documentation
For user manual as well as API documentation, check: https://harfbuzz.github.io
Download
Tarball releases and Win32/Win64 binary bundles are available on the github releases page.
Development
For build information, see BUILD.md.
For custom configurations, see CONFIG.md.
For testing and profiling, see TESTING.md.
For using with Python, see README.python.md. There is also uharfbuzz.
For cross-compiling to Windows from Linux or macOS, see README.mingw.md.
To report bugs or submit patches please use github issues and pull-requests.
Developer documents
To get a better idea of where HarfBuzz stands in the text rendering stack you may want to read State of Text Rendering 2024. Here are a few presentation slides about HarfBuzz over the years:
- 2026 – HarfBuzz at 20!
- 2016 – Ten Years of HarfBuzz
- 2014 – Unicode, OpenType, and HarfBuzz: Closing the Circle
- 2012 – HarfBuzz, The Free and Open Text Shaping Engine
- 2009 – HarfBuzz: the Free and Open Shaping Engine
More presentations and papers are available on behdad's website. In particular, the following studies are relevant to HarfBuzz development:
- 2025 – AAT layout caches
- 2025 – OpenType Layout lookup caches
- 2025 – Introducing HarfRust
- 2025 – Subsetting
- 2025 – Caching
- 2025 –
hb-decycler - 2022 –
hb-iter - 2022 – A C library written in C++
- 2022 – The case of the slow
hb-ft>h_advancefunction - 2022 – PackTab: A static integer table packer
- 2020 – HarfBuzz OT+AAT "Unishaper"
- 2014 – Building the Indic Shaper
- 2012 – Memory Consumption
Name
HarfBuzz /hærfˈbɒːz/
From Persian حرف (Harf: letter) and باز (Buzz: open). Transliteration of the Persian calque for OpenType.
As a noun: The Open Source text shaping engine.
As an adjective: Insincerely talkative; glib. A nod to the GNOME project where HarfBuzz originates from.
The logo shows حرفباز in the IranNastaliq font, on a Damascus steel background.
Background: Originally there was this font format called TrueType. People and companies started calling their type engines all things ending in Type: FreeType, CoolType, ClearType, etc. And then came OpenType, which is the successor of TrueType. So, for my OpenType implementation, I decided to stick with the concept but use the Persian translation. Which is fitting given that Persian is written in the Arabic script, and OpenType is an extension of TrueType that adds support for complex script rendering, and HarfBuzz is an implementation of OpenType text shaping.
Users
HarfBuzz is used in Android, Chrome, ChromeOS, Firefox, Flutter, GNOME, GTK+, KDE, Qt, LibreOffice, OpenJDK, XeTeX, Adobe Photoshop, Illustrator, InDesign, Microsoft Edge, Amazon Kindle, PlayStation, Godot Engine, Unreal Engine, Figma, Canva, QuarkXPress, Scribus, smart TVs, car displays, and many other places.
