Repository navigation
Fix justified text with a negative wordSpacing running past the width - #1863
Open
TheeCoderAhmed wants to merge 1 commit into
Open
TheeCoderAhmed wants to merge 1 commit into
TheeCoderAhmed wants to merge 1 commit into
Conversation
Member
|
Not sure a negative wordSpacing makes sense |
Author
|
It works today and the line wrapper already uses it, so I fixed the overflow. If you don't want to support negative values, I can close this. |
Member
|
I realized that it works although the docs do not make clear it should work |
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.
What kind of change does this PR introduce?
Bug fix. Fixes #1458
With
align: 'justify'and a negativewordSpacing, justified lines run past the width.LineWrappercounts the negative spacing when it decides what fits, so a line can hold more words than it would at normal spacing._fragmentthen works out the justify spacing for that line, gets a negative number, and clamps it to 0 withMath.max(0, ...). The line is drawn with normal gaps and comes out wider thanwidth.The clamp now goes down to the negative
wordSpacingthe caller asked for, so those gaps can shrink. For zero or positivewordSpacingthe lower bound is still 0, so nothing changes there.In the new test, three
aaaawords at 12pt in a width of 85 are 86.736 wide with normal gaps. Before the fix the line is drawn as[<616161612061616161206161616120> 0] TJ, with no adjustment. After it the gaps are 2.468 wide.Checklist:
What I ran:
tests/unit/text.spec.js: the new test failed before the fix and passes after it.vitest --testTimeout 8000 run --exclude "tests/tools/**"(theyarn testcommand, unit and visual): 654 passed.eslintandprettier --checkon the two changed code files.I did not open a generated PDF in a viewer. I checked the TJ output and the tests only, and I did not run the sample from the issue, which needs the Poppins font.