Skip to content

Add Hebrew shaper, ported from HarfBuzz - #375

Merged
blikblum merged 1 commit into
foliojs:masterfrom
lineto:feature/hebrew-shaper
Oct 18, 2026
Merged

blikblum merged 1 commit into
foliojs:masterfrom
lineto:feature/hebrew-shaper

Conversation

@lehni

@lehni lehni commented May 20, 2026

Copy link
Copy Markdown
Contributor

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.

@lehni
lehni force-pushed the feature/hebrew-shaper branch from 07d759d to fbc7406 Compare May 20, 2026 20:19
@lehni
lehni force-pushed the feature/hebrew-shaper branch from fbc7406 to 5e49b8b Compare October 18, 2026 16:03
@blikblum

Copy link
Copy Markdown
Member

Please resolve the conflicts

- 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 5e49b8b to 2ff8b20 Compare October 18, 2026 16:27
@lehni

lehni commented Oct 18, 2026

Copy link
Copy Markdown
Contributor Author

@blikblum done!

@blikblum
blikblum merged commit 62915e8 into foliojs:master Oct 18, 2026
3 checks passed
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.

2 participants