From 1f148094d4ea0b8cab5f56186a0e4152c359d94b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 10:02:01 -0800 Subject: [PATCH 01/14] Type Tools: Create Font Sheet sets a sample text in every font, labeled Object > Plug-ins > Type Tools > Create Font Sheet... (addon.type.fontSheet) sets one line of sample text once in each family the font menus list, or in the families whose name contains a filter, or in a given list. Each entry is point type labeled with its font's name, flowed down columns on the active artboard inside a margin, and on new artboards of the same size to the right of the rightmost artboard when it fills. Every Style gives each style of a family its own entry. Fonts that do not load are left out, listed in `skipped` and named in a warning. The sheet is one selected group made in one undo step. The dialog's Preview starts off, since each preview sets the whole sheet again; addons::dialogs::open_with opens an add-on dialog with Preview off. Invalid parameters are refused with nothing changed: empty or multi-line text, sizes, columns, gaps and margins out of range or leaving no room, an unknown or repeated family, a filter that matches nothing, more than 5000 entries. Plug-ins cannot call the command, as with text.fontList. Docs: docs/mcp.md (Type Tools add-on > Create Font Sheet), docs/target-app-parity.md. --- crates/engine/src/cmd/addons/typetools.rs | 7 +- .../src/cmd/addons/typetools/font_sheet.rs | 280 ++++++++++++++++++ .../cmd/addons/typetools/font_sheet/tests.rs | 243 +++++++++++++++ crates/engine/src/cmd/plugin_call/reviewed.rs | 1 + crates/ui-egui/src/addons/dialogs.rs | 13 + crates/ui-egui/src/addons/dialogs/tests.rs | 22 ++ crates/ui-egui/src/addons/typetools.rs | 10 +- .../src/addons/typetools/font_sheet.rs | 84 ++++++ .../src/addons/typetools/font_sheet/tests.rs | 97 ++++++ docs/mcp.md | 49 ++- docs/target-app-parity.md | 4 + 11 files changed, 805 insertions(+), 5 deletions(-) create mode 100644 crates/engine/src/cmd/addons/typetools/font_sheet.rs create mode 100644 crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs create mode 100644 crates/ui-egui/src/addons/typetools/font_sheet.rs create mode 100644 crates/ui-egui/src/addons/typetools/font_sheet/tests.rs diff --git a/crates/engine/src/cmd/addons/typetools.rs b/crates/engine/src/cmd/addons/typetools.rs index 14a462d79f..586a716938 100644 --- a/crates/engine/src/cmd/addons/typetools.rs +++ b/crates/engine/src/cmd/addons/typetools.rs @@ -5,8 +5,10 @@ //! (). Release Type on a Path //! splits type on a path into point type holding the same text and the plain path it was set on //! (#5532). The reference app has no command for it, so it goes beyond parity and changes no -//! parity score. Its submenu (Object › Plug-ins › Type Tools) and dialogs are the UI's. +//! parity score. Create Font Sheet ([`font_sheet`]) sets a line of sample text in every font. Its +//! submenu (Object › Plug-ins › Type Tools) and dialogs are the UI's. +pub mod font_sheet; #[cfg(test)] mod tests; @@ -66,6 +68,9 @@ pub fn specs() -> Vec { release_path ), ] + .into_iter() + .chain(font_sheet::specs()) + .collect() } /// Release Type on a Path's command (the id in [`specs`]). diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs new file mode 100644 index 0000000000..699550c77f --- /dev/null +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -0,0 +1,280 @@ +//! Create Font Sheet (`addon.type.fontSheet`; Object › Plug-ins › Type Tools › Create Font +//! Sheet…): a line of sample text set once in each font the font menus list (or in the fonts a +//! filter or a list names), each labeled with its font's name, flowed down columns on the active +//! artboard and on new artboards to its right when it fills, as one group made in one undo step. + +use std::sync::Arc; + +use serde_json::{Value, json}; +use vectorcraft_doc::{Node, NodeKind, TextObject, TextRun}; +use vectorcraft_geom::{Point, Rect}; +use vectorcraft_text::FontDb; + +use super::super::super::create::{new_type_para, new_type_style}; +use super::super::super::typecmd::refresh_bounds; +use super::super::super::{CommandSpec, bad, cmd, has_doc, switch_or}; +use crate::{Result, Session}; + +/// The command. +pub const COMMAND: &str = "addon.type.fontSheet"; +/// The sample text when none is given. +pub const DEFAULT_TEXT: &str = "The quick brown fox jumps over the lazy dog"; +/// Most fonts one sheet sets. +pub const MAX_FONTS: usize = 5000; +/// Most characters the sample text has. +pub const MAX_CHARS: usize = 1000; +/// The largest size a label is set at; a smaller sample's label is set at the sample's size. +const LABEL_SIZE: f64 = 9.0; +/// The space between the artboards the sheet adds, as `artboard.new` leaves it. +const ARTBOARD_GAP: f64 = 20.0; +/// The page a document without artboards lays the sheet out on (US Letter). +const LETTER: Rect = Rect { x0: 0.0, y0: 0.0, x1: 612.0, y1: 792.0 }; + +pub fn specs() -> Vec { + vec![cmd!( + "addon.type.fontSheet", + "Create Font Sheet", + ["Object", "Plug-ins", "Type Tools"], + None, + "{text?: one line of sample text, at most 1000 characters, without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer, in one undo step; the group is selected. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", + has_doc, + font_sheet + )] +} + +/// `key` of `p`: `default` when omitted, else a number in `range`. +fn number(p: &Value, key: &str, default: f64, range: std::ops::RangeInclusive) -> Result { + match p.get(key) { + None | Some(Value::Null) => Ok(default), + Some(v) => v + .as_f64() + .filter(|n| n.is_finite() && range.contains(n)) + .ok_or_else(|| bad(COMMAND, format!("`{key}` must be a number {}..{}", range.start(), range.end()))), + } +} + +/// The sample text of `p`: one line, not empty, at most [`MAX_CHARS`] characters. +fn sample_text(p: &Value) -> Result { + let text = match p.get("text") { + None | Some(Value::Null) => return Ok(DEFAULT_TEXT.into()), + Some(Value::String(t)) => t.clone(), + Some(_) => return Err(bad(COMMAND, "`text` must be a string")), + }; + if text.trim().is_empty() { + return Err(bad(COMMAND, "`text` must not be empty")); + } + // The line and paragraph separators break a line too. + if text.chars().any(|c| c.is_control() || matches!(c, '\u{2028}' | '\u{2029}')) { + return Err(bad(COMMAND, "`text` must be one line, without line breaks or other control characters")); + } + if text.chars().count() > MAX_CHARS { + return Err(bad(COMMAND, format!("`text` must be at most {MAX_CHARS} characters"))); + } + Ok(text) +} + +/// The families the sheet sets, in order: those `families` names, else those the font menus of +/// `db` list whose name contains `filter`. +fn families(p: &Value, db: &FontDb) -> Result> { + let filter = match p.get("filter") { + None | Some(Value::Null) => None, + Some(Value::String(f)) => Some(f.trim().to_lowercase()).filter(|f| !f.is_empty()), + Some(_) => return Err(bad(COMMAND, "`filter` must be a string")), + }; + let listed = match p.get("families") { + None | Some(Value::Null) => { + let menu = db.menu_family_list(); + let wanted = |f: &&String| filter.as_ref().is_none_or(|w| f.to_lowercase().contains(w.as_str())); + let found: Vec = menu.iter().filter(wanted).cloned().collect(); + if found.is_empty() { + return Err(bad(COMMAND, "no font family matches `filter`")); + } + return Ok(found); + } + Some(_) if filter.is_some() => return Err(bad(COMMAND, "give `families` or `filter`, not both")), + Some(Value::Array(a)) => a, + Some(_) => return Err(bad(COMMAND, "`families` must be a list of font family names")), + }; + if listed.is_empty() { + return Err(bad(COMMAND, "`families` must name at least one family")); + } + let composites = db.composite_font_names(); + let mut out: Vec = Vec::with_capacity(listed.len()); + for f in listed { + let f = f.as_str().map(str::trim).filter(|f| !f.is_empty()).ok_or_else(|| bad(COMMAND, "`families` must be a list of font family names"))?; + if !db.has_family(f) { + return Err(bad(COMMAND, format!("font family `{f}` is not available"))); + } + // The name as the font menus spell it. + let name = match composites.iter().find(|c| c.eq_ignore_ascii_case(f)) { + Some(c) => c.clone(), + None => db.canonical(f, "").0, + }; + if out.iter().any(|o| o.eq_ignore_ascii_case(&name)) { + return Err(bad(COMMAND, format!("`families` names `{name}` twice"))); + } + out.push(name); + } + Ok(out) +} + +/// The index of the artboard the view has active, else the one the document opened on, else the first. +fn active_artboard(st: &crate::DocState) -> usize { + let index_of = |id: u32| st.doc.artboards.iter().position(|a| a.id == id); + st.active_artboard.and_then(index_of).or_else(|| st.doc.opened_artboard.and_then(index_of)).unwrap_or(0) +} + +fn font_sheet(s: &mut Session, p: &Value) -> Result { + font_sheet_in(s, p, FontDb::global()) +} + +/// [`font_sheet`] over the fonts of `db`. +fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { + const C: &str = COMMAND; + let text = sample_text(p)?; + let size = number(p, "size", 12.0, 1.0..=1296.0)?; + let columns = number(p, "columns", 2.0, 1.0..=50.0)?; + if columns.fract() != 0.0 { + return Err(bad(C, "`columns` must be a whole number 1..50")); + } + let columns = columns as usize; + let gap = number(p, "gap", 12.0, 0.0..=1000.0)?; + let margin = number(p, "margin", 36.0, 0.0..=1000.0)?; + let all_styles = switch_or(p, "allStyles", false, C)?; + let labels = switch_or(p, "labels", true, C)?; + let new_artboards = switch_or(p, "newArtboards", true, C)?; + let families = families(p, db)?; + + // Each entry's font: (family, style); no style for the family's Regular or closest style. + let mut fonts: Vec<(String, Option)> = vec![]; + for f in &families { + let styles = if all_styles { db.styles(f) } else { vec![] }; + if styles.is_empty() { + fonts.push((f.clone(), None)); + } else { + fonts.extend(styles.into_iter().map(|st| (f.clone(), Some(st)))); + } + if fonts.len() > MAX_FONTS { + return Err(bad(C, format!("a sheet sets at most {MAX_FONTS} fonts: give `filter` or `families`"))); + } + } + + // Each page's layout: the label and sample sizes, an entry's height with the gap below it, and + // the rows and column width that fit inside the margin. + let label = size.min(LABEL_SIZE); + let pitch = if labels { label } else { 0.0 } + size * 1.5 + gap; + let st = s.doc()?; + let d = &st.doc; + let active = active_artboard(st); + let template = d.artboards.get(active).cloned(); + let page = template.as_ref().map_or(LETTER, |a| a.rect); + let (inner_w, inner_h) = (page.width() - 2.0 * margin, page.height() - 2.0 * margin); + let column_w = (inner_w - gap * (columns - 1) as f64) / columns as f64; + if column_w <= 0.0 || inner_h < pitch - gap { + return Err(bad(C, "the margin, gap and columns leave no room for a font on the artboard")); + } + let rows = (((inner_h + gap) / pitch).floor() as usize).max(1); + let per_page = rows * columns; + let right = d.artboards.iter().map(|a| a.rect.x1).fold(page.x1, f64::max); + // Where page `k` starts: the active artboard, then to the right of every artboard. + let page_x = |k: usize| if k == 0 { page.x0 } else { right + ARTBOARD_GAP + (k - 1) as f64 * (page.width() + ARTBOARD_GAP) }; + let system_layout = d.setup.system_layout; + let parent = st.target_parent()?; + + let label_style = { + let mut style = new_type_style(s, &json!({ "size": label }), C)?; + style.leading = Some(label * 1.2); + style + }; + let mut entries: Vec<(String, TextObject)> = Vec::with_capacity(fonts.len()); + let mut skipped: Vec = vec![]; + let composites = db.composite_font_names(); + for (family, style) in fonts { + let mut sample = new_type_style(s, &json!({ "size": size, "font": family, "style": style }), C)?; + sample.leading = Some(size * 1.2); + let name = match &style { + Some(st) => format!("{family} {st}"), + None => family.clone(), + }; + // A font that doesn't load is drawn in the fallback font, and a style that doesn't in the + // family's closest style: either is left out. + let composite = composites.iter().any(|c| c.eq_ignore_ascii_case(&family)); + let wanted = db.canonical(&family, "").0; + let loads = db + .face(&sample.font_family, &sample.font_style) + .is_some_and(|face| face.family.eq_ignore_ascii_case(&wanted) && style.as_ref().is_none_or(|st| face.style.eq_ignore_ascii_case(st))); + if !composite && !loads { + skipped.push(name); + continue; + } + let i = entries.len(); + let (k, j) = (i / per_page, i % per_page); + let (col, row) = (j / rows, j % rows); + let x = page_x(k) + margin + col as f64 * (column_w + gap); + let top = page.y0 + margin + row as f64 * pitch; + // The origin is the first baseline: one line's size below the entry's top. + let baseline = top + if labels { label } else { size }; + let mut t = TextObject::point(Point::new(x, baseline), &text, sample.clone()); + if labels { + t.runs = vec![TextRun::new(format!("{name}\n"), label_style.clone()), TextRun::new(text.clone(), sample)]; + } + t.para = new_type_para(); + t.system_layout = system_layout; + refresh_bounds(&mut t); + entries.push((name, t)); + } + if entries.is_empty() { + return Err(bad(C, "none of the fonts could be loaded")); + } + let count = entries.len(); + let pages = count.div_ceil(per_page); + let boards: Vec = (1..pages).map(|k| Rect::new(page_x(k), page.y0, page_x(k) + page.width(), page.y1)).collect(); + let template = template.filter(|_| new_artboards); + let (gid, added) = s.edit("Create Font Sheet", |d, sel| { + let mut added = vec![]; + if let Some(template) = template { + for rect in boards { + let mut a = template.clone(); + a.id = d.next_artboard_id(); + a.name = format!("Artboard {}", d.artboards.len() + 1); + a.rect = rect; + a.locked = false; + d.artboards.push(a); + added.push(d.artboards.len() - 1); + } + } + let children: Vec> = entries + .into_iter() + .map(|(name, t)| { + let mut n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(t))); + n.name = Some(name); + Arc::new(n) + }) + .collect(); + let gid = d.alloc_id(); + let mut g = Node::new(gid, NodeKind::Group { children, clip: false }); + g.name = Some("Font Sheet".into()); + d.insert(parent, usize::MAX, g)?; + sel.set([gid]); + Ok((gid, added)) + })?; + let mut out = json!({ "id": gid.0, "count": count, "skipped": skipped, "artboards": added }); + if let Some(warning) = skipped_warning(&skipped) { + out["warning"] = json!(warning); + } + Ok(out) +} + +/// The warning a sheet that left fonts out gives, naming the first few. +fn skipped_warning(skipped: &[String]) -> Option { + const NAMED: usize = 5; + let (first, more) = (skipped.iter().take(NAMED).cloned().collect::>(), skipped.len().saturating_sub(NAMED)); + match (first.is_empty(), more) { + (true, _) => None, + (false, 0) => Some(format!("{} font(s) could not be loaded and were left out: {}", skipped.len(), first.join(", "))), + (false, more) => Some(format!("{} font(s) could not be loaded and were left out: {} and {more} more", skipped.len(), first.join(", "))), + } +} + +#[cfg(test)] +mod tests; diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs new file mode 100644 index 0000000000..5a6064d530 --- /dev/null +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -0,0 +1,243 @@ +use serde_json::{Value, json}; +use vectorcraft_doc::{Node, NodeId, NodeKind, TextObject}; +use vectorcraft_text::FontDb; + +use super::{COMMAND, DEFAULT_TEXT, MAX_CHARS}; +use crate::Session; + +/// The bundled families, available on every platform. +const BUNDLED: [&str; 3] = ["Inter", "Source Serif 4", "JetBrains Mono"]; + +fn session() -> Session { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 600, "height": 400})).unwrap(); + s +} + +fn steps(s: &Session) -> usize { + s.doc().unwrap().history.undo.len() +} + +fn group(s: &Session, r: &Value) -> Node { + s.doc().unwrap().doc.node(NodeId(r["id"].as_u64().unwrap())).unwrap().clone() +} + +/// Each entry of the sheet `g`: its name and its type. +fn entries(g: &Node) -> Vec<(String, TextObject)> { + g.children() + .unwrap() + .iter() + .map(|n| match &n.kind { + NodeKind::Text(t) => (n.name.clone().unwrap_or_default(), (**t).clone()), + _ => panic!("a font sheet holds only type"), + }) + .collect() +} + +/// Where the first baseline of `t` starts. +fn origin(t: &TextObject) -> (f64, f64) { + let [.., x, y] = t.xf.as_coeffs(); + (x, y) +} + +#[test] +fn a_sheet_sets_the_text_in_each_family_labeled_in_columns_in_one_undo_step() { + let mut s = session(); + let undo = steps(&s); + let r = s.execute(COMMAND, &json!({"families": BUNDLED, "columns": 2, "size": 12, "gap": 10, "margin": 20, "text": "Hamburgefonstiv"})).unwrap(); + assert_eq!(r["count"], 3); + assert_eq!(r["skipped"], json!([])); + assert_eq!(r["artboards"], json!([]), "three entries fit on the artboard"); + assert_eq!(steps(&s), undo + 1, "one undo step"); + let g = group(&s, &r); + assert_eq!(g.name.as_deref(), Some("Font Sheet")); + assert_eq!(s.doc().unwrap().selection.objects, [g.id], "the sheet is selected"); + let e = entries(&g); + assert_eq!(e.iter().map(|(n, _)| n.as_str()).collect::>(), BUNDLED, "in the order given, each named after its font"); + for ((name, t), family) in e.iter().zip(BUNDLED) { + assert_eq!(t.plain_text(), format!("{name}\nHamburgefonstiv"), "a label line, then the sample"); + let [label, sample] = &t.runs[..] else { panic!("a label run and a sample run: {:?}", t.runs.len()) }; + assert_eq!(sample.style.font_family, family); + assert!((sample.style.size - 12.0).abs() < 1e-9 && (label.style.size - 9.0).abs() < 1e-9, "the label is set at 9 pt"); + assert_eq!(label.style.font_family, "Source Sans 3", "the label is in the normal type font"); + } + // Down the first column, 9 + 18 + 10 pt apart, inside the 20 pt margin, the first baseline one label below the top. + let board = s.doc().unwrap().doc.artboards[0].rect; + let (a, b) = (origin(&e[0].1), origin(&e[1].1)); + assert!((a.0 - board.x0 - 20.0).abs() < 1e-9 && (a.1 - board.y0 - 29.0).abs() < 1e-9, "{a:?}"); + assert!((b.0 - a.0).abs() < 1e-9 && (b.1 - a.1 - 37.0).abs() < 1e-9, "{b:?}"); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(s.doc().unwrap().doc.node(g.id).is_none(), "undo removes the sheet"); +} + +#[test] +fn a_full_artboard_continues_on_new_artboards_to_the_right() { + let mut s = session(); + let undo = steps(&s); + // 400 pt tall less 2 × 100 pt of margin: 200 pt, room for two 72 pt entries (9 + 54 + 9). + let r = s.execute(COMMAND, &json!({"families": BUNDLED, "columns": 1, "size": 36, "gap": 9, "margin": 100})).unwrap(); + assert_eq!(r["count"], 3); + assert_eq!(r["artboards"], json!([1]), "the third entry goes on a new artboard"); + assert_eq!(steps(&s), undo + 1, "the new artboard is in the same undo step"); + let doc = &s.doc().unwrap().doc; + let (first, added) = (doc.artboards[0].rect, doc.artboards[1].rect); + assert!((added.x0 - first.x1 - 20.0).abs() < 1e-9 && (added.y0 - first.y0).abs() < 1e-9, "{added:?}"); + assert!((added.width() - first.width()).abs() < 1e-9 && (added.height() - first.height()).abs() < 1e-9, "the same size"); + let e = entries(&group(&s, &r)); + assert!((origin(&e[2].1).0 - added.x0 - 100.0).abs() < 1e-9, "inset by the margin on the new artboard"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(s.doc().unwrap().doc.artboards.len(), 1, "undo removes the artboard too"); + + // Without new artboards, the page after the first is laid out in the same place with none. + let r = s.execute(COMMAND, &json!({"families": BUNDLED, "columns": 1, "size": 36, "gap": 9, "margin": 100, "newArtboards": false})).unwrap(); + assert_eq!(r["artboards"], json!([])); + assert_eq!(s.doc().unwrap().doc.artboards.len(), 1); + let e = entries(&group(&s, &r)); + assert!((origin(&e[2].1).0 - added.x0 - 100.0).abs() < 1e-9); +} + +#[test] +fn a_filter_picks_families_and_all_styles_lists_each_style() { + let mut s = session(); + let r = s.execute(COMMAND, &json!({"filter": " sOURCE s ", "labels": false})).unwrap(); + let e = entries(&group(&s, &r)); + let names: Vec<&str> = e.iter().map(|(n, _)| n.as_str()).collect(); + assert!(names.contains(&"Source Sans 3") && names.contains(&"Source Serif 4"), "{names:?}"); + assert!(names.iter().all(|n| n.to_lowercase().contains("source s")), "{names:?}"); + assert!(e.iter().all(|(_, t)| t.runs.len() == 1 && t.plain_text() == DEFAULT_TEXT), "no labels: the sample alone"); + + let r = s.execute(COMMAND, &json!({"families": ["Source Sans 3"], "allStyles": true})).unwrap(); + let e = entries(&group(&s, &r)); + let styles: Vec = vectorcraft_text::FontDb::global().styles("Source Sans 3"); + assert!(styles.len() > 1, "{styles:?}"); + assert_eq!(e.len(), styles.len(), "one entry for each style"); + for ((name, t), style) in e.iter().zip(&styles) { + assert_eq!(name, &format!("Source Sans 3 {style}")); + assert_eq!(&t.runs[1].style.font_style, style); + } +} + +/// Columns sit side by side, each `gap` apart and as wide as the room inside the margin allows. +#[test] +fn columns_share_the_room_inside_the_margin() { + let mut s = session(); + // 400 pt less 2 × 50 pt of margin leaves 300 pt: eight 39 pt entries (9 + 18 + 12) fit in a column. + let r = s.execute(COMMAND, &json!({"families": BUNDLED, "columns": 3, "margin": 50, "gap": 12})).unwrap(); + let board = s.doc().unwrap().doc.artboards[0].rect; + let e = entries(&group(&s, &r)); + // The first column fills before the second starts, so all three share it. + let xs: Vec = e.iter().map(|(_, t)| origin(t).0).collect(); + assert!(xs.iter().all(|x| (x - board.x0 - 50.0).abs() < 1e-9), "{xs:?}"); + // One row per column: each entry starts a column, (500 − 2 × 12) / 3 wide plus the gap apart. + let r = s.execute(COMMAND, &json!({"families": BUNDLED, "columns": 3, "margin": 50, "gap": 12, "size": 150})).unwrap(); + let e = entries(&group(&s, &r)); + let step = (500.0 - 24.0) / 3.0 + 12.0; + for (i, (_, t)) in e.iter().enumerate() { + let (x, y) = origin(t); + assert!((x - board.x0 - 50.0 - i as f64 * step).abs() < 1e-9 && (y - board.y0 - 59.0).abs() < 1e-9, "entry {i}: {x}, {y}"); + } + assert_eq!(r["artboards"], json!([])); +} + +#[test] +fn bad_params_are_refused_without_a_change() { + let mut s = session(); + let before = steps(&s); + let long = "x".repeat(MAX_CHARS + 1); + for bad in [ + json!({"text": ""}), + json!({"text": " "}), + json!({"text": "two\nlines"}), + json!({"text": "two\u{2028}lines"}), + json!({"text": "two\u{2029}paragraphs"}), + json!({"text": long}), + json!({"text": 5}), + json!({"size": 0.5}), + json!({"size": "12"}), + json!({"columns": 0}), + json!({"columns": 1.5}), + json!({"gap": -1}), + json!({"margin": 2000}), + json!({"margin": 300}), + json!({"columns": 50, "gap": 1000}), + json!({"filter": "no family is called this"}), + json!({"filter": 3}), + json!({"families": []}), + json!({"families": "Inter"}), + json!({"families": ["Inter", "inter"]}), + json!({"families": ["No Such Family Anywhere"]}), + json!({"families": [""]}), + json!({"families": ["Inter"], "filter": "Inter"}), + json!({"labels": "yes"}), + json!({"allStyles": 1}), + json!({"newArtboards": "no"}), + ] { + assert!(s.execute(COMMAND, &bad).is_err(), "{bad}"); + } + assert_eq!(steps(&s), before); + assert!(s.doc().unwrap().doc.layers.iter().all(|l| l.children().is_none_or(|c| c.is_empty())), "nothing was drawn"); +} + +/// Fonts left out are named in the warning, the first five of them, with a count of the rest. +#[test] +fn fonts_left_out_are_named_in_a_warning() { + let names = |n: usize| (1..=n).map(|i| format!("Font {i}")).collect::>(); + assert_eq!(super::skipped_warning(&[]), None); + assert_eq!(super::skipped_warning(&names(2)).as_deref(), Some("2 font(s) could not be loaded and were left out: Font 1, Font 2")); + assert_eq!( + super::skipped_warning(&names(7)).as_deref(), + Some("7 font(s) could not be loaded and were left out: Font 1, Font 2, Font 3, Font 4, Font 5 and 2 more") + ); + let mut s = session(); + let r = s.execute(COMMAND, &json!({"families": ["Inter"]})).unwrap(); + assert!(r.get("warning").is_none(), "nothing left out: no warning"); +} + +/// A family the font menus list whose file no longer reads as a font is left out, as is a style +/// that would be drawn in another style of its family; the rest of the sheet is made. +#[test] +fn fonts_that_do_not_load_are_left_out_and_named() { + use vectorcraft_text::test_fonts::named_copy; + let dir = vectorcraft_testkit::temp_dir("font-sheet-unreadable"); + let file = |family: &str, style: &str| dir.join(format!("{}-{style}.ttf", family.replace(' ', ""))); + for (family, style) in [("Sheet Gone", "Regular"), ("Sheet Half", "Regular"), ("Sheet Half", "Bold")] { + let postscript = format!("{}-{style}", family.replace(' ', "")); + std::fs::write(file(family, style), named_copy(false, (family, style, "Version 1.000", &postscript)).unwrap()).unwrap(); + } + let db = FontDb::with_font_dirs(vec![dir.clone()]); + // Cataloged while every file reads; then two of them stop reading as fonts. + assert_eq!(db.styles("Sheet Half").len(), 2, "{:?}", db.styles("Sheet Half")); + assert!(db.menu_family_list().iter().any(|f| f == "Sheet Gone")); + for (family, style) in [("Sheet Gone", "Regular"), ("Sheet Half", "Bold")] { + std::fs::write(file(family, style), b"not a font").unwrap(); + } + let mut s = session(); + let r = super::font_sheet_in(&mut s, &json!({"families": ["Sheet Gone", "Inter"]}), &db).unwrap(); + assert_eq!(r["skipped"], json!(["Sheet Gone"]), "drawn in the fallback font, it is left out: {r}"); + assert_eq!(r["count"], 1); + assert_eq!(r["warning"], "1 font(s) could not be loaded and were left out: Sheet Gone"); + assert_eq!(entries(&group(&s, &r)).iter().map(|(n, _)| n.as_str()).collect::>(), ["Inter"]); + let r = super::font_sheet_in(&mut s, &json!({"families": ["Sheet Half"], "allStyles": true}), &db).unwrap(); + assert_eq!(r["skipped"], json!(["Sheet Half Bold"]), "drawn in its Regular, the Bold is left out: {r}"); + assert_eq!(entries(&group(&s, &r)).iter().map(|(n, _)| n.as_str()).collect::>(), ["Sheet Half Regular"]); + // Nothing that loads: an error, with nothing changed. + let before = steps(&s); + assert!(super::font_sheet_in(&mut s, &json!({"families": ["Sheet Gone"]}), &db).is_err()); + assert_eq!(steps(&s), before); +} + +#[test] +fn it_needs_a_document() { + let mut s = Session::new(); + assert!(s.execute(COMMAND, &json!({})).is_err()); +} + +#[test] +fn a_locked_layer_takes_no_sheet() { + let mut s = session(); + let layer = s.doc().unwrap().doc.layers[0].id; + s.execute("layer.setProps", &json!({"id": layer.0, "locked": true})).unwrap(); + let before = steps(&s); + assert!(s.execute(COMMAND, &json!({"families": ["Inter"]})).is_err()); + assert_eq!(steps(&s), before); +} diff --git a/crates/engine/src/cmd/plugin_call/reviewed.rs b/crates/engine/src/cmd/plugin_call/reviewed.rs index 783f971487..132519d050 100644 --- a/crates/engine/src/cmd/plugin_call/reviewed.rs +++ b/crates/engine/src/cmd/plugin_call/reviewed.rs @@ -757,6 +757,7 @@ pub(super) const DENIED: &[&str] = &[ "addon.cleanup.splitText", "addon.pathtools.movePointsTogether", "addon.pen.nextSegment", + "addon.type.fontSheet", "color.contrast", "effect.refreshDeferred", "graphicStyle.setOptions", diff --git a/crates/ui-egui/src/addons/dialogs.rs b/crates/ui-egui/src/addons/dialogs.rs index e58443e259..09b8fe4efe 100644 --- a/crates/ui-egui/src/addons/dialogs.rs +++ b/crates/ui-egui/src/addons/dialogs.rs @@ -85,9 +85,21 @@ pub(crate) fn open( spec: &'static Spec, fields: DialogFields, build: impl for<'b> Fn(&'b mut DialogFields) -> ParamDialog<'b> + Send + 'static, +) -> Result { + open_with(app, spec, fields, build, true) +} + +/// [`open`], with the Preview box on at the start when `previewing`, else off. +pub(crate) fn open_with( + app: &mut VectorcraftApp, + spec: &'static Spec, + fields: DialogFields, + build: impl for<'b> Fn(&'b mut DialogFields) -> ParamDialog<'b> + Send + 'static, + previewing: bool, ) -> Result { let ctx = app.ui_ctx.clone().ok_or("no window")?; let dialog = HostedParamDialog::new(&ctx, spec.command, fields, build); + let dialog = if previewing { dialog } else { dialog.preview_off() }; let host = app.dialogs().ok_or("no window")?; close_open(app); let id = dialog.id(); @@ -105,6 +117,7 @@ pub(crate) fn open_from_menu(app: &mut VectorcraftApp, id: &str) -> Option pathtools::bridge::open, pathtools::tangent_circle::COMMAND => pathtools::tangent_circle::open, typetools::COMMAND => typetools::open, + typetools::font_sheet::COMMAND => typetools::font_sheet::open, color::legend::COMMAND => color::legend::open, color::nearest::COMMAND => color::nearest::open, select::COMMAND => select::open, diff --git a/crates/ui-egui/src/addons/dialogs/tests.rs b/crates/ui-egui/src/addons/dialogs/tests.rs index 679a2e2e34..d2d21855ad 100644 --- a/crates/ui-egui/src/addons/dialogs/tests.rs +++ b/crates/ui-egui/src/addons/dialogs/tests.rs @@ -222,6 +222,28 @@ fn rows() -> Vec { assert!(label.contains("#123456") && label.contains("C="), "{label}"); }, }, + Row { + group: "Type Tools", + label: "Create Font Sheet…", + setup: new_app, + refused: || vec![("text", json!(" "))], + values: || vec![("text", json!("Sample")), ("filter", json!("JetBrains Mono"))], + check: |app| { + let doc = &app.session.doc().unwrap().doc; + let sheet = doc.layers[0].children().unwrap().last().unwrap(); + assert_eq!(sheet.name.as_deref(), Some("Font Sheet")); + let texts: Vec = sheet + .children() + .unwrap() + .iter() + .filter_map(|c| match &c.kind { + NodeKind::Text(t) => Some(t.plain_text()), + _ => None, + }) + .collect(); + assert!(texts.contains(&"JetBrains Mono\nSample".to_string()), "{texts:?}"); + }, + }, ] } diff --git a/crates/ui-egui/src/addons/typetools.rs b/crates/ui-egui/src/addons/typetools.rs index 3f73b835ee..790d4e661c 100644 --- a/crates/ui-egui/src/addons/typetools.rs +++ b/crates/ui-egui/src/addons/typetools.rs @@ -1,6 +1,8 @@ //! Type Tools in the interface: its submenu (Object › Plug-ins › Type Tools) and Text Tweaker's //! dialog, which picks an attribute, its start and end values and a shape, previews on the canvas -//! and runs `addon.type.textTweaker` on OK. +//! and runs `addon.type.textTweaker` on OK. Create Font Sheet's dialog is [`font_sheet`]'s. + +pub mod font_sheet; use craft::menu::Node; use craft::ui::contract::Bind; @@ -40,7 +42,11 @@ pub const RELEASE_MODES: &[(&str, &str)] = &[("Text and Path", "both"), ("Path O /// Object › Plug-ins › Type Tools. pub fn menu() -> Vec { - vec![c("Text Tweaker…", COMMAND), cp("Release Type on a Path…", RELEASE, json!({"mode": "both", "keepOriginal": false}))] + vec![ + c("Text Tweaker…", COMMAND), + cp("Release Type on a Path…", RELEASE, json!({"mode": "both", "keepOriginal": false})), + c("Create Font Sheet…", font_sheet::COMMAND), + ] } /// The attribute row of param `key` (the first, Font Size, for an unknown one). diff --git a/crates/ui-egui/src/addons/typetools/font_sheet.rs b/crates/ui-egui/src/addons/typetools/font_sheet.rs new file mode 100644 index 0000000000..3d92a96f1b --- /dev/null +++ b/crates/ui-egui/src/addons/typetools/font_sheet.rs @@ -0,0 +1,84 @@ +//! Create Font Sheet in the interface (Object › Plug-ins › Type Tools › Create Font Sheet…): a +//! dialog for the sample text, its size, a filter on the family names, whether each style gets an +//! entry and a label, and the columns, gap and margin of the pages. Its Preview box starts off; +//! switched on, it previews on the canvas. It runs `addon.type.fontSheet` on OK. + +use craft::ui::contract::Bind; +use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue, Param, ParamDialog, ParamKind}; +use craft::ui::runtime::env::UnitKind; +use serde_json::{Value, json}; + +use crate::VectorcraftApp; +use crate::addons::dialogs::{self, Spec}; +use crate::canvas::rulers::general_lengths; + +/// The command. +pub const COMMAND: &str = "addon.type.fontSheet"; +/// The sample text the dialog opens on. +const SAMPLE: &str = "The quick brown fox jumps over the lazy dog"; + +/// How the dialog's values reach the command. +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None }; + +/// The command's parameters from the dialog's fields; an empty filter sets every family. +pub(crate) fn params(fields: &DialogFields) -> Value { + let mut p = json!({ + "text": fields.text("text").unwrap_or(SAMPLE), + "size": fields.number("size").unwrap_or(12.0), + "allStyles": fields.bool("allStyles").unwrap_or(false), + "labels": fields.bool("labels").unwrap_or(true), + "columns": fields.int("columns").unwrap_or(2), + "gap": fields.number("gap").unwrap_or(12.0), + "margin": fields.number("margin").unwrap_or(36.0), + "newArtboards": fields.bool("newArtboards").unwrap_or(true), + }); + if let Some(filter) = fields.text("filter").map(str::trim).filter(|f| !f.is_empty()) { + p["filter"] = json!(filter); + } + p +} + +/// Opens Create Font Sheet's dialog on the command's defaults, with Preview off: each preview sets +/// the whole sheet again. +pub(crate) fn open(app: &mut VectorcraftApp) -> Result { + let fields = DialogFields::from_pairs([ + ("text", FieldValue::Text(SAMPLE.into())), + ("size", FieldValue::Number(12.0)), + ("filter", FieldValue::Text(String::new())), + ("allStyles", FieldValue::Bool(false)), + ("labels", FieldValue::Bool(true)), + ("columns", FieldValue::Int(2)), + ("gap", FieldValue::Number(12.0)), + ("margin", FieldValue::Number(36.0)), + ("newArtboards", FieldValue::Bool(true)), + ]); + let lengths = general_lengths(app); + dialogs::open_with( + app, + &SPEC, + fields, + move |fields| { + let written = fields.text("text").is_some_and(|t| !t.trim().is_empty()); + let rows = vec![ + Param::new("text", tl!("Sample Text:"), ParamKind::text(SAMPLE)), + Param::number("size", tl!("Size:"), 12.0, 1.0, 1).unit(UnitKind::Points).bounds(Some(1.0), Some(1296.0)), + Param::new("filter", tl!("Font Names Containing:"), ParamKind::text("")), + Param::new("allStyles", tl!("Every Style"), ParamKind::bool(false)), + Param::new("labels", tl!("Label Each Font"), ParamKind::bool(true)), + Param::new("columns", tl!("Columns:"), ParamKind::int(Some(1), Some(50), 2)), + Param::number("gap", tl!("Gap:"), 12.0, 1.0, 2).length(lengths).bounds(Some(0.0), Some(1000.0)), + Param::number("margin", tl!("Margin:"), 36.0, 1.0, 2).length(lengths).bounds(Some(0.0), Some(1000.0)), + Param::new("newArtboards", tl!("Add Artboards When Full"), ParamKind::bool(true)), + ]; + ParamDialog::new(COMMAND, tl!("Create Font Sheet"), rows) + .ok_enabled(written) + .ok_reason(tl!("Type a sample text.").into()) + .values(Bind::bound(fields)) + .previews(true) + }, + false, + ) +} + +#[cfg(test)] +mod tests; diff --git a/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs b/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs new file mode 100644 index 0000000000..4891cea545 --- /dev/null +++ b/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs @@ -0,0 +1,97 @@ +use craft::behavior::Mixed; +use craft::ui::contract::Role; +use craft::ui::patterns::form_dialogs::{DialogFields, FieldValue}; +use serde_json::json; +use vectorcraft_doc::{NodeKind, TextObject}; + +use crate::VectorcraftApp; +use crate::tests::panel_harness::Panel; + +/// The entries of the selected font sheet. +fn sheet(app: &VectorcraftApp) -> Vec { + let state = app.session.active().unwrap(); + let group = state.doc.node(state.selection.objects[0]).unwrap(); + assert_eq!(group.name.as_deref(), Some("Font Sheet")); + group + .children() + .unwrap() + .iter() + .map(|node| match &node.kind { + NodeKind::Text(text) => (**text).clone(), + _ => panic!("a font sheet holds only type"), + }) + .collect() +} + +fn assert_typed_sheet(app: &VectorcraftApp) { + let entries = sheet(app); + assert_eq!(entries.len(), 1, "the typed filter picks one family"); + let entry = &entries[0]; + assert_eq!(entry.plain_text(), "Hamburg", "the typed text, with the label switched off"); + assert_eq!(entry.runs[0].style.font_family, "Source Serif 4"); + assert!((entry.runs[0].style.size - 20.0).abs() < 1e-9, "the typed size reaches the sample"); +} + +/// The dialog opens with Preview off. The keyboard and checkbox edits reach the preview once it is +/// switched on, and OK; Cancel restores the drawing, while OK with Preview left off applies the +/// same fields in one undo step. +#[test] +fn keyboard_and_checkbox_edits_reach_font_sheet_preview_ok_and_cancel() { + for commit in [false, true] { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 600, "height": 400})).unwrap(); + let before = app.session.active().unwrap().doc.clone(); + let undo = app.session.active().unwrap().history.undo.len(); + let mut panel = Panel::new(app, crate::tests::picks::dialogs); + panel.room(egui::vec2(800.0, 700.0)); + crate::menus::invoke(&mut panel.app(), super::COMMAND, json!({})); + panel.frame(); + assert_eq!(panel.toggled("Preview"), Some(Mixed::Same(false)), "Preview starts off"); + assert!(!panel.app().session.in_interaction(), "the opening sheet is not previewed"); + assert!(panel.app().session.active().unwrap().doc == before); + if !commit { + panel.click_role("Preview", Role::CHECK_BOX); + panel.frame(); + assert!(panel.app().session.in_interaction(), "switched on, Preview shows the sheet"); + } + for (label, input) in [("Sample Text", "Hamburg"), ("Font Names Containing", "Source Serif 4")] { + panel.click_role(label, Role::TEXT_INPUT); + panel.key(egui::Key::A, egui::Modifiers::COMMAND); + panel.type_text(input); + panel.key(egui::Key::Tab, egui::Modifiers::NONE); + } + for (label, input) in [("Size", "20"), ("Columns", "1")] { + panel.click_role(label, Role::SPIN_BUTTON); + panel.key(egui::Key::A, egui::Modifiers::COMMAND); + panel.type_text(input); + panel.key(egui::Key::Tab, egui::Modifiers::NONE); + } + panel.click_role("Label Each Font", Role::CHECK_BOX); + if commit { + assert!(panel.app().session.active().unwrap().doc == before, "Preview off leaves the drawing alone"); + panel.click("OK"); + assert_typed_sheet(&panel.app()); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo + 1, "one undo step"); + panel.app().run("edit.undo", json!({})).unwrap(); + } else { + assert_typed_sheet(&panel.app()); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo, "Preview adds no undo step"); + panel.click("Cancel"); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo); + } + assert!(!panel.app().session.in_interaction()); + assert!(panel.app().session.active().unwrap().doc == before, "Cancel or Undo restores the original drawing"); + assert!(crate::tests::picks::open_dialogs(&panel.app()).is_empty()); + } +} + +/// An empty filter sends none, so the sheet sets every family; a filter is sent trimmed. +#[test] +fn params_sends_a_filter_only_when_one_is_typed() { + let mut fields = DialogFields::from_pairs([("text", FieldValue::Text("Abc".into())), ("filter", FieldValue::Text(" ".into()))]); + let p = super::params(&fields); + assert!(p.get("filter").is_none(), "{p}"); + assert_eq!((&p["text"], &p["columns"], &p["labels"], &p["newArtboards"]), (&json!("Abc"), &json!(2), &json!(true), &json!(true))); + fields.set("filter", FieldValue::Text(" Inter ".into())); + assert_eq!(super::params(&fields)["filter"], json!("Inter")); +} diff --git a/docs/mcp.md b/docs/mcp.md index 7ed0eebae6..fde01f0426 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17913,8 +17913,8 @@ enabled only when a selected image has a mask. → `{changed, ids}` ## Type Tools add-on -Type Tools is a built-in add-on for type: its commands are `addon.type.textTweaker` and `addon.type.releasePath`, and -in the desktop app it lives in Object › Plug-ins › Type Tools (#4924, #5532). Text Tweaker gives one character attribute to the characters letter by letter, +Type Tools is a built-in add-on for type: its commands are `addon.type.textTweaker`, `addon.type.releasePath` and +`addon.type.fontSheet`, and in the desktop app it lives in Object › Plug-ins › Type Tools (#4924, #5532). Text Tweaker gives one character attribute to the characters letter by letter, from a start value to an end value along a shape, as one undo step; the text stays live and editable. Each value is set as `text.setRangeStyle` sets it (the Character panel), in its units and ranges ([formatting type](https://helpx.adobe.com/illustrator/using/formatting-type.html)), so on scaled type it is the size shown. @@ -17978,6 +17978,51 @@ Path Options' Preview does (#5360). {"name":"run_command","arguments":{"command":"addon.type.releasePath","params":{"mode":"path","keepOriginal":true}}} ``` +### Create Font Sheet + +`addon.type.fontSheet` makes a font specimen sheet in the active document: a line of sample text set once in each +font family the font menus list (the bundled, added and installed fonts), each entry labeled with its font's name, so +the fonts can be compared on the artboard or printed. + +- **Entries** are point type, one per family in the font menus' order (or in the order `families` gives), each named + after its font. With `labels` on, an entry starts with a line naming its font in the document's normal type font, at + the sample's size up to 9 pt, and the sample follows on the next line. With `allStyles` each style of a family gets + its own entry, labeled with the family and style; otherwise the family's Regular is used, else its closest style. +- **Layout:** the entries flow down the columns of the active artboard, inside `margin`, with `gap` between entries + and between columns. A sample wider than its column runs on past it. When the artboard is full, the sheet continues + on new artboards of the same size to the right of the rightmost artboard, 20 pt apart; with `newArtboards` off the + later pages are laid out in the same places without artboards. A document without artboards lays the sheet out on a + 612 × 792 pt page at the origin and adds no artboards. +- **Fonts that don't load:** a family whose font can't be loaded (text in it would be drawn in the fallback font), or + with `allStyles` a style that can't (it would be drawn in the family's closest style), is left out, listed in + `skipped` and named in `warning`, which the status bar shows. +- The sheet is one group named Font Sheet, in the current layer, made in one undo step and selected. Nothing changes, + and an error is returned, when no family matches, when there would be more than 5000 entries, when no font loads, + when the margin, gap and columns leave no room for one entry, or when the current layer is locked or hidden. + +| Parameter | Values (default) | +|---|---| +| `text` | one line of sample text, at most 1000 characters, without line or paragraph breaks or other control characters (`The quick brown fox jumps over the lazy dog`) | +| `size` | the sample's size, pt 1…1296 (12) | +| `filter` | only the families whose name contains this text, in any case; empty: every family | +| `families` | instead of `filter`: these family names, in this order; each must be available and named once | +| `allStyles` | false; true: one entry for each style of each family | +| `labels` | true; false: the sample alone | +| `columns` | whole number 1…50 (2) | +| `gap` | pt 0…1000, between entries and between columns (12) | +| `margin` | pt 0…1000, inside each page (36) | +| `newArtboards` | true; false: the pages after the first get no artboards | + +→ `{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 +off: switched on, it sets the whole sheet again after each change. OK is off while the sample text is empty. Plug-ins can't call the command, since the sheet lists the installed fonts as +`text.fontList` does. + +```json +{"name":"run_command","arguments":{"command":"addon.type.fontSheet","params":{"text":"Hamburgefonstiv","size":18,"filter":"sans"}}} +{"name":"run_command","arguments":{"command":"addon.type.fontSheet","params":{"families":["Inter","JetBrains Mono"],"allStyles":true,"columns":1}}} +``` + ## Unit Converter add-on Unit Converter is a built-in add-on that shows one length in every unit at once (#5528): its commands are diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f2d93a4568..cadb5b2c33 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3166,6 +3166,10 @@ A VectorCraft addition, not a feature of the reference app, so no area score mov A VectorCraft addition, not a feature of the reference app (it has no command for this), so no area score moves. Object › Plug-ins › Type Tools › Release Type on a Path… splits each selected type on a path into point type holding the same text and the plain path it was set on, or keeps only one of them (#5532). The path keeps its exact shape (open or closed, anchors and handles, the object's transform), layer and place in the stacking order, with no fill and no stroke since type paths carry no paint of their own. The text keeps its runs, character and paragraph attributes and becomes point type on one straight line whose baseline starts where the first character sat on the path; Type on a Path Options don't apply to point type and are dropped. Keep Original leaves the type on a path and adds the released objects above it. Other objects are left alone and a selection with no type on a path makes no undo step; otherwise the run is one undo step, the released objects are selected, and the dialog's Preview works as Type on a Path Options' does (#5360). Tests: `cmd::addons::typetools::tests::release` in `vectorcraft-engine` (each mode, Keep Original, mixed and empty selections, closed, open, curved and flipped paths, transformed and grouped type, multi-style and unicode text with a centred paragraph, empty type, undo and redo, preview, cancel and commit, bad params refused), `release_type_on_a_path_previews_cancels_and_runs_on_ok` in `vectorcraft-ui-egui` and `command_sweep`. Commands: `docs/mcp.md` › Type Tools add-on › Release Type on a Path. +## 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, 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 are left out and listed. The sheet is one selected group made in one undo step, from a dialog whose Preview starts off (`addon.type.fontSheet`). 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, undo, a locked layer, bad params refused), `addons::typetools::font_sheet::tests` 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) A VectorCraft addition, so no area score moves. Object › Plug-ins › Unit Converter opens a panel with one number field per unit of Preferences › Units › East Asian Type (pt, picas, in, mm, cm, px, ft & in, m, yd, ft, Q, Ha), as proposed in #5528. A length typed in any field, with units and arithmetic as every number field reads them, updates the others as it is typed; text that does not read leaves them as they were. From Selection reads the selection's width and height as the Transform panel measures them, Width or Height picks which one the fields show, and Apply sets that side of the selection through `object.setBounds` as the Transform panel's W or H field does (its reference point, Constrain Width and Height Proportions and its Transform Object Only, Pattern Only or Both choice) as one undo step, with no step when the size is already that length. Each field's copy button copies its value, with its unit when Copy with Units is on. Agents use `addon.units.convert` and `addon.units.selectionSize`, which change nothing in the document (`docs/mcp.md`). Tests: `cmd::addons::units::tests` in `vectorcraft-engine` (every unit, number-field syntax, preview bounds and selected anchors, bad params and unknown keys refused), `addons::units::tests` in `vectorcraft-ui-egui` (typing, From Selection and a changed selection, Apply with the Transform panel's reference point, proportions, pattern choice and a symbol's registration point, copy, screen-reader names) and `command_sweep`. From db8fe499782e507fbad5ef5dcb1f89afd37b1727 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 14:58:14 -0800 Subject: [PATCH 02/14] Type Tools: Create Font Sheet's text parameter reads as one key CI failed `tests::params::every_description_parses`: the `text` note in `addon.type.fontSheet`'s description had commas outside parentheses, so the description parser split it and read `at most 1000 characters` as a key. The note now has no commas and keeps the same limits and default. --- crates/engine/src/cmd/addons/typetools/font_sheet.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs index 699550c77f..38073be8c9 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -36,7 +36,7 @@ pub fn specs() -> Vec { "Create Font Sheet", ["Object", "Plug-ins", "Type Tools"], None, - "{text?: one line of sample text, at most 1000 characters, without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer, in one undo step; the group is selected. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", + "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer, in one undo step; the group is selected. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", has_doc, font_sheet )] From 2198519cc73a67eb89f7a9271f336346c3715ad6 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 29 Nov 2026 22:18:10 -0800 Subject: [PATCH 03/14] Type Tools: Create Font Sheet keeps its opening artboard and sizes rows by ink Preview and OK now place the sheet on the artboard that was active when the dialog opened, and the view's active artboard is restored afterwards. Deleting that artboard while the dialog is open is refused; if it is gone, Preview and OK stop and ask to reopen the dialog. Other add-on dialogs keep using the current artboard. Rows are sized from each run's laid-out ink, so composite fonts whose sample uses fallback faces get rows tall enough for what they draw. The layout keeps per-run ink bounds so labeled sheets measure each glyph outline once. --- .../src/cmd/addons/typetools/font_sheet.rs | 127 +++++-- .../cmd/addons/typetools/font_sheet/tests.rs | 149 ++++++++ crates/engine/src/cmd/layer.rs | 6 + crates/engine/src/lib.rs | 7 + crates/engine/src/session/documents.rs | 1 + crates/text/src/layout/driver.rs | 12 +- crates/text/src/layout/vertical.rs | 12 +- crates/text/src/lib.rs | 36 +- crates/text/src/test_fonts.rs | 14 + crates/ui-egui/src/addons/arrange.rs | 10 +- crates/ui-egui/src/addons/color/legend.rs | 2 +- crates/ui-egui/src/addons/dialogs.rs | 71 +++- crates/ui-egui/src/addons/pathtools/bridge.rs | 2 +- crates/ui-egui/src/addons/pathtools/dashes.rs | 2 +- .../src/addons/pathtools/set_corners.rs | 2 +- .../src/addons/pathtools/tangent_circle.rs | 2 +- crates/ui-egui/src/addons/typetools.rs | 2 +- .../src/addons/typetools/font_sheet.rs | 2 +- .../src/addons/typetools/font_sheet/tests.rs | 331 ++++++++++++++++++ crates/ui-egui/src/app/commands.rs | 7 +- crates/ui-egui/src/dialogs/preview.rs | 6 +- docs/mcp.md | 12 +- docs/target-app-parity.md | 2 +- 23 files changed, 743 insertions(+), 74 deletions(-) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs index 38073be8c9..9d71c86610 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -7,8 +7,8 @@ use std::sync::Arc; use serde_json::{Value, json}; use vectorcraft_doc::{Node, NodeKind, TextObject, TextRun}; -use vectorcraft_geom::{Point, Rect}; -use vectorcraft_text::FontDb; +use vectorcraft_geom::{Affine, Point, Rect, Shape}; +use vectorcraft_text::{FontDb, FontMatch}; use super::super::super::create::{new_type_para, new_type_style}; use super::super::super::typecmd::refresh_bounds; @@ -36,7 +36,7 @@ pub fn specs() -> Vec { "Create Font Sheet", ["Object", "Plug-ins", "Type Tools"], None, - "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer, in one undo step; the group is selected. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", + "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer (else the topmost layer shown and unlocked), in one undo step; the group is selected. Each row is as tall as the tallest laid-out entry. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, or a composite font with a part setting the sample whose font or style can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", has_doc, font_sheet )] @@ -159,34 +159,32 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { } } - // Each page's layout: the label and sample sizes, an entry's height with the gap below it, and - // the rows and column width that fit inside the margin. let label = size.min(LABEL_SIZE); - let pitch = if labels { label } else { 0.0 } + size * 1.5 + gap; let st = s.doc()?; let d = &st.doc; let active = active_artboard(st); let template = d.artboards.get(active).cloned(); let page = template.as_ref().map_or(LETTER, |a| a.rect); - let (inner_w, inner_h) = (page.width() - 2.0 * margin, page.height() - 2.0 * margin); - let column_w = (inner_w - gap * (columns - 1) as f64) / columns as f64; - if column_w <= 0.0 || inner_h < pitch - gap { - return Err(bad(C, "the margin, gap and columns leave no room for a font on the artboard")); - } - let rows = (((inner_h + gap) / pitch).floor() as usize).max(1); - let per_page = rows * columns; let right = d.artboards.iter().map(|a| a.rect.x1).fold(page.x1, f64::max); - // Where page `k` starts: the active artboard, then to the right of every artboard. - let page_x = |k: usize| if k == 0 { page.x0 } else { right + ARTBOARD_GAP + (k - 1) as f64 * (page.width() + ARTBOARD_GAP) }; let system_layout = d.setup.system_layout; let parent = st.target_parent()?; + // An entry's first baseline is at least one line's size below its top, and the entry at least + // this tall; the fonts are only laid out when the page has room for that. + let (least_above, least_height) = (if labels { label } else { size }, if labels { label } else { 0.0 } + size * 1.5); + let (inner_w, inner_h) = (page.width() - 2.0 * margin, page.height() - 2.0 * margin); + let column_w = (inner_w - gap * (columns - 1) as f64) / columns as f64; + let no_room = || bad(C, "the margin, gap and columns leave no room for a font on the artboard"); + if column_w <= 0.0 || inner_h < least_height { + return Err(no_room()); + } let label_style = { let mut style = new_type_style(s, &json!({ "size": label }), C)?; style.leading = Some(label * 1.2); style }; - let mut entries: Vec<(String, TextObject)> = Vec::with_capacity(fonts.len()); + // Each entry laid out at the origin, and how far its laid-out ink reaches above and below its first baseline. + let mut laid: Vec<(String, TextObject, (f64, f64))> = Vec::with_capacity(fonts.len()); let mut skipped: Vec = vec![]; let composites = db.composite_font_names(); for (family, style) in fonts { @@ -197,35 +195,54 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { None => family.clone(), }; // A font that doesn't load is drawn in the fallback font, and a style that doesn't in the - // family's closest style: either is left out. + // family's closest style: either is left out. A composite font is left out when a part + // that sets the sample names a font or style that doesn't load. let composite = composites.iter().any(|c| c.eq_ignore_ascii_case(&family)); - let wanted = db.canonical(&family, "").0; - let loads = db - .face(&sample.font_family, &sample.font_style) - .is_some_and(|face| face.family.eq_ignore_ascii_case(&wanted) && style.as_ref().is_none_or(|st| face.style.eq_ignore_ascii_case(st))); - if !composite && !loads { + let loads = if composite { + db.composite_coverage(&family, &[text.as_str()]).is_some_and(|c| c.status == FontMatch::Exact) + } else { + let wanted = db.canonical(&family, "").0; + db.face(&sample.font_family, &sample.font_style) + .is_some_and(|face| face.family.eq_ignore_ascii_case(&wanted) && style.as_ref().is_none_or(|st| face.style.eq_ignore_ascii_case(st))) + }; + if !loads { skipped.push(name); continue; } - let i = entries.len(); + let (first, more) = if labels { + (TextRun::new(format!("{name}\n"), label_style.clone()), Some(TextRun::new(text.clone(), sample))) + } else { + (TextRun::new(text.clone(), sample), None) + }; + let t = laid_out(first, more, system_layout); + let extent = ink_extent(&t); + laid.push((name, t, extent)); + } + if laid.is_empty() { + return Err(bad(C, "none of the fonts could be loaded")); + } + + // Each page's layout: each entry's first baseline as far below its top as its ink reaches above + // it, a row as tall as the tallest entry with the gap below it, and the rows that fit inside the margin. + let height = laid.iter().map(|(.., (a, b))| a.max(least_above) + b).fold(least_height, f64::max); + let pitch = height + gap; + if inner_h < height { + return Err(no_room()); + } + let rows = (((inner_h + gap) / pitch).floor() as usize).max(1); + let per_page = rows * columns; + // Where page `k` starts: the active artboard, then to the right of every artboard. + let page_x = |k: usize| if k == 0 { page.x0 } else { right + ARTBOARD_GAP + (k - 1) as f64 * (page.width() + ARTBOARD_GAP) }; + let mut entries: Vec<(String, TextObject)> = Vec::with_capacity(laid.len()); + for (i, (name, mut t, (above, _))) in laid.into_iter().enumerate() { let (k, j) = (i / per_page, i % per_page); let (col, row) = (j / rows, j % rows); let x = page_x(k) + margin + col as f64 * (column_w + gap); - let top = page.y0 + margin + row as f64 * pitch; - // The origin is the first baseline: one line's size below the entry's top. - let baseline = top + if labels { label } else { size }; - let mut t = TextObject::point(Point::new(x, baseline), &text, sample.clone()); - if labels { - t.runs = vec![TextRun::new(format!("{name}\n"), label_style.clone()), TextRun::new(text.clone(), sample)]; - } - t.para = new_type_para(); - t.system_layout = system_layout; - refresh_bounds(&mut t); + let baseline = page.y0 + margin + row as f64 * pitch + above.max(least_above); + // The layout is in text space, so moving the type keeps it. + t.xf = Affine::translate((x, baseline)); entries.push((name, t)); } - if entries.is_empty() { - return Err(bad(C, "none of the fonts could be loaded")); - } let count = entries.len(); let pages = count.div_ceil(per_page); let boards: Vec = (1..pages).map(|k| Rect::new(page_x(k), page.y0, page_x(k) + page.width(), page.y1)).collect(); @@ -265,6 +282,44 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { Ok(out) } +/// Point type set in `first` and then `more`, with its first baseline at the origin, laid out. +fn laid_out(first: TextRun, more: Option, system_layout: bool) -> TextObject { + let mut t = TextObject::point(Point::ZERO, "", first.style.clone()); + t.runs = std::iter::once(first).chain(more).collect(); + t.para = new_type_para(); + t.system_layout = system_layout; + t.normalize_paras(); + let layout = vectorcraft_text::layout(FontDb::global(), &t); + t.cached_bounds = Some(layout.bounds); + t.cached_baselines = layout.baselines(); + let mut ink = layout.run_ink_bounds.clone(); + for (run, bar) in vectorcraft_text::decorations(&layout, FontDb::global(), &t) { + if let Some(bounds) = ink.get_mut(run) { + let bar = bar.bounding_box(); + *bounds = Some(bounds.map_or(bar, |bounds| bounds.union(bar))); + } + } + t.cached_ink = Some((layout.bounds, ink.iter().copied().flatten().reduce(|a, b| a.union(b)))); + if t.runs.len() == 2 + && let (Some(label), Some(sample)) = (ink[0], ink[1]) + { + let overlap = label.y1 - sample.y0; + if overlap > 0.0 + && let Some(run) = t.runs.get_mut(1) + { + run.style.leading = Some(run.style.leading.unwrap_or(run.style.size * 1.2) + overlap); + refresh_bounds(&mut t); + } + } + t +} + +/// How far the ink of laid-out type `t` reaches above and below its first baseline, underline and +/// strikethrough bars included; none when nothing draws. +fn ink_extent(t: &TextObject) -> (f64, f64) { + t.cached_ink.and_then(|(_, ink)| ink).map_or((0.0, 0.0), |b| ((-b.y0).max(0.0), b.y1.max(0.0))) +} + /// The warning a sheet that left fonts out gives, naming the first few. fn skipped_warning(skipped: &[String]) -> Option { const NAMED: usize = 5; diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index 5a6064d530..1095b4428c 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -226,6 +226,155 @@ fn fonts_that_do_not_load_are_left_out_and_named() { assert_eq!(steps(&s), before); } +/// Where the ink of `t` starts and ends down the page. +fn ink_rows(t: &TextObject) -> (f64, f64) { + let (_, y) = origin(t); + let b = vectorcraft_text::layout(FontDb::global(), t).ink_bounds().unwrap(); + (y + b.y0, y + b.y1) +} + +/// A composite font whose Roman part sets the sample at four times its size gets rows as tall as +/// its laid-out ink: the first entry stays inside the margin, the second starts below the first, +/// and each sample starts below its own label. +#[test] +fn rows_fit_the_laid_out_ink_of_a_composite_font() { + let mut s = session(); + let big = |name: &str| json!({"name": name, "parts": {"kanji": {"font": "Source Sans 3"}, "roman": {"font": "Inter", "size": 400}}}); + s.execute("type.compositeFonts.set", &json!({"fonts": [big("CF Sheet Big A"), big("CF Sheet Big B")]})).unwrap(); + let p = json!({"families": ["CF Sheet Big A", "CF Sheet Big B"], "columns": 1, "size": 12, "gap": 10, "margin": 20, "text": "Hamburg"}); + let r = s.execute(COMMAND, &p).unwrap(); + assert_eq!((&r["count"], &r["skipped"]), (&json!(2), &json!([])), "{r}"); + let board = s.doc().unwrap().doc.artboards[0].rect; + let e = entries(&group(&s, &r)); + let ((top0, bottom0), (top1, _)) = (ink_rows(&e[0].1), ink_rows(&e[1].1)); + assert!(top0 >= board.y0 + 20.0 - 1e-6, "the first entry reaches into the margin: {top0}"); + assert!(top1 >= bottom0 - 1e-6, "the second entry overlaps the first: {top1} < {bottom0}"); + for (name, t) in &e { + let mut label = t.clone(); + label.runs.truncate(1); + let mut sample = t.clone(); + sample.runs.remove(0); + let (y0, y1) = (t.cached_baselines[0].0.y, t.cached_baselines[1].0.y); + let label_bottom = y0 + vectorcraft_text::layout(FontDb::global(), &label).ink_bounds().unwrap().y1; + let sample_top = y1 + vectorcraft_text::layout(FontDb::global(), &sample).ink_bounds().unwrap().y0; + assert!(sample_top >= label_bottom - 1e-6, "{name}: the sample reaches into its label: {sample_top} < {label_bottom}"); + } +} + +/// A composite font whose part setting the sample names a font that doesn't load is left out and +/// named, as a family that doesn't load is. +#[test] +fn a_composite_font_with_a_missing_part_is_left_out() { + let mut s = session(); + let font = json!({"name": "CF Sheet Gone", "parts": {"kanji": {"font": "Source Sans 3"}, "roman": {"font": "No Such Sheet Font"}}}); + s.execute("type.compositeFonts.set", &json!({"fonts": [font]})).unwrap(); + let r = s.execute(COMMAND, &json!({"families": ["CF Sheet Gone", "Inter"], "text": "Hamburg"})).unwrap(); + assert_eq!(r["skipped"], json!(["CF Sheet Gone"]), "{r}"); + assert_eq!(r["count"], 1); + assert_eq!(entries(&group(&s, &r)).iter().map(|(n, _)| n.as_str()).collect::>(), ["Inter"]); +} + +#[test] +fn a_composite_font_with_an_unavailable_part_style_is_left_out() { + let mut s = session(); + let font = json!({ + "name": "CF Sheet Missing Style", + "parts": { + "kanji": {"font": "Source Sans 3"}, + "roman": {"font": "Inter", "style": "No Such Sheet Style"} + } + }); + s.execute("type.compositeFonts.set", &json!({"fonts": [font]})).unwrap(); + let coverage = FontDb::global().composite_coverage("CF Sheet Missing Style", &["Hamburg"]).unwrap(); + assert_eq!(coverage.status, vectorcraft_text::FontMatch::Style); + let r = s.execute(COMMAND, &json!({"families": ["CF Sheet Missing Style", "Inter"], "text": "Hamburg"})).unwrap(); + assert_eq!(r["skipped"], json!(["CF Sheet Missing Style"])); + assert_eq!(r["count"], 1); + assert_eq!(r["warning"], "1 font(s) could not be loaded and were left out: CF Sheet Missing Style"); + assert_eq!(entries(&group(&s, &r)).iter().map(|(n, _)| n.as_str()).collect::>(), ["Inter"]); + let before = (s.doc().unwrap().doc.clone(), steps(&s)); + assert!(s.execute(COMMAND, &json!({"families": ["CF Sheet Missing Style"], "text": "Hamburg"})).is_err()); + assert_eq!(s.doc().unwrap().doc, before.0); + assert_eq!(steps(&s), before.1); +} + +#[test] +fn labels_without_overlap_need_no_additional_layouts() { + use vectorcraft_text::test_fonts::{ink_work_on_this_thread, layouts_on_this_thread}; + + let mut counts = vec![]; + for labels in [false, true] { + let mut s = session(); + let before = layouts_on_this_thread(); + let ink_before = ink_work_on_this_thread(); + let r = s.execute(COMMAND, &json!({"families": BUNDLED, "text": "Hamburg", "labels": labels})).unwrap(); + let ink_after = ink_work_on_this_thread(); + counts.push(layouts_on_this_thread() - before); + assert_eq!(r["count"], BUNDLED.len()); + let mut outlines = 0; + for (_, t) in entries(&group(&s, &r)) { + assert!(t.cached_ink.unwrap().1.is_some()); + assert_eq!(t.cached_baselines.len(), if labels { 2 } else { 1 }); + let layout = vectorcraft_text::layout(FontDb::global(), &t); + outlines += layout.glyphs.iter().chain(&layout.ruby).filter(|glyph| !glyph.outline.elements().is_empty()).count() as u64; + assert_eq!(t.cached_ink.unwrap().1, vectorcraft_render::effects::preview::laid_out_ink(&layout, &t)); + } + assert_eq!(ink_after.0 - ink_before.0, outlines, "each glyph outline is measured once"); + assert_eq!(ink_after.1 - ink_before.1, BUNDLED.len() as u64, "decorations are measured once per entry"); + } + assert!(counts[0] > 0); + assert_eq!(counts[1], counts[0], "labels that fit must not cause separate label and sample layouts"); +} + +#[test] +fn reused_font_sheet_ink_includes_decorations_and_handles_blank_runs() { + use vectorcraft_doc::{CharStyle, TextRun}; + + for text in ["Hamburg", " "] { + for labels in [false, true] { + let style = CharStyle { font_family: "Inter".into(), size: 12.0, underline: true, strikethrough: true, ..Default::default() }; + let sample = TextRun::new(text, style.clone()); + let (first, more) = if labels { (TextRun::new("Font\n", style), Some(sample)) } else { (sample, None) }; + let t = super::laid_out(first, more, false); + let layout = vectorcraft_text::layout(FontDb::global(), &t); + let bars = vectorcraft_text::decorations(&layout, FontDb::global(), &t); + assert!(!bars.is_empty(), "the entry includes underline and strikethrough bars"); + let ink = t.cached_ink.unwrap().1; + assert_eq!(ink, vectorcraft_render::effects::preview::laid_out_ink(&layout, &t)); + let ink = ink.unwrap(); + for (_, bar) in bars { + let bounds = vectorcraft_geom::Shape::bounding_box(&bar); + assert!(ink.x0 <= bounds.x0 && ink.y0 <= bounds.y0 && ink.x1 >= bounds.x1 && ink.y1 >= bounds.y1); + } + } + } +} + +#[test] +fn an_artboard_deletion_guard_checks_the_document_and_artboard_ids() { + let mut s = Session::new(); + s.execute("file.new", &json!({"artboards": 3})).unwrap(); + let state = s.doc().unwrap(); + let document = (state.uid, state.reverts); + let artboard = state.doc.artboards[1].id; + s.artboard_deletion_guard = Some(crate::ArtboardDeletionGuard { document, artboard, message: "The artboard is in use.".into() }); + s.execute("artboard.delete", &json!({"index": 0})).unwrap(); + let before = (s.doc().unwrap().doc.clone(), steps(&s)); + for params in [json!({"index": 0}), json!({"indices": [1, 0]})] { + let error = s.execute("artboard.delete", ¶ms).unwrap_err(); + assert_eq!(error.to_string(), "The artboard is in use."); + assert_eq!(s.doc().unwrap().doc, before.0); + assert_eq!(steps(&s), before.1); + } + s.execute("file.new", &json!({"artboards": 2})).unwrap(); + s.execute("artboard.delete", &json!({"index": 1})).unwrap(); + assert_eq!(s.doc().unwrap().doc.artboards.len(), 1, "another document is not protected"); + s.execute("document.activate", &json!({"index": 0})).unwrap(); + s.doc_mut().unwrap().reverts += 1; + s.execute("artboard.delete", &json!({"index": 0})).unwrap(); + assert_eq!(s.doc().unwrap().doc.artboards.len(), 1, "a reverted drawing is not protected"); +} + #[test] fn it_needs_a_document() { let mut s = Session::new(); diff --git a/crates/engine/src/cmd/layer.rs b/crates/engine/src/cmd/layer.rs index 78febf0f18..9528bb6c86 100644 --- a/crates/engine/src/cmd/layer.rs +++ b/crates/engine/src/cmd/layer.rs @@ -1155,6 +1155,12 @@ fn artboard_new(s: &mut Session, p: &Value) -> Result { fn artboard_delete(s: &mut Session, p: &Value) -> Result { let indices = super::panelcmds::artboard_indices(&s.doc()?.doc, p, "artboard.delete")?; + if let Some(guard) = &s.artboard_deletion_guard { + let state = s.doc()?; + if (state.uid, state.reverts) == guard.document && indices.iter().any(|&index| state.doc.artboards[index].id == guard.artboard) { + return Err(EngineError::Other(guard.message.clone())); + } + } super::panelcmds::refuse_locked(&s.doc()?.doc, &indices)?; s.edit("Delete Artboard", |d, sel| remove_artboards(d, sel, &indices))?; ok() diff --git a/crates/engine/src/lib.rs b/crates/engine/src/lib.rs index 48964aad0c..e1cabd484b 100644 --- a/crates/engine/src/lib.rs +++ b/crates/engine/src/lib.rs @@ -50,12 +50,19 @@ pub use vectorcraft_tools as tools; pub use vectorcraft_doc::MAX_COORD; const _: () = assert!(vectorcraft_doc::MAX_DEPTH == 32, "TOO_DEEP (and its catalog rows) names the cap"); +pub struct ArtboardDeletionGuard { + pub document: (u64, u64), + pub artboard: u32, + pub message: String, +} + pub struct Session { docs: Vec, active: Option, pub prefs: Prefs, /// Whether Caps Lock is on, as the desktop host reports it; never saved with the preferences. pub caps_lock: bool, + pub artboard_deletion_guard: Option, /// Fill/stroke for new art (the toolbar proxy). pub paint: PaintDefaults, /// Which proxy is in front (true = Fill, false = Stroke) — the X key toggles. diff --git a/crates/engine/src/session/documents.rs b/crates/engine/src/session/documents.rs index 9c65271161..110722fa55 100644 --- a/crates/engine/src/session/documents.rs +++ b/crates/engine/src/session/documents.rs @@ -51,6 +51,7 @@ impl Session { active: None, prefs: Prefs::default(), caps_lock: false, + artboard_deletion_guard: None, paint: PaintDefaults::default(), fill_active: true, clipboard: Clipboard::default(), diff --git a/crates/text/src/layout/driver.rs b/crates/text/src/layout/driver.rs index 5813687d76..07f74f44cc 100644 --- a/crates/text/src/layout/driver.rs +++ b/crates/text/src/layout/driver.rs @@ -99,6 +99,8 @@ pub fn fit_source_lines(db: &FontDb, t: &mut TextObject, lines: usize) -> bool { /// own underline and strikeout metrics through the glyph's transform (so the size, baseline shift /// and scaling follow) → (run, bar in text space). Type on a path and vertical type have none yet. pub fn decorations(layout: &TextLayout, db: &FontDb, t: &TextObject) -> Vec<(usize, BezPath)> { + #[cfg(any(test, feature = "test-fonts"))] + crate::test_fonts::count_decorations(); let mut out = vec![]; if layout.on_path || layout.vertical { return out; @@ -449,6 +451,14 @@ fn layout_once(db: &FontDb, t: &TextObject, opts: &LayoutOptions) -> TextLayout let original = |run: &mut usize| *run = from.get(*run).copied().unwrap_or(*run); l.glyphs.iter_mut().chain(l.ruby.iter_mut()).for_each(|g| original(&mut g.run)); l.inlines.iter_mut().for_each(|i| original(&mut i.run)); + let mut ink: Vec> = vec![None; t.runs.len()]; + for (mut run, bounds) in std::mem::take(&mut l.run_ink_bounds).into_iter().enumerate() { + original(&mut run); + if let (Some(ink), Some(bounds)) = (ink.get_mut(run), bounds) { + *ink = Some(ink.map_or(bounds, |ink| ink.union(bounds))); + } + } + l.run_ink_bounds = ink; l } @@ -572,6 +582,6 @@ fn layout_runs(db: &FontDb, t: &TextObject, opts: &LayoutOptions, set: Option<&T cx.out.line_xf = line_xf; } keep_lone_ligature_carets(&mut cx.out.glyphs); - finish_bounds(&mut cx.out); + finish_bounds(&mut cx.out, t.runs.len()); cx.out } diff --git a/crates/text/src/layout/vertical.rs b/crates/text/src/layout/vertical.rs index 3262362fae..c8ed01552d 100644 --- a/crates/text/src/layout/vertical.rs +++ b/crates/text/src/layout/vertical.rs @@ -402,9 +402,17 @@ pub(super) fn stands_upright(g: &SGlyph) -> bool { !needs_vertical_form || g.gid != g.face.glyph_for(g.ch) } -pub(super) fn finish_bounds(out: &mut TextLayout) { +pub(super) fn finish_bounds(out: &mut TextLayout, runs: usize) { let xf = out.line_xf; - let mut b: Option = out.ink_bounds(); + let mut ink: Vec> = vec![None; runs]; + let mut b: Option = None; + out.for_each_ink(|run, bounds| { + b = Some(b.map_or(bounds, |b| b.union(bounds))); + if let Some(ink) = ink.get_mut(run) { + *ink = Some(ink.map_or(bounds, |ink| ink.union(bounds))); + } + }); + out.run_ink_bounds = ink; let mut add = |r: Rect| b = Some(b.map_or(r, |b| b.union(r))); if !out.on_path { for l in &out.lines { diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index 25e44392d6..27555a8e4a 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -387,6 +387,9 @@ pub struct TextLayout { pub lines: Vec, /// Ink/advance bounds in text space. pub bounds: Rect, + /// Ink bounds per text run when layout completed, excluding decorations. These bounds do + /// not update when glyph geometry changes; [`Self::ink_bounds`] measures the current geometry. + pub run_ink_bounds: Vec>, /// True if area text did not fit its frame (the red overflow "+" marker), or on-path text ran /// past the end of the path. pub overflow: bool, @@ -421,6 +424,7 @@ impl Default for TextLayout { ruby: Vec::new(), lines: Vec::new(), bounds: Rect::ZERO, + run_ink_bounds: Vec::new(), overflow: false, on_path: false, frames: Vec::new(), @@ -476,16 +480,34 @@ impl TextLayout { /// inline graphics included, without the lines' em boxes that [`Self::bounds`] also covers. /// What Align to Glyph Bounds aligns. `None` when nothing draws (only spaces, or no text). pub fn ink_bounds(&self) -> Option { - let outlined = |g: &PositionedGlyph| (!g.outline.elements().is_empty()).then(|| g.outline.bounding_box()); - let glyphs = self.glyphs.iter().flat_map(|g| { + let mut bounds: Option = None; + self.for_each_ink(|_, ink| bounds = Some(bounds.map_or(ink, |bounds| bounds.union(ink)))); + bounds + } + fn for_each_ink(&self, mut add: impl FnMut(usize, Rect)) { + let outlined = |g: &PositionedGlyph| { + (!g.outline.elements().is_empty()).then(|| { + #[cfg(any(test, feature = "test-fonts"))] + test_fonts::count_ink_outline(); + g.outline.bounding_box() + }) + }; + for g in &self.glyphs { let image = g.placed_image().map(|(image, xf)| xf.transform_rect_bbox(image.rect())); let colour = g.colour.as_ref().and_then(|c| c.geometric_bounds()).map(|b| g.xf.transform_rect_bbox(b)); - [outlined(g), image, colour] - }); + for ink in [outlined(g), image, colour].into_iter().flatten() { + add(g.run, ink); + } + } // Ruby is covered by its line's ascent, but its ink can overhang sideways past the line. - let ruby = self.ruby.iter().map(outlined); - let inlines = self.inlines.iter().map(|i| Some(i.bounds)); - glyphs.chain(ruby).chain(inlines).flatten().reduce(|a, b| a.union(b)) + for g in &self.ruby { + if let Some(ink) = outlined(g) { + add(g.run, ink); + } + } + for inline in &self.inlines { + add(inline.run, inline.bounds); + } } /// The box of [`Self::ink_bounds`]' ink with text space mapped by `m`: the glyph and ruby /// outlines are mapped point by point, so a rotated or sheared `m` gives the outlines' own diff --git a/crates/text/src/test_fonts.rs b/crates/text/src/test_fonts.rs index b07c7d63d8..800a832ae2 100644 --- a/crates/text/src/test_fonts.rs +++ b/crates/text/src/test_fonts.rs @@ -29,6 +29,20 @@ pub(crate) fn keeps_shape_plans() -> bool { std::thread_local! { /// How many layouts this thread has started ([`layouts_on_this_thread`]). static LAYOUTS: std::cell::Cell = const { std::cell::Cell::new(0) }; + static INK_OUTLINES: std::cell::Cell = const { std::cell::Cell::new(0) }; + static DECORATIONS: std::cell::Cell = const { std::cell::Cell::new(0) }; +} + +pub(crate) fn count_ink_outline() { + INK_OUTLINES.with(|n| n.set(n.get() + 1)); +} + +pub(crate) fn count_decorations() { + DECORATIONS.with(|n| n.set(n.get() + 1)); +} + +pub fn ink_work_on_this_thread() -> (u64, u64) { + (INK_OUTLINES.with(std::cell::Cell::get), DECORATIONS.with(std::cell::Cell::get)) } pub(crate) fn count_layout() { diff --git a/crates/ui-egui/src/addons/arrange.rs b/crates/ui-egui/src/addons/arrange.rs index a26f5f7a28..98f4061064 100644 --- a/crates/ui-egui/src/addons/arrange.rs +++ b/crates/ui-egui/src/addons/arrange.rs @@ -68,11 +68,11 @@ pub fn menu() -> Vec { ] } -static GRID_SPEC: Spec = Spec { command: GRID, params: grid_params, found: None }; -static REPLACE_SPEC: Spec = Spec { command: REPLACE, params: replace_params, found: None }; -static SIZE_SPEC: Spec = Spec { command: SIZE, params: size_params, found: None }; -static OPACITY_SPEC: Spec = Spec { command: OPACITY, params: opacity_params, found: None }; -static SORT_SPEC: Spec = Spec { command: SORT, params: sort_params, found: None }; +static GRID_SPEC: Spec = Spec { command: GRID, params: grid_params, found: None, pin_opening_artboard: false }; +static REPLACE_SPEC: Spec = Spec { command: REPLACE, params: replace_params, found: None, pin_opening_artboard: false }; +static SIZE_SPEC: Spec = Spec { command: SIZE, params: size_params, found: None, pin_opening_artboard: false }; +static OPACITY_SPEC: Spec = Spec { command: OPACITY, params: opacity_params, found: None, pin_opening_artboard: false }; +static SORT_SPEC: Spec = Spec { command: SORT, params: sort_params, found: None, pin_opening_artboard: false }; /// The dialog over `rows`, titled by the heading of `command`. fn dialog<'a>(command: &str, rows: Vec) -> ParamDialog<'a> { diff --git a/crates/ui-egui/src/addons/color/legend.rs b/crates/ui-egui/src/addons/color/legend.rs index 31fa3a5011..9badbd1a8a 100644 --- a/crates/ui-egui/src/addons/color/legend.rs +++ b/crates/ui-egui/src/addons/color/legend.rs @@ -17,7 +17,7 @@ pub const COMMAND: &str = "addon.color.swatchLegend"; pub const VALUES: [(&str, &str); 5] = [("hex", "HEX"), ("rgb", "RGB"), ("cmyk", "CMYK"), ("lab", "Lab"), ("gray", "Grayscale")]; /// How the dialog's values reach the command. -pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None }; +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None, pin_opening_artboard: false }; /// The command's params from the dialog's fields. pub(crate) fn params(fields: &DialogFields) -> Value { diff --git a/crates/ui-egui/src/addons/dialogs.rs b/crates/ui-egui/src/addons/dialogs.rs index 09b8fe4efe..dd6565701a 100644 --- a/crates/ui-egui/src/addons/dialogs.rs +++ b/crates/ui-egui/src/addons/dialogs.rs @@ -27,6 +27,7 @@ pub(crate) struct Spec { pub params: fn(&DialogFields) -> Value, /// Receives the answer of each preview run (or its error), to show it in the dialog. pub found: Option, + pub pin_opening_artboard: bool, } /// The add-on dialog open now and the live preview it drives; one at a time, since a preview owns the document. @@ -34,6 +35,8 @@ pub(crate) struct Spec { pub(crate) struct AddonDialogs { open: Option, preview: LivePreview, + /// Preview and OK are running with the dialog's opening artboard. + pub(crate) using_opening_artboard: bool, /// The open Tangent Circle Tool radius dialog. pub(crate) tangent_radius: Option, } @@ -44,6 +47,8 @@ struct Open { spec: &'static Spec, /// The opening document's uid and revert count: File › Revert keeps the uid but replaces the drawing. document: Option<(u64, u64)>, + /// The view's active artboard when the dialog opened. + artboard: Option, } impl Open { @@ -62,6 +67,40 @@ fn active_document(app: &VectorcraftApp) -> Option<(u64, u64)> { app.session.active().map(|state| (state.uid, state.reverts)) } +/// Runs the open dialog's command with its opening artboard, then restores the saved artboard. +pub(crate) fn with_opening_artboard(app: &mut VectorcraftApp, command: &str, run: impl FnOnce(&mut VectorcraftApp) -> T) -> T { + let saved = + app.addon_dialogs.open.filter(|open| open.spec.pin_opening_artboard && open.spec.command == command && open.on_document(app)).and_then( + |open| { + let state = app.session.active_mut()?; + let saved = (state.uid, state.active_artboard); + state.active_artboard = open.artboard; + Some(saved) + }, + ); + let using_opening_artboard = app.addon_dialogs.using_opening_artboard; + if saved.is_some() { + app.addon_dialogs.using_opening_artboard = true; + } + let answer = run(app); + app.addon_dialogs.using_opening_artboard = using_opening_artboard; + if let Some((uid, artboard)) = saved + && let Some(state) = app.session.document_mut(uid) + { + state.active_artboard = artboard; + } + answer +} + +pub(crate) fn artboard_deletion_guard(app: &VectorcraftApp) -> Option { + let open = app.addon_dialogs.open.filter(|open| open.spec.pin_opening_artboard)?; + Some(vectorcraft_engine::ArtboardDeletionGuard { + document: open.document?, + artboard: open.artboard?, + message: tl!("Close Create Font Sheet before deleting its opening artboard.").to_owned(), + }) +} + /// Closes the open add-on dialog without an answer and rolls its preview back. fn close_open(app: &mut VectorcraftApp) { let Some(open) = app.addon_dialogs.open.take() else { return }; @@ -102,9 +141,11 @@ pub(crate) fn open_with( let dialog = if previewing { dialog } else { dialog.preview_off() }; let host = app.dialogs().ok_or("no window")?; close_open(app); + crate::io::remember_active_artboard(app); + let artboard = app.session.active().and_then(|state| state.active_artboard); let id = dialog.id(); host.with(|h| h.open(dialog)); - app.addon_dialogs.open = Some(Open { id, spec, document: active_document(app) }); + app.addon_dialogs.open = Some(Open { id, spec, document: active_document(app), artboard }); Ok(json!({ "dialog": spec.command })) } @@ -142,12 +183,22 @@ fn pump_commit(app: &mut VectorcraftApp) { let Some(host) = app.dialogs() else { return }; let Open { id, spec, .. } = open; let on_document = open.on_document(app); + let missing_artboard = spec.pin_opening_artboard + && on_document + && open.artboard.is_some_and(|id| app.session.active().is_some_and(|state| !state.doc.artboards.iter().any(|artboard| artboard.id == id))); if !on_document { // Switching drawings already ends the old preview. Discard its bookkeeping without touching the other drawing. app.addon_dialogs.preview = LivePreview::default(); } let live = host.with(|h| h.get_mut_by_id::(id).map(|d| (d.is_previewing(), (spec.params)(d.fields())))); - if on_document && let Some((previewing, params)) = &live { + if missing_artboard { + mem::take(&mut app.addon_dialogs.preview).cancel(app); + app.status(tl!("The opening artboard was deleted. Reopen this dialog to continue.")); + } + if on_document + && !missing_artboard + && let Some((previewing, params)) = &live + { let mut preview = mem::take(&mut app.addon_dialogs.preview); let label = vectorcraft_engine::find_command(spec.command).map_or(spec.command, |command| command.label); let answer = preview.run(app, *previewing, label, spec.command, params); @@ -162,16 +213,22 @@ fn pump_commit(app: &mut VectorcraftApp) { } match host.with(|h| h.take_by_id::(id)).map(DialogResult::ok) { Some(Some(result)) => { - app.addon_dialogs.open = None; let preview = mem::take(&mut app.addon_dialogs.preview); // The dialog is closed already, so a refusal can only go to the status line. if open.reverted(app) { - app.status("The document was reverted. Reopen this dialog to continue."); + app.status(tl!("The document was reverted. Reopen this dialog to continue.")); } else if !on_document { - app.status("The add-on settings apply only to the drawing where the dialog opened."); - } else if let Err(error) = preview.commit(app, spec.command, (spec.params)(&result.fields)) { - app.status(error); + app.status(tl!("The add-on settings apply only to the drawing where the dialog opened.")); + } else if missing_artboard { + preview.cancel(app); + app.status(tl!("The opening artboard was deleted. Reopen this dialog to continue.")); + } else { + let answer = preview.commit(app, spec.command, (spec.params)(&result.fields)); + if let Err(error) = answer { + app.status(error); + } } + app.addon_dialogs.open = None; } Some(None) => { app.addon_dialogs.open = None; diff --git a/crates/ui-egui/src/addons/pathtools/bridge.rs b/crates/ui-egui/src/addons/pathtools/bridge.rs index 76b3627f76..e3da637953 100644 --- a/crates/ui-egui/src/addons/pathtools/bridge.rs +++ b/crates/ui-egui/src/addons/pathtools/bridge.rs @@ -25,7 +25,7 @@ const REACHES: std::ops::RangeInclusive = 0.0..=10000.0; const REACH: f64 = 10.0; /// How the dialog's values reach the command. -pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None }; +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None, pin_opening_artboard: false }; /// The command's parameters from the dialog's fields: the radius, or with Constant Gap the gap. fn params(fields: &DialogFields) -> Value { diff --git a/crates/ui-egui/src/addons/pathtools/dashes.rs b/crates/ui-egui/src/addons/pathtools/dashes.rs index 48432a81e6..ca266f7139 100644 --- a/crates/ui-egui/src/addons/pathtools/dashes.rs +++ b/crates/ui-egui/src/addons/pathtools/dashes.rs @@ -16,7 +16,7 @@ const DASHES: std::ops::RangeInclusive = 0.01..=1e6; const GAPS: std::ops::RangeInclusive = 0.0..=1e6; /// How the dialog's values reach the command. -pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None }; +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None, pin_opening_artboard: false }; /// The command's parameters from the dialog's fields. pub(crate) fn params(fields: &DialogFields) -> Value { diff --git a/crates/ui-egui/src/addons/pathtools/set_corners.rs b/crates/ui-egui/src/addons/pathtools/set_corners.rs index 50233b0908..dc631f0afe 100644 --- a/crates/ui-egui/src/addons/pathtools/set_corners.rs +++ b/crates/ui-egui/src/addons/pathtools/set_corners.rs @@ -23,7 +23,7 @@ const EVERY: [(&str, &str); 3] = [("all", "All Anchors"), ("odd", "Odd-Numbered const ANGLES: std::ops::RangeInclusive = 0.0..=180.0; /// How the dialog's values reach the command. -pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None }; +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None, pin_opening_artboard: false }; /// The command's parameters from the dialog's fields. pub(crate) fn params(fields: &DialogFields) -> Value { diff --git a/crates/ui-egui/src/addons/pathtools/tangent_circle.rs b/crates/ui-egui/src/addons/pathtools/tangent_circle.rs index c890e063da..743672324a 100644 --- a/crates/ui-egui/src/addons/pathtools/tangent_circle.rs +++ b/crates/ui-egui/src/addons/pathtools/tangent_circle.rs @@ -20,7 +20,7 @@ const MAX_CIRCLES: u64 = 64; const RADIUS: f64 = 36.0; /// How the dialog's values reach the command; the preview's answer says how many circles were found. -pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: Some(found) }; +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: Some(found), pin_opening_artboard: false }; /// The circle number the choice holds (an option id): 0 is every circle, `k` the k-th, counted from 1. fn circle(fields: &DialogFields) -> u64 { diff --git a/crates/ui-egui/src/addons/typetools.rs b/crates/ui-egui/src/addons/typetools.rs index 790d4e661c..32ba39d4a2 100644 --- a/crates/ui-egui/src/addons/typetools.rs +++ b/crates/ui-egui/src/addons/typetools.rs @@ -55,7 +55,7 @@ fn attribute(key: &str) -> &'static Attribute { } /// How the dialog's values reach the command. -pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None }; +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None, pin_opening_artboard: false }; /// The command's parameters from the dialog's fields; an end of the ramp not set yet is the attribute's own. pub(crate) fn params(fields: &DialogFields) -> Value { diff --git a/crates/ui-egui/src/addons/typetools/font_sheet.rs b/crates/ui-egui/src/addons/typetools/font_sheet.rs index 3d92a96f1b..987adbdc75 100644 --- a/crates/ui-egui/src/addons/typetools/font_sheet.rs +++ b/crates/ui-egui/src/addons/typetools/font_sheet.rs @@ -18,7 +18,7 @@ pub const COMMAND: &str = "addon.type.fontSheet"; const SAMPLE: &str = "The quick brown fox jumps over the lazy dog"; /// How the dialog's values reach the command. -pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None }; +pub(crate) static SPEC: Spec = Spec { command: COMMAND, params, found: None, pin_opening_artboard: true }; /// The command's parameters from the dialog's fields; an empty filter sets every family. pub(crate) fn params(fields: &DialogFields) -> Value { 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 4891cea545..76eaf6193b 100644 --- a/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs +++ b/crates/ui-egui/src/addons/typetools/font_sheet/tests.rs @@ -85,6 +85,337 @@ fn keyboard_and_checkbox_edits_reach_font_sheet_preview_ok_and_cancel() { } } +/// Asserts that every entry of the selected font sheet starts on artboard `index`. +fn assert_on_artboard(app: &VectorcraftApp, index: usize, case: &str) { + let board = app.session.active().unwrap().doc.artboards[index].rect; + let entries = sheet(app); + assert!(!entries.is_empty(), "{case}"); + for entry in &entries { + let [.., x, _] = entry.xf.as_coeffs(); + assert!(x >= board.x0 && x <= board.x1, "{case}: entry at {x} lies outside artboard {index} {board:?}"); + } +} + +/// Preview and OK with Preview off use the artboard picked in the view before the dialog opens. +#[test] +fn font_sheet_preview_and_ok_use_the_views_current_artboard() { + for preview in [false, true] { + 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(); + panel.click_role("Font Names Containing", Role::TEXT_INPUT); + panel.type_text("Source Serif 4"); + panel.key(egui::Key::Tab, egui::Modifiers::NONE); + panel.app().view_mut().unwrap().artboard = 0; + if preview { + panel.click_role("Preview", Role::CHECK_BOX); + panel.frame(); + assert!(panel.app().session.in_interaction()); + assert_on_artboard(&panel.app(), 1, "the preview on the opening artboard"); + } + panel.click("OK"); + assert_on_artboard(&panel.app(), 1, if preview { "OK after Preview" } else { "OK with Preview off" }); + } +} + +#[test] +fn deleting_the_opening_artboard_refuses_font_sheet_preview_and_ok() { + for preview in [false, true] { + 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(); + panel.click_role("Font Names Containing", Role::TEXT_INPUT); + panel.type_text("Source Serif 4"); + panel.key(egui::Key::Tab, egui::Modifiers::NONE); + panel.app().session.execute("artboard.delete", &json!({"index": 1})).unwrap(); + let before = panel.app().session.active().unwrap().doc.clone(); + let undo = panel.app().session.active().unwrap().history.undo.len(); + if preview { + panel.click_role("Preview", Role::CHECK_BOX); + panel.frame(); + assert!(!panel.app().session.in_interaction()); + assert_eq!(panel.app().session.active().unwrap().doc, before); + assert_eq!(panel.app().ui.status, "The opening artboard was deleted. Reopen this dialog to continue."); + assert_eq!(panel.app().ui.status, tl!("The opening artboard was deleted. Reopen this dialog to continue.")); + } + panel.click("OK"); + assert_eq!(panel.app().session.active().unwrap().doc, before, "OK creates no sheet entries after the opening artboard is deleted"); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo); + assert!(!panel.app().session.in_interaction()); + assert_eq!(panel.app().ui.status, "The opening artboard was deleted. Reopen this dialog to continue."); + assert_eq!(panel.app().ui.status, tl!("The opening artboard was deleted. Reopen this dialog to continue.")); + assert!(crate::tests::picks::open_dialogs(&panel.app()).is_empty()); + } +} + +#[test] +fn deleting_the_opening_artboard_is_refused_before_it_changes_a_font_sheet_preview() { + for preview in [false, true] { + for commit in [false, true] { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 600, "height": 400, "artboards": 3})).unwrap(); + app.sync_views(); + let original = app.session.active().unwrap().doc.clone(); + let undo = app.session.active().unwrap().history.undo.len(); + 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(); + panel.click_role("Font Names Containing", Role::TEXT_INPUT); + panel.type_text("Source Serif 4"); + panel.key(egui::Key::Tab, egui::Modifiers::NONE); + if preview { + panel.click_role("Preview", Role::CHECK_BOX); + } + let before = panel.app().session.active().unwrap().doc.clone(); + let selection = panel.app().session.active().unwrap().selection.clone(); + for params in [json!({"index": 1}), json!({"indices": [2, 1, 1]})] { + let (request, _) = craft::automation::ControlRequest::new("engine.execute", json!({"command": "artboard.delete", "params": params})); + let craft::automation::Reply::Done(answer) = crate::control::handle(&mut panel.app(), &egui::Context::default(), &request) else { + panic!("the deletion did not finish"); + }; + assert_eq!(answer["ok"], false, "{answer}"); + assert!(answer.to_string().contains(tl!("Close Create Font Sheet before deleting its opening artboard.")), "{answer}"); + panel.frame(); + assert_eq!(panel.app().session.active().unwrap().doc, before); + assert_eq!(panel.app().session.active().unwrap().selection, selection); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo); + assert_eq!(panel.app().session.in_interaction(), preview); + assert!(panel.app().session.artboard_deletion_guard.is_none()); + } + panel.click(if commit { "OK" } else { "Cancel" }); + assert!(!panel.app().session.in_interaction()); + if commit { + assert_on_artboard(&panel.app(), 1, "OK after a refused deletion"); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo + 1); + panel.app().run("edit.undo", json!({})).unwrap(); + } + assert_eq!(panel.app().session.active().unwrap().doc, original); + panel.app().run("artboard.delete", json!({"index": 1})).unwrap(); + assert_eq!(panel.app().session.active().unwrap().doc.artboards.len(), 2); + } + } +} + +#[test] +fn a_batch_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": 3})).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(); + let undo = panel.app().session.active().unwrap().history.undo.len(); + let error = panel + .app() + .run( + "command.batch", + json!({"commands": [ + {"command": "artboard.delete", "params": {"index": 0}}, + {"command": "artboard.delete", "params": {"index": 0}} + ]}), + ) + .unwrap_err(); + assert!(error.contains(tl!("Close Create Font Sheet before deleting its opening artboard.")), "{error}"); + assert_eq!(panel.app().session.active().unwrap().doc, before, "the earlier deletion is rolled back"); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo); + assert!(panel.app().session.artboard_deletion_guard.is_none()); + panel.click("Cancel"); + assert_eq!(panel.app().session.active().unwrap().doc, before); +} + +#[test] +fn font_sheet_allows_deleting_another_artboard() { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 600, "height": 400, "artboards": 3})).unwrap(); + app.sync_views(); + let opening = app.session.active().unwrap().doc.artboards[1].id; + 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(); + panel.app().run("artboard.delete", json!({"index": 0})).unwrap(); + assert_eq!(panel.app().session.active().unwrap().doc.artboards[0].id, opening); + assert!(panel.app().run("artboard.delete", json!({"index": 0})).is_err(), "the protection follows the artboard ID"); + let before = panel.app().session.active().unwrap().doc.clone(); + panel.click("Cancel"); + assert_eq!(panel.app().session.active().unwrap().doc, before); +} + +#[test] +fn another_addon_uses_the_current_artboard_and_survives_deleting_its_opening_artboard() { + use crate::addons::dialogs::tests as host; + + for commit in [false, true] { + let mut app = VectorcraftApp::new(vectorcraft_engine::Session::new(), Default::default()); + app.run("file.new", json!({"width": 600, "height": 400, "artboards": 2})).unwrap(); + let id = app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 20, "height": 20})).unwrap()["id"].as_u64().unwrap(); + app.sync_views(); + let current = app.session.active().unwrap().doc.artboards[0].id; + 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; + let command = "addon.arrange.randomizeOpacity"; + crate::menus::invoke(&mut panel.app(), command, json!({})); + panel.frame(); + panel.click_role("Preview", Role::CHECK_BOX); + panel.app().view_mut().unwrap().artboard = 0; + crate::io::remember_active_artboard(&mut panel.app()); + let active = crate::addons::dialogs::with_opening_artboard(&mut panel.app(), command, |app| app.session.active().unwrap().active_artboard); + assert_eq!(active, Some(current), "the other dialog does not pin the opening artboard"); + panel.app().run("artboard.delete", json!({"index": 1})).unwrap(); + let before = panel.app().session.active().unwrap().doc.clone(); + let undo = panel.app().session.active().unwrap().history.undo.len(); + let dialog = host::dialog_id(&panel.app()); + host::set(&panel.app(), dialog, "min", json!(37)); + host::set(&panel.app(), dialog, "max", json!(37)); + panel.click_role("Preview", Role::CHECK_BOX); + panel.frame(); + assert!(panel.app().session.in_interaction()); + assert!((panel.app().session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().opacity - 0.37).abs() < 1e-6); + panel.click(if commit { "OK" } else { "Cancel" }); + assert!(!panel.app().session.in_interaction()); + assert_eq!(panel.app().session.active().unwrap().doc.artboards.len(), 1); + assert_eq!(panel.app().session.active().unwrap().history.undo.len(), undo + usize::from(commit)); + if commit { + assert!((panel.app().session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().opacity - 0.37).abs() < 1e-6); + } else { + assert_eq!(panel.app().session.active().unwrap().doc, before); + } + } +} + +#[test] +fn font_sheet_frames_restore_the_active_artboard_after_preview_and_commit() { + for commit in [false, true] { + for preview_at_close in [false, true] { + 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 current = app.session.active().unwrap().doc.artboards[0].id; + 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(); + panel.click_role("Font Names Containing", Role::TEXT_INPUT); + panel.type_text("Source Serif 4"); + panel.key(egui::Key::Tab, egui::Modifiers::NONE); + panel.app().view_mut().unwrap().artboard = 0; + crate::io::remember_active_artboard(&mut panel.app()); + for _ in 0..2 { + panel.frame(); + assert_eq!(panel.app().session.active().unwrap().active_artboard, Some(current), "Preview off preserves the active artboard"); + } + for preview in [true, false, true, false] { + panel.click_role("Preview", Role::CHECK_BOX); + assert_eq!(panel.app().session.active().unwrap().active_artboard, Some(current), "toggling Preview preserves the active artboard"); + for _ in 0..2 { + panel.frame(); + assert_eq!(panel.app().session.active().unwrap().active_artboard, Some(current), "idle frames preserve the active artboard"); + } + assert_eq!(panel.app().session.in_interaction(), preview); + if preview { + assert_on_artboard(&panel.app(), 1, "Preview uses the opening artboard"); + } + } + if preview_at_close { + panel.click_role("Preview", Role::CHECK_BOX); + assert_eq!(panel.app().session.active().unwrap().active_artboard, Some(current)); + } + panel.click(if commit { "OK" } else { "Cancel" }); + assert_eq!(panel.app().session.active().unwrap().active_artboard, Some(current), "closing the dialog preserves the active artboard"); + assert!(!panel.app().session.in_interaction()); + if commit { + assert_on_artboard(&panel.app(), 1, "OK uses the opening artboard"); + } + } + } +} + +#[test] +fn a_standalone_font_sheet_uses_the_current_artboard_with_its_dialog_open() { + 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)); + crate::menus::invoke(&mut panel.app(), super::COMMAND, json!({})); + panel.frame(); + panel.app().view_mut().unwrap().artboard = 1; + let (request, _) = craft::automation::ControlRequest::new( + "engine.execute", + json!({"command": super::COMMAND, "params": {"families": ["Inter"], "labels": false}}), + ); + let craft::automation::Reply::Done(answer) = crate::control::handle(&mut panel.app(), &egui::Context::default(), &request) else { + panic!("the font sheet command did not finish"); + }; + assert_eq!(answer["ok"], true, "{answer}"); + assert_on_artboard(&panel.app(), 1, "a standalone command while Preview is off"); + panel.click("Cancel"); + assert_on_artboard(&panel.app(), 1, "Cancel keeps the standalone sheet"); +} + +/// The sheet stays on its opening artboard when a preview removes the page shown in the view. +#[test] +fn going_to_a_page_the_font_sheet_preview_added_keeps_its_start() { + 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)); + crate::menus::invoke(&mut panel.app(), super::COMMAND, json!({})); + panel.frame(); + let original_artboards = panel.app().session.active().unwrap().doc.artboards.len(); + // Each page holds one 100 pt entry. + let edits = [("Font Names Containing", Role::TEXT_INPUT, "Source S"), ("Size", Role::SPIN_BUTTON, "100"), ("Columns", Role::SPIN_BUTTON, "1")]; + for (label, role, input) in edits { + panel.click_role(label, role); + panel.key(egui::Key::A, egui::Modifiers::COMMAND); + panel.type_text(input); + panel.key(egui::Key::Tab, egui::Modifiers::NONE); + } + panel.click_role("Preview", Role::CHECK_BOX); + panel.frame(); + assert!(panel.app().session.active().unwrap().doc.artboards.len() > original_artboards, "the preview adds a page"); + panel.app().view_mut().unwrap().artboard = original_artboards; + panel.frame(); + let first_on_opening_artboard = |panel: &Panel| { + let app = panel.app(); + let [.., x, _] = sheet(&app)[0].xf.as_coeffs(); + let board = app.session.active().unwrap().doc.artboards[0].rect; + assert!(x >= board.x0 && x <= board.x1, "the first entry stays on the opening artboard: {x}, {board:?}"); + }; + first_on_opening_artboard(&panel); + panel.click_role("Add Artboards When Full", Role::CHECK_BOX); + panel.frame(); + assert_eq!(panel.app().session.active().unwrap().doc.artboards.len(), original_artboards); + panel.app().sync_views(); + assert_eq!(panel.app().view().unwrap().artboard, original_artboards - 1, "the view clamps to the last original artboard"); + panel.frame(); + first_on_opening_artboard(&panel); + panel.click_role("Preview", Role::CHECK_BOX); + panel.frame(); + assert!(!panel.app().session.in_interaction()); + panel.click("OK"); + first_on_opening_artboard(&panel); +} + /// An empty filter sends none, so the sheet sets every family; a filter is sent trimmed. #[test] fn params_sends_a_filter_only_when_one_is_typed() { diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index b7ff421414..e6b526f441 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -88,7 +88,10 @@ impl VectorcraftApp { let touch_workspace = self.session.prefs.touch_workspace; // A `prefs.reset` that ran straight on the session applies before this command can switch workspaces. crate::prefs_dialog::apply_prefs_resets(self); + let guard = crate::addons::dialogs::artboard_deletion_guard(self); + let previous_guard = std::mem::replace(&mut self.session.artboard_deletion_guard, guard); let result = self.run_now(id, params); + self.session.artboard_deletion_guard = previous_guard; crate::prefs_dialog::apply_prefs_resets(self); if id == "prefs.import" && result.is_ok() { crate::prefs_dialog::imported(self, touch_workspace); @@ -157,7 +160,9 @@ impl VectorcraftApp { self.wait_for_tool_edit(id); // A `.ai` file a command writes (a save, an export, a timestamped copy, a batch's save) names // the view's active artboard. - io::remember_active_artboard(self); + if !self.addon_dialogs.using_opening_artboard { + io::remember_active_artboard(self); + } let artboards = self.artboard_tool_state(); if let Some(r) = menus::run_ui_command(self, id, ¶ms) { self.ui.recording_base = None; diff --git a/crates/ui-egui/src/dialogs/preview.rs b/crates/ui-egui/src/dialogs/preview.rs index 2e029fc1c6..79654f4c92 100644 --- a/crates/ui-egui/src/dialogs/preview.rs +++ b/crates/ui-egui/src/dialogs/preview.rs @@ -76,7 +76,7 @@ impl LivePreview { app.status(e); return None; } - let answer = match app.session.preview(cmd, params) { + let answer = match crate::addons::dialogs::with_opening_artboard(app, cmd, |app| app.session.preview(cmd, params)) { Ok(v) => Ok(v), Err(e) => { app.status(e.to_string()); @@ -105,9 +105,9 @@ impl LivePreview { if app.session.in_interaction() { return Err(tl!("Finish the active edit first.").to_owned()); } - return app.run(cmd, params); + return crate::addons::dialogs::with_opening_artboard(app, cmd, |app| app.run(cmd, params)); } - let result = app.session.preview(cmd, ¶ms).and_then(|answer| { + let result = crate::addons::dialogs::with_opening_artboard(app, cmd, |app| app.session.preview(cmd, ¶ms)).and_then(|answer| { app.session.commit_interaction()?; Ok(answer) }); diff --git a/docs/mcp.md b/docs/mcp.md index fde01f0426..dee1f80313 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -17995,10 +17995,14 @@ the fonts can be compared on the artboard or printed. 612 × 792 pt page at the origin and adds no artboards. - **Fonts that don't load:** a family whose font can't be loaded (text in it would be drawn in the fallback font), or with `allStyles` a style that can't (it would be drawn in the family's closest style), is left out, listed in - `skipped` and named in `warning`, which the status bar shows. -- The sheet is one group named Font Sheet, in the current layer, made in one undo step and selected. Nothing changes, - and an error is returned, when no family matches, when there would be more than 5000 entries, when no font loads, - when the margin, gap and columns leave no room for one entry, or when the current layer is locked or hidden. + `skipped` and named in `warning`, which the status bar shows. A composite font is left out the same way when a part + that sets the sample text names a font or style that can't be loaded. +- Each row is as tall as the tallest laid-out entry needs, so a composite font whose part enlarges or raises the + sample does not overlap the entry above it or reach into the margin. +- The sheet is one group named Font Sheet, made in one undo step and selected. It goes where new art goes: the current + layer, or, when that layer is locked or hidden, the topmost layer that is shown and unlocked. Nothing changes, and an + error is returned, when no family matches, when there would be more than 5000 entries, when no font loads, when the + margin, gap and columns leave no room for one entry, or when no layer is shown and unlocked. | Parameter | Values (default) | |---|---| diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index cadb5b2c33..0e11ab4886 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3168,7 +3168,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, 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 are left out and listed. The sheet is one selected group made in one undo step, from a dialog whose Preview starts off (`addon.type.fontSheet`). 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, undo, a locked layer, bad params refused), `addons::typetools::font_sheet::tests` 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, 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. 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) From e58c1f2a07935064fe57e9cd5b29b0572a042e63 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 03:07:02 -0800 Subject: [PATCH 04/14] Type Tools: Create Font Sheet's artboard guard covers every artboard deletion Cut Artboard, Delete Empty Artboards and Artwork Cleanup's Empty Artboards now return the guard's error, with nothing changed, when they would delete the artboard an open Create Font Sheet dialog uses, as Delete Artboard already did. `families` with any `filter`, an empty one included, is an error. docs/mcp.md says that `null` is the same as an omitted parameter for `addon.type.fontSheet`, and the progress line says labels are optional. --- crates/engine/src/cmd/addons/cleanup.rs | 9 ++++++- .../src/cmd/addons/typetools/font_sheet.rs | 4 +-- .../cmd/addons/typetools/font_sheet/tests.rs | 26 +++++++++++++++++++ crates/engine/src/cmd/layer.rs | 25 ++++++++++++------ crates/engine/src/cmd/panelcmds.rs | 3 ++- docs/mcp.md | 11 ++++++-- docs/target-app-parity.md | 2 +- 7 files changed, 65 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/cmd/addons/cleanup.rs b/crates/engine/src/cmd/addons/cleanup.rs index d5f241b4ee..9050f07479 100644 --- a/crates/engine/src/cmd/addons/cleanup.rs +++ b/crates/engine/src/cmd/addons/cleanup.rs @@ -64,7 +64,7 @@ pub fn specs() -> Vec { "Fix All Issues", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{scope?: \"selection\"|\"document\", kinds?: [kind…] (default: all; see addon.cleanup.check)} fix the issues addon.cleanup.check finds, in up to three rounds while a round still finds some (a fix can leave issues for another kind), as one undo step: what is empty, unpainted, invisible, duplicated or off the artboards goes, anchors merge, snap or go, tiny handles retract, paths close and needless groups, compound paths and clipping groups give way to their contents → {scope, total, fixed: {kind: count}}", + "{scope?: \"selection\"|\"document\", kinds?: [kind…] (default: all; see addon.cleanup.check)} fix the issues addon.cleanup.check finds, in up to three rounds while a round still finds some (a fix can leave issues for another kind), as one undo step: what is empty, unpainted, invisible, duplicated or off the artboards goes, anchors merge, snap or go, tiny handles retract, paths close and needless groups, compound paths and clipping groups give way to their contents. An error, with nothing fixed, when the fixes would delete the artboard an open Create Font Sheet dialog uses → {scope, total, fixed: {kind: count}}", has_doc, fix ), @@ -260,6 +260,13 @@ fn fix(s: &mut Session, p: &Value) -> Result { } // With nothing to fix, the document and its undo history stay as they are. if total > 0 { + if let Some(guard) = &s.artboard_deletion_guard { + let st = s.doc()?; + let protected = |doc: &Document| doc.artboards.iter().any(|a| a.id == guard.artboard); + if (st.uid, st.reverts) == guard.document && protected(&st.doc) && !protected(&d) { + return Err(EngineError::Other(guard.message.clone())); + } + } sel.prune(&d); s.edit("Fix Issues", |doc, selection| { *doc = d; diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs index 9d71c86610..14c4f46edf 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -36,7 +36,7 @@ pub fn specs() -> Vec { "Create Font Sheet", ["Object", "Plug-ins", "Type Tools"], None, - "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer (else the topmost layer shown and unlocked), in one undo step; the group is selected. Each row is as tall as the tallest laid-out entry. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, or a composite font with a part setting the sample whose font or style can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", + "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once; an error with any filter, an empty one included), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer (else the topmost layer shown and unlocked), in one undo step; the group is selected. Each row is as tall as the tallest laid-out entry. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, or a composite font with a part setting the sample whose font or style can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", has_doc, font_sheet )] @@ -91,7 +91,7 @@ fn families(p: &Value, db: &FontDb) -> Result> { } return Ok(found); } - Some(_) if filter.is_some() => return Err(bad(COMMAND, "give `families` or `filter`, not both")), + Some(_) if p.get("filter").is_some_and(|f| !f.is_null()) => return Err(bad(COMMAND, "give `families` or `filter`, not both")), Some(Value::Array(a)) => a, Some(_) => return Err(bad(COMMAND, "`families` must be a list of font family names")), }; diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index 1095b4428c..5119d6c339 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -168,6 +168,8 @@ fn bad_params_are_refused_without_a_change() { json!({"families": ["No Such Family Anywhere"]}), json!({"families": [""]}), json!({"families": ["Inter"], "filter": "Inter"}), + json!({"families": ["Inter"], "filter": ""}), + json!({"families": ["Inter"], "filter": " "}), json!({"labels": "yes"}), json!({"allStyles": 1}), json!({"newArtboards": "no"}), @@ -375,6 +377,30 @@ fn an_artboard_deletion_guard_checks_the_document_and_artboard_ids() { assert_eq!(s.doc().unwrap().doc.artboards.len(), 1, "a reverted drawing is not protected"); } +/// Cut Artboard, Delete Empty Artboards and Artwork Cleanup's Empty Artboards keep the guarded artboard too. +#[test] +fn an_artboard_deletion_guard_covers_every_command_that_deletes_artboards() { + let mut s = Session::new(); + s.execute("file.new", &json!({"artboards": 3})).unwrap(); + let state = s.doc().unwrap(); + let document = (state.uid, state.reverts); + let artboard = state.doc.artboards[1].id; + s.artboard_deletion_guard = Some(crate::ArtboardDeletionGuard { document, artboard, message: "The artboard is in use.".into() }); + let before = (s.doc().unwrap().doc.clone(), steps(&s)); + for (command, params) in [ + ("artboard.cut", json!({"index": 1})), + ("artboard.deleteEmpty", json!({})), + ("addon.cleanup.fix", json!({"kinds": ["emptyArtboards"], "scope": "document"})), + ] { + let error = s.execute(command, ¶ms).unwrap_err(); + assert_eq!(error.to_string(), "The artboard is in use.", "{command}"); + assert_eq!(s.doc().unwrap().doc, before.0, "{command}"); + assert_eq!(steps(&s), before.1, "{command}"); + } + s.execute("artboard.cut", &json!({"index": 2})).unwrap(); + assert_eq!(s.doc().unwrap().doc.artboards.len(), 2, "another artboard is cut"); +} + #[test] fn it_needs_a_document() { let mut s = Session::new(); diff --git a/crates/engine/src/cmd/layer.rs b/crates/engine/src/cmd/layer.rs index 9528bb6c86..19c1358c2a 100644 --- a/crates/engine/src/cmd/layer.rs +++ b/crates/engine/src/cmd/layer.rs @@ -147,7 +147,7 @@ pub fn specs() -> Vec { "Delete Artboard", ["Window", "Artboards"], None, - "{index | indices: [index…]} delete artboards (with their guides) in one step; one is always left, and a locked one is an error", + "{index | indices: [index…]} delete artboards (with their guides) in one step; one is always left, and a locked one, or the one an open Create Font Sheet dialog uses, is an error", has_doc, artboard_delete ), @@ -156,7 +156,7 @@ pub fn specs() -> Vec { "Delete Empty Artboards", ["Window", "Artboards"], None, - "{} delete every artboard with no artwork on it (no object, hidden, locked and template art included, whose visual bounds meet or touch it, clip groups and clipping layers by their members inside the clip; guides don't count), with its guides, in one step; locked artboards stay; when every artboard is empty and none is locked, artboard 1 stays (with a locked one left, artboard 1 can go) → {deleted: [index…]} (the indices before deleting)", + "{} delete every artboard with no artwork on it (no object, hidden, locked and template art included, whose visual bounds meet or touch it, clip groups and clipping layers by their members inside the clip; guides don't count), with its guides, in one step; locked artboards stay; when every artboard is empty and none is locked, artboard 1 stays (with a locked one left, artboard 1 can go); an error, with nothing deleted, when one of them is the artboard an open Create Font Sheet dialog uses → {deleted: [index…]} (the indices before deleting)", has_empty_artboards, artboard_delete_empty ), @@ -1155,17 +1155,25 @@ fn artboard_new(s: &mut Session, p: &Value) -> Result { fn artboard_delete(s: &mut Session, p: &Value) -> Result { let indices = super::panelcmds::artboard_indices(&s.doc()?.doc, p, "artboard.delete")?; - if let Some(guard) = &s.artboard_deletion_guard { - let state = s.doc()?; - if (state.uid, state.reverts) == guard.document && indices.iter().any(|&index| state.doc.artboards[index].id == guard.artboard) { - return Err(EngineError::Other(guard.message.clone())); - } - } + refuse_guarded(s, &indices)?; super::panelcmds::refuse_locked(&s.doc()?.doc, &indices)?; s.edit("Delete Artboard", |d, sel| remove_artboards(d, sel, &indices))?; ok() } +/// The session's artboard deletion guard's message when deleting artboards `indices` of the +/// active document would delete the artboard it protects. +pub(crate) fn refuse_guarded(s: &Session, indices: &[usize]) -> Result<()> { + let Some(guard) = &s.artboard_deletion_guard else { return Ok(()) }; + let state = s.doc()?; + if (state.uid, state.reverts) == guard.document + && indices.iter().any(|&index| state.doc.artboards.get(index).is_some_and(|a| a.id == guard.artboard)) + { + return Err(EngineError::Other(guard.message.clone())); + } + Ok(()) +} + /// Delete artboards `indices` (sorted, each once) of `d` with their guides; at least one must be /// left. The other artboards keep their order, no later artboard takes a deleted one's id, and /// `sel` forgets the deleted guides. One walk over the artboards and one over the ruler guides, @@ -1242,6 +1250,7 @@ fn artboard_delete_empty(s: &mut Session, _: &Value) -> Result { if indices.is_empty() { return Err(EngineError::Other("no empty artboards to delete".into())); } + refuse_guarded(s, &indices)?; s.edit("Delete Empty Artboards", |d, sel| remove_artboards(d, sel, &indices))?; Ok(json!({ "deleted": indices })) } diff --git a/crates/engine/src/cmd/panelcmds.rs b/crates/engine/src/cmd/panelcmds.rs index 433c69202c..4ccd3529e2 100644 --- a/crates/engine/src/cmd/panelcmds.rs +++ b/crates/engine/src/cmd/panelcmds.rs @@ -38,7 +38,7 @@ pub fn specs() -> Vec { "Cut Artboard", [], None, - "{index? | indices?, selectedArtboards?, art?, lockedAndHidden?} put the artboards and the art fully inside each on the clipboard (leaving oversized or overhanging art on the canvas and off the clipboard), then delete the artboards and that art in one undo step (one artboard is always left: the cut fails when it names every artboard, or a locked one; art also on another locked artboard stays, and is left off the clipboard, unless lockedAndHidden); edit.cut runs this while the Artboard tool is chosen → {copied: objects}", + "{index? | indices?, selectedArtboards?, art?, lockedAndHidden?} put the artboards and the art fully inside each on the clipboard (leaving oversized or overhanging art on the canvas and off the clipboard), then delete the artboards and that art in one undo step (one artboard is always left: the cut fails when it names every artboard, a locked one, or the one an open Create Font Sheet dialog uses; art also on another locked artboard stays, and is left off the clipboard, unless lockedAndHidden); edit.cut runs this while the Artboard tool is chosen → {copied: objects}", has_doc, |s, p| { boards_and_art_noted(s, p, "artboard.cut")?; @@ -366,6 +366,7 @@ pub(crate) fn artboard_copy(s: &mut Session, p: &Value, cut: bool) -> Result Date: Mon, 30 Nov 2026 05:16:31 -0800 Subject: [PATCH 05/14] Type Tools: Create Font Sheet's artboard guard covers script slices A script run that the frames take to its end ran each slice with no artboard deletion guard, so a vc.run of artboard.delete in a later slice could delete the artboard an open Create Font Sheet dialog uses. The script poll now sets the guard around each pump and restores the previous one after it. The new test runs such a script in the frames and checks that the deletion is refused and the document is unchanged. --- .../src/addons/typetools/font_sheet/tests.rs | 29 +++++++++++++++++++ crates/ui-egui/src/script_runs.rs | 4 +++ docs/mcp.md | 3 +- docs/target-app-parity.md | 2 +- 4 files changed, 36 insertions(+), 2 deletions(-) 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) From 3281477229c9da57d4cf4de89cde894fc62c05cd Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 06:08:53 -0800 Subject: [PATCH 06/14] Docs: Create Font Sheet adds artboards only with Add Artboards When Full on --- docs/target-app-parity.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 08ca2761bc..d6c812d7d2 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, 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. +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. When the artboard is full, Add Artboards When Full (on by default) adds new artboards of the same size to its right for the rest; with it off, the rest is laid out in the same places to the right without artboards. 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) From f80c7d33ac62a9e37956fdd675fa99af1eaf49da Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 30 Nov 2026 22:39:51 -0800 Subject: [PATCH 07/14] Type: test that a locked current layer sends Create Font Sheet to the topmost editable layer --- .../src/cmd/addons/typetools/font_sheet/tests.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index 5119d6c339..a64d79c7a2 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -416,3 +416,17 @@ fn a_locked_layer_takes_no_sheet() { assert!(s.execute(COMMAND, &json!({"families": ["Inter"]})).is_err()); assert_eq!(steps(&s), before); } + +#[test] +fn a_locked_current_layer_sends_the_sheet_to_the_topmost_editable_layer() { + let mut s = session(); + let editable = s.doc().unwrap().doc.layers[0].id; + let locked = NodeId(s.execute("layer.new", &json!({})).unwrap()["id"].as_u64().unwrap()); + s.execute("layer.setProps", &json!({"id": locked.0, "locked": true})).unwrap(); + let r = s.execute(COMMAND, &json!({"families": ["Inter"]})).unwrap(); + let gid = NodeId(r["id"].as_u64().unwrap()); + let doc = &s.doc().unwrap().doc; + let holds = |layer: NodeId| doc.children(Some(layer)).is_some_and(|c| c.iter().any(|n| n.id == gid)); + assert!(holds(editable), "the sheet goes to the layer that is shown and unlocked"); + assert!(!holds(locked)); +} From 8a808afc6fd7f84db77848972701781f019c20cc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 1 Dec 2026 12:22:29 -0800 Subject: [PATCH 08/14] Type: Create Font Sheet aligns right-to-left samples left and journals its artboard Right-to-left samples used the automatic alignment, which anchors them at their right edge, so a sample started left of its column and could cross the margin or the column before it. Every line is now aligned left. The command now takes `artboard`, and when it is left out the journal records the active artboard as `activeArtboard`, so a replay lays the sheet out on the same artboard. An action leaves `activeArtboard` out. --- .../src/cmd/addons/typetools/font_sheet.rs | 21 ++++++-- .../cmd/addons/typetools/font_sheet/tests.rs | 52 +++++++++++++++++++ crates/engine/src/command_sets.rs | 3 +- docs/mcp.md | 9 ++-- docs/target-app-parity.md | 2 +- 5 files changed, 79 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs index 14c4f46edf..46ae534764 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -11,6 +11,7 @@ use vectorcraft_geom::{Affine, Point, Rect, Shape}; use vectorcraft_text::{FontDb, FontMatch}; use super::super::super::create::{new_type_para, new_type_style}; +use super::super::super::panelcmds::artboard_at; use super::super::super::typecmd::refresh_bounds; use super::super::super::{CommandSpec, bad, cmd, has_doc, switch_or}; use crate::{Result, Session}; @@ -36,7 +37,7 @@ pub fn specs() -> Vec { "Create Font Sheet", ["Object", "Plug-ins", "Type Tools"], None, - "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once; an error with any filter, an empty one included), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, flowed down the columns of the active artboard (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer (else the topmost layer shown and unlocked), in one undo step; the group is selected. Each row is as tall as the tallest laid-out entry. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, or a composite font with a part setting the sample whose font or style can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", + "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once; an error with any filter, an empty one included), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards), artboard?: n (0-based; the artboard the first page is; default: the active one), activeArtboard?: n (the journal records that default here, for a replay; `artboard` goes ahead of it)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, every line aligned left (right-to-left samples too), flowed down the columns of the active artboard, or artboard `artboard` (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer (else the topmost layer shown and unlocked), in one undo step; the group is selected. Each row is as tall as the tallest laid-out entry. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, or a composite font with a part setting the sample whose font or style can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", has_doc, font_sheet )] @@ -160,9 +161,22 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { } let label = size.min(LABEL_SIZE); + // The artboard named, else `activeArtboard` (a replay of the journal), else the view's active + // one, which the journal entry then records as `activeArtboard` so a replay uses the same artboard. + let named = artboard_at(&s.doc()?.doc, p, "artboard", C)?; + let active = match named.or(artboard_at(&s.doc()?.doc, p, "activeArtboard", C)?) { + Some(i) => i, + None => { + let st = s.doc()?; + let i = active_artboard(st); + if i < st.doc.artboards.len() { + s.note_journal("activeArtboard", json!(i)); + } + i + } + }; let st = s.doc()?; let d = &st.doc; - let active = active_artboard(st); let template = d.artboards.get(active).cloned(); let page = template.as_ref().map_or(LETTER, |a| a.rect); let right = d.artboards.iter().map(|a| a.rect.x1).fold(page.x1, f64::max); @@ -286,7 +300,8 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { fn laid_out(first: TextRun, more: Option, system_layout: bool) -> TextObject { let mut t = TextObject::point(Point::ZERO, "", first.style.clone()); t.runs = std::iter::once(first).chain(more).collect(); - t.para = new_type_para(); + // Every paragraph is aligned left, right-to-left ones too, so each starts at the column's edge. + t.para = vectorcraft_doc::ParaStyle { justify: vectorcraft_doc::Justify::Left, ..new_type_para() }; t.system_layout = system_layout; t.normalize_paras(); let layout = vectorcraft_text::layout(FontDb::global(), &t); diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index a64d79c7a2..e52a1e8ce0 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -139,6 +139,58 @@ fn columns_share_the_room_inside_the_margin() { assert_eq!(r["artboards"], json!([])); } +/// The journal records the active artboard, so a replay in a new session lays the sheet out on the +/// same one; an action leaves it out, and a named artboard goes ahead of it. +#[test] +fn the_journal_records_the_artboard_the_sheet_was_laid_out_on() { + let mut s = session(); + s.execute("artboard.new", &json!({"x": 700, "y": 0, "width": 300, "height": 300})).unwrap(); + let second = s.doc().unwrap().doc.artboards[1].clone(); + s.doc_mut().unwrap().active_artboard = Some(second.id); + let start = s.journal.len(); + let params = json!({"families": ["Inter"], "margin": 10}); + let r = s.execute(COMMAND, ¶ms).unwrap(); + let e = entries(&group(&s, &r)); + assert!((origin(&e[0].1).0 - second.rect.x0 - 10.0).abs() < 1e-9, "on the active artboard"); + let (id, recorded) = s.journal.last().unwrap().clone(); + assert_eq!((id.as_str(), &recorded["activeArtboard"]), (COMMAND, &json!(1))); + assert_eq!(s.journal_for_action(start)[0].1.get("activeArtboard"), None, "an action uses the artboard active when it plays"); + + // A replay in a session whose view has no active artboard uses the recorded one. + let mut fresh = session(); + fresh.execute("artboard.new", &json!({"x": 700, "y": 0, "width": 300, "height": 300})).unwrap(); + let r = fresh.replay(COMMAND, &recorded).unwrap(); + let e = entries(&group(&fresh, &r)); + assert!((origin(&e[0].1).0 - second.rect.x0 - 10.0).abs() < 1e-9, "the replay lays it out on the recorded artboard"); + // A named artboard goes ahead of the recorded one. + let r = fresh.execute(COMMAND, &json!({"families": ["Inter"], "margin": 10, "artboard": 0, "activeArtboard": 1})).unwrap(); + let e = entries(&group(&fresh, &r)); + let first = fresh.doc().unwrap().doc.artboards[0].rect; + assert!((origin(&e[0].1).0 - first.x0 - 10.0).abs() < 1e-9); + assert!(fresh.execute(COMMAND, &json!({"families": ["Inter"], "artboard": 5})).is_err(), "no such artboard"); +} + +/// A right-to-left sample starts at its column's left edge like any other, so it stays inside its column. +#[test] +fn a_right_to_left_sample_stays_inside_its_column() { + let mut s = session(); + let rtl = "\u{5e9}\u{5dc}\u{5d5}\u{5dd}"; + let board = s.doc().unwrap().doc.artboards[0].rect; + // Alone, and under a left-to-right label: each line starts at the column's left edge. + for labels in [false, true] { + let r = s.execute(COMMAND, &json!({"families": BUNDLED, "columns": 3, "margin": 50, "gap": 12, "labels": labels, "text": rtl})).unwrap(); + for (name, t) in &entries(&group(&s, &r)) { + let x = origin(t).0; + assert!((x - board.x0 - 50.0).abs() < 1e-9, "{name}: {x}"); + let layout = vectorcraft_text::layout(FontDb::global(), t); + for line in &layout.lines { + let left = x + line.x0; + assert!(left > board.x0 + 50.0 - 1e-6, "{name}, labels {labels}: a line starts at {left}, left of the column's edge"); + } + } + } +} + #[test] fn bad_params_are_refused_without_a_change() { let mut s = session(); diff --git a/crates/engine/src/command_sets.rs b/crates/engine/src/command_sets.rs index 228d23a0f0..9b2b0ad033 100644 --- a/crates/engine/src/command_sets.rs +++ b/crates/engine/src/command_sets.rs @@ -37,7 +37,7 @@ pub const DRAWS_SHAPE: [&str; 5] = ["shape.rectangle", "shape.ellipse", "shape.p /// Artboard tool had selected for its commands and for Paste in Place, in Front and in Back; the artboards and art Cut and Copy took with that /// tool chosen; the view's center the app passes to Edit Symbol); an action leaves them out /// ([`Session::journal_for_action`]). -const REPLAY_ONLY: [(&str, &str); 37] = [ +const REPLAY_ONLY: [(&str, &str); 38] = [ ("edit.copy", "artboard"), ("edit.cut", "artboard"), ("file.new", "created"), @@ -67,6 +67,7 @@ const REPLAY_ONLY: [(&str, &str); 37] = [ ("artboard.distribute", "activeArtboard"), ("artboard.distributeSpacing", "selectedArtboards"), ("artboard.distributeSpacing", "activeArtboard"), + ("addon.type.fontSheet", "activeArtboard"), ("edit.copy", "selectedArtboards"), ("edit.copy", "art"), ("edit.cut", "selectedArtboards"), diff --git a/docs/mcp.md b/docs/mcp.md index a14d344869..8ccd65f7c5 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -18252,8 +18252,9 @@ the fonts can be compared on the artboard or printed. after its font. With `labels` on, an entry starts with a line naming its font in the document's normal type font, at the sample's size up to 9 pt, and the sample follows on the next line. With `allStyles` each style of a family gets its own entry, labeled with the family and style; otherwise the family's Regular is used, else its closest style. -- **Layout:** the entries flow down the columns of the active artboard, inside `margin`, with `gap` between entries - and between columns. A sample wider than its column runs on past it. When the artboard is full, the sheet continues +- **Layout:** the entries flow down the columns of the active artboard (or the one `artboard` names), inside `margin`, with `gap` between entries + and between columns. Every line is aligned left, right-to-left samples too, so each starts at its column's left + edge. A sample wider than its column runs on past it. When the artboard is full, the sheet continues on new artboards of the same size to the right of the rightmost artboard, 20 pt apart; with `newArtboards` off the later pages are laid out in the same places without artboards. A document without artboards lays the sheet out on a 612 × 792 pt page at the origin and adds no artboards. @@ -18280,6 +18281,8 @@ the fonts can be compared on the artboard or printed. | `gap` | pt 0…1000, between entries and between columns (12) | | `margin` | pt 0…1000, inside each page (36) | | `newArtboards` | true; false: the pages after the first get no artboards | +| `artboard` | 0-based index of the artboard the first page is laid out on (the active artboard) | +| `activeArtboard` | the journal records the active artboard here when `artboard` is left out, so a replay uses the same artboard; `artboard` goes ahead of it, and an action leaves it out | 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 @@ -18288,7 +18291,7 @@ would delete the artboard the dialog opened on, and so does a running script's ` 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 +(`ui.menuDialog {command}`) whose fields are the command's parameters except `families`, `artboard` and `activeArtboard` (it lays the sheet out on the artboard that was active when it opened), with Preview, which starts off: switched on, it sets the whole sheet again after each change. OK is off while the sample text is empty. Plug-ins can't call the command, since the sheet lists the installed fonts as `text.fontList` does. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ef28729815..0e5b2852b3 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3186,7 +3186,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. When the artboard is full, Add Artboards When Full (on by default) adds new artboards of the same size to its right for the rest; with it off, the rest is laid out in the same places to the right without artboards. 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. +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 (or the one `artboard` names; the journal records the active one, so a replay uses the same artboard). Every line is aligned left, right-to-left samples too, so each starts at its column's left edge. When the artboard is full, Add Artboards When Full (on by default) adds new artboards of the same size to its right for the rest; with it off, the rest is laid out in the same places to the right without artboards. 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) From ebc14a9b36ff906edf11b502cf6790848b318d1b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 1 Dec 2026 13:37:32 -0800 Subject: [PATCH 09/14] Type: Create Font Sheet names entries whose font lacks a glyph of the sample An entry whose font has no glyph for a character the sample draws (by the shaper's rules and the style's numerals) stays on the sheet, and is listed in `fallback` and named in the warning. Composite font names given in another letter case, accented letters included, are found as the font database compares names. --- .../src/cmd/addons/typetools/font_sheet.rs | 49 +++++++++++----- .../cmd/addons/typetools/font_sheet/tests.rs | 57 +++++++++++++++++++ crates/text/src/lib.rs | 2 +- crates/text/src/shape.rs | 6 +- docs/mcp.md | 5 +- docs/target-app-parity.md | 2 +- 6 files changed, 100 insertions(+), 21 deletions(-) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs index 46ae534764..bb009540e4 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -37,7 +37,7 @@ pub fn specs() -> Vec { "Create Font Sheet", ["Object", "Plug-ins", "Type Tools"], None, - "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once; an error with any filter, an empty one included), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards), artboard?: n (0-based; the artboard the first page is; default: the active one), activeArtboard?: n (the journal records that default here, for a replay; `artboard` goes ahead of it)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, every line aligned left (right-to-left samples too), flowed down the columns of the active artboard, or artboard `artboard` (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer (else the topmost layer shown and unlocked), in one undo step; the group is selected. Each row is as tall as the tallest laid-out entry. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, or a composite font with a part setting the sample whose font or style can't, is left out, listed in `skipped` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], artboards: [index…] (the artboards added), warning?}", + "{text?: one line of sample text of at most 1000 characters without line or paragraph breaks or other control characters (\"The quick brown fox jumps over the lazy dog\"), size?: pt 1..1296 (12), filter?: text (only the families whose name contains it, in any case; empty: every family), families?: [family name…] (instead of filter: these families, in this order; each must be available and named once; an error with any filter, an empty one included), allStyles?: false (true: one entry for each style of each family; false: the family's Regular, else its closest style), labels?: true (each entry starts with a line naming its font, at the sample's size up to 9 pt, in the document's normal type font), columns?: 1..50 (2), gap?: pt 0..1000 (12, between entries and between columns), margin?: pt 0..1000 (36, inside each page), newArtboards?: true (false: the pages after the first are laid out in the same places without artboards), artboard?: n (0-based; the artboard the first page is; default: the active one), activeArtboard?: n (the journal records that default here, for a replay; `artboard` goes ahead of it)} set the sample text once in every family the font menus list (the bundled, added and installed fonts), as point type labeled with the font's name, every line aligned left (right-to-left samples too), flowed down the columns of the active artboard, or artboard `artboard` (inset by `margin`) and on to new artboards of the same size to the right of the rightmost artboard when it fills, as one group named Font Sheet in the current layer (else the topmost layer shown and unlocked), in one undo step; the group is selected. Each row is as tall as the tallest laid-out entry. A sample wider than its column runs on past it. A family whose font can't be loaded, or with allStyles a style that can't, or a composite font with a part setting the sample whose font or style can't, is left out, listed in `skipped` and named in `warning`. An entry whose font lacks a glyph needed by the sample stays on the sheet, and is listed in `fallback` and named in `warning`. An error, with nothing changed, when no font matches, when there are more than 5000 entries, when no font loads, or when the margin, gap and columns leave no room for an entry → {id, count, skipped: [family, or family and style…], fallback: [entry name…], artboards: [index…] (the artboards added), warning?}", has_doc, font_sheet )] @@ -99,19 +99,18 @@ fn families(p: &Value, db: &FontDb) -> Result> { if listed.is_empty() { return Err(bad(COMMAND, "`families` must name at least one family")); } - let composites = db.composite_font_names(); let mut out: Vec = Vec::with_capacity(listed.len()); for f in listed { let f = f.as_str().map(str::trim).filter(|f| !f.is_empty()).ok_or_else(|| bad(COMMAND, "`families` must be a list of font family names"))?; if !db.has_family(f) { return Err(bad(COMMAND, format!("font family `{f}` is not available"))); } - // The name as the font menus spell it. - let name = match composites.iter().find(|c| c.eq_ignore_ascii_case(f)) { - Some(c) => c.clone(), + // The name as the font menus spell it, looked up as the database compares names. + let name = match db.composite_font(f) { + Some(c) => c.name.clone(), None => db.canonical(f, "").0, }; - if out.iter().any(|o| o.eq_ignore_ascii_case(&name)) { + if out.iter().any(|o| o.to_lowercase() == name.to_lowercase()) { return Err(bad(COMMAND, format!("`families` names `{name}` twice"))); } out.push(name); @@ -200,7 +199,8 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { // Each entry laid out at the origin, and how far its laid-out ink reaches above and below its first baseline. let mut laid: Vec<(String, TextObject, (f64, f64))> = Vec::with_capacity(fonts.len()); let mut skipped: Vec = vec![]; - let composites = db.composite_font_names(); + // The entries whose font lacks a glyph needed by the sample. + let mut fallback: Vec = vec![]; for (family, style) in fonts { let mut sample = new_type_style(s, &json!({ "size": size, "font": family, "style": style }), C)?; sample.leading = Some(size * 1.2); @@ -211,18 +211,25 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { // A font that doesn't load is drawn in the fallback font, and a style that doesn't in the // family's closest style: either is left out. A composite font is left out when a part // that sets the sample names a font or style that doesn't load. - let composite = composites.iter().any(|c| c.eq_ignore_ascii_case(&family)); - let loads = if composite { - db.composite_coverage(&family, &[text.as_str()]).is_some_and(|c| c.status == FontMatch::Exact) + let composite = db.composite_font(&family).is_some(); + let (loads, covers) = if composite { + (db.composite_coverage(&family, &[text.as_str()]).is_some_and(|c| c.status == FontMatch::Exact), true) } else { let wanted = db.canonical(&family, "").0; - db.face(&sample.font_family, &sample.font_style) - .is_some_and(|face| face.family.eq_ignore_ascii_case(&wanted) && style.as_ref().is_none_or(|st| face.style.eq_ignore_ascii_case(st))) + match db.face(&sample.font_family, &sample.font_style) { + Some(face) if face.family.eq_ignore_ascii_case(&wanted) && style.as_ref().is_none_or(|st| face.style.eq_ignore_ascii_case(st)) => { + (true, vectorcraft_text::drawn_chars(&text, sample.digits).all(|c| face.covers(c))) + } + _ => (false, true), + } }; if !loads { skipped.push(name); continue; } + if !covers { + fallback.push(name.clone()); + } let (first, more) = if labels { (TextRun::new(format!("{name}\n"), label_style.clone()), Some(TextRun::new(text.clone(), sample))) } else { @@ -289,13 +296,25 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { sel.set([gid]); Ok((gid, added)) })?; - let mut out = json!({ "id": gid.0, "count": count, "skipped": skipped, "artboards": added }); - if let Some(warning) = skipped_warning(&skipped) { - out["warning"] = json!(warning); + let mut out = json!({ "id": gid.0, "count": count, "skipped": skipped, "fallback": fallback, "artboards": added }); + let warnings: Vec = skipped_warning(&skipped).into_iter().chain(fallback_warning(&fallback)).collect(); + if !warnings.is_empty() { + out["warning"] = json!(warnings.join("; ")); } Ok(out) } +/// The warning a sheet with entries whose font lacks a glyph of the sample gives, naming the first few. +fn fallback_warning(fallback: &[String]) -> Option { + const NAMED: usize = 5; + let (first, more) = (fallback.iter().take(NAMED).cloned().collect::>(), fallback.len().saturating_sub(NAMED)); + match (first.is_empty(), more) { + (true, _) => None, + (false, 0) => Some(format!("{} font(s) lack glyphs for the sample: {}", fallback.len(), first.join(", "))), + (false, more) => Some(format!("{} font(s) lack glyphs for the sample: {} and {more} more", fallback.len(), first.join(", "))), + } +} + /// Point type set in `first` and then `more`, with its first baseline at the origin, laid out. fn laid_out(first: TextRun, more: Option, system_layout: bool) -> TextObject { let mut t = TextObject::point(Point::ZERO, "", first.style.clone()); diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index e52a1e8ce0..ffa62df82b 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -179,6 +179,8 @@ fn a_right_to_left_sample_stays_inside_its_column() { // Alone, and under a left-to-right label: each line starts at the column's left edge. for labels in [false, true] { let r = s.execute(COMMAND, &json!({"families": BUNDLED, "columns": 3, "margin": 50, "gap": 12, "labels": labels, "text": rtl})).unwrap(); + assert_eq!(r["fallback"], json!(BUNDLED), "no bundled font has Hebrew glyphs, so each entry is named"); + assert!(r["warning"].as_str().is_some_and(|w| w.contains("lack glyphs") && w.contains("Inter")), "{r}"); for (name, t) in &entries(&group(&s, &r)) { let x = origin(t).0; assert!((x - board.x0 - 50.0).abs() < 1e-9, "{name}: {x}"); @@ -191,6 +193,48 @@ fn a_right_to_left_sample_stays_inside_its_column() { } } +#[test] +fn a_variation_selector_does_not_require_a_separate_glyph() { + let mut s = session(); + let face = FontDb::global().face("Inter", "Regular").unwrap(); + assert!(face.covers('A')); + assert!(!face.covers('\u{fe0f}')); + let text = "A\u{fe0f}"; + let r = s.execute(COMMAND, &json!({"families": ["Inter"], "labels": false, "text": text})).unwrap(); + assert_eq!(r["count"], 1); + assert_eq!(r["skipped"], json!([])); + assert_eq!(r["fallback"], json!([])); + assert!(r.get("warning").is_none(), "{r}"); + let e = entries(&group(&s, &r)); + assert_eq!(e.len(), 1); + assert_eq!(e[0].1.plain_text(), text); +} + +#[test] +fn coverage_uses_the_samples_numeral_system() { + let mut s = session(); + let face = FontDb::global().face("Inter", "Regular").unwrap(); + assert!(face.covers('1')); + assert!(!face.covers('\u{661}')); + for (digits, text, missing) in [("hindi", "1", true), ("arabic", "\u{661}", false)] { + s.execute("charStyle.edit", &json!({"name": "[Normal Character Style]", "to": "[Normal Character Style]", "attrs": {"digits": digits}})) + .unwrap(); + let r = s.execute(COMMAND, &json!({"families": ["Inter"], "labels": false, "text": text})).unwrap(); + assert_eq!(r["count"], 1); + assert_eq!(r["skipped"], json!([])); + assert_eq!(r["fallback"], if missing { json!(["Inter"]) } else { json!([]) }, "{digits}: {r}"); + if missing { + assert!(r["warning"].as_str().is_some_and(|w| w.contains("lack glyphs") && w.contains("Inter")), "{r}"); + } else { + assert!(r.get("warning").is_none(), "{r}"); + } + let e = entries(&group(&s, &r)); + assert_eq!(e.len(), 1); + assert_eq!(e[0].1.plain_text(), text); + assert_eq!(e[0].1.runs[0].style.digits.id(), digits); + } +} + #[test] fn bad_params_are_refused_without_a_change() { let mut s = session(); @@ -315,6 +359,19 @@ fn rows_fit_the_laid_out_ink_of_a_composite_font() { } } +/// A composite font named in other letter case, accented letters included, is found by its own name. +#[test] +fn a_composite_font_named_in_other_case_is_set() { + let mut s = session(); + let font = json!({"name": "\u{c9}preuve Sheet", "parts": {"kanji": {"font": "Source Sans 3"}, "roman": {"font": "Inter"}}}); + s.execute("type.compositeFonts.set", &json!({"fonts": [font]})).unwrap(); + let r = s.execute(COMMAND, &json!({"families": ["\u{e9}preuve sheet"], "text": "Hamburg"})).unwrap(); + assert_eq!((r["skipped"].clone(), r["count"].clone()), (json!([]), json!(1)), "{r}"); + assert_eq!(entries(&group(&s, &r))[0].0, "\u{c9}preuve Sheet"); + let twice = s.execute(COMMAND, &json!({"families": ["\u{c9}preuve Sheet", "\u{e9}PREUVE SHEET"]})).unwrap_err().to_string(); + assert!(twice.contains("twice"), "{twice}"); +} + /// A composite font whose part setting the sample names a font that doesn't load is left out and /// named, as a family that doesn't load is. #[test] diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index 27555a8e4a..e41c8ccce7 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -59,7 +59,7 @@ pub use svg_glyph::{SvgGlyphReader, set_svg_glyph_reader}; pub use kept::{KeptLayoutsFrame, LayoutStamp, keep_layout, take_kept_layout}; use kurbo::{Affine, BezPath, Point, Rect, Shape, Vec2}; pub use layout::{decorations, drawn, fit_first_line, fit_source_lines, layout, layout_with, scaled}; -pub use shape::{aki_space, inseparable, kinsoku_set_from, line_start_space, repeat_base, spacing_scale}; +pub use shape::{aki_space, drawn_chars, inseparable, kinsoku_set_from, line_start_space, repeat_base, spacing_scale}; pub use vectorcraft_doc::TextObject; pub use vectorcraft_doc::{AreaFit, FirstBaseline, TextFlow, VerticalAlign}; diff --git a/crates/text/src/shape.rs b/crates/text/src/shape.rs index 00658a1b34..004f5a5cb0 100644 --- a/crates/text/src/shape.rs +++ b/crates/text/src/shape.rs @@ -1382,11 +1382,11 @@ fn shapes_alike(a: &CharStyle, b: &CharStyle) -> bool { && ligatures_suppressed_by(*tracking) == ligatures_suppressed_by(b.tracking) } -/// The characters of a grapheme cluster that need a glyph of their own, in the numeral system +/// The characters of the text that need a glyph of their own, in the numeral system /// `digits`: not what the layout handles itself (tab, line and paragraph breaks), joiners or /// variation selectors. -fn drawn_chars(cluster: &str, digits: Digits) -> impl Iterator + '_ { - craft::font_catalog::drawable_characters(cluster, move |c| digits.map(c)) +pub fn drawn_chars(text: &str, digits: Digits) -> impl Iterator + '_ { + craft::font_catalog::drawable_characters(text, move |c| digits.map(c)) } /// Does the face with charmap `map` have a glyph for `c` (any face does when it has no charmap)? diff --git a/docs/mcp.md b/docs/mcp.md index 8ccd65f7c5..e0e74f962e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -18262,6 +18262,8 @@ the fonts can be compared on the artboard or printed. with `allStyles` a style that can't (it would be drawn in the family's closest style), is left out, listed in `skipped` and named in `warning`, which the status bar shows. A composite font is left out the same way when a part that sets the sample text names a font or style that can't be loaded. +- **Missing glyphs:** an entry whose font lacks a glyph needed by the sample text stays on the sheet, and is listed + in `fallback` and named in `warning`. - Each row is as tall as the tallest laid-out entry needs, so a composite font whose part enlarges or raises the sample does not overlap the entry above it or reach into the margin. - The sheet is one group named Font Sheet, made in one undo step and selected. It goes where new art goes: the current @@ -18290,7 +18292,8 @@ Artboard, Delete Empty Artboards and Artwork Cleanup's Empty Artboards return an 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 +→ `{id, count, skipped: [family, or family and style…], fallback: [entry name…], artboards: [index…] (the artboards added), warning?}`. +`fallback` lists entries kept on the sheet whose font lacks a glyph needed by the sample. Create Font Sheet… opens a dialog (`ui.menuDialog {command}`) whose fields are the command's parameters except `families`, `artboard` and `activeArtboard` (it lays the sheet out on the artboard that was active when it opened), with Preview, which starts off: switched on, it sets the whole sheet again after each change. OK is off while the sample text is empty. Plug-ins can't call the command, since the sheet lists the installed fonts as `text.fontList` does. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 0e5b2852b3..342f4a1c1f 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -3186,7 +3186,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 (or the one `artboard` names; the journal records the active one, so a replay uses the same artboard). Every line is aligned left, right-to-left samples too, so each starts at its column's left edge. When the artboard is full, Add Artboards When Full (on by default) adds new artboards of the same size to its right for the rest; with it off, the rest is laid out in the same places to the right without artboards. 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. +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 (or the one `artboard` names; the journal records the active one, so a replay uses the same artboard). Every line is aligned left, right-to-left samples too, so each starts at its column's left edge. When the artboard is full, Add Artboards When Full (on by default) adds new artboards of the same size to its right for the rest; with it off, the rest is laid out in the same places to the right without artboards. 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, listed in `skipped` and named in `warning`. Entries whose font lacks a glyph needed by the sample stay on the sheet, are listed in `fallback` and named in `warning`. 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) From 417e857a892cfa18126b99a0c0f135d511c6891d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 1 Dec 2026 20:44:24 -0800 Subject: [PATCH 10/14] Artboards: touching artboards cast no shadow on each other Artboards made with Spacing 0 sit edge to edge, but the canvas painted each artboard's drop shadow and then its paper in turn, so the lower artboard's shadow darkened the upper one along the join and showed a dark band between them. craft-libs#4740 paints every page shadow before any page. This moves the craft-libs pin to that pull request's head, a59264281, which is craft-libs main at 77ade517e plus the fix, and the egui pin to 861d60a6, the rev that craft-libs commit pins. The PDF dependency check reads the new rev. The new test makes two 200 x 200 artboards in a column with Spacing 0, checks that they touch, and checks that both shadows paint before both papers. It fails on the previous pin. --- Cargo.lock | 194 ++++++++++++++--------------- Cargo.toml | 98 +++++++-------- apps/vectorcraft-web/Cargo.toml | 2 +- crates/ui-egui/src/canvas/tests.rs | 27 ++++ xtask/src/pdf_deps.rs | 2 +- 5 files changed, 175 insertions(+), 148 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a398edf733..dfd56b5ca4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1231,7 +1231,7 @@ dependencies = [ [[package]] name = "craft" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-automation", "craft-behavior", @@ -1272,7 +1272,7 @@ dependencies = [ [[package]] name = "craft-affinity" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "crc32fast", "flate2", @@ -1283,7 +1283,7 @@ dependencies = [ [[package]] name = "craft-appkit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "block2 0.6.2", "objc2 0.6.5", @@ -1295,7 +1295,7 @@ dependencies = [ [[package]] name = "craft-atomic" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "rustix 1.1.6", ] @@ -1303,7 +1303,7 @@ dependencies = [ [[package]] name = "craft-automation" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1328,7 +1328,7 @@ dependencies = [ [[package]] name = "craft-behavior" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "accesskit", "bitflags 2.13.2", @@ -1346,7 +1346,7 @@ dependencies = [ [[package]] name = "craft-browse" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-docpath", @@ -1364,7 +1364,7 @@ dependencies = [ [[package]] name = "craft-cdr" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "crc32fast", "flate2", @@ -1373,7 +1373,7 @@ dependencies = [ [[package]] name = "craft-cloud-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "egui", ] @@ -1381,7 +1381,7 @@ dependencies = [ [[package]] name = "craft-cms" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "md-5", "rayon", @@ -1390,12 +1390,12 @@ dependencies = [ [[package]] name = "craft-codepage" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" [[package]] name = "craft-color-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-cms", @@ -1415,7 +1415,7 @@ dependencies = [ [[package]] name = "craft-control" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-control-protocol", "craft-platform", @@ -1426,7 +1426,7 @@ dependencies = [ [[package]] name = "craft-control-protocol" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "getrandom 0.3.4", "serde_json", @@ -1436,7 +1436,7 @@ dependencies = [ [[package]] name = "craft-dds" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "rayon", ] @@ -1444,7 +1444,7 @@ dependencies = [ [[package]] name = "craft-dialogs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "block2 0.6.2", "craft-appkit", @@ -1470,7 +1470,7 @@ dependencies = [ [[package]] name = "craft-doc" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "blake3", "craft-ecproj-format", @@ -1486,7 +1486,7 @@ dependencies = [ [[package]] name = "craft-docpath" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "serde", ] @@ -1494,7 +1494,7 @@ dependencies = [ [[package]] name = "craft-draw" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1513,7 +1513,7 @@ dependencies = [ [[package]] name = "craft-dxf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-codepage", "encoding_rs", @@ -1525,7 +1525,7 @@ dependencies = [ [[package]] name = "craft-ecproj-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "serde", "serde_json", @@ -1535,12 +1535,12 @@ dependencies = [ [[package]] name = "craft-eps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" [[package]] name = "craft-font-catalog" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "fontique", "harfrust 0.13.3", @@ -1555,7 +1555,7 @@ dependencies = [ [[package]] name = "craft-font-manager" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -1574,7 +1574,7 @@ dependencies = [ [[package]] name = "craft-font-os-windows" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "windows-registry", "windows-sys 0.61.2", @@ -1583,7 +1583,7 @@ dependencies = [ [[package]] name = "craft-font-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "cap-primitives", "craft-atomic", @@ -1606,12 +1606,12 @@ dependencies = [ [[package]] name = "craft-fonts-build" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" [[package]] name = "craft-gif" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "gif", ] @@ -1619,7 +1619,7 @@ dependencies = [ [[package]] name = "craft-gzip" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "flate2", ] @@ -1627,7 +1627,7 @@ dependencies = [ [[package]] name = "craft-host" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "bitflags 2.13.2", "craft-i18n", @@ -1640,7 +1640,7 @@ dependencies = [ [[package]] name = "craft-i18n" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -1670,7 +1670,7 @@ dependencies = [ [[package]] name = "craft-image-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-dds", "craft-jpeg", @@ -1697,7 +1697,7 @@ dependencies = [ [[package]] name = "craft-imaging" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-color-ui", @@ -1715,7 +1715,7 @@ dependencies = [ [[package]] name = "craft-jpeg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "thiserror 2.0.21", ] @@ -1723,7 +1723,7 @@ dependencies = [ [[package]] name = "craft-jxl" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "brotli-decompressor 5.0.3", "jixel", @@ -1734,7 +1734,7 @@ dependencies = [ [[package]] name = "craft-keymap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-host", "craft-i18n", @@ -1749,7 +1749,7 @@ dependencies = [ [[package]] name = "craft-layers" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-i18n", @@ -1763,7 +1763,7 @@ dependencies = [ [[package]] name = "craft-menu" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-host", @@ -1781,7 +1781,7 @@ dependencies = [ [[package]] name = "craft-metadata" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "brotli-decompressor 6.3.2", "chrono", @@ -1793,7 +1793,7 @@ dependencies = [ [[package]] name = "craft-metafile" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "encoding_rs", "image", @@ -1804,7 +1804,7 @@ dependencies = [ [[package]] name = "craft-mime" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "chrono", "craft-codepage", @@ -1814,7 +1814,7 @@ dependencies = [ [[package]] name = "craft-nightly" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "uds_windows", "winsafe", @@ -1823,7 +1823,7 @@ dependencies = [ [[package]] name = "craft-pages" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-keymap", @@ -1839,7 +1839,7 @@ dependencies = [ [[package]] name = "craft-pcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "flate2", "serde", @@ -1850,7 +1850,7 @@ dependencies = [ [[package]] name = "craft-pdf" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "hayro-interpret", "hayro-syntax", @@ -1862,7 +1862,7 @@ dependencies = [ [[package]] name = "craft-platform" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "async-channel", "async-io", @@ -1895,7 +1895,7 @@ dependencies = [ [[package]] name = "craft-plotter" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "kurbo 0.13.1", "thiserror 2.0.21", @@ -1904,7 +1904,7 @@ dependencies = [ [[package]] name = "craft-print" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-host", @@ -1928,7 +1928,7 @@ dependencies = [ [[package]] name = "craft-proof" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "log", "miniz_oxide 0.9.1", @@ -1939,7 +1939,7 @@ dependencies = [ [[package]] name = "craft-ps" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-eps", "flate2", @@ -1953,7 +1953,7 @@ dependencies = [ [[package]] name = "craft-psd" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "encoding_rs", "flate2", @@ -1964,7 +1964,7 @@ dependencies = [ [[package]] name = "craft-quit" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "dispatch2", "egui", @@ -1977,7 +1977,7 @@ dependencies = [ [[package]] name = "craft-review" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "base64 0.23.1", "craft-behavior", @@ -1996,7 +1996,7 @@ dependencies = [ [[package]] name = "craft-settings" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-atomic", "craft-host", @@ -2013,7 +2013,7 @@ dependencies = [ [[package]] name = "craft-stream-codecs" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "fax", "hayro-ccitt", @@ -2024,7 +2024,7 @@ dependencies = [ [[package]] name = "craft-svg" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-image-codecs", "craft-xml", @@ -2045,7 +2045,7 @@ dependencies = [ [[package]] name = "craft-table" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-keymap", @@ -2057,7 +2057,7 @@ dependencies = [ [[package]] name = "craft-text" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-font-manager", @@ -2082,7 +2082,7 @@ dependencies = [ [[package]] name = "craft-theme" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "bitflags 2.13.2", "craft-tracked", @@ -2097,7 +2097,7 @@ dependencies = [ [[package]] name = "craft-theme-store" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-atomic", "craft-behavior", @@ -2112,7 +2112,7 @@ dependencies = [ [[package]] name = "craft-tiff" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "serde", "thiserror 2.0.21", @@ -2122,7 +2122,7 @@ dependencies = [ [[package]] name = "craft-time" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "serde", "thiserror 2.0.21", @@ -2131,7 +2131,7 @@ dependencies = [ [[package]] name = "craft-timeline" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-keymap", @@ -2146,12 +2146,12 @@ dependencies = [ [[package]] name = "craft-tracked" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" [[package]] name = "craft-ui" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-cloud-ui", "craft-ui-canvas", @@ -2165,7 +2165,7 @@ dependencies = [ [[package]] name = "craft-ui-canvas" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-font-catalog", @@ -2182,7 +2182,7 @@ dependencies = [ [[package]] name = "craft-ui-contract" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "accesskit", "craft-behavior", @@ -2220,7 +2220,7 @@ dependencies = [ [[package]] name = "craft-ui-macros" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -2231,7 +2231,7 @@ dependencies = [ [[package]] name = "craft-ui-panels" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-host", @@ -2249,7 +2249,7 @@ dependencies = [ [[package]] name = "craft-ui-patterns" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-host", @@ -2270,7 +2270,7 @@ dependencies = [ [[package]] name = "craft-ui-shell" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-host", @@ -2291,7 +2291,7 @@ dependencies = [ [[package]] name = "craft-ui-widgets" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-behavior", "craft-host", @@ -2310,7 +2310,7 @@ dependencies = [ [[package]] name = "craft-update" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "base64 0.22.1", "chrono", @@ -2342,7 +2342,7 @@ dependencies = [ [[package]] name = "craft-vectorcraft-format" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "flate2", "serde", @@ -2353,7 +2353,7 @@ dependencies = [ [[package]] name = "craft-wayland" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "raw-window-handle", "wayland-backend", @@ -2363,7 +2363,7 @@ dependencies = [ [[package]] name = "craft-web-api" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "js-sys", "serde_json", @@ -2374,7 +2374,7 @@ dependencies = [ [[package]] name = "craft-win32" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "winsafe", ] @@ -2382,7 +2382,7 @@ dependencies = [ [[package]] name = "craft-window" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "craft-appkit", "craft-atomic", @@ -2414,7 +2414,7 @@ dependencies = [ [[package]] name = "craft-xml" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "quick-xml 0.41.0", "serde", @@ -2759,7 +2759,7 @@ checksum = "92773504d58c093f6de2459af4af33faa518c13451eb8f2b5698ed3d36e7c813" [[package]] name = "ecolor" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "bytemuck", "emath", @@ -2792,7 +2792,7 @@ dependencies = [ [[package]] name = "eframe" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "ahash", "bytemuck", @@ -2827,7 +2827,7 @@ dependencies = [ [[package]] name = "egui" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "accesskit", "ahash", @@ -2846,7 +2846,7 @@ dependencies = [ [[package]] name = "egui-wgpu" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "ahash", "bytemuck", @@ -2865,7 +2865,7 @@ dependencies = [ [[package]] name = "egui-winit" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "accesskit_winit", "arboard", @@ -2890,7 +2890,7 @@ dependencies = [ [[package]] name = "egui_extras" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "ahash", "egui", @@ -2904,7 +2904,7 @@ dependencies = [ [[package]] name = "egui_glow" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "bytemuck", "egui", @@ -2917,7 +2917,7 @@ dependencies = [ [[package]] name = "egui_kittest" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "dify", "eframe", @@ -2943,7 +2943,7 @@ checksum = "0e9c71c2167ca323c882b99918929403426e2373ea17242ff5653e0d5e1058be" [[package]] name = "emath" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "bytemuck", ] @@ -3024,7 +3024,7 @@ dependencies = [ [[package]] name = "epaint" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "ahash", "bytemuck", @@ -3050,7 +3050,7 @@ dependencies = [ [[package]] name = "epaint_default_fonts" version = "0.37.0" -source = "git+https://github.com/storytold/egui.git?rev=07c20531f89717e461c0f387dd1f9649553f9321#07c20531f89717e461c0f387dd1f9649553f9321" +source = "git+https://github.com/storytold/egui.git?rev=861d60a65c50850e995bbb3dcee7c1f3b06815f6#861d60a65c50850e995bbb3dcee7c1f3b06815f6" dependencies = [ "brotli 9.1.3", "brotli-decompressor 6.3.2", @@ -3773,7 +3773,7 @@ checksum = "9f4d0e94ddd48749f06bbe4e5389fb9799a0c45bcaf00495042076ef05e3241a" [[package]] name = "hayro-cmap" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "brotli 8.0.4", "hayro-postscript", @@ -3782,7 +3782,7 @@ dependencies = [ [[package]] name = "hayro-interpret" version = "0.7.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "bitflags 2.13.2", "hayro-cmap", @@ -3800,7 +3800,7 @@ dependencies = [ [[package]] name = "hayro-jbig2" version = "0.3.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "fearless_simd", "hayro-ccitt", @@ -3818,12 +3818,12 @@ dependencies = [ [[package]] name = "hayro-postscript" version = "0.1.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" [[package]] name = "hayro-syntax" version = "0.7.2" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "flate2", "hayro-ccitt", @@ -4806,7 +4806,7 @@ dependencies = [ [[package]] name = "krilla" version = "0.8.2" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "base64 0.22.1", "bumpalo", @@ -4963,7 +4963,7 @@ checksum = "d4a5ff6bcca6c4867b1c4fd4ef63e4db7436ef363e0ad7531d1558856bae64f4" [[package]] name = "linesweeper" version = "0.5.0" -source = "git+https://github.com/storytold/craft-libs?rev=965c7beeb6076480e016e448bddddcce0a738ff6#965c7beeb6076480e016e448bddddcce0a738ff6" +source = "git+https://github.com/storytold/craft-libs?rev=a59264281e498d78ede8f503572b3d5502c44d51#a59264281e498d78ede8f503572b3d5502c44d51" dependencies = [ "arrayvec", "kurbo 0.13.1", diff --git a/Cargo.toml b/Cargo.toml index fcc2a1ad8f..8562d3201b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,51 +10,51 @@ license = "MIT OR Apache-2.0" rust-version = "1.95" [workspace.dependencies] -craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6", default-features = false, features = ["interpret", "write"] } -craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-cms = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-pdf = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51", default-features = false, features = ["interpret", "write"] } +craft-docpath = { version = "0.1.0", git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-proof = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # Language packs: the Craft apps' shared font store installs them (#4936). -craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-font-store = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-font-catalog = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # The `.vectorcraft` envelope: its members, version, embedded images and the data after the JSON. -craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-vectorcraft-format = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-gzip = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # `.pcraft` documents: their manifest, full-size composite, preview, layer pixels and ICC profile. -craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6", features = ["pcraft-pixels"] } +craft-doc = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51", features = ["pcraft-pixels"] } # Native Affinity documents (craft-libs#914). -craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-affinity = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # Bounded CDR (v1-v27) and CMX (32-bit) reader (craft-libs#778). -craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-cdr = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # SVG parsing, limits, SVGZ and writer (craft-libs#778). -craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6", features = ["tree"] } -craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-svg = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51", features = ["tree"] } +craft-mime = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # EPS container, previews, ASCII85 and DSC comments (craft-libs#778). -craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-eps = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # DXF tags, reader and writer (craft-libs#778, #926, #927). -craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-plotter = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-dxf = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # WMF, EMF and EMF+ reader (craft-libs#778). -craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6", default-features = false, features = ["read", "write"] } -craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-metafile = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-xml = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-image-codecs = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-gif = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-tiff = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-ps = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51", default-features = false, features = ["read", "write"] } +craft-psd = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-stream-codecs = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-jxl = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-codepage = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # The framework facade (`craft::ui`, `craft::settings`, `craft::platform`, ...). No default features: each crate names # the members it imports. -craft = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # Below the egui layer, so not through the facade: the colour harmony rules and their settings (craft-color-ui # without its `ui` feature), the colour type they work in, and the craft-fonts tables the text crate's build writes. -craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-color-ui = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-theme = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +craft-fonts-build = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # Nightly profile isolation, launch protocol, and security fence. -craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } +craft-nightly = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } # internal vectorcraft-geom = { path = "crates/geom" } vectorcraft-color = { path = "crates/color" } @@ -194,22 +194,22 @@ lto = "thin" codegen-units = 1 [patch.crates-io] -hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -krilla = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6" } -ecolor = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -emath = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -epaint = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -egui = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -egui-winit = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -egui_glow = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -egui_extras = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } -eframe = { git = "https://github.com/storytold/egui.git", rev = "07c20531f89717e461c0f387dd1f9649553f9321" } +hayro-syntax = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +hayro-interpret = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +hayro-jbig2 = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +hayro-cmap = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +hayro-postscript = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +krilla = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +linesweeper = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51" } +ecolor = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +emath = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +epaint = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +epaint_default_fonts = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +egui = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +egui-winit = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +egui-wgpu = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +egui_glow = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +egui_extras = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +egui_kittest = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } +eframe = { git = "https://github.com/storytold/egui.git", rev = "861d60a65c50850e995bbb3dcee7c1f3b06815f6" } winit = { git = "https://github.com/storytold/winit.git", rev = "0dfcec0eb62fda5904137a63a6dd0c3d83295f45" } diff --git a/apps/vectorcraft-web/Cargo.toml b/apps/vectorcraft-web/Cargo.toml index 824600f90a..d94dcf91cc 100644 --- a/apps/vectorcraft-web/Cargo.toml +++ b/apps/vectorcraft-web/Cargo.toml @@ -28,7 +28,7 @@ egui_extras = { workspace = true } # `wgpu` pulls egui-wgpu's defaults: WebGPU plus the WebGL2 fallback. eframe = { workspace = true, features = ["default_fonts", "wgpu", "accesskit"] } # The page command API (storytold/craft-libs#413): the request plumbing behind window.vectorcraft. -craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "965c7beeb6076480e016e448bddddcce0a738ff6", version = "0.1.0" } +craft-web-api = { git = "https://github.com/storytold/craft-libs", rev = "a59264281e498d78ede8f503572b3d5502c44d51", version = "0.1.0" } wasm-bindgen = "0.2" serde_json = { workspace = true } diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 41d0e93837..5c8f2ca4ab 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -6903,3 +6903,30 @@ fn a_wheel_pan_under_a_resting_pointer_keeps_the_tool_cursor() { } assert!(asks() > before, "once the view is still, the tool gives the cursor again"); } + +/// Artboards made with no spacing touch, and the canvas paints every artboard's drop shadow before any artboard's +/// paper, so the lower artboard's shadow does not darken the upper one along the shared edge. +#[test] +fn touching_artboards_cast_no_shadow_on_each_other() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 200, "height": 200, "artboards": 2, "artboardLayout": {"layout": "column", "spacing": 0}})).unwrap(); + let boards: Vec<_> = app.session.active().unwrap().doc.artboards.iter().map(|ab| ab.rect).collect(); + assert_eq!(boards[0].y1, boards[1].y0, "the artboards touch"); + app.ui.task_bar = false; + app.ui.view.rulers = false; + app.canvas.worker_started = true; + let ctx = crate::testing::ui_context(); + let _ = shapes(&mut app, &ctx); + let view = app.view_mut().unwrap(); + (view.zoom, view.center) = (1.0, Point::new(100.0, 200.0)); + let all = shapes(&mut app, &ctx); + let papers: Vec = all + .iter() + .enumerate() + .filter(|(_, s)| matches!(s, Shape::Mesh(m) if m.texture_id == egui::TextureId::default() && m.vertices.first().is_some_and(|v| v.color == Color32::WHITE))) + .map(|(at, _)| at) + .collect(); + let shadows: Vec = all.iter().enumerate().filter(|(_, s)| matches!(s, Shape::Rect(r) if r.blur_width > 0.0)).map(|(at, _)| at).collect(); + assert_eq!((papers.len(), shadows.len()), (2, 2), "each artboard paints its paper and casts a shadow"); + assert!(shadows.iter().all(|s| papers.iter().all(|p| s < p)), "every shadow lies under both papers: shadows {shadows:?}, papers {papers:?}"); +} diff --git a/xtask/src/pdf_deps.rs b/xtask/src/pdf_deps.rs index 337ba6325e..ab3fd17273 100644 --- a/xtask/src/pdf_deps.rs +++ b/xtask/src/pdf_deps.rs @@ -5,7 +5,7 @@ use std::process::Command; use serde_json::Value; -const REV: &str = "965c7beeb6076480e016e448bddddcce0a738ff6"; +const REV: &str = "a59264281e498d78ede8f503572b3d5502c44d51"; const PACKAGES: &[(&str, &str, &str)] = &[ ("craft-pdf", "0.1.0", REV), ("krilla", "0.8.2", REV), From 0db6dddc60dc55fc2fb466cd3b1460fee2a02b65 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 06:34:37 -0800 Subject: [PATCH 11/14] Type: Font Sheet lists composite fonts lacking sample glyphs as fallbacks A composite font's entry was never named in `fallback`, even when the part that sets the sample lacked a glyph it needs. The entry now checks each grapheme's part face for the characters layout draws, in the sample's numeral system, through the new `FontDb::composite_drawn_coverage`. --- .../src/cmd/addons/typetools/font_sheet.rs | 4 +++- .../cmd/addons/typetools/font_sheet/tests.rs | 24 +++++++++++++++++++ crates/text/src/fontdb/composite.rs | 19 +++++++++++++-- 3 files changed, 44 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs index bb009540e4..edc72587cc 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -213,7 +213,9 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { // that sets the sample names a font or style that doesn't load. let composite = db.composite_font(&family).is_some(); let (loads, covers) = if composite { - (db.composite_coverage(&family, &[text.as_str()]).is_some_and(|c| c.status == FontMatch::Exact), true) + // Glyph coverage is checked on the characters layout draws, in the sample's numeral system. + let covers = db.composite_drawn_coverage(&family, &[text.as_str()], sample.digits).is_none_or(|c| c.lacking.is_empty()); + (db.composite_coverage(&family, &[text.as_str()]).is_some_and(|c| c.status == FontMatch::Exact), covers) } else { let wanted = db.canonical(&family, "").0; match db.face(&sample.font_family, &sample.font_style) { diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index ffa62df82b..f1b207025b 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -409,6 +409,30 @@ fn a_composite_font_with_an_unavailable_part_style_is_left_out() { assert_eq!(steps(&s), before.1); } +/// A composite font whose parts load but lack a glyph the sample needs stays on the sheet and is +/// named in `fallback`, as a plain font is. +#[test] +fn a_composite_font_lacking_a_sample_glyph_is_named_as_a_fallback() { + let mut s = session(); + let font = json!({"name": "CF Sheet Lacking", "parts": {"kanji": {"font": "Source Sans 3"}, "roman": {"font": "Inter"}}}); + s.execute("type.compositeFonts.set", &json!({"fonts": [font]})).unwrap(); + let rtl = "\u{5e9}\u{5dc}\u{5d5}\u{5dd}"; + let coverage = FontDb::global().composite_coverage("CF Sheet Lacking", &[rtl]).unwrap(); + assert_eq!(coverage.status, vectorcraft_text::FontMatch::Exact); + assert!(!coverage.lacking.is_empty()); + let r = s.execute(COMMAND, &json!({"families": ["CF Sheet Lacking"], "text": rtl})).unwrap(); + assert_eq!((&r["count"], &r["skipped"]), (&json!(1), &json!([])), "{r}"); + assert_eq!(r["fallback"], json!(["CF Sheet Lacking"]), "{r}"); + assert!(r["warning"].as_str().is_some_and(|w| w.contains("lack glyphs") && w.contains("CF Sheet Lacking")), "{r}"); + // A variation selector needs no glyph of its own, and digits are checked in the sample's numeral system. + let r = s.execute(COMMAND, &json!({"families": ["CF Sheet Lacking"], "text": "A\u{fe0f}"})).unwrap(); + assert_eq!(r["fallback"], json!([]), "{r}"); + s.execute("charStyle.edit", &json!({"name": "[Normal Character Style]", "to": "[Normal Character Style]", "attrs": {"digits": "hindi"}})) + .unwrap(); + let r = s.execute(COMMAND, &json!({"families": ["CF Sheet Lacking"], "text": "1"})).unwrap(); + assert_eq!(r["fallback"], json!(["CF Sheet Lacking"]), "{r}"); +} + #[test] fn labels_without_overlap_need_no_additional_layouts() { use vectorcraft_text::test_fonts::{ink_work_on_this_thread, layouts_on_this_thread}; diff --git a/crates/text/src/fontdb/composite.rs b/crates/text/src/fontdb/composite.rs index 1ac538b7a0..371d8e2574 100644 --- a/crates/text/src/fontdb/composite.rs +++ b/crates/text/src/fontdb/composite.rs @@ -12,7 +12,7 @@ use std::sync::atomic::{AtomicU64, Ordering}; use unicode_segmentation::UnicodeSegmentation; use vectorcraft_doc::text::CompositeClasses; -use vectorcraft_doc::{CharClass, CompositeClass, CompositeFont, CompositePart, TextObject, TextRun}; +use vectorcraft_doc::{CharClass, CompositeClass, CompositeFont, CompositePart, Digits, TextObject, TextRun}; use super::face::FALLBACK_FAMILY; use super::{Arc, FontDb, FontFace, FontMatch}; @@ -242,6 +242,17 @@ impl FontDb { /// match, and the characters (neither whitespace nor control characters, sorted, each once) /// that their part's face lacks. `None` when `name` is no composite font. pub fn composite_coverage(&self, name: &str, texts: &[&str]) -> Option { + self.coverage_of(name, texts, None) + } + + /// [`FontDb::composite_coverage`] of the characters layout draws in numeral system `digits`: + /// each grapheme cluster's part is chosen by its own first character, and the part's face is + /// checked for the cluster's drawn characters ([`crate::drawn_chars`]). + pub fn composite_drawn_coverage(&self, name: &str, texts: &[&str], digits: Digits) -> Option { + self.coverage_of(name, texts, Some(digits)) + } + + fn coverage_of(&self, name: &str, texts: &[&str], digits: Option) -> Option { let f = self.composite_font(name)?; let rank = |m: FontMatch| match m { FontMatch::Exact => 0, @@ -272,7 +283,11 @@ impl FontDb { if worst.as_ref().is_none_or(|(w, _)| rank(m) > rank(*w)) { worst = Some((m, found.as_ref().map(|(face, _)| face.clone()))); } - lacking.extend(g.chars().filter(|c| !c.is_whitespace() && !c.is_control() && !found.as_ref().is_some_and(|(face, _)| face.covers(*c)))); + match digits { + Some(d) => lacking.extend(crate::drawn_chars(g, d).filter(|c| !found.as_ref().is_some_and(|(face, _)| face.covers(*c)))), + None => lacking + .extend(g.chars().filter(|c| !c.is_whitespace() && !c.is_control() && !found.as_ref().is_some_and(|(face, _)| face.covers(*c)))), + } } lacking.sort_unstable(); lacking.dedup(); From a94dbea4dad596064e59a806ed0b5f7064d637e2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 07:24:38 -0800 Subject: [PATCH 12/14] Tests: the PDF 1.3 transparency check reads dictionaries only pdf_1_3_flattens_all_transparency_and_looks_the_same failed on CI at 820f3d34 and passed on rerun. The transparency check searched the whole file for `/BM`, and the file ID, written in the trailer and the XMP stream, is base64 that changes with the export time. About one export in three thousand has an ID that contains `/BM`, so the check reported a blend mode in a flat file. The check now leaves out literal strings and stream data, skipped by the stream's direct `/Length`, and fails when that length does not end at `endstream`. Every dictionary key it looked for is still checked. A new test covers an ID and an XMP packet that spell the keys, a `(` in image data, nested and escaped parentheses, `endstream` inside stream data, and wrong lengths. --- crates/engine/src/cmd/fileio/tests_pdf13.rs | 84 ++++++++++++++++++++- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/fileio/tests_pdf13.rs b/crates/engine/src/cmd/fileio/tests_pdf13.rs index 7c0aa4a74b..7497b9490d 100644 --- a/crates/engine/src/cmd/fileio/tests_pdf13.rs +++ b/crates/engine/src/cmd/fileio/tests_pdf13.rs @@ -71,9 +71,59 @@ fn export(s: &mut Session, p: Value) -> (Vec, Vec) { (bytes, v["warnings"].as_array().unwrap().iter().map(|w| w.as_str().unwrap().to_string()).collect()) } -/// The transparency `pdf` has, in its dictionaries. +/// The transparency `pdf` has, in its dictionaries. Stream data and literal strings are left out: +/// the file ID, in the trailer and in the XMP stream, is base64 that changes with the export time +/// and can spell `/BM`. fn transparency(pdf: &[u8]) -> Vec<&'static str> { - let text = String::from_utf8_lossy(pdf); + let mut text = Vec::with_capacity(pdf.len()); + let mut i = 0; + while i < pdf.len() { + let rest = &pdf[i..]; + if rest.starts_with(b"endstream") { + text.extend_from_slice(b"endstream"); + i += b"endstream".len(); + } else if rest.starts_with(b"stream") { + // Stream data is the dictionary's `/Length` bytes after the end of line (else it runs to + // `endstream`); its bytes are not PDF syntax. + let start = i + b"stream".len() + if rest[b"stream".len()..].starts_with(b"\r\n") { 2 } else { 1 }; + let dict = String::from_utf8_lossy(&text[text.windows(3).rposition(|w| w == b"obj").unwrap_or(0)..]).into_owned(); + let length = dict.rfind("/Length ").and_then(|at| { + let digits = &dict[at + "/Length ".len()..]; + let (n, after) = digits.split_at(digits.find(|c: char| !c.is_ascii_digit()).unwrap_or(digits.len())); + (!after.trim_start().starts_with(|c: char| c.is_ascii_digit())).then(|| n.parse::().ok()).flatten() + }); + i = match length { + Some(n) => { + let mut end = start.checked_add(n).filter(|&end| end <= pdf.len()).expect("stream /Length is inconsistent with endstream"); + while matches!(pdf.get(end), Some(b'\r' | b'\n')) { + end += 1; + } + assert!(pdf[end..].starts_with(b"endstream"), "stream /Length is inconsistent with endstream"); + end + } + None => i + rest.windows(b"endstream".len()).position(|w| w == b"endstream").unwrap_or(rest.len()), + }; + } else if rest[0] == b'(' { + // A literal string: balanced parentheses, with `\` escaping the next byte. + let mut depth = 0usize; + while i < pdf.len() { + match pdf[i] { + b'\\' => i += 1, + b'(' => depth += 1, + b')' => depth -= 1, + _ => {} + } + i += 1; + if depth == 0 { + break; + } + } + } else { + text.push(rest[0]); + i += 1; + } + } + let text = String::from_utf8_lossy(&text); let mut found = vec![]; for (what, there) in [ ("soft masks", text.contains("/SMask") && !text.contains("/SMask/None")), @@ -193,3 +243,33 @@ fn pdf_1_3_files_are_encrypted_with_40_bit_rc4_and_can_be_linearised() { s.execute("document.open", &json!({"dataBase64": vectorcraft_format::base64_encode(&pdf), "name": "old.pdf", "password": "nope"})).is_err() ); } + +/// The file ID is base64 that changes with the export time, so it can spell `/BM`; the check +/// reads the file's dictionaries only, not its strings or its XMP packet. +#[test] +fn the_transparency_check_skips_strings_and_metadata() { + let pdf = b"%PDF-1.3\n5 0 obj\n<>\nendobj\n6 0 obj\n<>\nstream\nq/BMx/S/Transparency\nendstream\nendobj\ntrailer\n<>\n"; + assert_eq!(transparency(pdf), Vec::<&str>::new()); + assert_eq!(transparency(b"<>>>>>"), vec!["blend modes", "opacity"]); + // A `(` in image data starts no string, and nested and escaped parentheses end where the + // string does. + let pdf = b"<>\nstream\n(\x00(\nendstream\n<>\n<>"; + assert_eq!(transparency(pdf), vec!["soft masks", "transparency groups"]); + // Stream data is skipped by its length, even when it holds `endstream` itself. + let pdf = b"1 0 obj\n<>\nstream\nendstream (/BM\nendstream\nendobj\n<>"; + assert_eq!(transparency(pdf), vec!["blend modes"]); + let pdf = b"1 0 obj\n<>\nstream\nendstream /BM\nendstream\nendobj\n"; + assert_eq!(transparency(pdf), Vec::<&str>::new()); + let pdf = b"1 0 obj\n<>\nstream\nabc\r\nendstream\nendobj\n<>"; + assert_eq!(transparency(pdf), vec!["soft masks"]); + let pdf = b"1 0 obj\n<>\nstream\nabcendstream\nendobj\n<>"; + assert_eq!(transparency(pdf), vec!["blend modes"]); + let pdf = b"1 0 obj\n<>\nstream\nabc\nendstream\nendobj\n<>"; + assert_eq!(transparency(pdf), vec!["soft masks"]); + for length in [2, 20, 999, usize::MAX] { + let pdf = format!("1 0 obj\n<>\nstream\nabc\nendstream\nendobj\n<>"); + let panic = std::panic::catch_unwind(|| transparency(pdf.as_bytes())).expect_err("an inconsistent stream /Length must panic"); + let message = panic.downcast_ref::<&str>().copied().or_else(|| panic.downcast_ref::().map(String::as_str)); + assert_eq!(message, Some("stream /Length is inconsistent with endstream"), "length {length}"); + } +} From 9217a44f6ee064627845260459614a5a50afe64f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 14:05:15 -0800 Subject: [PATCH 13/14] Type: font sheet checks the capitals All Caps draws With All Caps on in [Normal Character Style], layout draws the sample in capitals, but the coverage check looked only at the text as typed, so a font with a lowercase letter and no capital was left out of the fallback warning. The check now also tests the capitals, in plain fonts and in composite fonts, where each cluster's part is still chosen by the character as typed. --- .../src/cmd/addons/typetools/font_sheet.rs | 8 +++- .../cmd/addons/typetools/font_sheet/tests.rs | 39 +++++++++++++++++++ crates/text/src/fontdb/composite.rs | 20 ++++++++-- 3 files changed, 62 insertions(+), 5 deletions(-) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet.rs b/crates/engine/src/cmd/addons/typetools/font_sheet.rs index edc72587cc..c73fab6d2f 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet.rs @@ -212,15 +212,19 @@ fn font_sheet_in(s: &mut Session, p: &Value, db: &FontDb) -> Result { // family's closest style: either is left out. A composite font is left out when a part // that sets the sample names a font or style that doesn't load. let composite = db.composite_font(&family).is_some(); + // Layout picks a font for each character as typed, then draws All Caps type in capitals in + // that font, so coverage is checked on both. let (loads, covers) = if composite { // Glyph coverage is checked on the characters layout draws, in the sample's numeral system. - let covers = db.composite_drawn_coverage(&family, &[text.as_str()], sample.digits).is_none_or(|c| c.lacking.is_empty()); + let covers = db.composite_cased_coverage(&family, &[text.as_str()], sample.digits, sample.all_caps).is_none_or(|c| c.lacking.is_empty()); (db.composite_coverage(&family, &[text.as_str()]).is_some_and(|c| c.status == FontMatch::Exact), covers) } else { let wanted = db.canonical(&family, "").0; match db.face(&sample.font_family, &sample.font_style) { Some(face) if face.family.eq_ignore_ascii_case(&wanted) && style.as_ref().is_none_or(|st| face.style.eq_ignore_ascii_case(st)) => { - (true, vectorcraft_text::drawn_chars(&text, sample.digits).all(|c| face.covers(c))) + let drawn = |t: &str| vectorcraft_text::drawn_chars(t, sample.digits).all(|c| face.covers(c)); + let capitals = || text.chars().flat_map(char::to_uppercase).collect::(); + (true, drawn(&text) && (!sample.all_caps || drawn(&capitals()))) } _ => (false, true), } diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index f1b207025b..0e8e81fc52 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -235,6 +235,45 @@ fn coverage_uses_the_samples_numeral_system() { } } +/// All Caps in the normal character style draws the sample in capitals, so a font with a lowercase +/// letter but not its capital is named in `fallback`, plain and composite fonts alike. +#[test] +fn coverage_checks_the_capitals_all_caps_draws() { + let mut s = session(); + let face = FontDb::global().face("Inter", "Regular").unwrap(); + let lower = (0x80..0x3000u32) + .filter_map(char::from_u32) + .find(|&c| { + let mut up = c.to_uppercase(); + face.covers(c) && up.len() == 1 && up.next().is_some_and(|u| u != c && !face.covers(u)) + }) + .unwrap_or_else(|| panic!("Inter has no lowercase letter without its capital")); + let font = json!({"name": "CF Sheet Caps", "parts": {"kanji": {"font": "Source Sans 3"}, "roman": {"font": "Inter"}}}); + s.execute("type.compositeFonts.set", &json!({"fonts": [font]})).unwrap(); + let text = lower.to_string(); + let r = s.execute(COMMAND, &json!({"families": ["Inter", "CF Sheet Caps"], "labels": false, "text": text})).unwrap(); + assert_eq!(r["fallback"], json!([]), "{lower:?}: {r}"); + s.execute("charStyle.edit", &json!({"name": "[Normal Character Style]", "to": "[Normal Character Style]", "attrs": {"all_caps": true}})).unwrap(); + let r = s.execute(COMMAND, &json!({"families": ["Inter", "CF Sheet Caps"], "labels": false, "text": text})).unwrap(); + assert_eq!((&r["count"], &r["skipped"]), (&json!(2), &json!([])), "{r}"); + assert_eq!(r["fallback"], json!(["Inter", "CF Sheet Caps"]), "{lower:?}: {r}"); + assert!(r["warning"].as_str().is_some_and(|w| w.contains("lack glyphs")), "{r}"); + let e = entries(&group(&s, &r)); + assert!(e[0].1.runs[0].style.all_caps); + assert_eq!(e[0].1.plain_text(), text, "the sample keeps its own case"); + // Layout picks the font for the character as typed, so one the font lacks still falls back + // when the font has its capitals. + let uncased = (0x80..0x3000u32) + .filter_map(char::from_u32) + .find(|&c| { + let up: String = c.to_uppercase().collect(); + !face.covers(c) && up != c.to_string() && up.chars().all(|u| face.covers(u)) + }) + .unwrap_or_else(|| panic!("Inter has every character whose capitals it has")); + let r = s.execute(COMMAND, &json!({"families": ["Inter"], "labels": false, "text": uncased.to_string()})).unwrap(); + assert_eq!(r["fallback"], json!(["Inter"]), "{uncased:?}: {r}"); +} + #[test] fn bad_params_are_refused_without_a_change() { let mut s = session(); diff --git a/crates/text/src/fontdb/composite.rs b/crates/text/src/fontdb/composite.rs index 371d8e2574..772b62cfb6 100644 --- a/crates/text/src/fontdb/composite.rs +++ b/crates/text/src/fontdb/composite.rs @@ -249,10 +249,17 @@ impl FontDb { /// each grapheme cluster's part is chosen by its own first character, and the part's face is /// checked for the cluster's drawn characters ([`crate::drawn_chars`]). pub fn composite_drawn_coverage(&self, name: &str, texts: &[&str], digits: Digits) -> Option { - self.coverage_of(name, texts, Some(digits)) + self.coverage_of(name, texts, Some((digits, false))) } - fn coverage_of(&self, name: &str, texts: &[&str], digits: Option) -> Option { + /// [`FontDb::composite_drawn_coverage`] of type set in All Caps when `all_caps` is on: each + /// cluster's part is still chosen by its own first character, and the part's face is also + /// checked for the capitals layout draws. + pub fn composite_cased_coverage(&self, name: &str, texts: &[&str], digits: Digits, all_caps: bool) -> Option { + self.coverage_of(name, texts, Some((digits, all_caps))) + } + + fn coverage_of(&self, name: &str, texts: &[&str], digits: Option<(Digits, bool)>) -> Option { let f = self.composite_font(name)?; let rank = |m: FontMatch| match m { FontMatch::Exact => 0, @@ -284,7 +291,14 @@ impl FontDb { worst = Some((m, found.as_ref().map(|(face, _)| face.clone()))); } match digits { - Some(d) => lacking.extend(crate::drawn_chars(g, d).filter(|c| !found.as_ref().is_some_and(|(face, _)| face.covers(*c)))), + Some((d, caps)) => { + let missing = |c: &char| !found.as_ref().is_some_and(|(face, _)| face.covers(*c)); + lacking.extend(crate::drawn_chars(g, d).filter(missing)); + if caps { + let upper: String = g.chars().flat_map(char::to_uppercase).collect(); + lacking.extend(crate::drawn_chars(&upper, d).filter(missing)); + } + } None => lacking .extend(g.chars().filter(|c| !c.is_whitespace() && !c.is_control() && !found.as_ref().is_some_and(|(face, _)| face.covers(*c)))), } From e2e89207fcc0dcc285c0714792531ba76ca8c883 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Wed, 2 Dec 2026 15:28:50 -0800 Subject: [PATCH 14/14] Type: font sheet test checks the document keeps its layers test-lint's all-unguarded rule flagged bad_params_are_refused_without_a_change: its all() over the layers also passed on a document with no layers. The test now asserts the layer list is not empty before checking nothing was drawn. --- crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs index 0e8e81fc52..ab86b42be4 100644 --- a/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs +++ b/crates/engine/src/cmd/addons/typetools/font_sheet/tests.rs @@ -312,7 +312,9 @@ fn bad_params_are_refused_without_a_change() { assert!(s.execute(COMMAND, &bad).is_err(), "{bad}"); } assert_eq!(steps(&s), before); - assert!(s.doc().unwrap().doc.layers.iter().all(|l| l.children().is_none_or(|c| c.is_empty())), "nothing was drawn"); + let layers = &s.doc().unwrap().doc.layers; + assert!(!layers.is_empty(), "the document keeps its layers"); + assert!(layers.iter().all(|l| l.children().is_none_or(|c| c.is_empty())), "nothing was drawn"); } /// Fonts left out are named in the warning, the first five of them, with a count of the rest.