Add support for GSUB Type 8 (Reverse Chaining Contextual Single Substitution)#370
Open
lehni wants to merge 1 commit into
Open
Add support for GSUB Type 8 (Reverse Chaining Contextual Single Substitution)#370lehni wants to merge 1 commit into
lehni wants to merge 1 commit into
Conversation
…itution) - Fix the GSUB Type 8 struct to include the missing `backtrackGlyphCount` field; without it the binary reader couldn't decode the table at all - Implement Type 8 application in GSUBProcessor: check coverage at the current glyph, verify backtrack + lookahead context, replace the glyph with `substitutes[coverageIndex]` on match - Iterate Type 8 lookups right-to-left in OTProcessor's applyLookups (per spec) so lookahead always sees post-substitution glyphs and backtrack sees the pre-substitution ones - Add Noto Coptic as a test fixture (its ccmp feature uses Type 8; without this fix any Coptic layout throws "GSUB lookupType 8 is not supported")
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fontkit's GSUBProcessor currently throws "GSUB lookupType 8 is not supported" when it encounters a Reverse Chaining Contextual Single Substitution lookup. This affects fonts whose default
ccmporcaltfeatures include Type 8 — for example, Noto Sans Coptic, where the failure prevents any layout call from succeeding.This PR:
backtrackGlyphCountfield meant the binary reader couldn't decode the table. Also renamessubstitutes→substitute(LazyArray) to match the Type 1 v2 convention in the same file.GSUBProcessor: check coverage at the current glyph, verify backtrack + lookahead context, replace the glyph withsubstitute.get(coverageIndex)on match.OTProcessor.applyLookups(per the OpenType spec) so lookahead context always sees post-substitution glyphs and backtrack sees pre-substitution ones.uni0305→uni0305.cap(glyph 199) when followed by another macron in the run.Spec reference: https://learn.microsoft.com/en-us/typography/opentype/spec/gsub#82-reverse-chaining-contextual-single-substitution-format-1
Resolves #365.