From 336b1271dd5e9ca590edad372d2eba6e83b2d798 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 4 Nov 2026 05:39:55 -0800 Subject: [PATCH] Type: Kerning menu checks neither method for a manual value A number typed into the Kerning field after Optical keeps the Optical flag on the type, and the manual value sets the spacing. The Kerning menu still checked Optical. It now checks neither Auto nor Optical while a manual value is set. --- crates/ui-egui/src/panels/character.rs | 6 +++--- crates/ui-egui/src/panels/character/tests.rs | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/panels/character.rs b/crates/ui-egui/src/panels/character.rs index 98c3be6bc..068094eee 100644 --- a/crates/ui-egui/src/panels/character.rs +++ b/crates/ui-egui/src/panels/character.rs @@ -317,10 +317,10 @@ fn caret_kerning(app: &VectorcraftApp, ui: &Ui) -> Option<(f64, bool)> { } /// The check marks of the Kerning menu's Auto and Optical entries for the selection's kerning -/// `mode` (Optical on, manual value). A selection that mixes modes checks neither, and the menu -/// still lists both. +/// `mode` (Optical on, manual value). A manual value checks neither, as it sets the spacing even +/// with Optical on. A selection that mixes modes checks neither, and the menu still lists both. fn kerning_methods(mode: Option<(bool, Option)>) -> (Option, Option) { - let (automatic, optical) = mode.map_or((false, false), |(optical, manual)| (!optical && manual.is_none(), optical)); + let (automatic, optical) = mode.map_or((false, false), |(optical, manual)| (!optical && manual.is_none(), optical && manual.is_none())); (Some(automatic), Some(optical)) } diff --git a/crates/ui-egui/src/panels/character/tests.rs b/crates/ui-egui/src/panels/character/tests.rs index 7cdfddad3..4a4264fe7 100644 --- a/crates/ui-egui/src/panels/character/tests.rs +++ b/crates/ui-egui/src/panels/character/tests.rs @@ -278,6 +278,21 @@ fn kerning_menu_lists_auto_and_optical_for_mixed_modes() { assert_eq!(kerning_methods(mode), (Some(false), Some(false)), "both entries are listed, neither checked"); } +/// A number typed into the Kerning field after Optical keeps the Optical flag on the type, and +/// the manual value sets the spacing; the menu then checks neither Auto nor Optical. +#[test] +fn kerning_menu_checks_neither_method_for_a_manual_value_after_optical() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 300, "height": 200})).unwrap(); + let a = app.run("text.create", json!({"x": 20, "y": 50, "text": "AV", "size": 12})).unwrap()["id"].clone(); + app.run("select.set", json!({"ids": [a]})).unwrap(); + app.run("text.setFormat", json!({"kerning": "optical"})).unwrap(); + app.run("text.setFormat", json!({"kerning": 50})).unwrap(); + let mode = shared(&app, |s| (s.optical_kerning, s.kerning)); + assert_eq!(mode, Some((true, Some(50.0))), "the manual value keeps the Optical flag"); + assert_eq!(kerning_methods(mode), (Some(false), Some(false)), "a manual value checks neither method"); +} + /// Highlight Kerning and Highlight Tracking show the Character panel and give its field the /// keyboard focus with the value selected: what is typed replaces it, and Enter applies it. /// Highlight Font Name opens the font family menu with its search field focused. Without