From 8d0a50ffa0bff71fe9a8a6994af2fd19ef835c22 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 20 Nov 2026 16:10:38 -0800 Subject: [PATCH] Type: Show Hidden Characters and Auto Spell Check list the type once per revision Both overlays visited every object of the document in every frame to find its type. They now draw from one list of the active document's text objects, kept for the document's uid and revision, so a frame that changes nothing visits only the type. An edit, Undo, Redo or a switch to another document makes a new list, and the canvas drops the list while it draws neither overlay. Show Hidden Characters no longer draws marks over type in a hidden group or layer, which the canvas does not draw. Auto Spell Check already left such type out. --- crates/ui-egui/src/app.rs | 1 + crates/ui-egui/src/caches.rs | 4 + crates/ui-egui/src/canvas.rs | 17 +- crates/ui-egui/src/canvas/tests.rs | 192 +++++++++++++++++++++ crates/ui-egui/src/canvas/tool_overlays.rs | 87 +++++++--- docs/target-app-parity.md | 3 +- docs/type-parity.md | 2 +- 7 files changed, 272 insertions(+), 34 deletions(-) diff --git a/crates/ui-egui/src/app.rs b/crates/ui-egui/src/app.rs index bba6a5d83d..458da81741 100644 --- a/crates/ui-egui/src/app.rs +++ b/crates/ui-egui/src/app.rs @@ -85,6 +85,7 @@ impl VectorcraftApp { find_font: None, hidden_chars: Default::default(), spelling: Default::default(), + text_nodes: Default::default(), selection_marks: Default::default(), shared_paths: Default::default(), selection_box: None, diff --git a/crates/ui-egui/src/caches.rs b/crates/ui-egui/src/caches.rs index 6e1d229023..01b0a2b6f7 100644 --- a/crates/ui-egui/src/caches.rs +++ b/crates/ui-egui/src/caches.rs @@ -52,6 +52,10 @@ pub struct CanvasCache { /// The words Edit › Spelling › Auto Spell Check underlined on each text object in the last /// frame; dropped while it is off. pub spelling: canvas::SpellingMarks, + /// The active document's text objects for (document uid, revision), which Show Hidden + /// Characters and Auto Spell Check draw over. A frame that draws neither drops them + /// ([`canvas::show`]). + pub text_nodes: canvas::TextNodes, /// The selected objects' outlines, anchors and handles as drawn in the last frame. A frame that /// does not draw them drops them ([`canvas::show`]). pub selection_marks: canvas::SelectionMarks, diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index 8b366665d4..128af6f67f 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -80,7 +80,7 @@ pub(crate) use task_bar::{bar_action_name, chip_paints, images_with_other_art, t pub(crate) use task_bar::{has_colors, task_bar_rect, task_bar_shows_fonts, task_bar_shows_type}; #[cfg(test)] use tool_overlays::{DIAL_RADIUS, HiddenMarks}; -pub use tool_overlays::{HiddenChars, SpellingMarks}; +pub use tool_overlays::{HiddenChars, SpellingMarks, TextNodes}; use tool_overlays::{ grid_repeat_overlay, hidden_chars_overlay, live_paint_gap_overlays, mirror_axis_overlay, nine_slice_overlay, original_path_overlay, print_tiling_overlay, radial_repeat_overlay, rotate_view_dial, shaper_widget_overlay, slice_overlay, spelling_overlay, thread_overlays, @@ -249,6 +249,9 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { // that does not draw the overlay drops them, for example with the option off, with the edges // hidden, on the Home screen or with no document open. let hidden_chars = std::mem::take(&mut app.canvas.hidden_chars); + // The text objects those marks and Auto Spell Check's lines are drawn over. Likewise, a frame + // that draws neither drops them. + let text_nodes = std::mem::take(&mut app.canvas.text_nodes); // The selection's kept marks. Likewise, a frame that does not draw them drops them. let selection_marks = std::mem::take(&mut app.canvas.selection_marks); // The meshes of the tools' shared paths. Likewise, a frame that does not draw the tools' @@ -431,7 +434,7 @@ pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { } original_path_overlay(app, &painter, &xf); - let overlays = selection_visuals(app, &painter, &xf, (hidden_chars, selection_marks, hover_still), revolve_edit, view_info); + let overlays = selection_visuals(app, &painter, &xf, (hidden_chars, text_nodes, selection_marks, hover_still), revolve_edit, view_info); draw_overlays(&painter, &xf, &overlays, &t, HandleLook::of(&app.session.prefs), &mut shared_paths); app.canvas.shared_paths = shared_paths; crate::panels::tabs::paint_stop_guide(app, &painter, &xf); @@ -1652,10 +1655,16 @@ fn selection_visuals( app: &mut VectorcraftApp, painter: &egui::Painter, xf: &Xf, - (hidden_chars, mut marks, hover_still): (HiddenChars, SelectionMarks, bool), + (hidden_chars, text_nodes, mut marks, hover_still): (HiddenChars, TextNodes, SelectionMarks, bool), revolve_edit: bool, view_info: vectorcraft_engine::ViewInfo, ) -> Vec { + // Show Hidden Characters (with the edges shown) and Auto Spell Check draw over the same text + // objects: their list is kept while either is drawn. + let draws_hidden_chars = app.ui.view.edges && !revolve_edit && app.ui.view.hidden_chars; + if draws_hidden_chars || (app.ui.view.auto_spell_check && !revolve_edit) { + app.canvas.text_nodes = text_nodes; + } // View → Hide Gradient Annotator hides the Gradient tool's annotator. let mut overlays = if !revolve_edit && (app.session.tool_id() != "gradient" || app.ui.view.gradient_annotator) { app.session.overlays(view_info) @@ -1688,7 +1697,7 @@ fn selection_visuals( if app.ui.view.live_paint_gaps { overlays.extend(live_paint_gap_overlays(app)); } - if app.ui.view.hidden_chars { + if draws_hidden_chars { app.canvas.hidden_chars = hidden_chars; hidden_chars_overlay(app, painter, xf); } diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index d5244aa234..4c98f2df4e 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -7530,9 +7530,11 @@ fn show_hidden_characters_off_releases_the_text_nodes() { after.inputs == inputs && std::sync::Arc::ptr_eq(&after.marks[&id].1, &marks) }); assert!(kept, "a frame keeps the marks of the frame before"); + assert!(app.canvas.text_nodes.list.is_some(), "the list of the text objects is kept"); app.run("type.hiddenCharacters", json!({})).unwrap(); assert!(hidden_char_marks(&mut app, &ctx).is_empty(), "off"); assert!(app.canvas.hidden_chars.marks.is_empty(), "no node is kept"); + assert!(app.canvas.text_nodes.list.is_none(), "no list of the text objects is kept"); app.run("type.hiddenCharacters", json!({})).unwrap(); assert_eq!(hidden_char_marks(&mut app, &ctx), on, "on again: the same marks"); } @@ -7556,9 +7558,199 @@ fn show_hidden_characters_releases_the_text_nodes_of_a_closed_document() { app.session.execute("file.close", &json!({})).unwrap(); assert!(hidden_char_marks(&mut app, &ctx).is_empty(), "the Home screen"); assert!(app.canvas.hidden_chars.marks.is_empty(), "no node of the closed document is kept"); + assert!(app.canvas.text_nodes.list.is_none(), "no list of the closed document's text objects is kept"); assert_eq!(open(&mut app), first, "the same type in a new document"); } +/// `paths` small rectangles and three point type objects with hidden characters and words no +/// dictionary knows: the first on the first layer, the second in a group on that layer and the +/// third on a second layer. Returns the type objects, the group, the second layer and a view. +fn type_among_paths(paths: usize) -> (VectorcraftApp, [vectorcraft_doc::NodeId; 3], vectorcraft_doc::NodeId, vectorcraft_doc::NodeId, Xf) { + use std::sync::Arc; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + let id = |v: serde_json::Value| vectorcraft_doc::NodeId(v["id"].as_u64().unwrap()); + let path = id(app.session.execute("shape.rectangle", &json!({"x": 300, "y": 250, "width": 5, "height": 5})).unwrap()); + { + let st = app.session.active_mut().unwrap(); + let doc = Arc::make_mut(&mut st.doc); + let template = doc.node(path).unwrap().clone(); + let more: Vec<_> = (1..paths) + .map(|_| { + let mut p = template.clone(); + p.id = doc.alloc_id(); + Arc::new(p) + }) + .collect(); + Arc::make_mut(&mut doc.layers[0]).children_mut().unwrap().extend(more); + doc.drop_lookup_cache(); + } + let text = + |app: &mut VectorcraftApp, y: u32, text: &str| id(app.session.execute("text.create", &json!({"x": 20, "y": y, "text": text})).unwrap()); + let a = text(&mut app, 40, "one\ttwo\u{00A0}the\nthree\u{2028}four"); + let b = text(&mut app, 110, "Qzvbtrw the\u{2003}cat"); + app.session.execute("select.set", &json!({"ids": [b.0]})).unwrap(); + let group = id(app.session.execute("object.group", &json!({})).unwrap()); + let layer = id(app.session.execute("layer.new", &json!({})).unwrap()); + let c = text(&mut app, 180, "Zvqtrbx the\u{202F}cat\n"); + assert_eq!(app.session.active().unwrap().doc.layers.iter().find(|l| l.id == layer).and_then(|l| l.children()).map(|c| c.len()), Some(1)); + let xf = Xf { rect: egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0)), zoom: 1.0, center: Point::new(200.0, 150.0), rot: 0.0 }; + (app, [a, b, c], group, layer, xf) +} + +/// The list of text objects Show Hidden Characters and Auto Spell Check last drew over. +fn listed_type(app: &VectorcraftApp) -> super::tool_overlays::TextList { + app.canvas.text_nodes.list.as_ref().map(|(_, l)| l.clone()).unwrap() +} + +/// Show Hidden Characters and Auto Spell Check find the type among the document's other objects +/// once for each revision, in one list both draw from: frames that change nothing draw from the +/// same list, and draw the marks and lines a frame drawing from a new list draws. The list holds +/// the visible type in the order the overlays drew it before they shared it. +#[test] +fn hidden_characters_and_auto_spell_check_share_one_list_of_the_type() { + let (mut app, ids, _, _, xf) = type_among_paths(2_000); + let ctx = egui::Context::default(); + // Each visible text object in `Document::walk` order, with no group or layer hidden. + let mut walked = vec![]; + app.session.active().unwrap().doc.walk(|n| { + if matches!(n.kind, vectorcraft_doc::NodeKind::Text(_)) && n.visible { + walked.push(n.id); + } + }); + assert_eq!(walked.len(), 3); + let marks = hidden_chars(&mut app, &ctx, &xf); + let list = listed_type(&app); + assert_eq!(list.iter().filter(|t| t.shown).map(|t| t.node.id).collect::>(), walked); + assert!(list.iter().all(|t| ids.contains(&t.node.id)), "only type"); + let lines = spelling_lines(&mut app, &ctx, &xf); + assert_eq!(lines.len(), 2, "{lines:?}"); + assert!(std::sync::Arc::ptr_eq(&list, &listed_type(&app)), "Auto Spell Check draws from the same list"); + for _ in 0..3 { + assert_eq!(hidden_chars(&mut app, &ctx, &xf), marks); + assert_eq!(spelling_lines(&mut app, &ctx, &xf), lines); + assert!(std::sync::Arc::ptr_eq(&list, &listed_type(&app)), "a frame that changes nothing lists no type"); + } + app.canvas.text_nodes = TextNodes::default(); + app.canvas.hidden_chars = HiddenChars::default(); + app.canvas.spelling = SpellingMarks::default(); + assert_eq!(hidden_chars(&mut app, &ctx, &xf), marks, "the marks drawn from a new list"); + assert_eq!(spelling_lines(&mut app, &ctx, &xf), lines, "the lines drawn from a new list"); + assert!(!std::sync::Arc::ptr_eq(&list, &listed_type(&app))); +} + +/// The list follows the document: a new text object, an edit, Undo, Redo and a switch to another +/// document each list the type again, and the marks are those of the type the document holds. +#[test] +fn the_list_of_type_follows_edits_undo_redo_and_the_active_document() { + use std::sync::Arc; + let (mut app, ids, _, _, xf) = type_among_paths(50); + let ctx = egui::Context::default(); + // Each listed object's id and node. + let nodes = |app: &VectorcraftApp| listed_type(app).iter().map(|t| (t.node.id, Arc::as_ptr(&t.node))).collect::>(); + hidden_chars(&mut app, &ctx, &xf); + let first = nodes(&app); + assert_eq!(first.len(), 3); + let added = + vectorcraft_doc::NodeId(app.session.execute("text.create", &json!({"x": 200, "y": 40, "text": "g h"})).unwrap()["id"].as_u64().unwrap()); + hidden_chars(&mut app, &ctx, &xf); + let with_new = nodes(&app); + assert_eq!(with_new.len(), 4); + assert!(with_new.iter().any(|(id, _)| *id == added), "the new object"); + assert!(app.canvas.hidden_chars.marks.contains_key(&added), "has marks"); + app.session.execute("text.setText", &json!({"id": ids[0].0, "text": "x\ty"})).unwrap(); + hidden_chars(&mut app, &ctx, &xf); + let edited = nodes(&app); + let node_of = |list: &[(vectorcraft_doc::NodeId, *const vectorcraft_doc::Node)], id| list.iter().find(|(i, _)| *i == id).map(|(_, n)| *n); + assert_ne!(node_of(&edited, ids[0]), node_of(&with_new, ids[0]), "the edited object's new node"); + assert_eq!(node_of(&edited, ids[1]), node_of(&with_new, ids[1]), "the others' nodes"); + assert_eq!(app.canvas.hidden_chars.marks[&ids[0]].1.chars.len(), 1, "the marks of the edited text: one tab"); + app.session.execute("edit.undo", &json!({})).unwrap(); + hidden_chars(&mut app, &ctx, &xf); + assert_eq!(nodes(&app), with_new, "Undo"); + assert_eq!(app.canvas.hidden_chars.marks[&ids[0]].1.chars.len(), 2, "the marks of the text before: a tab and a nonbreaking space"); + app.session.execute("edit.redo", &json!({})).unwrap(); + hidden_chars(&mut app, &ctx, &xf); + assert_eq!(nodes(&app), edited, "Redo"); + app.session.execute("file.new", &json!({"width": 400, "height": 300})).unwrap(); + assert!(hidden_chars(&mut app, &ctx, &xf).is_empty(), "another document: none of the first one's marks"); + assert!(nodes(&app).is_empty() && app.canvas.hidden_chars.marks.is_empty()); + app.session.execute("document.activate", &json!({"index": 0})).unwrap(); + hidden_chars(&mut app, &ctx, &xf); + assert_eq!(nodes(&app), edited, "back to the first document"); +} + +/// Neither overlay draws over type that the canvas does not draw: a hidden text object, or one in +/// a hidden group or layer. Shown again, its marks and lines come back. +#[test] +fn hidden_characters_and_auto_spell_check_leave_out_type_in_hidden_groups_and_layers() { + let (mut app, [a, b, c], group, layer, xf) = type_among_paths(10); + let ctx = egui::Context::default(); + let drawn = |app: &mut VectorcraftApp| { + let marks = hidden_chars(app, &ctx, &xf).len(); + let lines = spelling_lines(app, &ctx, &xf).len(); + let mut ids: Vec<_> = app.canvas.hidden_chars.marks.keys().copied().collect(); + ids.sort(); + let mut spelled: Vec<_> = app.canvas.spelling.lines.keys().copied().collect(); + spelled.sort(); + (ids, spelled, marks, lines) + }; + let all = drawn(&mut app); + assert_eq!((all.0.clone(), all.1.clone(), all.3), (vec![a, b, c], vec![a, b, c], 2)); + app.session.execute("object.setProps", &json!({"ids": [group.0], "visible": false})).unwrap(); + let (ids, spelled, marks, lines) = drawn(&mut app); + assert_eq!((ids, spelled, lines), (vec![a, c], vec![a, c], 1), "a hidden group"); + assert!(marks < all.2, "fewer marks: {marks} of {}", all.2); + assert!(listed_type(&app).iter().any(|t| t.node.id == b && !t.shown), "listed, not shown"); + app.session.execute("object.setProps", &json!({"ids": [group.0], "visible": true})).unwrap(); + assert_eq!(drawn(&mut app), all, "the group shown again"); + app.session.execute("layer.setProps", &json!({"id": layer.0, "visible": false})).unwrap(); + let (ids, spelled, _, lines) = drawn(&mut app); + assert_eq!((ids, spelled, lines), (vec![a, b], vec![a, b], 1), "a hidden layer"); + app.session.execute("layer.setProps", &json!({"id": layer.0, "visible": true})).unwrap(); + assert_eq!(drawn(&mut app), all, "the layer shown again"); + app.session.execute("object.setProps", &json!({"ids": [a.0], "visible": false})).unwrap(); + let (ids, spelled, _, _) = drawn(&mut app); + assert_eq!((ids, spelled), (vec![b, c], vec![b, c]), "a hidden text object"); + app.session.execute("object.setProps", &json!({"ids": [a.0], "visible": true})).unwrap(); + assert_eq!(drawn(&mut app), all, "the text object shown again"); +} + +/// An ignored diagnostic for the overlays' cost on a document of many paths and a little type: +/// frames of both overlays drawing from the kept list, and frames that list the type again each +/// time. There is no timing threshold; run on an idle machine and compare the printed cases. +#[test] +#[ignore = "manual performance diagnostic; no stable timing threshold"] +fn type_overlays_on_many_paths_diagnostic() { + use std::time::Instant; + const FRAMES: usize = 50; + for paths in [10_000, 100_000] { + let (mut app, _, _, _, xf) = type_among_paths(paths); + let ctx = egui::Context::default(); + let both = |app: &mut VectorcraftApp| { + hidden_chars(app, &ctx, &xf); + spelling_lines(app, &ctx, &xf); + }; + both(&mut app); + let t = Instant::now(); + for _ in 0..FRAMES { + both(&mut app); + } + let kept = t.elapsed(); + let t = Instant::now(); + for _ in 0..FRAMES { + app.canvas.text_nodes = TextNodes::default(); + both(&mut app); + } + let listed = t.elapsed(); + eprintln!( + "{paths} paths: {:?} a frame from the kept list, {:?} a frame listing the type again", + kept / FRAMES as u32, + listed / FRAMES as u32 + ); + } +} + /// General › Zoom with Mouse Wheel (#394), through the control channel's `ui.wheel`: off, /// the wheel scrolls and Cmd-wheel scrolls sideways (Scroll Sideways with Cmd/Ctrl + Wheel is on /// by default); on, the wheel zooms about the pointer, Shift-wheel diff --git a/crates/ui-egui/src/canvas/tool_overlays.rs b/crates/ui-egui/src/canvas/tool_overlays.rs index 958872d6b0..81215d883b 100644 --- a/crates/ui-egui/src/canvas/tool_overlays.rs +++ b/crates/ui-egui/src/canvas/tool_overlays.rs @@ -22,21 +22,13 @@ pub(super) fn hidden_chars_overlay(app: &mut VectorcraftApp, p: &egui::Painter, last.clear(); kept.inputs = inputs; } - // `walk` visits each node's `Arc` in the order `Document::walk` visits the nodes (depth first, - // in paint order). - fn walk(nodes: &[std::sync::Arc], f: &mut impl FnMut(&std::sync::Arc)) { - for n in nodes { - f(n); - if let Some(children) = n.children() { - walk(children, f); - } - } - } - walk(&st.doc.layers, &mut |n| { - let NodeKind::Text(tx) = &n.kind else { return }; + // Leaving out hidden objects and what is inside hidden groups and layers, as the canvas does. + for t in text_nodes(&mut app.canvas.text_nodes, st).iter().filter(|t| t.shown) { + let n = &t.node; + let NodeKind::Text(tx) = &n.kind else { continue }; // The box round the object's corners on screen, turned with the view. - if !n.visible || n.geometric_bounds().is_none_or(|b| !egui::Rect::from_points(&xf.quad(b)).intersects(clip)) { - return; + if n.geometric_bounds().is_none_or(|b| !egui::Rect::from_points(&xf.quad(b)).intersects(clip)) { + continue; } let marks = match last.remove(&n.id) { Some((was, marks)) if std::sync::Arc::ptr_eq(&was, n) => marks, @@ -62,7 +54,53 @@ pub(super) fn hidden_chars_overlay(app: &mut VectorcraftApp, p: &egui::Painter, p.text(xf.to_screen(at), align, glyph, font.clone(), color); } kept.marks.insert(n.id, (n.clone(), marks)); - }); + } +} + +/// One text object of the active document ([`TextNodes`]). +pub(super) struct TextNode { + pub(super) node: std::sync::Arc, + /// The object and every group and layer that holds it are visible: the canvas draws it. + pub(super) shown: bool, +} + +/// The text objects of the active document, for (document uid, revision): Show Hidden Characters +/// and Auto Spell Check draw over them every frame ([`crate::CanvasCache::text_nodes`]). A frame +/// that draws neither drops them ([`super::show`]). +#[derive(Default)] +pub struct TextNodes { + pub(super) list: Option<((u64, u64), TextList)>, +} + +/// The text objects of a document, in paint order ([`TextNodes`]). +pub(super) type TextList = std::sync::Arc>; + +/// The text objects of `st`'s document in the order `Document::walk` visits the nodes (depth +/// first, in paint order), hidden ones included. `kept` holds the list while the document and its +/// revision are those it was made for. +pub(super) fn text_nodes(kept: &mut TextNodes, st: &vectorcraft_engine::DocState) -> TextList { + let key = (st.uid, st.revision); + if let Some((k, list)) = &kept.list + && *k == key + { + return list.clone(); + } + fn walk(nodes: &[std::sync::Arc], shown: bool, out: &mut Vec) { + for n in nodes { + let shown = shown && n.visible; + if matches!(n.kind, NodeKind::Text(_)) { + out.push(TextNode { node: n.clone(), shown }); + } + if let Some(children) = n.children() { + walk(children, shown, out); + } + } + } + let mut list = Vec::new(); + walk(&st.doc.layers, true, &mut list); + let list = std::sync::Arc::new(list); + kept.list = Some((key, list.clone())); + list } /// `v` scaled to length 1, or `or` when `v` has no length. @@ -265,19 +303,12 @@ pub(super) fn spelling_overlay(app: &mut VectorcraftApp, p: &egui::Painter, xf: kept.inputs = Some(inputs); } let stroke = Stroke::new(1.0, Color32::from_rgb(0xe0, 0x20, 0x20)); - // Depth first in paint order, leaving out hidden objects and what is inside them. - fn walk(nodes: &[std::sync::Arc], f: &mut impl FnMut(&std::sync::Arc)) { - for n in nodes.iter().filter(|n| n.visible) { - f(n); - if let Some(children) = n.children() { - walk(children, f); - } - } - } - walk(&st.doc.layers, &mut |n| { - let NodeKind::Text(tx) = &n.kind else { return }; + // Leaving out hidden objects and what is inside hidden groups and layers. + for t in text_nodes(&mut app.canvas.text_nodes, st).iter().filter(|t| t.shown) { + let n = &t.node; + let NodeKind::Text(tx) = &n.kind else { continue }; if !auto_spell_checks(n) || n.geometric_bounds().is_none_or(|b| !egui::Rect::from_points(&xf.quad(b)).intersects(clip)) { - return; + continue; } let lines = match last.remove(&n.id) { Some((was, lines)) if std::sync::Arc::ptr_eq(&was, n) => lines, @@ -287,7 +318,7 @@ pub(super) fn spelling_overlay(app: &mut VectorcraftApp, p: &egui::Painter, xf: wavy_line(p, xf.to_screen(a), xf.to_screen(b), stroke); } kept.lines.insert(n.id, (n.clone(), lines)); - }); + } } /// Whether Auto Spell Check marks `n`'s words: not with an effect shown (the Appearance panel's diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 57ac87a396..5ce1ca2497 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -840,7 +840,7 @@ since 2026-10-01. - **Justification… on type on a path:** each paragraph's Desired Word Spacing, Letter Spacing and Glyph Scaling set its glyphs on type on a path as on point and area type, so the text after a wider gap starts further along the path, alignment and overflow use the spaced length, and a list marker keeps its width. Minimum and Maximum are not used on a path, and vertical type is not glyph scaled. SVG export writes such type as outlines with a warning. Tests `tests::justify::type_on_a_path_takes_desired_spacing_and_scaling`, `type_on_a_path_is_aligned_and_fitted_at_desired_spacing`, `vertical_type_and_list_markers_on_a_path_are_not_glyph_scaled` and the SVG test `text_layout::justification_spacing_on_a_path_is_outlined`. Public reference: the help page (). - **Letter spacing and Full Justify between shaped clusters:** Desired Letter Spacing on any line, the letter spacing range of a justified line, and Single Word Justification's Full Justify add space only between shaped clusters, in horizontal, right-to-left and vertical type, so a combining mark stays on its letter and a Devanagari syllable's glyphs stay together. They add no space next to a zero-width format control (a soft hyphen, a bidi mark, embedding, override or isolate, a zero-width space, a joiner or non-joiner, a word joiner, a variation selector, a tag, the byte order mark), so a word wrapped in an override still reaches both edges of a justified line, and a Kinsoku push-in counts no gap at one either. A zero-width space is a line break opportunity but not a word separator ([CSS Text Level 3](https://www.w3.org/TR/css-text-3/#word-separator) does not list it), so a justified line gives it no share of its room. Desired Letter Spacing between the letters on either side of a zero-width space goes after the zero-width space, so a line that breaks there ends at its last letter, and the line breaker does not measure a gap after it. A line that Full Justify spreads and that ends in a drawn hyphen puts the same gap between its last letter and the hyphen. The cluster boundary is VectorCraft's own rule, based on the typographic character unit of [CSS Text Level 3](https://www.w3.org/TR/css-text-3/#typographic-character-unit). Tests `tests::justify::single_word_full_justify_keeps_combining_mark_with_base`, `desired_and_fitted_letter_spacing_skip_shaped_cluster`, `rtl_single_word_cluster_gap_follows_drawn_order`, `vertical_single_word_cluster_gap_follows_drawn_order`, `single_word_full_justify_keeps_conjunct_cluster`, `desired_letter_spacing_skips_bidi_format_controls`, `letter_spacing_and_full_justify_skip_joiners_and_soft_hyphens`, `format_controls_are_the_zero_width_default_ignorables`, `zero_width_space_takes_no_word_space_room`, `desired_letter_spacing_ends_a_line_broken_at_a_zero_width_space_without_a_gap`, `single_word_full_justify_spreads_up_to_the_drawn_hyphen` and `layout::wrapping_tests::kinsoku_shori_type_counts_no_gap_at_a_format_control`. Public reference: the help page (). - **Justified lines with tabs:** a tab is not a word space, so a justified area type line no longer gives it a share of its room that no glyph draws. On a justified line with a tab, the text up to the last tab keeps its spacing, each tab keeps its stop and its leader stays in its gap, and the text after the last tab takes the room (word spaces first, then letter spacing, glyph scaling and the gaps between its letters), so the line ends on the far edge. A tab separates two words, so Single Word Justification does not align a word-tab-word line. Right-to-left lines take the text drawn after the last tab drawn, and vertical lines work down the column. Spreading the room after the last tab is VectorCraft's own rule. Tests `tests::justify::a_justified_line_with_a_tab_spreads_the_text_after_it_to_the_edge`, `a_justified_tab_keeps_its_leader_inside_its_gap`, `a_justified_word_tab_word_line_reaches_the_edge`, `the_last_line_with_a_tab_fills_the_measure_only_with_justify_all`, `a_justified_line_takes_its_room_after_its_last_tab`, `a_justified_vertical_line_with_a_tab_reaches_the_end_of_its_column`, `a_justified_right_to_left_line_with_a_tab_spans_its_measure` and `justified_point_type_with_a_tab_keeps_its_width`. Public reference: the help pages (, ). -- **Show Hidden Characters marks every character that prints no ink:** [the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/special-characters-glyphs/insert-white-space-and-break-characters.html) lists the characters that Type › Show Hidden Characters makes visible: paragraph returns, forced line breaks, tabs, spaces, nonbreaking spaces, discretionary hyphens and the end of the text. Besides the dot over a space, ¶ at a paragraph's end and # at the story's end, the canvas draws an arrow across each tab's advance to its stop, a ring over a nonbreaking space (U+00A0) and a smaller one over a narrow nonbreaking space (U+202F), a short tick over the spaces of a set width (U+2000 to U+200A, U+205F, U+3000), ¬ at a discretionary hyphen (U+00AD) whether or not the line breaks there, and a bent arrow after a line that a forced line break (U+2028) ends, which gets no ¶. The marks follow the baseline of vertical type and of type on a path, ¶ goes at the left end of a right-to-left line, and type on a path gets # after its last character when the path shows all of its text. The shapes of the marks, and marking U+202F and the spaces of a set width, are VectorCraft's own rules. The marks are drawn only on the canvas and are not saved or exported. Tests: `canvas::tests::hidden_characters_mark_tabs_nonbreaking_spaces_and_discretionary_hyphens`, `hidden_characters_mark_forced_line_breaks`, `hidden_characters_mark_a_discretionary_hyphen_at_a_break_once`, `hidden_characters_follow_vertical_type`, `hidden_characters_end_a_right_to_left_line_at_its_left`, `hidden_characters_mark_type_on_a_path` and `show_hidden_characters_draws_every_kind_of_mark`. +- **Show Hidden Characters marks every character that prints no ink:** [the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/special-characters-glyphs/insert-white-space-and-break-characters.html) lists the characters that Type › Show Hidden Characters makes visible: paragraph returns, forced line breaks, tabs, spaces, nonbreaking spaces, discretionary hyphens and the end of the text. Besides the dot over a space, ¶ at a paragraph's end and # at the story's end, the canvas draws an arrow across each tab's advance to its stop, a ring over a nonbreaking space (U+00A0) and a smaller one over a narrow nonbreaking space (U+202F), a short tick over the spaces of a set width (U+2000 to U+200A, U+205F, U+3000), ¬ at a discretionary hyphen (U+00AD) whether or not the line breaks there, and a bent arrow after a line that a forced line break (U+2028) ends, which gets no ¶. The marks follow the baseline of vertical type and of type on a path, ¶ goes at the left end of a right-to-left line, and type on a path gets # after its last character when the path shows all of its text. The shapes of the marks, and marking U+202F and the spaces of a set width, are VectorCraft's own rules. The marks are drawn only on the canvas and are not saved or exported. Type that the canvas does not draw, because it or a group or layer holding it is hidden, gets no marks; this is VectorCraft's own rule. Tests: `canvas::tests::hidden_characters_mark_tabs_nonbreaking_spaces_and_discretionary_hyphens`, `hidden_characters_and_auto_spell_check_leave_out_type_in_hidden_groups_and_layers`, `hidden_characters_mark_forced_line_breaks`, `hidden_characters_mark_a_discretionary_hyphen_at_a_break_once`, `hidden_characters_follow_vertical_type`, `hidden_characters_end_a_right_to_left_line_at_its_left`, `hidden_characters_mark_type_on_a_path` and `show_hidden_characters_draws_every_kind_of_mark`. - **The text style panel menus' Duplicate and Delete:** in the Character Styles and Paragraph Styles panel menus, Duplicate highlights the copy, as Create New Style highlights the new style, and Delete leaves no style highlighted, as the Delete button does, so Duplicate, Clear Overrides, Redefine and Style Options are disabled until another style is clicked. A highlighted style that is renamed in Style Options or deleted by a command is no longer highlighted either. The tests `panels::text_styles::tests::panel_menu_duplicate_and_delete_update_the_highlighted_style` and `a_highlighted_style_that_is_no_longer_listed_is_not_highlighted` cover this. Public reference: [Character and paragraph styles](https://web.archive.org/web/20261015081534/https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html). - **Item context menus in the Character Styles and Paragraph Styles panels:** right-clicking a style row displays a context menu ({Kind} Style Options…, Duplicate {Kind} Style, Delete {Kind} Style, Redefine {Kind} Style, Clear Overrides). Right-clicking an unselected row highlights it before displaying the menu; right-clicking an item in an existing multi-selection preserves the selection. Style Options and Delete are disabled for the built-in Normal style; Redefine is enabled when active text has styling; Clear Overrides is enabled when text is selected. Duplicate creates ` copy` and highlights it; Delete removes non-Normal styles in one undo step. Tests `panels::text_styles::tests::right_click_context_menu_in_character_styles_panel`, `right_click_context_menu_in_paragraph_styles_panel`, `right_click_context_menu_normal_style_disables_options_and_delete`, and `right_click_context_menu_preserves_multiselection`. Public reference: [Character and paragraph styles](https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html). - **Names of new styles and symbols:** `charStyle.new` and `paraStyle.new` trim the white space around the name they are given, as `charStyle.rename` and `paraStyle.rename` do, and refuse a name that is then empty; Duplicate names its copy from the trimmed name. `symbol.new` and `symbol.duplicate` trim the name as Symbol Options does, and `library.use` adds a library's text style under its trimmed name. Public reference: [Character and paragraph styles](https://web.archive.org/web/20260825113735/https://helpx.adobe.com/illustrator/using/character-paragraph-styles.html). @@ -2507,6 +2507,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A subpath keeps its anchors in chunks of up to 256 anchors, and the versions of a path share the chunks they have not changed. Editing one anchor copies only the chunk that holds it, so its undo step keeps that chunk instead of a copy of every anchor; adding or deleting an anchor copies the chunk it is in and rebuilds the subpath's table of chunks. When the renderer looks for the anchors that moved, it compares only the chunks the edit copied. Moving one anchor of a selected open path of 10,000 or 200,000 anchors (`path.moveAnchor`, `path.setHandle`, `path.moveAnchors` or a nudge) keeps at most 48 KiB in the undo step and in the redo step, where it kept a copy of every anchor at 56 bytes each (counted in the engine's tests). Files are written and read as before, each subpath's anchors as one list. Opening a document keeps the layouts it makes for its type objects, up to 128 MiB, and the first frame uses them instead of laying those objects out again. It does not keep a layout with bitmap or color glyphs or a text object with a gradient. The frame uses a layout only for a text object equal to the one laid out, and only while the fonts and the hyphenation exceptions have not changed. It uses each layout once. The renderer drops the rest when a frame that used one ends, and all of them after eight frames that use none. The frames of a threaded story are laid out while the file is read, and the first frame lays them out again. The pixels are the same. On Windows at 1600 × 1200, in medians of seven interleaved rounds of a local example, counted in the main thread's CPU cycles because other builds were running: with 5,000 point type objects in view the first frame takes 409 million cycles instead of 894 million and the open 816 million instead of 665 million, so the two together take 1,225 million instead of 1,559 million; with one area type object of 500 paragraphs the first frame takes 697 million instead of 1,193 million and the open 535 million instead of 568 million. Type › Show Hidden Characters keeps the marks it places on each text object from one frame to the next. The canvas lays a text object out again when an edit changes it or its threaded story, or when the last frame that showed the marks did not draw it, and it lays out all type in view again when the fonts or the hyphenation exceptions change. With 1,000 two-line labels in view, drawing the marks takes 0.8 ms per frame in a release build instead of 19.7 ms. + Show Hidden Characters and Auto Spell Check find the document's text objects among its other objects once for each change to the document, in one list that both draw from, instead of visiting every object in every frame. An edit, Undo, Redo or a switch to another document makes a new list, and the canvas drops the list while it draws neither overlay. With a Type tool active, the in and out ports of the selected area type and type on a path, and the highlight of a selected story's other frames after Select All, use each frame's layout from the last frame instead of laying the frame out again. A frame is laid out again when its text object changes, or when the fonts or the hyphenation exceptions change. With 200 selected area type frames of about 400 characters, one of them being edited, the Type tool's overlays take 0.27 ms per frame instead of 121 ms; with a 5-frame story selected they take 0.016 ms instead of 2.0 ms (release build on Linux, medians of seven runs, measured while other builds were running). A selection with more than 100,000 points to outline shows its bounds instead of each object's outline and anchors. Paths count their anchors. Area type and type on a path count the anchors of their frame or path, and point type counts six: its box's corners and the ends of its baseline marker. Images, symbol instances, placed documents, and area type or type on a path in perspective count the four corners of their box, and gradient meshes and envelopes count their points and the ends of their mesh lines. The hover highlight leaves out an object past that count, and such an object shows its bounds as the key object. With 32,768 type objects, images, symbol instances, gradient meshes or envelopes selected, the selection's outlines and anchors add fewer than 100 vertices to the canvas's mesh (#2460). The canvas keeps the selected objects' outlines, anchors and handles from one frame to the next as one mesh. It builds an object's marks again when the object, its layer color or its selected anchors change. A pan moves the kept outlines and handles and places the anchor squares again. Each subpath and handle gets its triangles the first time it is in view. A frame with a new zoom or rotation draws the marks one shape at a time and keeps nothing, and the next frame at that view builds them. The pixels are the same, apart from two small differences: a kept outline's corner of exactly 90 degrees in a rotated view can keep its miter or cut corner after a pan, and kept vertices can move by rounding errors. On Windows at 1440 × 900, in a release build, with 2,000 selected circles of 50 anchors each in 10 fill colors, an idle frame takes 12.8 ms instead of 59.9 ms with the Selection tool and 29.8 ms instead of 192.1 ms with Direct Selection (medians of five runs). A frame during a zoom takes about what it did: 86.7 ms instead of 80.0 ms with the Selection tool. diff --git a/docs/type-parity.md b/docs/type-parity.md index 111ee5d838..7f142cb60f 100644 --- a/docs/type-parity.md +++ b/docs/type-parity.md @@ -50,7 +50,7 @@ against Illustrator's public documentation; **estimated** unless noted. | Roman Hanging Punctuation | done | Paragraph panel menu › Roman Hanging Punctuation, `text.setFormat {romanHangingPunctuation}` (#2756): per paragraph, Optical Margin Alignment's punctuation and amounts without the letters; paragraph styles carry it. Evidence: `tests::roman_hanging_punctuation_hangs_punctuation_but_not_letters`, `typecmd::area_tests::roman_hanging_punctuation_is_set_per_paragraph_and_saved_only_when_on` | | Hyphenation… and Justification… options | done | Eleven Indian languages use attributed patterns and preserve syllables in both composers (#4947). Hyphenation… (`ui.hyphenation`, `text.setFormat`) sets each paragraph's Words Longer Than, After First, Before Last, Hyphen Limit, Hyphenation Zone (Single-line Composer only) and Hyphenate Capitalized Words, and paragraph styles carry them (#2310). Justification… (`ui.justification`, `text.setFormat`, #2755) sets Word Spacing, Letter Spacing and Glyph Scaling (Minimum, Desired, Maximum), Auto Leading and Single Word Justification; Desired applies to every line, justified lines and the Every-line Composer use the ranges. Vertical type isn't glyph scaled. Auto Leading also sets the Leading the Character panel shows for Auto type, the leading Alt+↑/↓ (`type.step`) steps from, per paragraph, and the lines Fill with Placeholder Text counts. Evidence: `crates/text/src/tests/justify.rs`, `dialogs::justification::tests`, `tests_prefs::auto_leading_steps_and_fills_from_the_paragraph_auto_leading`, `panels::character` test `leading_field_shows_the_paragraph_auto_leading` | | Tab stops and leaders; Tabs panel | partial | Tabs panel and stops with leaders in the model (`text.tabs.set`); a stop drags from where the press landed (#1458); leaders fill the tab's gap, repeated on a grid so they line up from line to line (#1877); Ctrl-dragging a stop (Command on macOS) moves all the stops together; in right-aligned area type the text before a line's last tab sits at its stops, from the left edge, and the text after it against the right edge, as Illustrator's own layout in a user's `.ai` sets a price list (evidence: `tests::right_aligned_area_type_sets_the_text_after_its_last_tab_against_the_edge`; centred lines are still aligned as a whole); in justified area type the text up to a line's last tab keeps its spacing and its tabs their stops, and the text after the last tab takes the line's room to the far edge, VectorCraft's own rule (evidence: `tests::justify::a_justified_line_with_a_tab_spreads_the_text_after_it_to_the_edge` and the other tab tests in `crates/text/src/tests/justify.rs`) | -| Hidden characters (Show Hidden Characters) | done | `type.hiddenCharacters`: marks spaces, tabs, nonbreaking and narrow nonbreaking spaces, the spaces of a set width, discretionary hyphens, forced line breaks, paragraph ends and the story's end, in horizontal, vertical and right-to-left type and on a path; the mark shapes are VectorCraft's own. Evidence: `canvas::tests::hidden_characters_*` | +| Hidden characters (Show Hidden Characters) | done | `type.hiddenCharacters`: marks spaces, tabs, nonbreaking and narrow nonbreaking spaces, the spaces of a set width, discretionary hyphens, forced line breaks, paragraph ends and the story's end, in horizontal, vertical and right-to-left type and on a path, and none on type in a hidden group or layer; the mark shapes are VectorCraft's own. Evidence: `canvas::tests::hidden_characters_*` | | Spell check (Check Spelling, Auto Spell Check, custom dictionary) | done | the engine (#4936): `text.spelling.check` lists the unknown words of the document's type, each run in its Language, at the bytes `text.editRange` changes, and `text.spelling.suggest` gives suggestions, both from craft-proof, each paragraph on its own (English from the first dictionary it finds: a Hunspell dictionary in the user's dictionaries folder, the SCOWL dictionary built in from craft-i18n, a system Hunspell dictionary, and last the public-domain Moby word list built into it; other languages from the dictionaries craft-proof finds for them). The custom dictionary commands are done: `text.spelling.addWord`, `removeWord` and `changeWord` (Add, and Edit Custom Dictionary's Add, Delete and Change), and `text.spelling.dictionary` lists the words, saved to `Custom Dictionary.txt` beside the preferences; Ignore All: `text.spelling.ignoreAll` skips a word in the active document while it is open. Auto Spell Check is done: Edit › Spelling › Auto Spell Check (`edit.autoSpellCheck`, off at first, saved with the view settings) draws a red wavy line under the unknown words of the visible type, leaves out type with effects, and follows edits, the custom dictionary and Ignore All. A right-click on an underlined word lists the words its dictionary suggests (each replaces it in one undo step, `text.editRange`), or No Suggestions, then Ignore All and Add to Dictionary, and a right-click on type has Spelling › Auto Spell Check, checked while it is on. Edit › Edit Custom Dictionary… lists the custom dictionary's words, with an Entry field and Add, Delete and Change, applied on Done (Cancel leaves the dictionary as it was). The modal Check Spelling dialog is done: Edit › Spelling › Check Spelling… (`Cmd+I`, `ui.checkSpelling`) opens a modal dialog displaying the unrecognized word in sentence context ("Not in Dictionary"), a list of suggestions with double-click or selection to replace ("Change to" field), and action buttons: Ignore, Ignore All, Change (one-step Undo/Redo via `text.editRange`), Change All (batched across occurrences in a single undo step), Add to Dictionary (`text.spelling.addWord`), Done and Cancel, with keyboard navigation (Tab between controls, Enter to Change or Done, Escape to close). Evidence: `crates/engine/src/tests/spelling.rs`, `crates/ui-egui/src/canvas/tests.rs` (`auto_spell_check_*`), `crates/ui-egui/src/tests/contextmenu.rs` (the right-click), `crates/ui-egui/src/dialogs/custom_dictionary.rs` (the dialog), `crates/ui-egui/src/dialogs/check_spelling.rs` (the Check Spelling dialog). | | Smart Punctuation, Change Case, Find & Replace | done | Type › Smart Punctuation… opens a dialog with the ff, fi, ffi and ff, fl, ffl ligatures, Smart Quotes, Smart Spaces, En, Em Dashes, Ellipses and Expert Fractions, Replace In and Report Results, which lists the count of each replacement; ligatures and fractions are written only where the font has a glyph for them. Evidence: `tests::menucmds::smart_punctuation_ligatures_spaces_and_fractions_are_counted`, `smart_punctuation_skips_ligatures_and_fractions_the_font_lacks`, `smart_spaces_keeps_one_space_after_a_period`, `dialogs::smart_punctuation::tests::menu_item_opens_the_dialog_and_ok_reports_the_counts` | | Alt + numeric-keypad codes while typing (Windows: `Alt+0176` → °) | partial | #5108: on Windows the character Windows posts when Alt comes up after keypad digits is typed at the caret like any other, in the typing's undo step, and the keypad digits typed with Alt run no shortcut. With NumLock off the keypad keys (Insert, End, arrows, Clear, Home, Page Up/Down without the extended-key flag) count as digits too and don't move the caret (`windows_alt_codes` unit tests; neither NumLock on nor off has been tried on a Windows machine yet). `type.insert {code}` (Windows Alt+0 code, Windows-1252 for 128–159) and `{unicode}` (hex code point) insert a character by its code (`menucmds::insert_a_character_by_its_code`). macOS and Linux have no such system convention and egui reports a keypad digit as the top-row digit, so there it does nothing; a floating panel window doesn't receive the character |