A Rust port of the HarfBuzz text shaping engine.
open sourceMITself-hostablefree
HarfRust is the HarfBuzz project's port of its text shaping engine to Rust: it turns a run of Unicode text and an OpenType font into positioned glyphs, applying the font's GSUB and GPOS rules and the script-specific shapers for Arabic, Indic, Khmer, Myanmar, Hangul and others. It started as a fork of RustyBuzz, reads fonts with read-fonts from Google's fontations (the parser under Skrifa), tracks a specific HarfBuzz release and mostly passes HarfBuzz's own test and fuzzing suites. The library has no unsafe code. A C API (harfrust_capi) mirrors HarfBuzz's shaping API with an hr_ prefix, and the hr-shape command-line tool shapes text and can trace each shaping step.
Problems it solves
- shape Arabic, Hindi or Thai text into correctly joined and reordered glyphs in pure Rust
- turn a Unicode string and an OpenType font into glyph IDs and positions for my renderer
- apply kerning, ligatures and OpenType features like small caps when laying out text in Rust
- replace HarfBuzz C bindings in my Rust app with memory-safe code that gives the same shaping
- my PDF generator draws Devanagari and Arabic text with broken letterforms
- shape text against variable fonts at specific axis settings in Rust
- a no_std text shaping engine for an embedded or WebAssembly target
- debug why a font shapes a string wrongly by tracing every lookup applied
- call a memory-safe HarfBuzz-compatible shaper from C or C++ code
- shape text from the command line to compare glyph output between fonts
Features
- port of HarfBuzz's shaping and Unicode routines, tracking a named HarfBuzz release
- OpenType GSUB and GPOS layout with script-specific shapers
- fonts parsed with read-fonts from fontations, shared with skrifa
- variable font support through font variation coordinates
- opt-in tracing of every shaping step, compatible with no_std
- hr-shape command-line tool with a --trace option
- C API (harfrust_capi) mirroring HarfBuzz's hb_ API as hr_, linkable alongside HarfBuzz
- passes most of HarfBuzz's test and fuzzing suites
- no unsafe code in the library
- no_std support with libm
Limitations
- Doesn't support Graphite fonts: only OpenType shaping is ported from HarfBuzz1
- Doesn't take a font size: shaping always works in font units (units per em) and you scale the results yourself1
- Doesn't integrate with FreeType, CoreText, DirectWrite, ICU or GLib: fonts are parsed with read-fonts and the Unicode functions are its own1
- Doesn't fall back on malformed fonts: it returns an error where HarfBuzz uses a fallback shaper1
- Doesn't subset fonts: HarfBuzz's subsetter is ported separately as skera in fontations1
Capabilities
| Has a command line tool | plan not known |
|---|---|
| Has official SDKs | plan not known |
