* [ot] Share mark attachment positioning across table widths MarkArray::apply instantiates the same positioning and attachment-chain updates for each mark-array and anchor-matrix representation. Resolve the format-specific anchors in the wrapper and pass them to a common helper. Preserve the anchor checks, buffer flags, messages, and attachment overflow behavior. With GCC 15.3 on x86-64 without LTO, this removes 1576 bytes of core code/read-only data at -O3 and 648 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped) and sampled shaping benchmarks. Assisted-by: OpenAI Codex <codex@openai.com> * [ot] Share cursive attachment positioning across table widths CursivePosFormat1_2 duplicates the direction-dependent positioning and attachment-chain updates for legacy and beyond-64k entry/exit records. Keep record access and anchor validation in the format-specific wrapper, then pass the resolved anchors to a common attachment helper. Preserve all direction cases, chain reversal, overflow handling, and messages. With GCC 15.3 on x86-64 without LTO, this removes another 2760 bytes of core code/read-only data at -O3 and 864 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped) and sampled shaping benchmarks. Assisted-by: OpenAI Codex <codex@openai.com> * [subset] Share mark-class remapping across record widths Mark classes remain 16-bit values in both mark-record representations; only the record stride and array count differ. Decode those in the wrapper and share the class collection and remapping work. Give the common helper hidden inline linkage so its body is shared across translation units as well as record formats. Class ordering, existing mappings, and allocation behavior are preserved. With GCC 15.3 on x86-64 without LTO, this removes 1152 bytes of subset code/read-only data at -O3 and 1440 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped) and subset benchmarks. Assisted-by: OpenAI Codex <codex@openai.com> * [subset] Share SinglePos serializers across source formats SinglePos output serializers only need the source value format and ValueBase pointer, but carried the full source lookup type through several template layers. The per-glyph mapper also had distinct lambda types for legacy and beyond-64k source tables. Pass the source format and base directly, and use a common mapper with the same reference captures as the original lambda. Output formats, device offsets, value copying, and allocation behavior are preserved. With GCC 15.3 on x86-64 without LTO, this removes 18080 bytes of subset code/read-only data at -O3 and 9472 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped) and subset benchmarks. Assisted-by: OpenAI Codex <codex@openai.com> * [subset] Share delta substitution subset serialization SingleSubstFormat1_3 constructs equivalent remapping iterators in each source-format specialization, giving the output and coverage serializers distinct iterator types and duplicating their bodies. Move the subset preparation into a common helper taking the decoded coverage, delta, and glyph mask. Preserve the glyph intersection, modular delta calculation, remapping, and serializer failure behavior. With GCC 15.3 on x86-64 without LTO, this removes 11896 bytes of subset code/read-only data at -O3 and 5776 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped) and subset benchmarks. Assisted-by: OpenAI Codex <codex@openai.com> * [ot] Share SinglePos optical-bound context setup SinglePos position_single duplicates the temporary apply context and value application for each source representation. Keep coverage and value-index checks in the wrappers and share the context setup through ValueFormat, passing the original value base explicitly. With GCC 15.3 on x86-64 without LTO, this removes 2088 bytes of core code/read-only data at -O3 and 616 bytes at -Os. Optical-bound benchmarks show no consistent slowdown across the four source formats. Validated with the full Meson suite (292 passed, one skipped) and synthetic optical-bound checks for all directions, 16/24-bit glyph IDs, missing glyphs, and device adjustments. Assisted-by: OpenAI Codex <codex@openai.com> * [subset] Share retained mark-anchor index collection Mark-to-base and mark-to-mark variation collection construct the same row-major anchor-index lists, but do so inside each table-width template. Pass the decoded row and class counts to a common collector. Preserve coverage filtering, class selection, index order, and the existing vector allocation behavior. Anchor access remains in the format-specific wrappers. With GCC 15.3 on x86-64 without LTO, this removes 2896 bytes of subset code/read-only data at -O3 and 2152 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped) and variable-font subset benchmarks. Assisted-by: OpenAI Codex <codex@openai.com> * [ot] Share delta substitution glyph traversal across widths Closure, dependency extraction, and glyph collection for delta substitutions only need a decoded coverage, delta, and glyph mask. Share those traversals instead of instantiating them for each source representation. Keep the closure population and overlapping-range guards, dependency bounds filtering, traversal order, and allocation behavior unchanged. With GCC 15.3 on x86-64 without LTO, this removes 1112 bytes of core and 952 bytes of subset code/read-only data at -O3, and 608/712 bytes at -Os. Validated with the full Meson suite (292 passed, one skipped), C++11 syntax checking, and subset benchmarks. Assisted-by: OpenAI Codex <codex@openai.com> * [subset] Share pair-position variation-index collection Resolve the table-width-dependent PairPos fields before collecting variation indices. Share the class sets and matrix traversal between the small and beyond-64k formats while retaining the original value base for device offsets. Saves 3328 bytes at -O3 and 2312 bytes at -Os in the subset library with GCC 15.3 without LTO. The full test suite passes, including the HB_NO_BEYOND_64K build; variable-font subset timings remain close. Assisted-by: OpenAI Codex <codex@openai.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. |
Experimental 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.
