Skip to content

fix(text): honour letter-spacing when breaking lines - #132

Merged
LeadcodeDev merged 1 commit into
mainfrom
fix/letter-spacing-wrap
Aug 2, 2026
Merged

fix(text): honour letter-spacing when breaking lines#132
LeadcodeDev merged 1 commit into
mainfrom
fix/letter-spacing-wrap

Conversation

@LeadcodeDev

Copy link
Copy Markdown
Owner

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.

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
@LeadcodeDev
LeadcodeDev merged commit 34faaa1 into main Aug 2, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(text): honour letter-spacing when breaking lines, and resolve relative units

1 participant