talira

HarfBuzz

The open source text shaping engine

open sourceMIT-Modern-Variantfree

HarfBuzz is a text shaping library: it turns a run of Unicode text and a font into correctly chosen and positioned glyphs for any writing system, applying OpenType layout (and Apple Advanced Typography and Graphite) so that Arabic joins, Indic scripts reorder and ligatures and kerning come out right. It has grown into a font platform: libharfbuzz-subset subsets fonts and instances variable fonts, and newer libraries rasterize glyphs to bitmaps, write them as SVG or PDF, or encode them for GPU rendering, with integrations for FreeType, Cairo, CoreText, DirectWrite, ICU and GObject. Command-line tools (hb-shape, hb-view, hb-subset, hb-info) come with it. Its API and ABI have stayed compatible since the 0.9 series. Android, Chrome, Firefox, GNOME, Qt, LibreOffice, Flutter and Adobe's apps use it. HarfRust is its Rust port.

Problems it solves

  • render Arabic, Hindi or Thai text correctly in my app, not as disconnected letters
  • turn a Unicode string and a font file into positioned glyphs for my text renderer
  • apply OpenType ligatures, kerning and font features when I draw text
  • subset a font to only the characters my web page or PDF uses
  • instance a variable font at a fixed weight to make a smaller static font
  • rasterize glyphs, including color emoji fonts, without depending on a platform's text APIs
  • render text on the GPU from glyph outlines
  • shape text from the command line to debug how a font renders a string

Features

  • OpenType, Apple Advanced Typography (AAT) and Graphite shaping
  • Font subsetting and variable-font instancing (libharfbuzz-subset)
  • Glyph rasterization to bitmaps, including color fonts (libharfbuzz-raster)
  • Glyph output to SVG and PDF (libharfbuzz-vector)
  • GPU glyph rendering with GLSL, WGSL, MSL and HLSL shaders (libharfbuzz-gpu)
  • Integrations with FreeType, CoreText, DirectWrite, Uniscribe, Cairo, ICU and GObject
  • Command-line tools: hb-shape, hb-view, hb-subset, hb-info, hb-raster, hb-vector
  • Stable API and ABI back to the 0.9.x series
  • Single-file amalgamated builds (harfbuzz.cc, harfbuzz-world.cc)
  • Python bindings (uharfbuzz)

Limitations

  • Doesn't do font hinting or autohinting: use FreeType or Skrifa for hinted rasterization1
  • Doesn't do bidirectional text reordering (bidi): apply the Unicode bidi algorithm with ICU or FriBidi first2
  • Doesn't do line breaking, hyphenation or justification: it shapes text along a single line2

Capabilities

Has a command line toolplan not known
Has official SDKsplan not known

Alternatives

The same job

These do what HarfBuzz does.

  1. HarfRust A Rust port of the HarfBuzz text shaping engine.
  2. subsetter Reduces the size and coverage of OpenType fonts.

Compare HarfBuzz with the top 3