pretext icon indicating copy to clipboard operation
pretext copied to clipboard

Required ligatures that match across a space measure a word too wide

Open mordechaim opened this issue 1 month ago • 0 comments

Some Hebrew display fonts (the Lia family; copyrighted, I can send one by email) ligate a word-final letter under ccmp/calt only when a following letter is in the same shaping buffer. HarfBuzz's lookup passes over the space, so in Chrome the final form appears whenever another word follows. Pretext measures each segment alone, gets the standalone form, and reports the word wider than Chrome lays it out, so lines wrap one word early. Kerning is not involved: fontKerning = 'none' changes nothing, and the per-character space-kerning probe cannot see it because the effect depends on the next letter, not the space.

In my fork I measure a text segment together with a short following context (one grapheme per following segment, through spaces up to the first letter) and attribute measure(seg + ctx) − measure(ctx) to the segment, cached on the same per-font map. It stands aside where a profile already models the boundary (Chrome's space kerning, Safari's measurement with the following space, Blink's han kerning) and ignores pairs with emoji.

Commit: codaworks/pretext@0f517cbb, with a test. Related: #524 (the direction option this needs for RTL text).

mordechaim avatar Oct 15 '26 03:10 mordechaim