Skip to content

Test a glyph's membership of a GDEF class by the glyph, not by its hex turning up in the class (#193) - #217

Merged
jakejackson1 merged 3 commits into
gravitypdffrom
recover/193-glyph-class-membership
Sep 17, 2026
Merged

jakejackson1 merged 3 commits into
gravitypdffrom
recover/193-glyph-class-membership

Conversation

@jakejackson1

Copy link
Copy Markdown
Member

Closes #193.

This carries PR #205's change to gravitypdf. #205 was merged into its stacked base branch after that branch had already been squash-merged into gravitypdf, so its commits never reached gravitypdf and #193 stayed open. The commits are #205's own, replayed with git rebase --onto and patch-for-patch identical per git range-diff. See #205 for the full description, measurements and review.

🤖 Generated with Claude Code

jakejackson1 and others added 3 commits September 17, 2026 12:48
…x turning up in the class (#193)

GDEF's classes are kept as " 00300| 00301", and every reader asked whether a glyph was in one
with strpos(). GlyphString::of() writes a plane 16 character six digits wide, and a six-digit
glyph holds two five-digit ones: U+100300 is 10030 followed by a 0, and a 1 followed by 00300.
Where a class named U+100300, U+0300 and U+10030 both read as members.

The stored formats do not change. GlyphString gains set(), a list of glyphs keyed by glyph, and
inList(), which finds a glyph only where no hex digit touches it on either side:

- LookupFlag::skips() looks each class up in a set, built once per class.
- Otl builds a set of the marks once per font, and its twenty GlyphClassMarks tests become
  isMark(). The LookupFlag it built per run is kept per font with it. LineBreaking is handed
  the set.
- The mark to base, ligature and mark attachment subtables found the base in a "|"-joined
  Coverage string and took its index as the strpos() offset over six; they look both up in a
  map of hex to Coverage Index.
- `finals`, Shaper\Arabic's backtrack, lookahead and ignore strings, the parser's test of a
  nested lookup's first glyph against a rule position, and OtlDump::positionHolds() go through
  inList().

No font TTFontFile parses can reach this today. It reads no cmap entry at or past U+30000 and
maps a glyph only such an entry reaches into the Private Use Area, so every glyph in a class is
five digits wide. Regenerating every golden master from cold moves none of them.

NotoSans-PlaneSixteenMark-Synthetic shows it all the same. It is Noto Sans 2.007 (OFL 1.1) cut
down in fontTools 4.59.2 to space, A, grave, asciitilde, gravecomb and acutecomb, with u10030
(drawn as A, mapped to U+10030) and u100300 (drawn as gravecomb, mapped to U+100300) added, its
layout tables replaced and name IDs 1, 4 and 6 renamed. GDEF classes gravecomb and u10030 as
bases, acutecomb and u100300 as marks; a 'ccmp' lookup setting IgnoreMarks substitutes grave for
gravecomb, and a 'mark' lookup attaches acutecomb to u10030. Handed the classes as the font
states them, the shaper drew A U+0300 unsubstituted and left the mark in U+10030 U+0301
unattached. It now draws `A grave` and attaches the mark at x -339 from the base's end, as
hb-shape 14.3.1 does.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
…mark attachment Coverage straight from the table (#193)

Otl built the marks into a set of its own beside the LookupFlag that built the same set on the
first IgnoreMarks lookup; LookupFlag::marks() hands out that one, and Otl keeps just the
LookupFlag per font. marksOutsideFilteringSet() reads its mark glyph set through
GlyphString::set(). coverageIndexByHex() was the last reader of _getCoverage(), whose hex list
was cached only to be turned into the index, so the index is built from the table and the list
goes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
)

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@jakejackson1 jakejackson1 added bug Something isn't working create-upstream-pr labels Sep 17, 2026
@jakejackson1
jakejackson1 merged commit 81cdc7a into gravitypdf Sep 17, 2026
27 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working create-upstream-pr

Projects

None yet

Development

Successfully merging this pull request may close these issues.

A five-digit glyph is found inside a plane-16 glyph's hex, so GDEF class tests take it for a member

1 participant