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.
This commit is contained in:
dotCooCoo
2026-11-04 20:50:50 +07:00
committed by bflatastic
parent bd8cc893da
commit 336b1271dd
2 changed files with 18 additions and 3 deletions
+3 -3
View File
@@ -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<f64>)>) -> (Option<bool>, Option<bool>) {
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))
}
@@ -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