Skip to content

Skip mark-positioning lookups with null anchors instead of crashing#374

Open
lehni wants to merge 1 commit into
foliojs:masterfrom
lineto:fix/null-gpos-anchor
Open

Skip mark-positioning lookups with null anchors instead of crashing#374
lehni wants to merge 1 commit into
foliojs:masterfrom
lineto:fix/null-gpos-anchor

Conversation

@lehni
Copy link
Copy Markdown

@lehni lehni commented May 20, 2026

GPOS subtables (Lookup Types 4, 5, 6) may legally contain NULL anchor offsets per the OT spec — they mean "no anchor for this base/ligature/mark class in this lookup", which the layout engine should treat as a no-op rather than an error.

GPOSProcessor.applyAnchor currently dereferences both baseAnchor and markRecord.markAnchor without guarding against null, so any font that ships a NULL anchor crashes with TypeError: Cannot read properties of null (reading 'xCoordinate') during shaping.

Add an early-return null check in applyAnchor, matching HarfBuzz's behaviour (MarkBasePosFormat1.hh and friends silently skip the application when the anchor is null).

Test

Added the hinted Noto Sans Malayalam (NotoSansMalayalam-Hinted.ttf, SIL OFL) which ships 189 NULL anchors. Layout of പുസ്തകം reaches the null path and used to throw; the assertion now matches HarfBuzz's output exactly.

Resolves #367.

@lehni lehni force-pushed the fix/null-gpos-anchor branch from 8e6fe5c to 00519d6 Compare May 20, 2026 17:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant