fix(text): honour letter-spacing when breaking lines - #132
Merged
Conversation
The fit test that decides where a line breaks measured with zero tracking while every consumer measured the resulting lines with the real value, so measurement and paint no longer shared a fixed point: the box was sized for one line, paint decided two were needed, and left-aligned them in a box sized for one. Measured on a centred headline, frame centre 960: at 290px with -9px tracking the ink centre sat at 552, a 408px error, and the validator called the scenario clean whenever the text carried an explicit height — it re-measures through the same intrinsic and inherited the same blind spot. At 240px a negative tracking, which makes the string narrower, gained it a break it did not have at zero. Wrapping now takes the tracking. All four sweep rows converge on the frame centre, and the spurious breaks are gone. This matters because tight negative tracking on large type is the defining trait of the register this project targets — it was the one thing that could not be expressed. gradient_text turned out to drop letter-spacing entirely: it was hardcoded to zero at wrap, at width measurement and at draw, while its intrinsic sized the box with the real value. Fixing only the wrap would have replaced one mismatch with another, so all three now agree. Relative units are the same defect one layer down: em, rem, vw and vh parse cleanly and are then discarded by Length::px(), which returns 0 — indistinguishable from a deliberate zero, and advertised as valid by the exported schema. A scenario sized in vw rendered a black frame and exited 0. They now resolve through a LengthContext where one is reachable, and warn loudly where it is not. em on font-size itself still needs a resolved parent size from the cascade; that is left, and documented, rather than half-done. All seven tracked examples render pixel-identically. Closes #125
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.
Closes #125. Part of the chantier #123.
Independent of the other six workstreams: disjoint file set, compiles and tests green on its own against
main. Mergeable in any order.Full rationale, measurements and evidence are in the commit message and in #125.