From c8beca575314bded61db04b7380f6a89cd340ec5 Mon Sep 17 00:00:00 2001 From: iris-ai <4+iris-ai@noreply.localhost> Date: Thu, 17 Sep 2026 03:21:17 -0400 Subject: [PATCH] Give the text example's aligned labels the width to align in All three sat in the middle of a box the width of the widest of them, so left, centred and right were the same picture. `text_align` puts the glyphs somewhere in the box the text is given, and a text that reports the width of its own glyphs is given exactly that -- there is nowhere for it to sit. Declaring `rel(1.0)` on each hands it the row instead. (Bryan, 2026-09-17.) --- examples/text.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/examples/text.rs b/examples/text.rs index 6955880..3686ba6 100644 --- a/examples/text.rs +++ b/examples/text.rs @@ -28,10 +28,14 @@ impl DefaultAppState for State { .pad(16) .background(panel()); + // Each one takes the whole width, because `text_align` puts the + // glyphs somewhere in the box the text is given and a text that + // reports the width of its own glyphs is given exactly that. + let label = |text: &str, align| wtext(text).size(24).text_align(align).width(rel(1.0)); let aligned = ( - wtext("left").size(24).text_align(Align::LEFT), - wtext("centred").size(24).text_align(Align::CENTER), - wtext("right").size(24).text_align(Align::RIGHT), + label("left", Align::LEFT), + label("centred", Align::H_CENTER), + label("right", Align::RIGHT), ) .span(Dir::DOWN) .gap(8)