git.lucas.co / cce-ui
GPU-accelerated UI toolkit (Vulkan)
git clone https://git.lucas.co/cce-ui.git

commite206240d8f99f6c5932fb9ca7318bf5a9f4df898
parent32da4f49b8
authorLucas Galante <[email protected]>
date2026-07-17 11:15
fix: StatusBar implements Paint::text_font — the walk re-fonts prim labels

The paint walk strips prim fonts (own_labels_for_walk) and re-derives
them from Paint::text_font, so the font passed by paint()'s text_with
never survived; the bar rendered in the sans fallback. Includes a
walk-output regression test.

Co-Authored-By: Claude Fable 5 <[email protected]>

 src/widget/display/status_bar.rs | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)

diff --git a/src/widget/display/status_bar.rs b/src/widget/display/status_bar.rs
index 6426982..fba1abd 100644
--- a/src/widget/display/status_bar.rs
+++ b/src/widget/display/status_bar.rs
@@ -147,6 +147,12 @@ impl Paint for StatusBar {
         }
     }
 
+    /// The paint walk re-fonts prim-derived labels through this (the prim's own font field
+    /// is stripped by `own_labels_for_walk`) — without it the bar's text falls back to sans.
+    fn text_font(&self) -> Option<String> {
+        Some(crate::layout::statusbar_font())
+    }
+
     fn prepare_text(&mut self, fs: &mut glyphon::FontSystem, _rect: Rect) {
         if !self.text.is_empty() && self.text_buf.is_none() {
             let (font_fam, font_size) = crate::layout::statusbar_font_parsed();
@@ -195,4 +201,27 @@ mod tests {
         assert_eq!(WidgetHost::corner_style(&bar).1, (false, false, false, false));
         assert!(!WidgetHost::blocks_backplate_drag(&bar));
     }
+
+    /// The paint walk strips prim fonts and re-fonts labels via `Paint::text_font` — the
+    /// bar's text must come out of the walk carrying the configured statusbar font.
+    #[test]
+    fn walk_text_carries_statusbar_font() {
+        let ui = crate::context::UiContext::new();
+        let mut bar = StatusBar::new().with_text("ready");
+        WidgetHost::set_rect(&mut bar, 0.0, 570.0, 800.0, 30.0);
+
+        let mut pc = PaintCtx::new();
+        crate::scene::painter::paint_root_into(&ui, &bar, &mut pc);
+        let fonts: Vec<_> = pc
+            .finish()
+            .items
+            .into_iter()
+            .filter_map(|item| match item.prim {
+                crate::scene::paint::Prim::Text { font, .. } => Some(font),
+                _ => None,
+            })
+            .collect();
+        assert_eq!(fonts.len(), 1, "one text label out of the walk");
+        assert_eq!(fonts[0].as_deref(), Some(crate::layout::statusbar_font().as_str()));
+    }
 }