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.
This commit is contained in:
iris committed 2026-09-13 23:28:47 -04:00
1 parent f192f75b25
commit ec012c4552
1 file changed
+10 -3
+10 -3
View File
@@ -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,
}