* Fix inter-word justification distribution and safety
TextAlignment.Justify was incorrect or a no-op in several common cases.
This corrects glyph targeting, buffer safety, run partitioning, the fill
target, and which lines get justified.
- Target the glyph ending each break boundary; step zero-width breaks
(CJK/Korean ideograph boundaries, hyphens) back one so the widened gap
sits on the break and the last visible glyph is never stretched.
- Copy-on-write the shaped buffer before adjusting advances and swap in a
fresh run, so justification never mutates glyph storage shared with a
TextRunCache entry, a Split sibling or a WithBidiLevel alias. Adds
ShapedBuffer.CloneWritable and TextLineImpl.ReplaceTextRun, which also
repoints the bidi-reordered runs used by draw and hit-test.
- Consume break opportunities per run instead of draining the whole queue
against the first run.
- Fill the visible Width to the paragraph width rather than the width
including trailing whitespace, so wrapped lines with trailing whitespace
justify instead of being left un-justified.
- Target MaxWidth for wrapped text rather than the widest produced line.
- Skip the last line, newline-terminated lines and hard-break lines.
Adds justification test coverage: CJK, mixed Latin+CJK, Arabic buffer
integrity, Latin wrapping, trailing whitespace and multi-run lines.
* Add failing test for trailing-whitespace overcount across runs
- TextLineImpl.CreateLineMetrics walks a line's runs backward to
compute trailing whitespace, stopping only when a run has none of
its own - not when a run is only partly whitespace.
- On a multi-run line where an interior run also ends in a space
(common at a script boundary, since each script run tends to end at
the following space), that space gets wrongly counted as trailing
too, even though visible content follows it later in the line.
- This shrinks Width, which InterWordJustification uses to decide how
much space a line still needs to reach the target width.
* Fix trailing-whitespace overcount across runs
- Only continue accumulating trailing whitespace from an earlier run
when the current run is entirely whitespace; otherwise the current
run's own visible content is the line's true end, and an earlier
run's trailing space is interior, not trailing.
- Width now correctly includes interior, non-trailing whitespace, so
wrapped multi-run lines (e.g. mixed-script text) no longer get
stretched past the target width when justified.
* Ignore CLAUDE.md