Repository navigation
This release matches HarfBuzz v14.5.1, and has an MSRV (minimum supported Rust version) of 1.85.
Breaking changes
- Replace
UnicodeBufferandGlyphBufferwith oneBufferthat holds input
Unicode code points before shaping and glyphs afterward.ContentType
reports which state the buffer is in. The old buffer types and their
conversion methods have been removed. - Replace the
FontRefentry point withFontfromread-fonts, re-exported
asharfrust::Font. Create aShaperFontfrom aFont(or one of its
instances) before shaping. - Replace the old
Shaper,ShaperBuilder,ShaperInstance, andShaperData
API withShaperFont. - Configure scale and custom
FontFuncsonShaperFontinstead of
ShapeOptions. - Shape in place with
harfrust::shape(&shaper_font, &mut buffer, options).
It returnsResult<(), ShapeError>for invalid shaping state or properties,
rather than returning a separate glyph buffer. Check
Buffer::allocation_successful()separately for allocation or shaping-limit
failure.
Migration
Replace UnicodeBuffer construction and the returned GlyphBuffer with a
single mutable Buffer. For example, with font_data containing font bytes:
use harfrust::{shape, Buffer, Font, ShapeOptions, ShaperFont};
let font = Font::new(font_data, 0).expect("invalid font");
let shaper_font = ShaperFont::new(&font);
let mut buffer = Buffer::new();
buffer.push_str("Hello");
buffer.guess_segment_properties();
shape(&shaper_font, &mut buffer, ShapeOptions::new()).expect("shaping failed");
let glyphs = buffer.glyph_infos();
let positions = buffer.glyph_positions();Use buffer.clear() to reuse its allocation for another run, then push new
text. Call guess_segment_properties() or set the direction and other segment
properties explicitly before shaping.
Use ShaperFont::set_scale or set_scale_separate for scaling, and
ShaperFont::set_font_funcs for custom font callbacks. ShaperFont borrows the
Font and any supplied callbacks, so it is intended as a short-lived shaping
view; keep the Font and callbacks alive and construct a ShaperFont as needed.
ShapeOptions holds per-call features, an optional plan, and point size.
Other changes
- Update
read-fontsto 0.45.0 and use its current font model API. - Update the built-in Unicode data to 18.0. Add Jurchen, Proto-Cuneiform, and
Seal script constants to the Rust and C APIs and route them through USE. - Treat U+180F as default ignorable during shaping.
- Support hexadecimal OpenType language and script overrides in
x-hbot-
andx-hbsc-private-use subtags, such asx-hbot-4d4f4e54forMONT. - Expose Unicode composition, one-step canonical decomposition, and canonical
combining classes through the publicharfrust::unicodemodule.
Decomposition returns aDecomposedenum. - Add the
harfrust_capicrate, a C API mirroring the shaping half of
HarfBuzz's API with anhr_prefix in place ofhb_. - Speed up repeated
hr-shaperuns and contextual lookup matching. - Reduce OpenType subtable cache memory by boxing the two large contextual
cache variants. - Leave a GPOS mark unattached when it is more than 32767 glyphs from its base,
as HarfBuzz does, instead of storing a truncatedattach_chainthat
mispositioned the mark. - Fix
would_applyfor format 3 (coverage-based) contextual lookups, which
never matched, so the Indic shaper missed features built from them. Noto Sans
Bengali's ra-phala (e.g. গ্র) came out as consonant, visible hasant and ra.