From abdc26d8d1c69ef6a3373332d98fb6414702d591 Mon Sep 17 00:00:00 2001 From: haven <54509200+Haven-King@users.noreply.github.com> Date: Thu, 8 Oct 2026 20:25:56 -0700 Subject: [PATCH] M7: Shrink Text to Fit scales inline art's baseline shift The fit scaled each run's size, leading and baseline shift but not an inline graphic's own shift (points), so shrunk symbols sat off the cap-height centre. --- crates/text/src/layout.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/text/src/layout.rs b/crates/text/src/layout.rs index 60c2e96d7..ba73c2109 100644 --- a/crates/text/src/layout.rs +++ b/crates/text/src/layout.rs @@ -206,14 +206,17 @@ fn shrink_to_fit(db: &FontDb, t: &TextObject, opts: &LayoutOptions, min: f64) -> Some(best.unwrap_or_else(|| at(lo))) } -/// `t` with every run's size, explicit leading and baseline shift scaled by `f` (auto leading -/// follows the size; paragraph spacing stays). +/// `t` with every run's size, explicit leading and baseline shift scaled by `f`, inline art's own +/// shift included (auto leading and the art's size follow the size; paragraph spacing stays). fn scaled(t: &TextObject, f: f64) -> TextObject { let mut s = t.clone(); for r in &mut s.runs { r.style.size *= f; r.style.leading = r.style.leading.map(|l| l * f); r.style.baseline_shift *= f; + if let Some(a) = &mut r.inline { + a.baseline_shift *= f; + } } s }