Skip to content

0.14.0

Latest

Choose a tag to compare

@dfrg dfrg released this 04 Oct 01:40
· 29 commits to main since this release
Immutable release. Only release title and notes can be modified.
3fbac46

This release matches HarfBuzz v14.5.1, and has an MSRV (minimum supported Rust version) of 1.85.

Breaking changes

  • Replace UnicodeBuffer and GlyphBuffer with one Buffer that 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 FontRef entry point with Font from read-fonts, re-exported
    as harfrust::Font. Create a ShaperFont from a Font (or one of its
    instances) before shaping.
  • Replace the old Shaper, ShaperBuilder, ShaperInstance, and ShaperData
    API with ShaperFont.
  • Configure scale and custom FontFuncs on ShaperFont instead of
    ShapeOptions.
  • Shape in place with harfrust::shape(&shaper_font, &mut buffer, options).
    It returns Result<(), 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-fonts to 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-
    and x-hbsc- private-use subtags, such as x-hbot-4d4f4e54 for MONT.
  • Expose Unicode composition, one-step canonical decomposition, and canonical
    combining classes through the public harfrust::unicode module.
    Decomposition returns a Decomposed enum.
  • Add the harfrust_capi crate, a C API mirroring the shaping half of
    HarfBuzz's API with an hr_ prefix in place of hb_.
  • Speed up repeated hr-shape runs 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 truncated attach_chain that
    mispositioned the mark.
  • Fix would_apply for 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.