From ec012c4552946503b0d39f024590f0e3cedd5fa6 Mon Sep 17 00:00:00 2001 From: iris <2+iris@noreply.localhost> Date: Sun, 13 Sep 2026 23:28:47 -0400 Subject: [PATCH] Text depends on its box for where it sits, not only for shaping Alignment was not accounted for. Glyphs anchored to the start of an axis stay where they are when that extent changes, but the default is `CENTER_LEFT`: a label in a box that grows taller has to re-centre, even though its shaping is untouched. Saying `Internal` there would keep a drawing that belongs somewhere else once the retained path can act on it. It costs nothing today, since neither `Internal` nor `External` reuses anything yet. It would be silent when the move chain lands, which is why the classification wants to be right while it is being written rather than when something starts trusting it. --- src/widget/text/mod.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/widget/text/mod.rs b/src/widget/text/mod.rs index 30de829..08208d0 100644 --- a/src/widget/text/mod.rs +++ b/src/widget/text/mod.rs @@ -89,10 +89,17 @@ impl TextView { (region, size) } - /// Wrapping reads the width it is offered, so a wider box reshapes it; a - /// taller one never does. + /// Wrapping reads the width it is offered, so a wider box reshapes it and + /// a taller one does not. Alignment matters too, and separately: glyphs + /// anchored to the start of an axis stay put when that extent changes, + /// but centred or end-aligned ones move even though the shaping stands. pub fn size_dependence(&self, axis: Axis) -> SizeDependence { - match axis == Axis::X && self.attrs.wrap { + let reshapes = axis == Axis::X && self.attrs.wrap; + let anchored = match axis { + Axis::X => self.align.x, + Axis::Y => self.align.y, + } == AxisAlign::Neg; + match reshapes || !anchored { true => SizeDependence::External, false => SizeDependence::Internal, }