diff --git a/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs b/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs index 76eaf6193b..5e998142a5 100644 --- a/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs +++ b/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs @@ -238,6 +238,35 @@ fn a_batch_cannot_delete_the_font_sheet_dialogs_opening_artboard() { assert_eq!(panel.app().session.active().unwrap().doc, before); } +#[test] +fn a_script_slice_cannot_delete_the_font_sheet_dialogs_opening_artboard() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 600, "height": 400, "artboards": 2})).unwrap(); + app.sync_views(); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + panel.room(egui::vec2(800.0, 700.0)); + panel.app().view_mut().unwrap().artboard = 1; + crate::menus::invoke(&mut panel.app(), super::COMMAND, json!({})); + panel.frame(); + let before = panel.app().session.active().unwrap().doc.clone(); + panel.app().session.script_frames = true; + let started = panel.app().run("script.run", json!({"source": "vc.run('artboard.delete', {index: 1});", "name": "t.js"})); + assert_eq!(started.map(|v| v["running"].clone()), Ok(json!(true)), "the run goes on in the frames"); + for _ in 0..1_000 { + if !panel.app().session.script_running() { + break; + } + crate::script_runs::poll(&mut panel.app()); + } + assert!(!panel.app().session.script_running()); + let status = panel.app().ui.status.clone(); + assert!(status.contains(tl!("Close Create Font Sheet before deleting its opening artboard.")), "{status}"); + assert_eq!(panel.app().session.active().unwrap().doc.artboards.len(), 2, "the opening artboard is kept"); + assert_eq!(panel.app().session.active().unwrap().doc, before); + assert!(panel.app().session.artboard_deletion_guard.is_none()); + panel.click("Cancel"); +} + #[test] fn font_sheet_allows_deleting_another_artboard() { let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); diff --git a/crates/ui-egui/src/script_runs.rs b/crates/ui-egui/src/script_runs.rs index ee469adf18..e32165515c 100644 --- a/crates/ui-egui/src/script_runs.rs +++ b/crates/ui-egui/src/script_runs.rs @@ -28,7 +28,11 @@ pub fn poll(app: &mut VectorcraftApp) { let name = app.session.script_name().unwrap_or_default(); let startup = app.session.startup_script_running(); let shared = share_views(app); + // A slice may delete an artboard; the one an open Create Font Sheet dialog uses is refused. + let guard = crate::addons::dialogs::artboard_deletion_guard(app); + let previous_guard = std::mem::replace(&mut app.session.artboard_deletion_guard, guard); let pumped = app.session.script_pump(); + app.session.artboard_deletion_guard = previous_guard; take_views(app, &shared); let Some(result) = pumped else { // A pump that started the next queued run shows the runs before it that could not start diff --git a/docs/mcp.md b/docs/mcp.md index b54b1f1f53..29319fd62f 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -18072,7 +18072,8 @@ the fonts can be compared on the artboard or printed. In `addon.type.fontSheet`, a parameter given as `null` is the same as one left out and takes its default; any other value of the wrong type or out of range is an error. While the Create Font Sheet… dialog is open, Delete Artboard, Cut Artboard, Delete Empty Artboards and Artwork Cleanup's Empty Artboards return an error and change nothing when they -would delete the artboard the dialog opened on; close the dialog first. +would delete the artboard the dialog opened on, and so does a running script's `vc.run` of one of them (a script +that does not catch the error ends with it); close the dialog first. → `{id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}`. Create Font Sheet… opens a dialog (`ui.menuDialog {command}`) whose fields are the command's parameters except `families`, with Preview, which starts diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 029ab9d55b..08ca2761bc 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3176,7 +3176,7 @@ A VectorCraft addition, not a feature of the reference app (it has no command fo ## Type Tools add-on: Create Font Sheet (2026-11-29) -A VectorCraft addition, so no area score moves. Object › Plug-ins › Type Tools › Create Font Sheet… sets a line of sample text once in each font family the font menus list, or in the families whose name contains a filter, each entry labeled with its font's name unless labels are switched off, as point type flowed down columns on the active artboard and on new artboards of the same size to its right when the artboard is full. Every Style gives each style of a family its own entry; families whose font can't be loaded, and composite fonts whose part setting the sample can't, are left out and listed. Each row is as tall as the tallest laid-out entry, so a composite font that enlarges the sample does not overlap. The sheet is one selected group made in one undo step, from a dialog whose Preview starts off (`addon.type.fontSheet`); its preview and OK set the sheet on the artboard active in the view when it opens, and while it is open, Delete Artboard, Cut Artboard, Delete Empty Artboards and Artwork Cleanup's Empty Artboards return an error when they would delete that artboard. Tests: `cmd::addons::typetools::font_sheet::tests` in `vectorcraft-engine` (labels, columns and margins, new artboards and none, the filter, every style, fonts and styles that don't load, composite fonts' row heights and missing parts, undo, a locked layer, bad params refused), `addons::typetools::font_sheet::tests` (including the artboard active when the dialog opens) and the Create Font Sheet row of `add_on_dialogs_preview_cancel_and_run_their_command` in `vectorcraft-ui-egui`. Commands: `docs/mcp.md` › Type Tools add-on › Create Font Sheet. +A VectorCraft addition, so no area score moves. Object › Plug-ins › Type Tools › Create Font Sheet… sets a line of sample text once in each font family the font menus list, or in the families whose name contains a filter, each entry labeled with its font's name unless labels are switched off, as point type flowed down columns on the active artboard and on new artboards of the same size to its right when the artboard is full. Every Style gives each style of a family its own entry; families whose font can't be loaded, and composite fonts whose part setting the sample can't, are left out and listed. Each row is as tall as the tallest laid-out entry, so a composite font that enlarges the sample does not overlap. The sheet is one selected group made in one undo step, from a dialog whose Preview starts off (`addon.type.fontSheet`); its preview and OK set the sheet on the artboard active in the view when it opens, and while it is open, Delete Artboard, Cut Artboard, Delete Empty Artboards and Artwork Cleanup's Empty Artboards return an error when they would delete that artboard, also when a running script calls them through `vc.run`. Tests: `cmd::addons::typetools::font_sheet::tests` in `vectorcraft-engine` (labels, columns and margins, new artboards and none, the filter, every style, fonts and styles that don't load, composite fonts' row heights and missing parts, undo, a locked layer, bad params refused), `addons::typetools::font_sheet::tests` (including the artboard active when the dialog opens) and the Create Font Sheet row of `add_on_dialogs_preview_cancel_and_run_their_command` in `vectorcraft-ui-egui`. Commands: `docs/mcp.md` › Type Tools add-on › Create Font Sheet. ## Unit Converter add-on (2026-11-14)