From 9a4c46933fd5cdb086a8bde80e938488f31a3276 Mon Sep 17 00:00:00 2001 From: AlienTech Software Date: Wed, 11 Nov 2026 08:49:05 -0800 Subject: [PATCH] fix(ui-egui): font size list is OneNote's whole sizes, without pt The size list now offers OneNote's whole sizes (8 to 72, 16 sizes) and drops the " pt" text. 9.5 and 10.5 wait for a page-format change, since the page stores whole sizes. Co-Authored-By: Claude Haiku 5.5 --- crates/ui-egui/src/ribbon.rs | 11 +++++++++-- crates/ui-egui/tests/ui.rs | 34 +++++++++++++++++----------------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index 8000de7..25b3add 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -18,7 +18,7 @@ use notecraft_model::{PageFormat, Tag}; /// shows a tab for what is selected. pub const TABS: [&str; 5] = ["Home", "Insert", "Draw", "History", "View"]; pub const SOURCE_TAB: &str = "Source"; -pub const FONT_SIZES: [u8; 14] = [8, 9, 10, 11, 12, 14, 16, 18, 20, 24, 28, 36, 48, 72]; +pub const FONT_SIZES: [u8; 16] = [8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72]; /// Shown only while the caret is in a table, the way Office shows a tab for the thing in /// hand. It goes when the caret leaves, and the ribbon falls back to Home. pub const TABLE_TAB: &str = "Table"; @@ -846,7 +846,7 @@ fn home_tab(ui: &mut Ui, view: &View<'_>, t: &Tokens, acts: &mut Vec) { let size_label = view.font_size.unwrap_or_else(|| crate::tl_id!("ui.font_size")); let size_menu = ui.menu_button(size_label, |ui| { for size in FONT_SIZES { - if ui.button(format!("{size} pt")).clicked() { + if ui.button(format!("{size}")).clicked() { acts.push(Act::FontSize(size)); ui.close(); } @@ -3027,4 +3027,11 @@ mod tests { assert_ne!(Act::Block("h1"), Act::Insert("h1")); assert_eq!(Act::Tab("Insert".into()), Act::Tab("Insert".to_string())); } + + /// SUP-009: the font size list is OneNote's whole sizes (the page format stores whole + /// numbers, so 9.5 and 10.5 wait for a format change). + #[test] + fn the_font_size_list_is_onenotes_whole_sizes() { + assert_eq!(FONT_SIZES.as_slice(), [8u8, 9, 10, 11, 12, 14, 16, 18, 20, 22, 24, 26, 28, 36, 48, 72].as_slice()); + } } diff --git a/crates/ui-egui/tests/ui.rs b/crates/ui-egui/tests/ui.rs index 552c3a1..2fc070d 100644 --- a/crates/ui-egui/tests/ui.rs +++ b/crates/ui-egui/tests/ui.rs @@ -5830,7 +5830,7 @@ fn font_size_does_not_change_the_wrong_text_for_a_cross_paragraph_selection() { let before = h.state().body().unwrap_or_default().to_string(); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); assert_eq!(h.state().body().unwrap_or_default(), before, "unsupported cross-paragraph selection must not change an unrelated caret"); let inspection = ask(&mut h, "ui.inspect", json!({})).expect("inspect"); @@ -6160,7 +6160,7 @@ fn font_selectors_show_selection_values_and_mixed_state_in_both_formats() { assert_eq!(h.get_by_label("Font Size").value().as_deref(), Some("Mixed")); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("24 pt").click(); + h.get_by_label("24").click(); settle(&mut h); assert_eq!(h.get_by_label("Font Size").value().as_deref(), Some("24 pt")); assert_eq!(h.get_by_label("Font Family").value().as_deref(), Some("Mixed")); @@ -6181,7 +6181,7 @@ fn font_selectors_show_pending_size_without_editing_the_page() { let before = h.state().body().unwrap_or_default().to_string(); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); assert_eq!(h.get_by_label("Font Size").value().as_deref(), Some("18 pt")); assert_eq!(h.state().body().unwrap_or_default(), before); @@ -6449,7 +6449,7 @@ fn font_size_replaces_only_the_partial_selection_inside_an_existing_size() { } h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("24 pt").click(); + h.get_by_label("24").click(); settle(&mut h); let body = h.state().body().unwrap_or_default(); let (blocks, _) = notecraft_formats::boxes::read(notecraft_model::PageFormat::Cmgfm, body); @@ -6477,7 +6477,7 @@ fn font_size_replaces_mixed_sizes_in_a_partial_selection() { pump(&mut h); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("24 pt").click(); + h.get_by_label("24").click(); settle(&mut h); let body = h.state().body().unwrap_or_default(); let (blocks, _) = notecraft_formats::boxes::read(notecraft_model::PageFormat::Cmgfm, body); @@ -6549,7 +6549,7 @@ fn pending_marks_combine_with_size_for_unicode_typing_in_both_formats() { settle(&mut h); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); assert_eq!(h.get_by_label("Font Size").value().as_deref(), Some("18 pt"), "the pending size is shown"); assert_eq!(h.state().body().unwrap_or_default(), before); @@ -6668,7 +6668,7 @@ fn selected_container_font_size_is_undoable_and_leaves_other_boxes_alone() { let before = h.state().body().unwrap_or_default().to_string(); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); assert_eq!(h.get_by_label("Font Size").value().as_deref(), Some("18 pt"), "the selected container reports its size"); let after = h.state().body().unwrap_or_default().to_string(); @@ -6836,7 +6836,7 @@ fn font_size_without_selection_formats_new_text() { let original = h.state().body().unwrap_or_default().to_string(); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); assert_eq!(h.state().body().unwrap_or_default(), original, "choosing a size alone does not change the page"); let history = ask(&mut h, "ui.inspect", json!({})).expect("inspect")["page"]["history"].clone(); @@ -6875,7 +6875,7 @@ fn pending_font_size_is_cleared_when_caret_moves() { ask(&mut h, "ui.caret", json!({"block": 1})).expect("caret"); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); ask(&mut h, "ui.key", json!({"key": "ArrowLeft"})).expect("move caret"); settle(&mut h); @@ -6895,7 +6895,7 @@ fn pending_font_size_applies_to_unicode_typing() { ask(&mut h, "ui.caret", json!({"block": 1})).expect("caret"); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); ask(&mut h, "ui.text", json!({"text": "مرحبا"})).expect("type unicode"); settle(&mut h); @@ -6914,13 +6914,13 @@ fn pending_font_size_can_change_in_a_typing_run() { ask(&mut h, "ui.caret", json!({"block": 1})).expect("caret"); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); ask(&mut h, "ui.text", json!({"text": "first"})).expect("first size"); settle(&mut h); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("24 pt").click(); + h.get_by_label("24").click(); settle(&mut h); ask(&mut h, "ui.text", json!({"text": "second"})).expect("second size"); settle(&mut h); @@ -6948,7 +6948,7 @@ fn font_size_applies_to_selected_text_and_survives_reopen_in_both_formats() { h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); let body = h.state().body().unwrap_or_default().to_string(); @@ -6978,7 +6978,7 @@ fn font_size_undo_and_redo_preserve_page_content_in_both_formats() { h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); settle(&mut h); let formatted = h.state().body().unwrap_or_default().to_string(); assert!(formatted.contains(""), "the size was applied: {formatted}"); @@ -7000,7 +7000,7 @@ fn font_size_undo_and_redo_preserve_page_content_in_both_formats() { pump(&mut h); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("24 pt").click(); + h.get_by_label("24").click(); settle(&mut h); let resized = h.state().body().unwrap_or_default().to_string(); assert!(resized.contains("font-size: 24pt"), "the second size was applied for {path}: {resized}"); @@ -7028,7 +7028,7 @@ fn font_size_undo_and_redo_preserve_page_content_in_both_formats() { pump(&mut h); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("24 pt").click(); + h.get_by_label("24").click(); settle(&mut h); assert_eq!(ask(&mut h, "ui.inspect", json!({})).expect("inspect")["page"]["history"], history, "same size is not an edit"); ask(&mut h, "ui.undo", json!({})).expect("undo through the user action"); @@ -7063,7 +7063,7 @@ fn font_size_history_stays_separate_from_typing() { pump(&mut h); h.get_by_label("Font Size").click(); h.run(); - h.get_by_label("18 pt").click(); + h.get_by_label("18").click(); h.run(); let formatted = h.state().body().unwrap_or_default().to_string(); assert!(formatted.contains("font-size: 18pt"), "the size was applied: {formatted}");