Repository navigation
Honour user alternateNumber in GSUB Type 3 substitutions - #371
Merged
blikblum merged 1 commit intoOct 23, 2026
Merged
Conversation
lehni
force-pushed
the
feature/gsub-type3-alternate-number
branch
2 times, most recently
from
October 21, 2026 22:10
c1abc1f to
45d36e2
Compare
Member
|
@lehni please fix the conflicts |
lehni
force-pushed
the
feature/gsub-type3-alternate-number
branch
from
October 22, 2026 23:29
45d36e2 to
26b7f74
Compare
Contributor
Author
|
@blikblum Rebased onto master, conflicts resolved. |
Member
|
I tried to fix conflict manually without success |
- Type 3 hardcoded USER_INDEX = 0; `nalt: 2` silently rendered as alt #1 - Thread user features through ShapingPlan so GSUB reads the 1-based index - Don't mutate caller's features in OTLayoutEngine.setup; overlay instead
Contributor
Author
|
@blikblum The merge lost the closing lines of the default ignorables tests. I've rebased onto master again instead. |
lehni
force-pushed
the
feature/gsub-type3-alternate-number
branch
from
October 23, 2026 04:18
a8d1d72 to
c7344dc
Compare
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 GSUB Type 3 (Alternate Substitution) hardcodes the alternate index to 0, so user-supplied alternateNumber values (e.g.
font.layout(text, { aalt: 2 })) are silently ignored and every aalt/nalt/etc. request resolves to the first alternate. This makes Type 3 features effectively read-only from a caller's perspective.This PR:
ShapingPlanso processors can read per-feature integer values without losing them to the shaper plan'strue/falsenormalisation.OTLayoutEngine.setupto overlay the user's original values onto the chosen-features map without mutating the caller's input object.GSUBProcessorType 3 now readsuserFeatures[currentFeature]as a 1-based alternate index, falls back to the first alternate when no value is given or the requested index is out of range.Test: FiraSans's aalt lookup carries multiple alternates per coverage entry. For 'A' (glyph 3) the alternate set is
[1078 'ordfeminine', 764 'a.sc']. The added test shapes 'A' with{ aalt: true }and{ aalt: 2 }and asserts the correct glyph ID for each — matching what HarfBuzz produces for--features='aalt=1'vs--features='aalt=2'.