Repository navigation
Conversation
wrapWords hyphenates each run on its own, so a word that continues into the next run (a period after a nested <Text>) ended up as two syllables with no space between them. The line breaker treats every such boundary as a hyphenation point, so the period could wrap alone and the previous line gained a hyphen, even with hyphenation disabled. Join the first word of a run to the previous syllable when neither side is whitespace. Fixes diegomura#3619 Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
@adarshsm 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: 7e20b8c 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 #3619. Also covers the same break described in #3462.
Problem
A word that continues across a text run boundary can break there. With
<Link><Text>Appendix</Text></Link>.in a narrow box,Appendixfits andAppendix.doesn't, so the line is rendered asAppendix-followed by a lone.. It still happens when hyphenation is turned off withFont.registerHyphenationCallback((word) => [word]).Root cause
wrapWordshyphenates each run separately and concatenates the syllables.Appendixand.come from different runs, so there is no space syllable between them. In the line breaker'sgetNodes, every syllable whose successor isn't a single space gets a hyphenation penalty, so the run boundary became a break opportunity with a hyphen glyph. The hyphenation callback can't prevent it because it never sees both runs.Fix
In
wrapWords, when the first word of a run directly continues the last syllable of the previous run (no whitespace on either side), join them into one syllable. The run boundary is then no longer a break or hyphenation point; hyphenation points the callback returns inside each run are kept.Side effect: a word split across two styled runs (
Hel+ boldlo) can no longer be hyphenated exactly at the style change. Before, that was the only place it could be hyphenated, by accident.Tests
should not split a word that continues across runsinpackages/textkit/tests/layout/wrapWords.test.ts. It fails without the change (['See', ' ', 'Appendix', '.', ...]) and passes with it.packages/textkitandpackages/layoutsuites pass (782 and 424 tests). 5 files in each fail to load here becausebidi-js/@react-pdf/paginatearen't installed in my checkout; they're unrelated and fail the same way without my change.wrapWordslevel and did not render a PDF.🤖 Generated with Claude Code