HarfRust
HarfRust is a Rust port of HarfBuzz text shaping engine. See Major changes below for major differences between HarfRust and HarfBuzz.
HarfRust started as a fork of RustyBuzz to explore porting from ttf-parser to
read-fonts to avoid shipping (and maintaining)
multiple implementations of core font parsing for skrifa consumers.
Further context in https://github.com/googlefonts/fontations/issues/956.
Matches HarfBuzz v11.3.3.
Why?
https://github.com/googlefonts/oxidize outlines Google Fonts motivations to try to migrate font production and consumption to Rust.
Major changes
- No font size property. Shaping is always using UnitsPerEm. You should scale the result manually.
- Most of the font loading and parsing is done using
read-fonts. - HarfRust doesn't provide any integration with external libraries, so no FreeType, CoreText, or Uniscribe/DirectWrite font-loading integration, and no ICU, or GLib Unicode-functions integration, as well as no
graphite2library support. morttable is not supported, since it's deprecated by Apple.- No
graphitelibrary support.
Conformance
The following conformance issues need to be fixed:
- HarfRust does not yet fully pass the HarfBuzz shaping or fuzzing tests
- Malformed fonts will cause an error. HarfBuzz uses fallback/dummy shaper in this case.
- No Arabic fallback shaper. This requires the ability to build lookups on the fly. In HarfBuzz (C++) this requires serialization code that is associated with subsetting.
avar2as well as other parts of the boring-expansion-spec are not supported yet.
Performance
At the moment, performance isn't that great. HarfRust can be 3x slower than HarfBuzz.
See benches/README.md for details.
Notes about the port
HarfRust is not a full port of HarfBuzz. HarfBuzz (C++ edition) can roughly be split into 6 parts:
- shaping, ported to HarfRust
- Unicode routines, ported to HarfRust
- font parsing, handled by
read-fonts - subsetting, handled by
klippa - custom containers and utilities (HarfBuzz doesn't use C++ standard library), reimplemented in
fontationswhere appropriate (e.g. int set) - glue for system/3rd party libraries, not ported
Safety
The library is completely safe.
There are no unsafe in this library and in most of its dependencies (excluding bytemuck).
Developer documents
For notes on the backporting process of HarfBuzz code, see docs/backporting.md.
For notes on generating state machine using ragel, see docs/ragel.md.
The following HarfBuzz studies are relevant to HarfRust development:
- 2025 - Introducing HarfRust
- 2025 – Caching
License
HarfRust is licensed under the MIT license.
HarfBuzz is licensed under the Old MIT