Files
pdfcraft/crates/edit
f0f42a3fe6 edit: restyling part of a paragraph keeps rows that start raised on their own baselines (#8879)
* fix(edit): keep rows that start raised on their baselines when restyled

Restyling part of a paragraph takes the styled rewrite, which read each
row's baseline from its first run. A TextLine's baseline is the raised one
(the interpreter starts a run at Tm x (0, Ts), ISO 32000-2 9.3.7), so a row
starting with a footnote mark or an exponent was lifted by that run's rise:
colouring a word in "2x plus one" (the 2 raised 4 pt) redrew the row 4 pt
up, and a row added below such rows took a 4 pt larger step.

Every place the styled rewrite reads a row's baseline now takes the rise
off first: the paragraph anchor, RowSpacing::place (both cases),
source_baseline, the source leading, and the offset back into each
segment's own text matrix. Each run's own Ts is drawn on top as before.

- TextLine::rise(): the rise a run starts drawn with, in user space.
- raised_row_tests pins the row baselines, the added-row step, paragraph
  gaps with spacing set, and a paragraph given a size.

Co-Authored-By: Claude Opus 5.5 <[email protected]>

* fix(edit): measure a run's rise as its height across the baseline

TextLine::rise() scaled Ts by the length of the text-to-user matrix's
y axis. On a slanted matrix that axis is longer than the distance the
rise moves the baseline (Tm [1 0 0.5 1 72 700] with 4 Ts read as 4.47),
so the unraised baseline came out wrong. Scale by the y axis's
component square to the baseline instead: on upright text that is the
user-space height the rise moves it, and a quarter-turned run still
reads its rise (the y axis's plain vertical part is 0 there).

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: KenM76 <[email protected]>
Co-authored-by: Claude Opus 5.5 <[email protected]>
Co-authored-by: FredApps <[email protected]>
2026-12-04 12:16:36 +01:00
..