fix(textkit): preserve variation selector font runs#3454
Open
to-na wants to merge 1 commit into
Open
Conversation
🦋 Changeset detectedLatest commit: 01d97f1 The changes in this PR will be included in the next version bump. This PR includes changesets to release 9 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
to-na
marked this pull request as ready for review
July 16, 2026 08:42
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.
What changed
Variation_Selectorproperty ranges with regression tests.@react-pdf/textkit.Why
A variation selector modifies the glyph selection of its preceding character and should not be assigned a fallback font independently. Splitting the sequence across font runs prevents the font layout engine from receiving the base character and selector together, and an unsupported selector can consequently appear as a visible fallback glyph.
Observable behavior
When a font supports the base character but not the following variation selector as a standalone glyph, font substitution can assign the selector to a fallback font. This splits the variation sequence across two font runs.
As a result, text such as 漢\uFE00 or 手\u{E0100} can display an extra fallback glyph—such as an @-like mark—over or next to the base character.
After this change, the base character and variation selector remain in the same font run. This allows the font shaping engine to process them as a single variation sequence, or to render the default form of the base character when the requested variation is unsupported.
Verification
yarn vitest packages/textkit/tests --run(92 files, 787 tests)yarn workspace @react-pdf/textkit typecheckyarn workspace @react-pdf/textkit buildyarn eslint packages/textkit/src/engines/fontSubstitution/index.ts packages/textkit/tests/engines/fontSubstitution.test.ts