From 19ebdcab54abe043a823d987ed5cb9abd42ae04c Mon Sep 17 00:00:00 2001 From: BFlat Date: Tue, 24 Nov 2026 20:04:21 +0700 Subject: [PATCH 1/3] Glyphs panel menu: East Asian form rows read the selection's fonts when the panel is hidden (#9223) Fixes main's red Linux gate leg 1 (`panels::glyphs::tests::east_asian_glyph_forms_in_the_panel_menu_set_the_selected_characters_form`, `glyphs/tests.rs:243`). It was a real bug on every platform. The test skips without the craft fonts, so only Linux CI ran it. **Cause.** The Glyphs panel menu's East Asian glyph form rows read the selection's faces from a cache that only the shown panel's `show` filled. With the panel hidden, the cache was empty, and the "unknown" arm enabled every form, so JIS 2004 was offered for a font with no `jp04`. Production always read the faces when it built the items (prod `panels/glyphs.rs:1407`, `:1492`). **Fix.** `form_faces` returns the cached faces while their key is current and reads them otherwise, as `symbols::instance_flags` does. The unknown-means-enabled arm is gone. `refresh_form_faces` runs from the menu rebuild next to `symbols::cache_instances`, so the faces are read once per change of document, selection or fonts, whether or not the panel is shown. Checks: `vectorcraft-ui-egui` lib tests 3779 passed, 0 failed, with `CRAFT_FONTS_DIR` set so the glyph tests run in full. Clippy (`-D warnings`, all targets) and `cargo fmt --check` are clean. --- crates/ui-egui/src/menus/model.rs | 2 ++ crates/ui-egui/src/panels/glyphs.rs | 43 +++++++++++++++-------------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/crates/ui-egui/src/menus/model.rs b/crates/ui-egui/src/menus/model.rs index 659a5390c4..9fdbeb7d84 100644 --- a/crates/ui-egui/src/menus/model.rs +++ b/crates/ui-egui/src/menus/model.rs @@ -225,6 +225,8 @@ fn rebuild(app: &mut VectorcraftApp, target: Target) { } // The Symbols panel menu's states read the selection's instances from the walk this keeps. crate::panels::symbols::cache_instances(app); + // The Glyphs panel menu's East Asian glyph forms read the faces that draw the selected text from the layout this keeps. + crate::panels::glyphs::refresh_form_faces(app); let listed = Listed::of(app); let mut build = Build { app, lang: crate::i18n::current(), states: CommandStates::new(), refs: Vec::new() }; let menus: Vec = menu_tree_named(app.session.prefs.font_names_in_english, &listed) diff --git a/crates/ui-egui/src/panels/glyphs.rs b/crates/ui-egui/src/panels/glyphs.rs index b219b55483..e595eb55fa 100644 --- a/crates/ui-egui/src/panels/glyphs.rs +++ b/crates/ui-egui/src/panels/glyphs.rs @@ -458,9 +458,6 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { // scrolls freely meanwhile. let reveal = (marked != app.ui.glyphs_marked).then_some(marked).flatten(); app.ui.glyphs_marked = marked; - if app.session.prefs.show_east_asian_options { - refresh_form_faces(app); - } let source = VcGlyphs::of(app); let (mut family, mut style) = { let (family, style) = source.font(); @@ -1297,10 +1294,13 @@ fn form_face_ids(app: &VectorcraftApp) -> Vec { ids } -/// Read the faces of the selection again when the document, the selection or the fonts changed: -/// laying the text out is too much to do for each menu state. The shown panel does it, and a panel -/// menu opens only from a shown panel. -fn refresh_form_faces(app: &mut VectorcraftApp) { +/// Read the faces of the selection again when the document, the selection or the fonts changed, +/// for the readers that only borrow the app ([`form_faces`]): laying the text out is too much to +/// do for each menu state. The menu model does it before it reads the panel menus' states. +pub(crate) fn refresh_form_faces(app: &mut VectorcraftApp) { + if !app.session.prefs.show_east_asian_options { + return; + } let Some(key) = faces_key(app) else { app.canvas.glyph_form_faces = None; return; @@ -1312,11 +1312,18 @@ fn refresh_form_faces(app: &mut VectorcraftApp) { app.canvas.glyph_form_faces = Some((key, ids)); } -/// The faces [`refresh_form_faces`] read, when they are those of the selection now. -fn form_faces(app: &VectorcraftApp) -> Option>> { - let key = faces_key(app)?; - let (cached, ids) = app.canvas.glyph_form_faces.as_ref()?; - (*cached == key).then(|| ids.iter().filter_map(|id| FontDb::global().face_by_id(*id)).collect()) +/// The faces of the selection: those [`refresh_form_faces`] read when they are still current, else +/// read now. +fn form_faces(app: &VectorcraftApp) -> Vec> { + let read; + let ids = match (&app.canvas.glyph_form_faces, faces_key(app)) { + (Some((cached, ids)), Some(key)) if *cached == key => ids, + _ => { + read = form_face_ids(app); + &read + } + }; + ids.iter().filter_map(|id| FontDb::global().face_by_id(*id)).collect() } /// The value `f` gives every character the glyph form rows act on: the Type tool's selected @@ -1386,8 +1393,7 @@ pub(crate) fn menu_rows(app: &VectorcraftApp) -> Vec { } /// The row titles of a category, which are the panel's words, with the check on the shown one. A -/// form a face of the selection has no feature for is disabled, once the shown panel has read the -/// faces ([`refresh_form_faces`]). +/// form no face of the selection has a feature for is disabled ([`form_faces`]). pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { let (_, _, face) = browsed_face(app); let cats = categories(face.as_deref()); @@ -1409,12 +1415,9 @@ pub(crate) fn menu_states(app: &VectorcraftApp, states: &mut CommandStates) { for form in GlyphForm::ALL { // A width form may be drawn with other widths for the same glyphs (`GPOS`) instead of // other glyphs. - let enabled = match (form.feature(), &faces) { - (Some(tag), Some(faces)) => { - faces.iter().any(|f| f.has_substitution_feature(*tag) || (form.is_width() && f.has_positioning_feature(*tag))) - } - (Some(_), None) => true, - (None, _) => has, + let enabled = match form.feature() { + Some(tag) => faces.iter().any(|f| f.has_substitution_feature(*tag) || (form.is_width() && f.has_positioning_feature(*tag))), + None => has, }; let checked = form != GlyphForm::Default && shared == Some(form); states.set(form_ref(form), CommandState::new().title(tl!(glyph_form_label(form))).enabled(enabled).checked(checked)); From bd685fff553af0f976e98ad710acf173aae1e637 Mon Sep 17 00:00:00 2001 From: BFlat Date: Tue, 24 Nov 2026 22:05:18 +0700 Subject: [PATCH 2/3] Preferences test: check the title bar note's wording, not the variable name (#9226) The row's help joins its notes with the setting's own sentence, which names VECTORCRAFT_TITLEBAR too, so on Linux the check held with the variable unset. --- crates/ui-egui/src/prefs_dialog/tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/prefs_dialog/tests.rs b/crates/ui-egui/src/prefs_dialog/tests.rs index 8d2e22729f..393561679d 100644 --- a/crates/ui-egui/src/prefs_dialog/tests.rs +++ b/crates/ui-egui/src/prefs_dialog/tests.rs @@ -320,7 +320,9 @@ fn dimmed_rows_follow_the_settings_they_depend_on() { if let Some((enabled, help)) = row_state(&mut a, "appTitleBar") { let label = format!("variable {from_env}, system {system}"); assert_eq!(enabled, !from_env && !system, "app title bar: {label}"); - assert_eq!(help.is_some_and(|h| h.contains("VECTORCRAFT_TITLEBAR")), from_env, "app title bar note: {label}"); + // The note, not the setting's sentence, which names the variable too. + let note = help.is_some_and(|h| h.contains("VECTORCRAFT_TITLEBAR environment variable")); + assert_eq!(note, from_env, "app title bar note: {label}"); } if let Some((enabled, _)) = row_state(&mut a, "systemTitleBar") { assert_eq!(enabled, !from_env, "system title bar: variable {from_env}"); From 825cf29a88f99b8ff101bc9b82778e023601c1ab Mon Sep 17 00:00:00 2001 From: BFlat Date: Tue, 24 Nov 2026 23:29:22 +0700 Subject: [PATCH 3/3] Cut tools test registers the app's icons before checking them (#9230) CI runs each test in its own process, where nothing else has registered them. --- crates/ui-egui/src/tests/cut.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/src/tests/cut.rs b/crates/ui-egui/src/tests/cut.rs index c529eb1198..4732a6347b 100644 --- a/crates/ui-egui/src/tests/cut.rs +++ b/crates/ui-egui/src/tests/cut.rs @@ -10,6 +10,8 @@ fn the_cut_tools_have_their_own_icons_and_toolbar_slot() { for (tool, icon) in [("mirrorCut", "dc-mirror-cut"), ("lineCut", "dc-line-cut"), ("rectCut", "dc-rect-cut")] { let info = vectorcraft_tools::tool_info(tool).unwrap(); assert_eq!(icons::tool_icon(info.icon), icon); + // The app registers its icons at start; a test run alone in its process must too. + craft::ui::primitives::register_app_icons(&icons::APP_ICONS); assert!(craft::ui::primitives::has_icon(&IconId::new(icon)), "{icon}"); assert!(crate::toolbar::BASIC.iter().flat_map(|(_, slots)| slots.iter()).any(|s| s.contains(&tool) && s.contains(&"knife"))); }