Repository navigation
fix(textkit): merge flattened runs in input order - #3614
Open
iliev-blnk wants to merge 1 commit into
Open
iliev-blnk wants to merge 1 commit into
iliev-blnk wants to merge 1 commit into
Conversation
flatten merged the active runs in the order they started, so a run starting mid-string overrode every run that was already open. Since preprocessRuns stopped omitting the font from the original runs and put the substitution runs last instead, any text fragment after the first one brought back the raw font stack, and characters missing from its first font rendered as .notdef. Keep the active runs sorted by input index, so later runs win wherever they start. Removing runs by index also stops two runs that share an attributes object from both ending at the first one's end. Fixes diegomura#3552
|
@iliev-blnk is attempting to deploy a commit to the diegomura Team on Vercel. A member of the Team first needs to authorize it. |
🦋 Changeset detectedLatest commit: abc34f4 The changes in this PR will be included in the next version bump. This PR includes changesets to release 8 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 |
This branch has not been deployed
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.
Fixes #3552
Cause
flattenRegularRunsmerged the open runs in the order they were pushed onto the stack, which is the order they start in. A run that starts mid-string therefore overrode every run that was already open.Before #3527, that didn't matter for fonts:
preprocessRunsremovedfontfrom the original runs (omitFont). #3527 dropped that pass and movedsubstitutedRunsto the end of the list instead, so that the substituted font would win. Butflattennever looked at list order. For the first fragment of a<Text>the substitution run is pushed last, and it wins. Every later fragment starts mid-string, gets pushed after the substitution run covering it, and brings back the raw font stack. Characters missing from the stack's first font then render as.notdef.Fix
The stack now holds run indices kept in input order, so a later run in the list overrides an earlier one wherever each starts. That is the precedence
preprocessRunsalready assumes. Attributes are still merged only when a segment is emitted (#3524).Ending a run now removes it by index rather than by
attributesidentity. Before, two runs sharing anattributesobject both left the stack when the first of them ended.Repro
The issue's script (
fontFamily: ['NoPercent', 'Latin'], where the first font has no%):two fragments: 69□two fragments: 69%pdftotexton master givestwo fragments: 69; with this change it givestwo fragments: 69%.Tests
flatten: a later run overrides an earlier one that starts before it; runs sharing anattributesobject.preprocessRuns: substituted attributes win over original runs that start mid-string.vitest run: 247 files, 3669 tests passing.