Skip to content

Add Hebrew shaper, ported from HarfBuzz#375

Open
lehni wants to merge 1 commit into
foliojs:masterfrom
lineto:feature/hebrew-shaper
Open

Add Hebrew shaper, ported from HarfBuzz#375
lehni wants to merge 1 commit into
foliojs:masterfrom
lineto:feature/hebrew-shaper

Conversation

@lehni
Copy link
Copy Markdown

@lehni lehni commented May 20, 2026

fontkit currently has no dedicated Hebrew shaper — Hebrew (hebr script) falls through to DefaultShaper. This PR ports the two Hebrew-specific behaviours from HarfBuzz's hb-ot-shaper-hebrew.cc:

  • Hebrew presentation-form composition: compose base + nikud → FBxx-range precomposed form when the font supports it. Gated on !has_gpos_mark (font without GPOS mark positioning), matching HarfBuzz's compose_hebrew.
  • Mark reordering: when a patah/qamats is followed by a sheva/hiriq followed by a meteg or other below-class mark, swap the latter two so the below mark settles next to the base, matching reorder_marks_hebrew.

Tests

Five tests added under test/shaping.js, ported from HarfBuzz's hebrew-diacritics.tests. Test fixture is Taamey Frank CLM (GPL v2 + font-embedding exception, the same font HB uses in its test suite).

Two of the tests specifically exercise the new reorder path and fail without this shaper registered.

- Compose Hebrew presentation forms (FBxx range) for fonts without GPOS marks, matching `compose_hebrew`; chain compositions step by step (e.g. SHIN + SHIN_DOT + DAGESH → FB2C) instead of bailing after the first match
- Reorder patah/qamats + sheva/hiriq + meteg/below mark triplet by codepoint identity, matching `reorder_marks_hebrew`'s end state for both canonical NFC input and HarfBuzz's modified-CCC pre-reorder order
- Scope the `hasGposMark` gate to the Hebrew script's GPOS features instead of scanning the global featureList, matching HarfBuzz's per-script `has_gpos_mark`
- Add Taamey Frank CLM fixture (GPL v2 + font exception, also used by HB) with 6 shaping tests; reorder tests now exercise real code (each fails with the function disabled)
@lehni lehni force-pushed the feature/hebrew-shaper branch from 07d759d to fbc7406 Compare May 20, 2026 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant