Browse / github.com/storytold/gridcraft / patch
fix(ui): left-align the font name box (#2454)
Font name is centered in the font box; Excel left-aligns it In the Home ribbon, the font name in the font box is centered. Excel left-aligns it. **Expected (Excel):** font name left-aligned. **Actual:** centered. Code: `font_combo` in `crates/ui-egui/src/ribbon.rs` draws the name as a centered button label. **Environment:** GridCraft v0.11.1, Windows 11 (build 10.0.26300), display scale 100%
- Status
- open
- Score
- 0.00
- Adopters
- 0 other operators
- Author
- Zaxaerith (imported from pull request #2636, open)
- Base
f6b0cec67e328f2f6352768b5cb2feb7e562c5db- Size
- +26 −1 in 2 files
- Review
- pending
- Shared
- 2026-10-28
- Id
50092ee9f50f7271228cf3c3
How it went
No other operator has reported using it yet.
Diff
raw · crates/ui-egui/src/ribbon.rs crates/ui-egui/tests/keytips.rs
@@ -1294,7 +1294,8 @@ fn autosum_menu(app: &mut SheetApp, ui: &mut Ui) { fn font_combo(app: &mut SheetApp, ui: &mut Ui, st: &Style) { let name = st.font.name.clone();- let resp = ui.add_sized([150.0, 24.0], egui::Button::new(egui::RichText::new(&name).font(theme::ui_font(12.5))));+ // The trailing grow atom left-aligns the existing label inside the button.+ let resp = ui.add_sized([150.0, 24.0], egui::Button::new(egui::RichText::new(&name).font(theme::ui_font(12.5))).right_text(())); control_keytip(app, ui, &resp, "home.fontName"); let forced = invoke(app, "home.fontName"); let items: Vec<(&str, String)> = FONTS.iter().map(|f| (*f, f.to_string())).collect();@@ -522,6 +522,30 @@ fn pending_sequences_go_live_when_the_command_lands() { assert_eq!(h.state().keytips.prefix(), None); } +#[test]+fn font_name_box_left_aligns_short_and_long_names() -> Result<(), String> {+ for name in ["Arial", "Calibri", "Times New Roman"] {+ let mut session = blank();+ session.execute("home.fontName", json!({"name": name})).map_err(|e| e.to_string())?;+ let h = harness(session);+ // Querying the original name also checks that the button keeps its accessible label.+ let rect = h.get_by_role_and_label(egui::accesskit::Role::Button, name).rect();+ assert!((rect.width() - 150.0).abs() < 0.1 && (rect.height() - 24.0).abs() < 0.1, "{name}: {rect:?}");+ let text_x = h+ .output()+ .shapes+ .iter()+ .find_map(|shape| match &shape.shape {+ egui::Shape::Text(text) if text.galley.text() == name && rect.contains(text.pos) => Some(text.pos.x),+ _ => None,+ })+ .ok_or("font name was not painted inside its button")?;+ let inset = text_x - rect.left();+ assert!((0.0..=10.0).contains(&inset), "{name}: expected a small left inset, got {inset}");+ }+ Ok(())+}+ #[test] fn control_keytips_open_dropdowns_and_run_handlers() { // HFF routes to the font control: its dropdown opens (popup items queryable).