From fb476ca64dbcb0c872dcd61a43a42082dc4aef75 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 11:49:35 -0800 Subject: [PATCH 001/108] Smooth tool: smoothing over a closed path's first anchor keeps its start When a drag reached the first anchor of a closed path, the smoothed path started at the first anchor past the drag, and a drag over the whole path could start it at a corner the refit kept. Dashes and type on the path then started somewhere else. The smoothed path now starts at its point nearest where the first anchor was: at an anchor there, or at a new anchor split into the segment there, which leaves the outline as it is. Of points equally near, the one earliest along the path before smoothing, from its first anchor, is used. A drag that does not reach the first anchor leaves it first, as before. Part of #2224. --- crates/engine/src/cmd/draw2/smooth.rs | 176 +++++++++++++++++++++++++- crates/engine/src/tests/draw2.rs | 91 +++++++++++++ docs/target-app-parity.md | 1 + 3 files changed, 266 insertions(+), 2 deletions(-) diff --git a/crates/engine/src/cmd/draw2/smooth.rs b/crates/engine/src/cmd/draw2/smooth.rs index 0ac4fc8d6b..cd7d48b572 100644 --- a/crates/engine/src/cmd/draw2/smooth.rs +++ b/crates/engine/src/cmd/draw2/smooth.rs @@ -37,6 +37,87 @@ fn refit_run(anchors: &[Anchor], tol: f64, sigma: f64) -> Vec { out } +/// Distance (points) from an anchor within which a smoothed closed path starts at that anchor +/// instead of at a new one split in beside it. +const START_SNAP: f64 = 1e-3; + +/// Distance (points) within which two points of a smoothed closed path count as equally near its +/// old start. +const START_TIE: f64 = 1e-6; + +/// Where `p` lies along the closed `orig` from its first anchor: the segment index and parameter of +/// the point of `orig` nearest `p`, the first such point in its order. Sorts after every finite place +/// when there is none. +fn place_along(orig: &SubPath, p: Point) -> (usize, f64) { + let mut best: Option<(f64, usize, f64)> = None; + for j in 0..orig.anchors.len() { + let hit = orig.segment(j).nearest(p, 1e-9); + if hit.distance_sq.is_finite() && hit.t.is_finite() && best.is_none_or(|(d, ..)| hit.distance_sq < d) { + best = Some((hit.distance_sq, j, hit.t)); + } + } + best.map_or((usize::MAX, f64::INFINITY), |(_, j, t)| (j, t)) +} + +/// The closed `sp` started at the point on it nearest `start`: at the anchor there, or at a new +/// anchor split into the segment there, which leaves the outline as it is. Of points equally near +/// `start`, the one earliest along `orig` (the path before smoothing) from its first anchor is used, +/// then the first in `sp`'s order. An open `sp`, or one with no segment or no finite nearest point, +/// is returned as it is. +fn start_nearest(mut sp: SubPath, start: Point, orig: &SubPath) -> SubPath { + let n = sp.anchors.len(); + if !sp.closed || n < 2 { + return sp; + } + // (distance, place along `orig` once a tie needs it, segment of `sp`, parameter) + type Best = (f64, Option<(usize, f64)>, usize, f64); + let mut best: Option = None; + for i in 0..n { + let c = sp.segment(i); + let hit = c.nearest(start, 1e-9); + if !hit.distance_sq.is_finite() || !hit.t.is_finite() { + continue; + } + let d = hit.distance_sq.sqrt(); + match &mut best { + None => best = Some((d, None, i, hit.t)), + Some((bd, bplace, bi, bt)) if (d - *bd).abs() <= START_TIE => { + let held = *bplace.get_or_insert_with(|| place_along(orig, sp.segment(*bi).eval(*bt))); + let place = place_along(orig, c.eval(hit.t)); + if place.0 < held.0 || (place.0 == held.0 && place.1 < held.1) { + best = Some((d, Some(place), i, hit.t)); + } + } + Some((bd, ..)) if d < *bd => best = Some((d, None, i, hit.t)), + Some(_) => {} + } + } + let Some((_, _, i, t)) = best else { return sp }; + let c = sp.segment(i); + let at = c.eval(t); + let first = if at.distance(c.p0) <= START_SNAP { + i + } else if at.distance(c.p3) <= START_SNAP { + (i + 1) % n + } else { + let mid = if sp.segment_is_line(i) { + Anchor::corner(at) + } else { + let (l, r) = (c.subsegment(0.0..t), c.subsegment(t..1.0)); + sp.anchors[i].h_out = l.p1; + sp.anchors[(i + 1) % n].h_in = r.p2; + Anchor::with_handles(at, l.p2, r.p1) + }; + sp.anchors.insert(i + 1, mid); + i + 1 + }; + sp.anchors.rotate_left(first); + sp +} + +/// `sp` with the anchors in the drag's reach (`near`) smoothed and refitted, `None` when none are +/// in reach. A closed path whose first anchor is in reach starts at the point of the refitted path +/// nearest that anchor's place (VectorCraft's own rule). fn smooth_subpath(sp: &SubPath, near: &dyn Fn(Point) -> bool, tol: f64, sigma: f64) -> Option { let n = sp.anchors.len(); let marked: Vec = sp.anchors.iter().map(|a| near(a.p)).collect(); @@ -44,10 +125,11 @@ fn smooth_subpath(sp: &SubPath, near: &dyn Fn(Point) -> bool, tol: f64, sigma: f return None; } if sp.closed { + let start = sp.anchors[0].p; let Some(k) = marked.iter().position(|m| !m) else { // Everything is in range: smooth the whole closed path, across its start too. let f = po::simplify_with(&PathData::single(sp.clone()), &refit_options(tol, sigma)); - return f.subpaths.into_iter().next(); + return f.subpaths.into_iter().next().map(|r| start_nearest(r, start, sp)); }; // Rotate so an untouched anchor comes first, duplicate it at the end and treat as open. let mut open = sp.clone(); @@ -62,7 +144,9 @@ fn smooth_subpath(sp: &SubPath, near: &dyn Fn(Point) -> bool, tol: f64, sigma: f if let Some(r0) = res.first_mut() { r0.h_in = l.h_in; } - return Some(SubPath::new(res, true)); + // With k = 0 the first anchor is out of reach and still starts the result. + let res = SubPath::new(res, true); + return Some(if k == 0 { res } else { start_nearest(res, start, sp) }); } Some(SubPath::new(smooth_open(&sp.anchors, &marked, near, tol, sigma), false)) } @@ -414,3 +498,91 @@ pub(super) fn join_scrub(s: &mut Session, p: &Value) -> Result { })?; Ok(json!({ "id": ida.0 })) } + +#[cfg(test)] +mod tests { + use super::*; + + /// A closed ring of four smooth anchors round (100, 100) with radius 50. + fn ring() -> SubPath { + let k = 0.5523 * 50.0; + let a = |x: f64, y: f64, dx: f64, dy: f64| Anchor::with_handles(Point::new(x, y), Point::new(x - dx, y - dy), Point::new(x + dx, y + dy)); + SubPath::new(vec![a(150.0, 100.0, 0.0, k), a(100.0, 150.0, -k, 0.0), a(50.0, 100.0, 0.0, -k), a(100.0, 50.0, k, 0.0)], true) + } + + /// A start between two anchors of a curve splits that curve there into two that trace it, and the + /// new anchor comes first. + #[test] + fn start_nearest_splits_a_curve_where_it_passes_the_start() { + let sp = ring(); + let old = sp.segment(0); + let start = old.eval(0.3) + (old.eval(0.3) - Point::new(100.0, 100.0)) * 0.1; + let out = start_nearest(sp.clone(), start, &sp); + assert!(out.closed && out.anchors.len() == 5, "{out:?}"); + let t = old.nearest(start, 1e-9).t; + assert!(out.anchors[0].p.distance(old.eval(t)) < 1e-9, "{out:?}"); + let (head, rest) = (out.segment(4), out.segment(0)); + for k in 0..=8 { + let u = f64::from(k) / 8.0; + assert!(head.eval(u).distance(old.eval(t * u)) < 1e-9); + assert!(rest.eval(u).distance(old.eval(t + (1.0 - t) * u)) < 1e-9); + } + for i in 1..4 { + assert_eq!(out.segment(i), sp.segment(i), "segment {i} stays"); + } + } + + /// A start within [`START_SNAP`] of an anchor starts the ring at that anchor, with no anchor added. + #[test] + fn start_nearest_starts_at_an_anchor_near_the_start() { + let sp = ring(); + let out = start_nearest(sp.clone(), Point::new(50.0, 100.0 + START_SNAP / 2.0), &sp); + let mut want = sp.anchors.clone(); + want.rotate_left(2); + assert_eq!(out.anchors, want); + } + + /// A start on a straight side of a triangle adds a corner point there without handles, and the + /// sides stay straight. + #[test] + fn start_nearest_splits_a_line_with_a_corner_point() { + let sp = SubPath::polyline(&[Point::new(0.0, 0.0), Point::new(100.0, 0.0), Point::new(50.0, 80.0)], true); + let out = start_nearest(sp.clone(), Point::new(40.0, -5.0), &sp); + let want: Vec = [(40.0, 0.0), (100.0, 0.0), (50.0, 80.0), (0.0, 0.0)].map(|(x, y)| Point::new(x, y)).to_vec(); + assert!(out.anchors.len() == 4 && out.anchors.iter().zip(&want).all(|(a, w)| a.p.distance(*w) < 1e-9), "{out:?}"); + assert!((0..4).all(|i| out.segment_is_line(i)), "{out:?}"); + } + + /// A ring whose last anchor lies on its first keeps its first anchor first, and gets no third + /// anchor at that place. + #[test] + fn start_nearest_keeps_the_first_of_two_anchors_on_one_place() { + let p = [(0.0, 0.0), (100.0, 0.0), (50.0, 80.0), (0.0, 0.0)].map(|(x, y)| Point::new(x, y)); + let sp = SubPath::polyline(&p, true); + assert_eq!(start_nearest(sp.clone(), p[0], &sp), sp); + } + + /// Of points equally near the start, the one earliest along the path before smoothing from its + /// first anchor comes first, whatever the smoothed path's order. The center of a square is equally + /// near the middle of each side. The square before smoothing starts at (-50, -50), so the middle + /// of its first side, (0, -50), comes first, though the smoothed copy starts at (50, 50). + #[test] + fn start_nearest_breaks_a_tie_by_the_order_before_smoothing() { + let p = [(-50.0, -50.0), (50.0, -50.0), (50.0, 50.0), (-50.0, 50.0)].map(|(x, y)| Point::new(x, y)); + let orig = SubPath::polyline(&p, true); + let mut sp = orig.clone(); + sp.anchors.rotate_left(2); + let out = start_nearest(sp, Point::new(0.0, 0.0), &orig); + assert!(out.closed && out.anchors.len() == 5, "{out:?}"); + assert!(out.anchors[0].p.distance(Point::new(0.0, -50.0)) < 1e-9, "{out:?}"); + assert!(out.anchors[1].p.distance(p[1]) < 1e-9, "{out:?}"); + } + + /// An open path, and a start that is not a number, leave the path as it is. + #[test] + fn start_nearest_leaves_an_open_path_or_a_start_without_a_place() { + let open = SubPath { closed: false, ..ring() }; + assert_eq!(start_nearest(open.clone(), Point::new(100.0, 50.0), &ring()), open); + assert_eq!(start_nearest(ring(), Point::new(f64::NAN, 0.0), &ring()), ring()); + } +} diff --git a/crates/engine/src/tests/draw2.rs b/crates/engine/src/tests/draw2.rs index f29df7ff23..0a8efea9a5 100644 --- a/crates/engine/src/tests/draw2.rs +++ b/crates/engine/src/tests/draw2.rs @@ -1606,6 +1606,97 @@ fn smoothing_a_whole_closed_path_smooths_a_bump_at_its_start() { assert!(start <= far + 0.5, "the bump at the start stays {start} pt high, the far one {far} pt"); } +/// Checks that the closed path `p` starts at its point nearest `old`, within `reach` of it: its first +/// anchor is no farther from `old` than any other point along the path, and its outline starts there. +fn assert_starts_nearest(p: &PathData, old: Point, reach: f64) { + let sp = &p.subpaths[0]; + assert!(sp.closed, "the path stays closed"); + let first = sp.anchors[0].p; + let nearest = smooth_test_samples(p).iter().map(|q| q.distance(old)).fold(f64::INFINITY, f64::min); + let d = first.distance(old); + assert!(d <= nearest + 1e-6 && d <= reach, "the path starts {d} pt from its old start, its nearest point is {nearest} pt away: {sp:?}"); + let mut bp = kurbo::BezPath::new(); + sp.to_bezpath_into(&mut bp); + assert_eq!(bp.elements().first(), Some(&kurbo::PathEl::MoveTo(first))); +} + +/// A drag over a closed path's first anchor and the anchors either side of it smooths the bump there, +/// and the path starts at the point of the smoothed path nearest the old first anchor. The anchors out +/// of reach keep their places, and undo brings the path back. +#[test] +fn smoothing_over_a_closed_paths_first_anchor_keeps_its_start() { + let mut s = session(); + let (c, r) = (Point::new(300.0, 300.0), 100.0); + let at = |deg: f64, rr: f64| c + rr * kurbo::Vec2::from_angle(deg.to_radians()); + let anchors: Vec<_> = (0..12) + .map(|i| { + let q = at(30.0 * f64::from(i), if i == 0 { r + 8.0 } else { r }); + json!({"x": q.x, "y": q.y}) + }) + .collect(); + let id = smooth_test_path(&mut s, &anchors, true); + let before = path(&s, id); + let old = before.subpaths[0].anchors[0].p; + // Along the circle from -40° to 40°, over anchors 11, 0 and 1. + let drag: Vec = (-20..=20).map(|k| at(2.0 * f64::from(k), r)).collect(); + smooth_pass(&mut s, &drag); + let after = path(&s, id); + assert_ne!(after, before, "the bump is smoothed"); + assert_starts_nearest(&after, old, 12.0); + let kept = &after.subpaths[0].anchors; + for a in &before.subpaths[0].anchors[2..=10] { + assert!(kept.iter().any(|k| k.p == a.p), "{:?} is out of reach and stays: {kept:?}", a.p); + } + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(path(&s, id), before); +} + +/// A drag over the whole of a closed path with a spike that turns back on itself, which the refit +/// keeps as a corner, leaves the path starting at its point nearest the old first anchor. +#[test] +fn smoothing_a_whole_closed_path_with_a_spike_keeps_its_start() { + let mut s = session(); + let mut seed = 5u64; + let (c, r) = (Point::new(300.0, 300.0), 80.0); + let at = |a: f64, rr: f64| c + rr * kurbo::Vec2::from_angle(a); + use std::f64::consts::{PI, TAU}; + let mut pts: Vec = (0..64).map(|i| at(f64::from(i) / 64.0 * TAU, r + 2.5 * smooth_noise(&mut seed))).collect(); + // Out from the anchor at 180° to a tip 40 pt beyond the circle and back. + pts.splice(33..33, [at(PI, r + 40.0), at(PI + 0.002, r)]); + let anchors: Vec<_> = pts.iter().map(|q| json!({"x": q.x, "y": q.y})).collect(); + let id = smooth_test_path(&mut s, &anchors, true); + let before = path(&s, id); + let mut drag: Vec = (0..=128).map(|i| at(f64::from(i) / 128.0 * TAU, r)).collect(); + drag.splice(65..65, (0..=16).chain((0..=16).rev()).map(|k| at(PI, r + 2.5 * f64::from(k)))); + smooth_pass(&mut s, &drag); + let after = path(&s, id); + assert_ne!(after, before, "the path is smoothed"); + assert_starts_nearest(&after, pts[0], 12.0); +} + +/// A drag that reaches a closed path but not its first anchor leaves that anchor first, where it was. +#[test] +fn smoothing_a_closed_path_away_from_its_first_anchor_keeps_it_first() { + let mut s = session(); + let (c, r) = (Point::new(300.0, 300.0), 100.0); + let at = |deg: f64, rr: f64| c + rr * kurbo::Vec2::from_angle(deg.to_radians()); + let anchors: Vec<_> = (0..12) + .map(|i| { + let q = at(30.0 * f64::from(i), if i == 6 { r + 8.0 } else { r }); + json!({"x": q.x, "y": q.y}) + }) + .collect(); + let id = smooth_test_path(&mut s, &anchors, true); + let before = path(&s, id); + // Along the circle from 140° to 220°, over anchors 5, 6 and 7. + let drag: Vec = (70..=110).map(|k| at(2.0 * f64::from(k), r)).collect(); + smooth_pass(&mut s, &drag); + let after = path(&s, id); + assert_ne!(after, before, "the bump is smoothed"); + assert!(after.subpaths[0].closed); + assert_eq!(after.subpaths[0].anchors[0], before.subpaths[0].anchors[0]); +} + #[test] fn join_tool_joins_two_lines() { let mut s = session(); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index e309f72409..dc1d322ff8 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1118,6 +1118,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur The Pencil's and the Paintbrush's Fidelity is in screen pixels, the same at any zoom: their Tool Options give it in px, from 0.01 px on the logarithmic slider to 20 px and up to 100 px in the field, and the tool sends `path.freehand` the value in points at the current zoom (#5729). The Smooth tool's and the Blob Brush's Fidelity stays in points. `path.freehand` and `brush.freehand` take a Fidelity of up to 100 / 0.0313 pt (about 3194.89 pt), the 100 px field maximum at the lowest zoom (3.13 %), and reject a value outside their range with an error, so a Pencil or Paintbrush stroke drawn zoomed out keeps the Fidelity set in pixels (engine tests `pencil_fit_keeps_its_anchors_on_a_stroke_drawn_zoomed_out` and `pencil_takes_fidelity_within_its_range_and_rejects_the_rest`). Each drag of the Smooth tool smooths the stretch of a selected path in its reach along its length before refitting it within Fidelity, so a wobble wider than Fidelity is smoothed out and another drag over the same place smooths it further, as [the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/smooth-tool.html) describes (`path.smoothRegion`). The smoothing spread (a third of the reach) and the rule that each refit stays within twice the distance the smoothing moved the path, so repeated drags do not drift from it, are VectorCraft's own. A drag over the whole of a closed path smooths it across its first anchor too, so a bump there is smoothed like any other and no corner is left; Object › Path › Smooth smooths a closed path across its first anchor the same way. + When a Smooth tool drag reaches the first anchor of a closed path, the smoothed path starts at its point nearest where that anchor was: at an anchor there, or at a new anchor split into the curve without changing its outline. Dashes and type on the path start from that point. A drag that does not reach the first anchor leaves it first. This is VectorCraft's own rule (engine tests `smoothing_over_a_closed_paths_first_anchor_keeps_its_start` and `smoothing_a_whole_closed_path_with_a_spike_keeps_its_start`). Before a press that draws a new path, the Pencil cursor shows a small star, as [Draw freeform paths with the Pencil tool](https://web.archive.org/web/20260926095638/https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/draw-shapes/draw-freeform-paths-with-the-pencil-tool.html) describes; over a selected path within Edit selected paths' distance, which the press continues from an end or redraws, the star is not shown ([Reshape paths with the Pencil tool](https://web.archive.org/web/20260106004407/https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/draw-shapes/reshape-paths-with-the-pencil-tool.html)). Keep selected in the Pencil and Paintbrush Tool Options is on by default: while it is on, a stroke selects the path it draws or continues and replaces the earlier selection. While it is off, a new stroke leaves nothing selected, the earlier selection included, as the reference application starts the stroke by dropping it (#5752); a continued or redrawn path is deselected while the rest of the selection stays (`path.freehand` `keepSelected`). With two open paths selected, a Pencil stroke from an end of one that ends within Edit selected paths' distance of an end of the other connects them into one path with the first path's appearance, in one undo step, as [Connect two paths with the Pencil tool](https://helpx.adobe.com/illustrator/desktop/draw-shapes-and-paths/draw-shapes/connect-two-paths-with-the-pencil-tool.html) describes (`path.freehand` `connect`). From 1a77932167c838ebb992bbccd5f60a25ccfcd040 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 12:11:12 -0800 Subject: [PATCH 002/108] .ai export: the pieces of a warped image write only the pixels they show The pieces of a Warp effect, an envelope or their expanded art each held a copy of the whole image in the .ai editing data and in legacy .ai files: 200 copies for a Warp's 10 x 10 mesh. - An embedded image cut to a clipping path (in the editing data, also an image under an opacity mask that clips) is written whole the first time; later copies of the same pixels are written as the rectangle the path or mask shows, 2 pixels more on each side, with the matrix moved to keep their place. A copy that the path shows none of is written as one pixel. - An opacity mask's window covers everything the mask's art paints, its effects and symbol art included. - An image's editable original and an image in an opacity mask's art are written whole. A live Warp's drawn look is not cut to the clipping groups around the object, so a clipped image with a live Warp reads back with its Warp live. - When art that held an image's whole copy is left out (an opacity mask's art, a live envelope or a definition past the object limit), the next copy is written whole again. A whole copy written on hidden lines after an earlier one leaves the earlier one as the copy that counts. - The writers read an image's pixels once for the pieces that follow one another. Docs: docs/target-app-parity.md. --- crates/eps/src/ai_editing/tests.rs | 270 ++++++++++++++++++++ crates/eps/src/ai_editing/writer.rs | 44 +++- crates/eps/src/ai_editing/writer/brushes.rs | 4 +- crates/eps/src/ai_editing/writer/images.rs | 73 +++++- crates/eps/src/ai_editing/writer/paints.rs | 4 +- crates/eps/src/ai_editing/writer/styles.rs | 4 + crates/eps/src/ai_editing/writer/symbols.rs | 4 +- crates/eps/src/ai_ops.rs | 51 +++- crates/eps/src/legacy_ai/tests.rs | 41 +++ crates/eps/src/legacy_ai/writer.rs | 61 ++++- docs/target-app-parity.md | 1 + 11 files changed, 531 insertions(+), 26 deletions(-) diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 1321188f12..98e4194931 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -7228,6 +7228,276 @@ fn an_image_on_hidden_lines_does_not_come_in_beside_its_look() { assert_eq!(art[0].name.as_deref(), Some("Photo")); } +/// A 64 × 64 RGB image, every pixel of it different, 128 pt square at (20, 10) in `doc`. +fn speckled_photo(doc: &mut Document) -> Node { + let px = image::RgbImage::from_fn(64, 64, |x, y| image::Rgb([(x * 4) as u8, (y * 4) as u8, ((x * 7 + y * 13) % 256) as u8])); + image_node(doc, ImageBlob::png(png_of(px.into())), (64, 64), Affine::new([2.0, 0.0, 0.0, 2.0, 20.0, 10.0]), None) +} + +/// The sizes `%%BeginData:` gives the images' samples in the program written from `doc`. +fn sample_sizes(doc: &Document) -> Vec { + let program = export_ai_editing(doc, &opts()).unwrap().program; + String::from_utf8_lossy(&program).lines().filter_map(|l| l.strip_prefix("%%BeginData: ")?.trim().parse().ok()).collect() +} + +/// The samples of a 64 × 64 RGB image, as `%%BeginData:` counts them (`XI` and CR LF too). +const SPECKLED_WHOLE: usize = 64 * 64 * 3 + 4; + +/// The pieces of an image cut into a raster mesh warp (as Object › Expand leaves a Warp or an +/// envelope on an image) are written as the image whole once, then each as the part of it that its +/// triangle shows: the file holds a little more than the image's pixels rather than a copy for every +/// piece, and it reads back drawing as it did. +#[test] +fn the_pieces_of_a_warped_image_are_written_as_the_parts_they_show() { + // GUARDS: each of a warped image's 200 pieces was written with all of the image's samples. + let doc = photo_doc(|d| { + let photo = speckled_photo(d); + let NodeKind::Image(im) = &photo.kind else { panic!("not an image") }; + let bend = |p: vectorcraft_geom::Point| vectorcraft_geom::Point::new(p.x, p.y + 12.0 * ((p.x - 20.0) / 128.0 * std::f64::consts::PI).sin()); + vectorcraft_doc::live::mesh_warp_image(&photo, im, &bend, 10, false, false) + }); + let sizes = sample_sizes(&doc); + assert_eq!(sizes.len(), 200, "{sizes:?}"); + assert_eq!(sizes[0], SPECKLED_WHOLE, "the first piece holds the whole image"); + // Each piece holds its cell (two triangles share one) and 2 pixels more around it. + let total: usize = sizes.iter().sum(); + assert!(total < 10 * SPECKLED_WHOLE, "{total} bytes of samples for an image of {SPECKLED_WHOLE}"); + let back = read_back(&doc); + let st = vectorcraft_testkit::raster::perceptual_diff( + &vectorcraft_testkit::raster::render_artboard(&doc), + &vectorcraft_testkit::raster::render_artboard(&back), + 8.0, + ); + assert!((st.bad_pixels as f64) < 0.005 * st.pixels as f64, "{} of {} pixels differ", st.bad_pixels, st.pixels); +} + +/// The pieces of a warped image that Preserve Shape Using Transparency cuts with opacity masks that +/// clip are written as the parts their masks show, and the file reads back drawing as it did. +#[test] +fn masked_pieces_of_a_warped_image_are_written_as_the_parts_they_show() { + // GUARDS: each masked piece of a warped image was written with all of the image's samples. + let doc = photo_doc(|d| { + let photo = speckled_photo(d); + let NodeKind::Image(im) = &photo.kind else { panic!("not an image") }; + let bend = |p: vectorcraft_geom::Point| vectorcraft_geom::Point::new(p.x, p.y + 12.0 * ((p.x - 20.0) / 128.0 * std::f64::consts::PI).sin()); + vectorcraft_doc::live::mesh_warp_image(&photo, im, &bend, 4, false, true) + }); + let sizes = sample_sizes(&doc); + assert_eq!(sizes.len(), 32, "{sizes:?}"); + assert_eq!(sizes[0], SPECKLED_WHOLE, "the first piece holds the whole image"); + let total: usize = sizes.iter().sum(); + assert!(total < 6 * SPECKLED_WHOLE, "{total} bytes of samples for an image of {SPECKLED_WHOLE}"); + let back = read_back(&doc); + let st = vectorcraft_testkit::raster::perceptual_diff( + &vectorcraft_testkit::raster::render_artboard(&doc), + &vectorcraft_testkit::raster::render_artboard(&back), + 8.0, + ); + assert!((st.bad_pixels as f64) < 0.005 * st.pixels as f64, "{} of {} pixels differ", st.bad_pixels, st.pixels); +} + +/// An image with a live Warp keeps its pixels whole once, and its drawn look's pieces are each the +/// part of them they show: it reads back as the image with its Warp live. +#[test] +fn an_image_with_a_live_warp_writes_its_pixels_whole_once() { + // GUARDS: a live Warp's drawn look wrote all of the image's samples for each of its pieces. + let doc = photo_doc(|d| { + let mut photo = speckled_photo(d); + photo.appearance = Appearance { effects: vec![fx("warp.arc", serde_json::json!({"bend": 40.0}))], ..Appearance::default() }.into(); + photo + }); + let sizes = sample_sizes(&doc); + assert!(sizes.len() > 100, "{sizes:?}"); + assert_eq!(sizes.iter().filter(|s| **s == SPECKLED_WHOLE).count(), 1, "{sizes:?}"); + let total: usize = sizes.iter().sum(); + assert!(total < 10 * SPECKLED_WHOLE, "{total} bytes of samples for an image of {SPECKLED_WHOLE}"); + let back = read_back(&doc); + let art = back.layers[0].children().unwrap(); + assert_eq!(art.len(), 1, "{:#?}", lines(&back)); + assert!(matches!(art[0].kind, NodeKind::Image(_)), "{:?}", art[0].kind); + assert_eq!(art[0].appearance.effects.len(), 1, "{:?}", art[0].appearance); +} + +/// An image cut to a clipping path is written with all of its pixels when it is the first of them +/// written, so releasing the clipping path shows the whole image; a second copy cut to a small part +/// is written as that part, 2 pixels more on each side. +#[test] +fn a_clipped_image_written_first_keeps_all_of_its_pixels() { + let window = |d: &mut Document| { + let photo = speckled_photo(d); + let corner = clipping(d, shapes::rectangle(Rect::new(30.0, 20.0, 50.0, 40.0))); + group(d, vec![corner, photo], true) + }; + let doc = photo_doc(|d| { + let (a, b) = (window(d), window(d)); + group(d, vec![a, b], false) + }); + let sizes = sample_sizes(&doc); + assert_eq!(sizes.len(), 2, "{sizes:?}"); + assert_eq!(sizes[0], SPECKLED_WHOLE); + // The path shows 10 × 10 pixels. + assert_eq!(sizes[1], 14 * 14 * 3 + 4, "{sizes:?}"); + let back = read_back(&doc); + let st = vectorcraft_testkit::raster::perceptual_diff( + &vectorcraft_testkit::raster::render_artboard(&doc), + &vectorcraft_testkit::raster::render_artboard(&back), + 8.0, + ); + assert!((st.bad_pixels as f64) < 0.002 * st.pixels as f64, "{} of {} pixels differ", st.bad_pixels, st.pixels); +} + +/// The images in `n` and its members, each as its count of effects, its width and its height. +fn images_in(n: &Node, out: &mut Vec<(usize, u32, u32)>) { + if let NodeKind::Image(im) = &n.kind { + out.push((n.appearance.effects.len(), im.width, im.height)); + } + for c in n.children().into_iter().flatten() { + images_in(c, out); + } +} + +/// A copy of an image written whole already that its clipping path shows none of is written as one +/// pixel of it. +#[test] +fn a_copy_of_an_image_that_does_not_show_is_one_pixel() { + // GUARDS: a copy whose clipping path missed the image was written with all of its pixels. + let doc = photo_doc(|d| { + let photo = speckled_photo(d); + let corner = clipping(d, shapes::rectangle(Rect::new(30.0, 20.0, 50.0, 40.0))); + let first = group(d, vec![corner, photo], true); + let photo = speckled_photo(d); + let away = clipping(d, shapes::rectangle(Rect::new(0.0, 0.0, 10.0, 5.0))); + let second = group(d, vec![away, photo], true); + group(d, vec![first, second], false) + }); + assert_eq!(sample_sizes(&doc), [SPECKLED_WHOLE, 3 + 4]); +} + +/// A 200 × 100 document of: the speckled image when `first`; a square whose opacity mask's art is +/// the image then six squares; the image in a small clipping group. +fn mask_art_then_clipped_photo(first: bool) -> Document { + let mut doc = Document::new(200.0, 100.0); + let layer = doc.layers[0].id; + if first { + let photo = speckled_photo(&mut doc); + doc.insert(Some(layer), usize::MAX, photo).unwrap(); + } + let mut masked = square(&mut doc, Rect::new(10.0, 10.0, 50.0, 50.0), Color::gray(0.5)); + // The image, then more objects than the clipping group after the mask holds. + let mut members = vec![speckled_photo(&mut doc)]; + for i in 0..6 { + let x = f64::from(i) * 10.0; + members.push(square(&mut doc, Rect::new(x, 0.0, x + 5.0, 5.0), Color::rgb(1.0, 1.0, 1.0))); + } + let art = group(&mut doc, members, false); + masked.extras_mut().mask = Some(Box::new(OpacityMask::new(art, false))); + doc.insert(Some(layer), usize::MAX, masked).unwrap(); + let photo = speckled_photo(&mut doc); + let corner = clipping(&mut doc, shapes::rectangle(Rect::new(30.0, 20.0, 50.0, 40.0))); + let clipped = group(&mut doc, vec![corner, photo], true); + doc.insert(Some(layer), usize::MAX, clipped).unwrap(); + doc +} + +/// For each object limit from none to all of `doc`'s objects: whether the mask is written, and the +/// sizes `%%BeginData:` gives the images' samples on `%_` lines (the mask's art) and on the others. +fn samples_within_each_limit(doc: &Document) -> Vec<(usize, bool, Vec, Vec)> { + let read = crate::import::objects_read(&export_ai_editing(doc, &opts()).unwrap().program).unwrap(); + (0..=read) + .map(|max| { + let text = String::from_utf8_lossy(&export_within(doc, &opts(), max).unwrap().program).replace("\r\n", "\n"); + let size = |l: &str| l.strip_prefix("%%BeginData: ")?.trim().parse::().ok(); + let hidden = text.lines().filter_map(|l| size(l.strip_prefix("%_")?)).collect(); + let shown = text.lines().filter_map(size).collect(); + (max, text.contains("(AI9_Mask)"), hidden, shown) + }) + .collect() +} + +/// An image whose whole copy was in art left out for the object limit (here an opacity mask's art) +/// is written whole again where it is next written, even cut to a small clipping path: the file +/// always holds all of its pixels once. +#[test] +fn an_image_whose_whole_copy_is_left_out_is_written_whole_again() { + // GUARDS: once the mask's art was left out, the clipped copy was written as the part it shows. + let mut left_out_with_copy = 0; + for (max, mask, hidden, shown) in samples_within_each_limit(&mask_art_then_clipped_photo(false)) { + if hidden.is_empty() && shown.is_empty() { + continue; + } + assert!(hidden.contains(&SPECKLED_WHOLE) || shown.contains(&SPECKLED_WHOLE), "room for {max}: {hidden:?} {shown:?}"); + left_out_with_copy += usize::from(!mask); + } + assert!(left_out_with_copy > 0, "no room left the mask out and kept the clipped copy"); +} + +/// An image written whole, then whole again in an opacity mask's art left out for the object limit, +/// is not written whole a third time: the first copy is kept, and the clipped copy after the mask is +/// the part it shows. +#[test] +fn an_image_written_whole_before_art_left_out_stays_written_whole() { + // GUARDS: the mask's copy took the first copy's place, so giving it back wrote the clipped copy whole. + let mut left_out = 0; + for (max, mask, _, shown) in samples_within_each_limit(&mask_art_then_clipped_photo(true)) { + assert!(shown.iter().filter(|s| **s == SPECKLED_WHOLE).count() <= 1, "room for {max}: {shown:?}"); + left_out += usize::from(!mask && shown.len() == 2); + } + assert!(left_out > 0, "no room left the mask out and kept both copies"); +} + +/// An image with a live Warp in a small clipping group keeps all of its pixels: its drawn look is +/// written first, and neither the look nor the image itself is cut to the clipping path, so it +/// reads back with its Warp live and every pixel it had. +#[test] +fn a_clipped_image_with_a_live_warp_keeps_all_of_its_pixels() { + // GUARDS: the image under a live Warp was cut to the clipping path around it. + let doc = photo_doc(|d| { + let mut photo = speckled_photo(d); + photo.appearance = Appearance { effects: vec![fx("warp.arc", serde_json::json!({"bend": 40.0}))], ..Appearance::default() }.into(); + let corner = clipping(d, shapes::rectangle(Rect::new(30.0, 20.0, 60.0, 50.0))); + group(d, vec![corner, photo], true) + }); + let sizes = sample_sizes(&doc); + assert_eq!(sizes.iter().filter(|s| **s == SPECKLED_WHOLE).count(), 1, "the look's first piece: {sizes:?}"); + let total: usize = sizes.iter().sum(); + assert!(total < 10 * SPECKLED_WHOLE, "{total} bytes of samples for an image of {SPECKLED_WHOLE}"); + // The image itself, on `%_` lines. + let program = export_ai_editing(&doc, &opts()).unwrap().program; + let hidden: Vec = + String::from_utf8_lossy(&program).lines().filter_map(|l| l.strip_prefix("%_%%BeginData: ")?.trim().parse().ok()).collect(); + assert_eq!(hidden, [SPECKLED_WHOLE]); + let back = read_back(&doc); + let mut images = vec![]; + for n in back.layers[0].children().unwrap() { + images_in(n, &mut images); + } + assert_eq!(images, [(1, 64, 64)], "{:#?}", lines(&back)); +} + +/// An image cut by an opacity mask whose art has an effect that paints past its path keeps the +/// pixels the effect shows: a copy of an image written whole already is cut to all that its mask +/// paints. +#[test] +fn a_masked_image_keeps_the_pixels_its_mask_effects_show() { + // GUARDS: the copy was cut to the mask art's path, short of what its Offset Path paints. + let doc = photo_doc(|d| { + let photo = speckled_photo(d); + let corner = clipping(d, shapes::rectangle(Rect::new(20.0, 10.0, 24.0, 14.0))); + let first = group(d, vec![corner, photo], true); + let mut masked = speckled_photo(d); + let mut ap = Appearance::basic(solid(Color::WHITE), Paint::None, 0.0); + ap.effects = vec![fx("path.offsetPath", serde_json::json!({"offset": 30.0}))]; + let art = Node::path(d.alloc_id(), shapes::rectangle(Rect::new(70.0, 40.0, 80.0, 50.0)), ap); + masked.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(art), clip: true, invert: false, disabled: false, linked: true })); + group(d, vec![first, masked], false) + }); + let sizes = sample_sizes(&doc); + assert_eq!(sizes.len(), 2, "{sizes:?}"); + assert_eq!(sizes[0], SPECKLED_WHOLE); + // The offset art covers (40, 10) to (110, 80): 35 × 35 pixels of the image. + assert!(sizes[1] >= 35 * 35 * 3, "{sizes:?}"); +} + /// A linked image, an image with an opacity mask, and an image with a Warp and another effect are /// written as their drawn art, with no art style. #[test] diff --git a/crates/eps/src/ai_editing/writer.rs b/crates/eps/src/ai_editing/writer.rs index 7db5d11896..689e7ca87f 100644 --- a/crates/eps/src/ai_editing/writer.rs +++ b/crates/eps/src/ai_editing/writer.rs @@ -270,6 +270,15 @@ pub(super) struct Writer<'a> { /// How many more envelopes may be written live: as many as the reader checks in one file /// ([`crate::import::ENVELOPE_CHECKS`]). envelopes_left: usize, + /// The image read last and its pixels ([`images::Samples::of`], `None` when they can't be + /// read): the pieces of a warped image, which follow one another, read them once. + last_samples: Option<(vectorcraft_doc::ImageBlob, Option)>, + /// The images written whole so far, by the address of their data (which each entry keeps), each + /// with the index of its samples in [`Self::payloads`]. + whole_images: HashMap>, usize)>, + /// The outlines of the clipping groups the art being written is in, in the document (empty in + /// a definition, an opacity mask's art and a brush's art, which are written apart from them). + shown: Vec, } impl<'a> Writer<'a> { @@ -334,6 +343,9 @@ impl<'a> Writer<'a> { definition_objects: 0, definition_symbol_nodes: 0, max_objects: crate::import::MAX_EDITING_OBJECTS, + last_samples: None, + whole_images: HashMap::new(), + shown: vec![], } } @@ -400,15 +412,21 @@ impl<'a> Writer<'a> { /// Art written since `c` as `lines` is not used: the objects and symbol art charged since are /// given back, except those of the definitions written since, and the images `lines` marks - /// are emptied (the others keep their indices). + /// are emptied (the others keep their indices). An image whose whole copy is among them is no + /// longer written whole ([`Self::whole_images`]). fn give_back(&mut self, c: Charges, lines: &str) { self.objects = c.objects + (self.definition_objects - c.kept_objects); self.symbol_nodes = c.symbol_nodes + (self.definition_symbol_nodes - c.kept_symbol_nodes); + let mut emptied = HashSet::new(); for index in lines.split(PAYLOAD).skip(1).step_by(2) { - if let Some(p) = index.parse::().ok().and_then(|i| self.payloads.get_mut(i)) { + if let Some((i, p)) = index.parse::().ok().and_then(|i| Some((i, self.payloads.get_mut(i)?))) { *p = Vec::new(); + emptied.insert(i); } } + if !emptied.is_empty() { + self.whole_images.retain(|_, (_, i)| !emptied.contains(i)); + } } /// Whether the art of a symbol, `art`, may be written: the objects of the symbol art written @@ -654,7 +672,23 @@ impl<'a> Writer<'a> { } NodeKind::Compound { rule, .. } => self.shape(n, &compound_path(n), *rule, xy), NodeKind::Text(_) => self.text(n, xy), - NodeKind::Image(im) => self.image(&self.doc.shown_image(n, im), xy), + NodeKind::Image(im) => { + // An opacity mask that clips shows the image within what its art paints only (its + // effects and its symbol instances' art included, as the renderer measures it). + let masked = n + .extras() + .mask + .as_ref() + .filter(|m| m.clip && !m.invert && !m.disabled) + .and_then(|m| vectorcraft_render::painted_bounds(self.doc, &m.art)); + if let Some(b) = masked { + self.shown.push(b.to_path(0.1)); + } + self.image(&self.doc.shown_image(n, im), xy); + if masked.is_some() { + self.shown.pop(); + } + } NodeKind::SymbolInstance { symbol, xf } if self.live_instance_in_room(n, symbol, *xf) => self.symbol_instance(symbol, *xf, xy), NodeKind::SymbolInstance { symbol, xf } => { if !self.open_group("u") { @@ -828,6 +862,7 @@ impl<'a> Writer<'a> { fn mask(&mut self, m: &OpacityMask) -> bool { let outer = std::mem::take(&mut self.body); let (state, gs, clip) = (self.state, self.gs, self.clip.take()); + let shown_by = std::mem::take(&mut self.shown); let (charges, bound) = (self.charges(), self.bound.len()); (self.state, self.gs) = (Some((false, false)), Some(Xy::OPAQUE)); // The canvas draws the art's root even when it is hidden, and the reader puts a hidden object @@ -861,6 +896,7 @@ impl<'a> Writer<'a> { self.hidden -= 1; self.nest -= 1; let lines = std::mem::replace(&mut self.body, outer); + self.shown = shown_by; if self.left_out_since(charges) { // The art isn't written, nor are the variable bindings of its objects. self.give_back(charges, &lines); @@ -946,9 +982,11 @@ impl<'a> Writer<'a> { } } self.clip_paint_part(first, &path, rule, &fills); + self.shown.push(path.to_bezpath()); for c in rest { self.node(c); } + self.shown.pop(); self.clip_paint_part(first, &path, rule, &strokes); self.state(first.locked, !first.visible); let start = self.body.len(); diff --git a/crates/eps/src/ai_editing/writer/brushes.rs b/crates/eps/src/ai_editing/writer/brushes.rs index 2c281e702d..36730c73a6 100644 --- a/crates/eps/src/ai_editing/writer/brushes.rs +++ b/crates/eps/src/ai_editing/writer/brushes.rs @@ -373,7 +373,7 @@ impl Writer<'_> { (self.to_art, self.grad_space, self.canvas), self.state.take(), self.gs.replace(Xy::OPAQUE), - self.clip.take(), + (self.clip.take(), std::mem::take(&mut self.shown)), (self.block_start, self.block_end), // The art is the brush's own: not on `%_` lines, in a drawn look or in a symbol that // first uses the brush. @@ -410,7 +410,7 @@ impl Writer<'_> { (self.to_art, self.grad_space, self.canvas), self.state, self.gs, - self.clip, + (self.clip, self.shown), (self.block_start, self.block_end), (self.hidden, self.in_look, self.in_symbol), ) = saved; diff --git a/crates/eps/src/ai_editing/writer/images.rs b/crates/eps/src/ai_editing/writer/images.rs index 36c21c14eb..d69b1d7e09 100644 --- a/crates/eps/src/ai_editing/writer/images.rs +++ b/crates/eps/src/ai_editing/writer/images.rs @@ -2,13 +2,14 @@ //! (see [`crate::ai_editing`] for the form). use std::fmt::Write; +use std::sync::Arc; use vectorcraft_color::{Color, Paint}; use vectorcraft_doc::{FillLayer, ImageBlob, ImageObject, LinkInfo}; use vectorcraft_geom::{Affine, FillRule, PathData, Rect, Shape}; use super::{Writer, Xy}; -use crate::ps; +use crate::{ai_ops, ps}; pub(in crate::ai_editing) const IMAGES: &str = "images that can't be decoded or have more than 33,554,432 pixels are written as their outlines filled mid gray in the editing data for other apps"; pub(in crate::ai_editing) const IMAGE_DEPTH: &str = "images of 16 bits a channel are written at 8 bits a channel in the editing data for other apps"; @@ -26,8 +27,11 @@ pub(in crate::ai_editing) const PAYLOAD: char = '\u{1}'; /// What starts the line of an image's samples: `XI` and its payload, then `%%EndData`. pub(super) const SAMPLES_LINE: &str = "XI\u{1}"; +/// An image's pixels as the data holds them, and whether it had 16 bits a channel ([`Samples::of`]). +pub(super) type Read = Arc<(Samples, bool)>; + /// An image's pixels as the data holds them. -struct Samples { +pub(super) struct Samples { /// `/DeviceGray`, `/DeviceRGB` or `/DeviceCMYK`. space: &'static str, /// The image type of `XI` (§8.1): 1 gray, 3 RGB, 4 CMYK. @@ -79,6 +83,19 @@ impl Samples { Some((Samples { space, kind, width, height, color, alpha }, deep)) } + /// The pixels of `window` (`[x0, y0, x1, y1]`, within the image) alone. + fn window(&self, window: [u32; 4]) -> Samples { + let [x0, y0, x1, y1] = window; + Samples { + space: self.space, + kind: self.kind, + width: x1 - x0, + height: y1 - y0, + color: ai_ops::window_samples(&self.color, self.width, usize::from(self.kind), window), + alpha: self.alpha.as_ref().map(|a| ai_ops::window_samples(a, self.width, 1, window)), + } + } + /// `XI`'s fourth flag as the files users sent have it: 0 gray, 1 RGB, 2 CMYK, 16 more with an /// alpha channel. fn reserved(&self) -> u8 { @@ -95,10 +112,13 @@ impl Writer<'_> { /// Image object `im` of transparency `xy`: embedded, a raster ([`Self::raster`]); linked, a /// placed file with a preview ([`Self::placed_file`]), except in a part of the data written on /// `%_` lines and in a symbol's art. One whose pixels can't be read is its outline filled mid gray. Where the art is - /// cut to a clipping path, the image is in a clipping group of that path. + /// cut to a clipping path, the image is in a clipping group of that path; a raster of pixels + /// written whole already is then the part of them that the path shows ([`ai_ops::image_window`]). pub(super) fn image(&mut self, im: &ImageObject, xy: Xy) { let doc = self.doc; - let Some((samples, deep)) = doc.image_blob(im).and_then(Samples::of) else { + let blob = doc.image_blob(im); + let read = blob.and_then(|b| self.samples(b)); + let Some((samples, deep)) = read.as_deref() else { let bounds = PathData::from_bezpath(&(im.xf * Rect::new(0.0, 0.0, f64::from(im.width), f64::from(im.height)).to_path(0.1))); self.warn(IMAGES); return self.fill_object(&bounds, FillRule::NonZero, &FillLayer::new(Paint::solid(Color::gray(0.5))), xy); @@ -112,7 +132,7 @@ impl Writer<'_> { if !self.take_objects(1 + clipping) { return; } - if deep { + if *deep { self.warn(IMAGE_DEPTH); } let cut = self.clip.take(); @@ -128,13 +148,38 @@ impl Writer<'_> { Some(link) if self.hidden == 0 && !self.in_symbol => { // Cut to a region, the placed file is in a clipping group. self.placed = cut.is_none(); - self.placed_file(link, &samples, (im.width.max(1), im.height.max(1)), im.xf); + self.placed_file(link, samples, (im.width.max(1), im.height.max(1)), im.xf); } other => { if other.is_some() { self.warn(LINKS_EMBEDDED); } - self.raster(&samples, im.xf * fit); + // An image written whole already: the part its region shows, placed where it is in + // the image (the pieces of a warped image each show a small part of the same one). + // An object's editable original (on `%_` lines) and an image in an opacity mask's art + // are written whole. + let data = blob.map(|b| &b.bytes); + let written = self.hidden == 0 && data.is_some_and(|d| self.whole_images.contains_key(&(Arc::as_ptr(d) as usize))); + let window = written + .then(|| { + let clips: Vec<_> = self.shown.iter().cloned().chain(cut.iter().map(PathData::to_bezpath)).collect(); + ai_ops::image_window(&clips, im.xf * fit, (samples.width, samples.height)) + }) + .flatten(); + match window { + Some(window) => { + self.raster(&samples.window(window), im.xf * fit * Affine::translate((f64::from(window[0]), f64::from(window[1])))) + } + None => { + if let Some(d) = data { + // `raster` adds the samples as the next payload. A copy written whole on + // `%_` lines after an earlier whole copy keeps the earlier one's entry. + let next = self.payloads.len(); + self.whole_images.entry(Arc::as_ptr(d) as usize).or_insert_with(|| (d.clone(), next)); + } + self.raster(samples, im.xf * fit); + } + } } } if let Some(region) = &cut { @@ -231,6 +276,20 @@ impl Writer<'_> { ); } + /// The pixels of `blob` ([`Samples::of`]), read once for images that follow one another with + /// the same data. + fn samples(&mut self, blob: &ImageBlob) -> Option { + if let Some((last, read)) = &self.last_samples + && Arc::ptr_eq(&last.bytes, &blob.bytes) + && last.mime == blob.mime + { + return read.clone(); + } + let read = Samples::of(blob).map(Arc::new); + self.last_samples = Some((blob.clone(), read.clone())); + read + } + /// Keep `bytes` to go in the program where the mark this returns is. fn payload(&mut self, bytes: Vec) -> String { self.payloads.push(bytes); diff --git a/crates/eps/src/ai_editing/writer/paints.rs b/crates/eps/src/ai_editing/writer/paints.rs index f1b52dd91b..d0a90ce86a 100644 --- a/crates/eps/src/ai_editing/writer/paints.rs +++ b/crates/eps/src/ai_editing/writer/paints.rs @@ -481,7 +481,7 @@ impl Writer<'_> { (self.to_art, self.grad_space, self.canvas), self.state.take(), self.gs.replace(Xy::OPAQUE), - self.clip.take(), + (self.clip.take(), std::mem::take(&mut self.shown)), self.block_end, ); // `Bg` places a gradient in a pattern's tile as on the canvas, mirrored top to bottom: its @@ -505,7 +505,7 @@ impl Writer<'_> { self.hidden -= 1; self.nest -= 1; let art; - (art, (self.to_art, self.grad_space, self.canvas), self.state, self.gs, self.clip, self.block_end) = saved; + (art, (self.to_art, self.grad_space, self.canvas), self.state, self.gs, (self.clip, self.shown), self.block_end) = saved; let art = std::mem::replace(&mut self.body, art); self.defining.pop(); if self.left_out_since(before) { diff --git a/crates/eps/src/ai_editing/writer/styles.rs b/crates/eps/src/ai_editing/writer/styles.rs index fe3e68ce24..ef5072e79d 100644 --- a/crates/eps/src/ai_editing/writer/styles.rs +++ b/crates/eps/src/ai_editing/writer/styles.rs @@ -742,6 +742,9 @@ impl Writer<'_> { let xy = Xy::of(orig); let was = self.in_look; self.in_look = true; + // The reader draws the look apart from the clipping groups around the object to compare it + // with the object's effects, and keeps the object itself: neither is cut to those groups. + let shown_by = std::mem::take(&mut self.shown); self.line("u"); let mut look = n.clone(); (look.name, look.opacity, look.blend, look.isolate, look.knockout, look.knockout_shape) = @@ -785,6 +788,7 @@ impl Writer<'_> { } self.dictionary(orig); self.hidden -= 1; + self.shown = shown_by; let part = std::mem::replace(&mut self.body, saved); hide(&part, &mut self.body); self.block_end = usize::MAX; diff --git a/crates/eps/src/ai_editing/writer/symbols.rs b/crates/eps/src/ai_editing/writer/symbols.rs index 9b9724f843..84033a959f 100644 --- a/crates/eps/src/ai_editing/writer/symbols.rs +++ b/crates/eps/src/ai_editing/writer/symbols.rs @@ -243,7 +243,7 @@ impl Writer<'_> { (self.to_art, self.grad_space, self.canvas, self.instance_space), self.state.replace((false, false)), self.gs.replace(Xy::OPAQUE), - self.clip.take(), + (self.clip.take(), std::mem::take(&mut self.shown)), (self.block_start, self.block_end), (std::mem::replace(&mut self.in_symbol, true), std::mem::take(&mut self.hidden)), self.root_entries.take(), @@ -300,7 +300,7 @@ impl Writer<'_> { (self.to_art, self.grad_space, self.canvas, self.instance_space), self.state, self.gs, - self.clip, + (self.clip, self.shown), (self.block_start, self.block_end), (self.in_symbol, self.hidden), self.root_entries, diff --git a/crates/eps/src/ai_ops.rs b/crates/eps/src/ai_ops.rs index 3b2bdd88d8..6b1374cd83 100644 --- a/crates/eps/src/ai_ops.rs +++ b/crates/eps/src/ai_ops.rs @@ -7,7 +7,7 @@ use std::fmt::Write; use vectorcraft_color::{Color, Gradient}; use vectorcraft_doc::{LAYER_COLORS, LayerColor, LineCap, LineJoin, StrokeLayer}; -use vectorcraft_geom::{Affine, Anchor, AnchorKind, PathData, Point, SubPath}; +use vectorcraft_geom::{Affine, Anchor, AnchorKind, PathData, Point, Shape, SubPath}; use crate::ps; @@ -131,6 +131,55 @@ pub(crate) fn average(g: &Gradient) -> Color { Color::rgb(unit(sum[0] / n), unit(sum[1] / n), unit(sum[2] / n)) } +/// The pixels an image's part keeps past the edge of the region that shows it, on each side: as +/// many as smoothing reads from beside a pixel, and one more. +const WINDOW_MARGIN: f64 = 2.0; + +/// The part of an image of `w` × `h` pixels, which `to_doc` places in the document, that regions +/// `clips` (each in the document, the image cut to all of them) show, with [`WINDOW_MARGIN`] pixels +/// more on each side: `[x0, y0, x1, y1]`, in pixels from the top left. One pixel of the image, the +/// nearest to where the regions are, when they show none of it. `None` when that part has half the +/// image's pixels or more, or when `to_doc` can't be undone; the whole image is written then. +pub(crate) fn image_window(clips: &[kurbo::BezPath], to_doc: Affine, (w, h): (u32, u32)) -> Option<[u32; 4]> { + if clips.is_empty() || w == 0 || h == 0 || !to_doc.is_finite() || to_doc.determinant().abs() < 1e-12 { + return None; + } + let to_pixels = to_doc.inverse(); + let (mut x0, mut y0, mut x1, mut y1) = (0.0, 0.0, f64::from(w), f64::from(h)); + for clip in clips { + let b = (to_pixels * clip.clone()).bounding_box(); + if !b.is_finite() { + return None; + } + x0 = f64::max(x0, b.x0.floor() - WINDOW_MARGIN); + y0 = f64::max(y0, b.y0.floor() - WINDOW_MARGIN); + x1 = f64::min(x1, b.x1.ceil() + WINDOW_MARGIN); + y1 = f64::min(y1, b.y1.ceil() + WINDOW_MARGIN); + } + if x0 >= x1 || y0 >= y1 { + let (x, y) = ((x0 as u32).min(w - 1), (y0 as u32).min(h - 1)); + return Some([x, y, x + 1, y + 1]); + } + if 2.0 * (x1 - x0) * (y1 - y0) >= f64::from(w) * f64::from(h) { + return None; + } + Some([x0 as u32, y0 as u32, x1 as u32, y1 as u32]) +} + +/// The rows `y0..y1` and columns `x0..x1` (`window`) of `samples`, `w` pixels a row of `channels` +/// bytes each, rows from the top. +pub(crate) fn window_samples(samples: &[u8], w: u32, channels: usize, [x0, y0, x1, y1]: [u32; 4]) -> Vec { + let row = w as usize * channels; + let (from, to) = (x0 as usize * channels, x1 as usize * channels); + let mut out = Vec::with_capacity((y1 - y0) as usize * (to - from)); + for y in y0 as usize..y1 as usize { + if let Some(part) = samples.get(y * row + from..y * row + to) { + out.extend_from_slice(part); + } + } + out +} + /// The stroke's width, cap, join, miter limit and dashes: `w J j M d`. pub(crate) fn line_style(s: &mut String, st: &StrokeLayer) { let cap = match st.cap { diff --git a/crates/eps/src/legacy_ai/tests.rs b/crates/eps/src/legacy_ai/tests.rs index 6b2f8335b8..bb68c520d2 100644 --- a/crates/eps/src/legacy_ai/tests.rs +++ b/crates/eps/src/legacy_ai/tests.rs @@ -658,6 +658,47 @@ fn images_are_written_in_the_form_the_specification_shows() { assert!(rgb.iter().zip([247.0, 148.0, 29.0]).all(|(c, want)| (c * 255.0 - want).abs() < 0.1), "{rgb:?}"); } +/// The pieces of an image cut into a raster mesh warp (as Object › Expand leaves a Warp on an +/// image) are written as the image whole once, then each as the part of it that its triangle shows, +/// and the file draws as the document does ([`write`] runs it). +#[test] +fn the_pieces_of_a_warped_image_are_written_as_the_parts_they_show() { + // GUARDS: each of a warped image's 200 pieces was written with all of the image's samples. + let mut doc = Document::new(200.0, 160.0); + let mut png = vec![]; + image::RgbaImage::from_fn(64, 64, |x, y| image::Rgba([(x * 4) as u8, (y * 4) as u8, ((x * 7 + y * 13) % 256) as u8, 255])) + .write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png) + .unwrap(); + let blob = ImageBlob::new("image/png", png); + let key = blob.content_key(); + doc.images.insert(key.clone(), blob); + let im = ImageObject { + key, + width: 64, + height: 64, + xf: Affine::new([2.0, 0.0, 0.0, 2.0, 20.0, 10.0]), + link: None, + placement: Default::default(), + pixels: None, + }; + let photo = Node::new(doc.alloc_id(), NodeKind::Image(Box::new(im.clone()))); + let bend = |p: vectorcraft_geom::Point| vectorcraft_geom::Point::new(p.x, p.y + 12.0 * ((p.x - 20.0) / 128.0 * std::f64::consts::PI).sin()); + let warped = vectorcraft_doc::live::mesh_warp_image(&photo, &im, &bend, 10, false, false); + let layer = doc.layers[0].id; + doc.insert(Some(layer), usize::MAX, warped).unwrap(); + let text = String::from_utf8(write(&doc).bytes).unwrap(); + let images = rasters(&text); + assert_eq!(images.len(), 200); + let digits = |lines: &Vec<&str>| { + lines.iter().filter_map(|l| l.strip_prefix('%')).filter(|l| l.bytes().all(|b| b.is_ascii_hexdigit())).map(str::len).sum::() + }; + let whole = 64 * 64 * 3 * 2; + assert_eq!(digits(&images[0]), whole, "the first piece holds the whole image"); + // Each piece holds its cell (two triangles share one) and 2 pixels more around it. + let total: usize = images.iter().map(digits).sum(); + assert!(total < 10 * whole, "{total} digits of samples for an image of {whole}"); +} + /// An image whose data is empty is left out with the note for empty or too large images, and an /// image whose data can't be decoded is left out with the decode note. #[test] diff --git a/crates/eps/src/legacy_ai/writer.rs b/crates/eps/src/legacy_ai/writer.rs index 20f8b32b96..9ab947bdc8 100644 --- a/crates/eps/src/legacy_ai/writer.rs +++ b/crates/eps/src/legacy_ai/writer.rs @@ -45,6 +45,13 @@ pub(super) struct Writer<'a> { roman: bool, /// Inside a Kumi block `1 TY` began (Tate-chu-yoko in horizontal type). kumi: bool, + /// The outlines of the clipping groups the art being written is in, in the document. + clips: Vec, + /// The image decoded last (`None` when it can't be): the pieces of a warped image, which follow + /// one another, decode it once. + last_image: Option<(ImageBlob, Option>)>, + /// The images written whole so far, by the address of their data (which each entry keeps). + whole_images: std::collections::HashMap>>, } impl<'a> Writer<'a> { @@ -68,6 +75,9 @@ impl<'a> Writer<'a> { fonts: vec![], roman: false, kumi: false, + clips: vec![], + last_image: None, + whole_images: std::collections::HashMap::new(), } } @@ -360,12 +370,14 @@ impl<'a> Writer<'a> { if several { self.line("*U"); } + self.clips.push(outline); if let Some(fill) = &paint.fill { self.node(fill, locked); } for c in rest { self.node(c, locked); } + self.clips.pop(); self.lock(locked); self.line("Q"); if let Some(stroke) = &paint.stroke { @@ -992,7 +1004,8 @@ impl<'a> Writer<'a> { /// whose pixels are all black or white is written as an image mask (ImageMask 1, §8.1): its /// color as the fill, then 1-bit samples, a 0 bit for each black pixel, which takes the color, /// and a 1 bit for each white pixel, which is clear. Another colorized image is written with - /// its color in its pixels. + /// its color in its pixels. In a clipping group, an image whose pixels were written whole + /// already is written as the part of them the group shows ([`ai_ops::image_window`]). fn image(&mut self, blob: Option<&ImageBlob>, width: u32, height: u32, xf: Affine, colorize: Option<&Paint>) { let flip = Affine::new([1.0, 0.0, 0.0, -1.0, 0.0, 0.0]); let m = self.to_art * xf * flip; @@ -1003,7 +1016,7 @@ impl<'a> Writer<'a> { self.warn(LARGE_IMAGE); return; } - let Some(img) = blob.and_then(|b| image::load_from_memory(&b.bytes).ok()) else { + let Some((blob, img)) = blob.and_then(|b| Some((b, self.decoded(b)?))) else { self.warn(UNDECODED); return; }; @@ -1014,14 +1027,31 @@ impl<'a> Writer<'a> { } // The object places the image's own pixel grid (its width × height) wherever the file's is. let fit = Affine::scale_non_uniform(f64::from(width.max(1)) / f64::from(w), f64::from(height.max(1)) / f64::from(h)); - let m = self.to_art * xf * fit * flip; + let coverage = match colorize { + Some(paint) => { + let Some((_, _, coverage)) = ImageBlob::coverage(blob).filter(|(cw, ch, _)| (*cw, *ch) == (w, h)) else { + self.warn(UNDECODED); + return; + }; + Some((paint, coverage)) + } + None => None, + }; + // An image written whole already, cut to a clipping group: the part the group shows, placed + // where it is in the image (the pieces of a warped image each show a small part of the same one). + let key = Arc::as_ptr(&blob.bytes) as usize; + let window = if self.whole_images.contains_key(&key) { ai_ops::image_window(&self.clips, xf * fit, (w, h)) } else { None }; + if window.is_none() { + self.whole_images.insert(key, blob.bytes.clone()); + } + let window = window.unwrap_or([0, 0, w, h]); + let [x0, y0, x1, y1] = window; + let m = self.to_art * xf * fit * Affine::translate((f64::from(x0), f64::from(y0))) * flip; + let (w, h) = (x1 - x0, y1 - y0); // Over white. let over = |c: u8, a: u8| ((u32::from(c) * u32::from(a) + 255 * (255 - u32::from(a)) + 127) / 255) as u8; - if let Some(paint) = colorize { - let Some((_, _, coverage)) = blob.and_then(ImageBlob::coverage).filter(|(cw, ch, _)| (*cw, *ch) == (w, h)) else { - self.warn(UNDECODED); - return; - }; + if let Some((paint, coverage)) = coverage { + let coverage = ai_ops::window_samples(&coverage, img.width(), 1, window); if coverage.iter().all(|&v| v == 0 || v == 255) { let stride = (w as usize).div_ceil(8); let mut bits = vec![0xFF; stride.saturating_mul(h as usize)]; @@ -1041,7 +1071,7 @@ impl<'a> Writer<'a> { self.raster(m, &format!("0 0 {w} {h} {w} {h} 8 3 0 0 0 0"), &samples); return; } - let rgba = img.to_rgba8(); + let rgba = img.crop_imm(x0, y0, w, h).to_rgba8(); let mut samples = Vec::with_capacity(rgba.len() / 4 * 3); let mut see_through = false; for px in rgba.pixels() { @@ -1057,6 +1087,19 @@ impl<'a> Writer<'a> { self.raster(m, &format!("0 0 {w} {h} {w} {h} 8 3 0 0 0 0"), &samples); } + /// The pixels of `blob`, decoded once for images that follow one another with the same data. + fn decoded(&mut self, blob: &ImageBlob) -> Option> { + if let Some((last, img)) = &self.last_image + && Arc::ptr_eq(&last.bytes, &blob.bytes) + && last.mime == blob.mime + { + return img.clone(); + } + let img = image::load_from_memory(&blob.bytes).ok().map(Arc::new); + self.last_image = Some((blob.clone(), img.clone())); + img + } + /// An image's lines (§8.4): `%AI5_File:`, `%AI5_BeginRaster`, matrix `m` as `[ a b c d tx ty ]` /// and the numbers `operands` with `XI`, `samples` in hex on comment lines of [`HEX_LINE`] /// digits, `%AI5_EndRaster`, then `F`. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index e309f72409..dbf0890bba 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -616,6 +616,7 @@ since 2026-10-01. - **Warp effects bend images:** a Warp effect on an image, or on a group that holds one, bends the image's pixels with its frame, as the Warp effect is documented to distort bitmap images in [Reshaping with effects](https://helpx.adobe.com/illustrator/using/reshaping-objects-effects.html): after the last effect, the image is cut into 10 × 10 cells of two triangles, each a clipped piece under its own affine map. Effects after the Warp reshape only the frame, a second Warp bends the same pieces, and warps saved without a version bend the pixels with their earlier map, as they bend the frame. A placed gradient on a group that holds the image follows the group's bounds as the pieces draw them. SVG writes the image once for the pieces; PDF, EPS, `.ai` and PNG write the bent pieces. The images stay unbent when their pieces would make the art pass 2 million objects, and so does an image whose frame keeps its shape past the anchor budget. A grayscale image's fill color now colorizes the pieces of a warp or an envelope, and an image under any geometry effect keeps that color and its smoothing setting. Existing documents with a Warp effect on an image, or on a group that holds one, draw differently: before, the image showed unbent, cut by the bent frame. So do existing documents with a colorized image under an envelope or a geometry effect, or an image drawn without smoothing under a geometry effect: before, those lost the color or the setting. The cell count and the limits are VectorCraft's own (effects `tests::warped_images_stay_within_the_object_budget`, `tests::warped_images_keep_document_keys_and_hidden_images_apart`, `tests::an_image_whose_frame_passes_the_budget_stays_whole`, `tests::effects_after_a_warp_reshape_an_images_frame_and_not_its_pieces`, `tests::an_images_pixels_take_the_map_their_warps_version_names`, `tests::an_image_under_a_geometry_effect_keeps_its_color_and_smoothing`, `tests::a_nested_groups_gradient_follows_its_warped_image`; engine `warp_images::an_images_pixels_bend_with_effect_warp`, `a_warped_image_keeps_its_bend_in_svg`, `a_warped_image_keeps_its_bend_in_pdf`, `a_warped_image_keeps_its_bend_in_ai`, `a_warped_image_keeps_its_bend_in_eps`, `a_warped_image_keeps_its_bend_in_png`, `svg_writes_an_image_clipped_twice_in_a_users_group_twice`, `expand_appearance_of_a_warped_image_draws_as_the_canvas_did`, `a_colorized_image_keeps_its_color_when_warped`, `a_warp_on_a_group_bends_the_image_in_it`, `envelope_distort::a_colorized_image_keeps_its_color_in_an_envelope`). Scores and hours unchanged. - **`.ai` files keep an image's Warp live:** an embedded image whose appearance is one Warp effect, with no opacity mask, is saved to the `.ai` editing data with an art style of that Warp: its bent pieces are its drawn look, and the image itself follows on `%_` lines, as for other styled objects. Opening an `.ai` file reads such an image as the image with its Warp live, its pixels, placement, name and opacity kept, when the live warp draws as the file's drawn look and the import has a comparison left; otherwise the drawn look stays, with the drawn-look note. The Warp effect applies to bitmap images ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html)), and native files keep live effects ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/supported-file-formats-in-illustrator.html)). A linked image with a Warp is saved as its drawn art, as before, and its live Warp is not saved. Images with an opacity mask, and images with a Warp and another effect or with another geometry effect, are saved and opened as their drawn art. Existing `.ai` files with an embedded image on `%_` lines open differently: before, that image also came in beside its drawn look. Which images keep the Warp and the comparison are VectorCraft's own rules (eps `ai_editing::tests::an_image_with_a_warp_reads_back_with_its_warp_live`, `an_image_whose_warp_draws_otherwise_than_its_look_keeps_its_look`, `an_image_on_hidden_lines_does_not_come_in_beside_its_look`, `other_warped_images_are_written_as_their_drawn_art`, `import::ai::read::ops::tests::an_image_takes_a_style_of_one_warp_alone`). Scores and hours unchanged. - **EPS writes a repeated image's samples once:** an image drawn more than once in an EPS file (the pieces of an envelope or a Warp effect, copies of one image, or one image in a symbol's instances) has its compressed samples written once in the setup, and each placement reads them from there: a reusable stream rewound for each placement at Language Level 3 ([PostScript Language Reference, 3rd ed., §3.13](https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf)), and an array of strings of at most 49,152 bytes fed to the image by a procedure at Level 2. An image drawn once is written where it is drawn, as before. The 256 MB limit on the page counts the samples once, so an envelope of a large photo no longer loses pieces to it. A colorized image is reused per ink (eps `tests::an_image_placed_twice_writes_its_samples_once_at_both_levels`, `tests::an_envelopes_image_pieces_draw_one_copy_of_its_samples`, `tests::each_ink_of_a_colorized_image_placed_twice_is_written_once`, `tests::samples_longer_than_a_string_are_reused_at_both_levels`, `tests::the_page_limit_counts_a_repeated_images_samples_once`). Scores and hours unchanged. +- **`.ai` files write a warped image's pieces as the parts they show:** in the `.ai` editing data and in legacy `.ai` files, an embedded image cut to a clipping path (in the editing data, also an image under an opacity mask that clips) is written with all of its pixels the first time, and every later copy of the same pixels is written as the rectangle of them that the path or mask shows, 2 pixels more on each side, placed where it lies in the image. The pieces of a Warp effect, an envelope or their expanded art, 200 copies of the image for 10 × 10 cells before, now add about twice the image's pixels. Each image's pixels are read once for the pieces that follow one another. An image cut to a rectangle of half its pixels or more, and the first copy written, keep all of their pixels. The `XI` operator's arguments give an image's location and size ([AI file-format specification, §8.1](https://web.archive.org/web/20050126105313/https://partners.adobe.com/public/developer/en/illustrator/sdk/AI7FileFormat.pdf)); the 2-pixel margin and the half-the-pixels limit are VectorCraft's own rules (eps `ai_editing::tests::the_pieces_of_a_warped_image_are_written_as_the_parts_they_show`, `masked_pieces_of_a_warped_image_are_written_as_the_parts_they_show`, `an_image_with_a_live_warp_writes_its_pixels_whole_once`, `a_clipped_image_written_first_keeps_all_of_its_pixels`, `legacy_ai::tests::the_pieces_of_a_warped_image_are_written_as_the_parts_they_show`). Scores and hours unchanged. - **Distort Appearance with Transform effect options:** with Envelope Options › Distort Appearance on, a path whose Transform effect has Scale Strokes & Effects or Transform Patterns on, or copies it with a gradient, is bent as the same per-copy art it draws and expands as outside the envelope: each copy's own stroke weight, dashes, pattern placement and gradient (effects `bake::tests`). Scores and hours unchanged. - **Fitted gradients turn with the Transform effect:** a gradient fitted to the object (not placed with the Gradient tool) turns, reflects and stretches with the object when its Transform effect rotates, reflects or scales it unevenly, as Object › Transform already does: the gradient is fixed to its fit on the geometry the effect takes, then follows the effect and the effects after it as a placed gradient does. Under moves and even scales it draws as a refit does, and a Transform effect that scales the object to nothing across leaves it fitted, with Scale Strokes & Effects or Transform Patterns on too, and on each copy. This holds on the canvas and in Object › Expand of the fill, for an object's own effects, a fill's or stroke's own, and a group's, where the gradients fitted to its paths, to its own fill, to the groups inside it and to its images' and symbol instances' own fills each fix to their own object's fit. Existing documents with such a Transform effect on fitted-gradient art draw differently: before, the gradient refit to the turned outline. The Gradient tool still shows a fitted gradient's vector at its unturned fit. How gradients follow the effect is VectorCraft's own rule; what the effect does to the object is described in [Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html) (effects `bake::tests::a_fitted_gradient_turns_reflects_and_stretches_with_a_transform_effect`, `bake::tests::a_transform_effect_that_scales_to_nothing_leaves_a_fitted_gradient_fitted`, `group::tests::a_groups_transform_turns_the_gradients_fitted_to_its_members_and_its_own_fill`; render `objectfx::a_fitted_gradient_turns_and_reflects_with_its_transform_on_the_canvas`; engine `objexpand::a_fitted_gradient_turned_by_a_transform_expands_as_the_canvas_draws_it`). Scores and hours unchanged. - **Placed gradients follow Transform and Free Distort effects:** a gradient placed with the Gradient tool moves, turns and scales with the object when the object's Transform effect moves its outline, and each copy of the Transform effect takes it as many times as it takes the transform. Under Free Distort it moves and scales from the path's bounds before the effect to its bounds after it. This holds on the canvas, in export, in Expand Appearance, in Pathfinder and compound shapes, and in Object › Expand of the fill, for an object's own effects, a group's (the own fills of the group, of the groups inside it, of a symbol's art, and of the images and symbol instances it moves, included) and a fill's or stroke's own. A gradient on a path inside a group with a Transform effect now moves with the path (#2214 moved only the gradients of type), and so does a gradient on an image's or symbol instance's own fill. When a path keeps its shape because the effect would pass the geometry budget, the group's own gradients stay in place; a hidden path in a layer, which the layer's bounds leave out, does not hold them. A freeform gradient whose points were edited moves its points in the same way. How gradients follow each effect is VectorCraft's own rule; what each effect does to the object is described in [Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html) (effects `bake::tests::a_baked_transform_moves_a_placed_gradient_with_the_path`, `bake::tests::a_strokes_own_transform_and_free_distort_move_its_placed_gradient`, `bake::tests::a_fills_gradient_follows_the_effects_around_its_transform_with_options`, `bake::tests::baked_free_distort_moves_placed_gradients_from_the_bounds_to_the_distorted_bounds`, `group::tests::a_groups_transform_and_free_distort_move_the_gradients_placed_on_its_paths`, `group::tests::a_groups_transform_moves_the_gradient_of_its_own_fill`, `group::tests::a_nested_groups_own_gradient_follows_the_outer_groups_transform_and_free_distort`, `group::tests::a_groups_transform_moves_the_gradients_placed_on_an_images_own_fills`, `group::tests::shape_art_moves_gradients_with_a_transform_effect`, `group::tests::shape_art_moves_the_gradient_of_a_symbol_instances_art_with_its_transform`, `tests::art_past_the_budget_keeps_its_own_gradients_in_place`, `tests::a_hidden_path_past_the_budget_leaves_a_layers_gradients_free_to_move`, `tests::edited_freeform_points_follow_a_transform_effect_and_free_distort`; render `objectfx::a_paths_gradient_moves_with_its_transform_and_free_distort`; engine `objexpand::a_placed_gradient_moved_by_a_transform_or_free_distort_expands_as_the_canvas_draws_it`). Scores and hours unchanged.- **Constrain Angle (#394):** General › Constrain Angle turns the arrow keys' axes (guides stay on the page's), holds Shift drags of the Selection, Direct Selection, Free Transform, Slice Selection, Reshape and Measure tools and the Pen's handles to the turned axes, and new rectangles, rounded rectangles, ellipses, grids, point and area type, Shift-drawn polygons and stars and the shape size dialogs are drawn along it with their bounding box turned; 0° and whole turns are exactly as before, quarter turns exact (). Tests: `tests_constrain_tools`, `tests_constrain_new` (engine), `geom` `constrain_axes` / `rotate_deg`, the shape, grid and type tool tests. From 8703859c66f15db85542b5c33b02784c10890176 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 12:10:11 -0800 Subject: [PATCH 003/108] Contextual Task Bar: Smooth opens the Smooth slider with Direct Selection MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With a path selected whole by the Direct Selection tool, the bar's "Smooth" button converted every anchor point to smooth at once. It was the anchor convert, labeled like the path Smooth that the overview lists beside Simplify as adjusting the path's curvature, and the bar had no button for Object › Path › Smooth…. - A path selected whole with Direct Selection now offers Smooth after Simplify. It runs object.path.smooth the way the menu item does, so it opens the Smooth slider and changes nothing until it is confirmed. - The two anchor convert buttons, with a whole path or with anchors selected, show their icons alone, named by the Control bar's tool tips "Convert Selected Anchor Points to Corner" and "to Smooth". The keyboard shortcut part of #6784 is fixed on main by #6810. Docs: docs/mcp.md, docs/target-app-parity.md, the ui.smoothAuto params. Fixes #6784 --- crates/mcp/src/ui_catalog.rs | 2 +- crates/ui-egui/src/canvas/task_bar.rs | 40 ++++++--- crates/ui-egui/src/canvas/tests.rs | 48 +++++++++-- crates/ui-egui/src/menus/ui_commands.rs | 2 +- crates/ui-egui/src/tests/taskbar.rs | 107 ++++++++++++++++++++---- docs/mcp.md | 7 +- docs/target-app-parity.md | 2 +- 7 files changed, 171 insertions(+), 37 deletions(-) diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 8836b72ac2..9557bf6bf8 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -1258,7 +1258,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.smoothAuto", "Auto-Smooth", "", - "{} the open Smooth slider (Object › Path › Smooth and the canvas context menu's Smooth… open it: dialog `smoothSlider` with field `level` 0..100, object.path.smooth's level, opening at the level object.path.smooth {auto: true} picks, previewed on the canvas until ui.dialog.confirm keeps it as one undo step) moves to the level object.path.smooth {auto: true} picks and previews it → {level}; an error when the slider isn't open", + "{} the open Smooth slider (Object › Path › Smooth, the canvas context menu's Smooth… and the Contextual Task Bar's Smooth open it: dialog `smoothSlider` with field `level` 0..100, object.path.smooth's level, opening at the level object.path.smooth {auto: true} picks, previewed on the canvas until ui.dialog.confirm keeps it as one undo step) moves to the level object.path.smooth {auto: true} picks and previews it → {level}; an error when the slider isn't open", ), ( "ui.simplifyMoreOptions", diff --git a/crates/ui-egui/src/canvas/task_bar.rs b/crates/ui-egui/src/canvas/task_bar.rs index e908640c25..f89a921371 100644 --- a/crates/ui-egui/src/canvas/task_bar.rs +++ b/crates/ui-egui/src/canvas/task_bar.rs @@ -163,8 +163,8 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { items.push((tl!("Remove Anchor Points"), "pen-tool-delete", "path.removeAnchors", none())); items.push((tl!("Connect"), "dc-join", "path.join", none())); items.push((tl!("Cut Path"), "scissors", "path.cutAtAnchors", none())); - items.push((tl!("Corner"), "dc-anchor", TASK_BAR_TO_CORNER, none())); - items.push((tl!("Smooth"), "dc-anchor-smooth", TASK_BAR_TO_SMOOTH, none())); + items.push((tl!("Convert Selected Anchor Points to Corner"), "dc-anchor", TASK_BAR_TO_CORNER, none())); + items.push((tl!("Convert Selected Anchor Points to Smooth"), "dc-anchor-smooth", TASK_BAR_TO_SMOOTH, none())); } // As in the reference app, open paths offer Join and Edit Path, compound paths and clipping // masks their Release, images selected with vector art Make Clipping Mask, type converts @@ -213,14 +213,17 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { } else if is_image { // Offset Path and Simplify don't apply to an image. } else if !anchors && direct { - // Corner and Smooth convert every anchor of a path selected whole; Remove and Cut - // need anchors picked out, so they wait for them. + // The two convert buttons convert every anchor of a path selected whole; Remove and Cut + // need anchors picked out, so they wait for them. Simplify and Smooth open their + // sliders, as Object › Path › Simplify… and Smooth… do; the page above names Smooth as + // adjusting the path's curvature, apart from converting its anchor points. if open_path { items.push((tl!("Connect"), "dc-join", "path.join", none())); } - items.push((tl!("Corner"), "dc-anchor", TASK_BAR_TO_CORNER, none())); - items.push((tl!("Smooth"), "dc-anchor-smooth", TASK_BAR_TO_SMOOTH, none())); + items.push((tl!("Convert Selected Anchor Points to Corner"), "dc-anchor", TASK_BAR_TO_CORNER, none())); + items.push((tl!("Convert Selected Anchor Points to Smooth"), "dc-anchor-smooth", TASK_BAR_TO_SMOOTH, none())); items.push((tl!("Simplify"), "spline", "object.path.simplify", none())); + items.push((tl!("Smooth"), "dc-smooth", "object.path.smooth", none())); } else if !anchors { if open_path { items.push((tl!("Join"), "dc-join", "path.join", none())); @@ -297,6 +300,14 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { ui.ctx().set_cursor_icon(egui::CursorIcon::Grab); } for (label, icon, cmd, params) in &items { + // The convert buttons show their icon alone, named by their hover text, as + // the Control bar's do. + if icon_only(cmd) { + if widgets::icon_button(ui, icon, label, false, 30.0).clicked() { + run = Some((*cmd, params.clone())); + } + continue; + } let galley = ui.painter().layout_no_wrap(label.to_string(), egui::FontId::proportional(13.0), t.text_strong); let (r, resp) = ui.allocate_exact_size(vec2(galley.size().x + 38.0, 30.0), Sense::click()); resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, *label)); @@ -405,7 +416,7 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { Some((TASK_BAR_ARTBOARD_OPTIONS, _)) => crate::menus::invoke(app, "tool.options", json!({"tool": "artboard"})), Some((TASK_BAR_DUPLICATE_ARTBOARDS, _)) => crate::panels::artboards::duplicate_picked(app), Some((TASK_BAR_REARRANGE_ARTBOARDS, _)) => crate::panels::artboards::open_rearrange(app), - // Corner and Smooth convert the direct-selected anchors, as the Control bar's buttons do. + // The convert buttons convert the direct-selected anchors, as the Control bar's buttons do. Some((TASK_BAR_TO_CORNER, _)) => crate::menus::invoke(app, "path.convertAnchors", json!({"to": "corner"})), Some((TASK_BAR_TO_SMOOTH, _)) => crate::menus::invoke(app, "path.convertAnchors", json!({"to": "smooth"})), Some((c, p)) => crate::menus::invoke(app, c, p), @@ -419,10 +430,16 @@ pub(super) fn task_bar(app: &mut VectorcraftApp, ui: &mut Ui, xf: &Xf) { /// `room` (and narrow to fit it there). fn size_estimate(items: &[(&str, &str, &str, serde_json::Value)], fonts: bool, fixed: f32, room: f32) -> (bool, Vec2) { let font_w: f32 = crate::panels::character::TASK_BAR_WIDTHS.iter().filter(|_| fonts).map(|w| w + 6.0).sum(); - let items_w = if fonts { fixed } else { 150.0 } + items.iter().map(|(l, _, _, _)| l.len() as f32 * 7.2 + 44.0).sum::(); + let width = |(l, _, cmd, _): &(&str, &str, &str, serde_json::Value)| if icon_only(cmd) { 36.0 } else { l.len() as f32 * 7.2 + 44.0 }; + let items_w = if fonts { fixed } else { 150.0 } + items.iter().map(width).sum::(); if fonts && items_w + font_w > room { (true, vec2(items_w.max((font_w + 16.0).min(room)), 80.0)) } else { (false, vec2(items_w + font_w, 44.0)) } } +/// Whether the bar's item that runs `cmd` shows its icon alone: the anchor convert buttons. +fn icon_only(cmd: &str) -> bool { + matches!(cmd, TASK_BAR_TO_CORNER | TASK_BAR_TO_SMOOTH) +} + /// The paints the Fill and Stroke chips show, and whether each is mixed ("?"): the proxies', or /// while a Type tool edits type, the edited characters' fill, which a swatch picked then paints. pub(crate) fn chip_paints(app: &VectorcraftApp, ctx: &egui::Context) -> (vectorcraft_color::Paint, vectorcraft_color::Paint, bool, bool) { @@ -473,8 +490,11 @@ const TASK_BAR_DUPLICATE_ARTBOARDS: &str = "taskBar.duplicateArtboards"; /// The Contextual Task Bar's Rearrange All button with the Artboard tool. const TASK_BAR_REARRANGE_ARTBOARDS: &str = "taskBar.rearrangeArtboards"; -/// The Contextual Task Bar's Corner button for direct-selected anchors. +/// The Contextual Task Bar's Convert Selected Anchor Points to Corner button, for direct-selected +/// anchors or a path selected whole with Direct Selection. const TASK_BAR_TO_CORNER: &str = "taskBar.toCorner"; -/// The Contextual Task Bar's Smooth button for direct-selected anchors. +/// The Contextual Task Bar's Convert Selected Anchor Points to Smooth button, for direct-selected +/// anchors or a path selected whole with Direct Selection. The bar's Smooth button runs +/// `object.path.smooth` instead. const TASK_BAR_TO_SMOOTH: &str = "taskBar.toSmooth"; diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index d6df378c87..dc95453b98 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -10350,9 +10350,34 @@ fn the_artboard_tools_task_bar_buttons_act_on_the_selected_artboards() { assert_eq!(boards(&app), before, "one undo step"); } +/// The names and places of the buttons the Contextual Task Bar draws, from the accessibility tree +/// (`ctx` has it enabled): an icon-only button is named by its hover text. +fn task_bar_buttons(app: &mut VectorcraftApp, ctx: &egui::Context) -> Vec<(String, egui::Rect)> { + frame(app, ctx, vec![]); + let raw = egui::RawInput { screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(800.0, 600.0))), ..Default::default() }; + let mut out = ctx.run_ui(raw, |ui| show(app, ui)); + out.textures_delta.clear(); + let Some(bar) = task_bar_rect(ctx) else { return vec![] }; + let Some(update) = out.platform_output.accesskit_update.as_ref() else { return vec![] }; + let mut v: Vec<(String, egui::Rect)> = update + .nodes + .iter() + .filter(|(_, n)| n.role() == egui::accesskit::Role::Button) + .filter_map(|(_, n)| { + let b = n.bounds()?; + let r = egui::Rect::from_min_max(Pos2::new(b.x0 as f32, b.y0 as f32), Pos2::new(b.x1 as f32, b.y1 as f32)); + let label = n.label()?; + bar.contains(r.center()).then(|| (label.to_string(), r)) + }) + .collect(); + v.sort_by(|a, b| a.1.left().total_cmp(&b.1.left())); + v +} + /// With anchors direct-selected, the Contextual Task Bar offers Remove Anchor Points, Connect, -/// Cut Path, Corner and Smooth. Smooth and Corner convert the selected anchor, Cut Path opens -/// the path there and Connect closes it again, as the Control bar's anchor buttons do. +/// Cut Path and the two convert buttons, which show their icons alone. Converting to smooth and to +/// corner changes the selected anchor, Cut Path opens the path there and Connect closes it again, +/// as the Control bar's anchor buttons do. #[test] fn the_task_bar_connects_cuts_and_converts_direct_selected_anchors() { let mut app = VectorcraftApp::new(Session::new(), Default::default()); @@ -10361,10 +10386,21 @@ fn the_task_bar_connects_cuts_and_converts_direct_selected_anchors() { app.select_tool("directSelection"); app.run("select.anchors", json!({"id": id, "anchors": [[0, 1]]})).unwrap(); let ctx = egui::Context::default(); + ctx.enable_accesskit(); let names = |app: &mut VectorcraftApp| task_bar_labels(app, &ctx).into_iter().map(|(t, _)| t).collect::>(); - assert_eq!(names(&mut app), ["Remove Anchor Points", "Connect", "Cut Path", "Corner", "Smooth", "Duplicate"]); + assert_eq!(names(&mut app), ["Remove Anchor Points", "Connect", "Cut Path", "Duplicate"]); + let buttons = task_bar_buttons(&mut app, &ctx).into_iter().map(|(t, _)| t).collect::>(); + let expected = [ + "Remove Anchor Points", + "Connect", + "Cut Path", + "Convert Selected Anchor Points to Corner", + "Convert Selected Anchor Points to Smooth", + "Duplicate", + ]; + assert_eq!(buttons[..expected.len()], expected, "{buttons:?}"); let press = |app: &mut VectorcraftApp, label: &str| { - let labels = task_bar_labels(app, &ctx); + let labels = task_bar_buttons(app, &ctx); let at = labels.iter().find(|(t, _)| t == label).unwrap_or_else(|| panic!("{label} in {labels:?}")).1.center(); let button = |pressed| egui::Event::PointerButton { pos: at, button: egui::PointerButton::Primary, pressed, modifiers: Default::default() }; frame(app, &ctx, vec![egui::Event::PointerMoved(at)]); @@ -10374,11 +10410,11 @@ fn the_task_bar_connects_cuts_and_converts_direct_selected_anchors() { let subpath = |app: &VectorcraftApp| app.session.active().unwrap().doc.node(vectorcraft_doc::NodeId(id)).unwrap().path_data().unwrap().subpaths[0].clone(); let last_undo = |app: &VectorcraftApp| app.session.active().unwrap().history.undo.last().unwrap().label.clone(); - press(&mut app, "Smooth"); + press(&mut app, "Convert Selected Anchor Points to Smooth"); let a = subpath(&app).anchors[1]; assert!(a.has_in() && a.has_out(), "smooth: {a:?}"); assert_eq!(last_undo(&app), "Convert Anchor Points"); - press(&mut app, "Corner"); + press(&mut app, "Convert Selected Anchor Points to Corner"); let a = subpath(&app).anchors[1]; assert!(!a.has_in() && !a.has_out(), "corner: {a:?}"); press(&mut app, "Cut Path"); diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 37cdcb2d56..b21c28006c 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -1259,7 +1259,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "ui.smoothAuto", "Auto-Smooth", "", - "{} the open Smooth slider (Object › Path › Smooth and the canvas context menu's Smooth… open it: dialog `smoothSlider` with field `level` 0..100, object.path.smooth's level, opening at the level object.path.smooth {auto: true} picks, previewed on the canvas until ui.dialog.confirm keeps it as one undo step) moves to the level object.path.smooth {auto: true} picks and previews it → {level}; an error when the slider isn't open", + "{} the open Smooth slider (Object › Path › Smooth, the canvas context menu's Smooth… and the Contextual Task Bar's Smooth open it: dialog `smoothSlider` with field `level` 0..100, object.path.smooth's level, opening at the level object.path.smooth {auto: true} picks, previewed on the canvas until ui.dialog.confirm keeps it as one undo step) moves to the level object.path.smooth {auto: true} picks and previews it → {level}; an error when the slider isn't open", ), ( "ui.simplifyMoreOptions", diff --git a/crates/ui-egui/src/tests/taskbar.rs b/crates/ui-egui/src/tests/taskbar.rs index 68ef8a3f15..1d29663473 100644 --- a/crates/ui-egui/src/tests/taskbar.rs +++ b/crates/ui-egui/src/tests/taskbar.rs @@ -54,6 +54,42 @@ fn click(app: &mut VectorcraftApp, label: &str) { frame(app, &ctx, vec![]); } +/// The names and places of the buttons the task bar draws, from the accessibility tree: an +/// icon-only button is named by its hover text. +fn buttons(app: &mut VectorcraftApp) -> (egui::Context, Vec<(String, Rect)>) { + let ctx = egui::Context::default(); + ctx.enable_accesskit(); + crate::theme::install_fonts(&ctx); + frame(app, &ctx, vec![]); + let screen = Rect::from_min_size(Pos2::ZERO, vec2(1000.0, 700.0)); + let mut out = ctx.run_ui(egui::RawInput { screen_rect: Some(screen), ..Default::default() }, |ui| canvas::show(app, ui)); + out.textures_delta.clear(); + let nodes = &out.platform_output.accesskit_update.as_ref().expect("an accessibility tree").nodes; + let named = nodes + .iter() + .filter(|(_, n)| n.role() == egui::accesskit::Role::Button) + .filter_map(|(_, n)| { + let b = n.bounds()?; + Some((n.label()?.to_string(), Rect::from_min_max(Pos2::new(b.x0 as f32, b.y0 as f32), Pos2::new(b.x1 as f32, b.y1 as f32)))) + }) + .collect(); + (ctx, named) +} + +/// Click the task bar's button named `name` (its label, or an icon-only button's hover text). +fn click_button(app: &mut VectorcraftApp, name: &str) { + let (ctx, named) = buttons(app); + let p = named.iter().find(|(n, _)| n == name).unwrap_or_else(|| panic!("no button named {name:?} in {named:?}")).1.center(); + let press = |pressed| Event::PointerButton { pos: p, button: PointerButton::Primary, pressed, modifiers: Default::default() }; + frame(app, &ctx, vec![Event::PointerMoved(p)]); + frame(app, &ctx, vec![press(true)]); + frame(app, &ctx, vec![press(false)]); + frame(app, &ctx, vec![]); +} + +const TO_CORNER: &str = "Convert Selected Anchor Points to Corner"; +const TO_SMOOTH: &str = "Convert Selected Anchor Points to Smooth"; + fn select(app: &mut VectorcraftApp, ids: &[u64]) { app.run("select.set", json!({"ids": ids})).unwrap(); } @@ -293,27 +329,67 @@ fn direct_selection_of_a_whole_path_offers_its_anchor_actions() { click(&mut app, "Edit Path"); assert_eq!(app.session.tool_id(), "directSelection"); assert!(app.session.active().unwrap().selection.anchors.is_empty(), "the path is selected whole"); + let (_, named) = buttons(&mut app); + let names: Vec<&str> = named.iter().map(|(n, _)| n.as_str()).collect(); + for name in ["Connect", TO_CORNER, TO_SMOOTH, "Simplify", "Smooth", "Duplicate"] { + assert!(names.contains(&name), "{name}: {names:?}"); + } + for name in ["Edit Path", "Offset Path", "Join", "Remove Anchor Points", "Cut Path"] { + assert!(!names.contains(&name), "{name}: {names:?}"); + } + // The convert buttons show their icons alone: the bar draws no convert text, and one "Smooth". let (_, texts) = bar(&mut app); - for label in ["Connect", "Corner", "Smooth", "Simplify", "Duplicate"] { - assert!(has(&texts, label), "{label}: {texts:?}"); - } - for label in ["Edit Path", "Offset Path", "Join", "Remove Anchor Points", "Cut Path"] { - assert!(!has(&texts, label), "{label}: {texts:?}"); - } - // Smooth and Corner convert every anchor of the path, one undo step each. - click(&mut app, "Smooth"); + assert!(!has(&texts, "Corner") && !texts.iter().any(|(t, _)| t.starts_with("Convert")), "{texts:?}"); + assert_eq!(texts.iter().filter(|(t, _)| t == "Smooth").count(), 1, "{texts:?}"); + // The convert buttons convert every anchor of the path, one undo step each. + click_button(&mut app, TO_SMOOTH); let a = anchors(&app, line); assert_eq!(a[1].kind, vectorcraft_geom::AnchorKind::Smooth, "{a:?}"); assert!(a[1].has_in() && a[1].has_out(), "{a:?}"); - click(&mut app, "Corner"); + click_button(&mut app, TO_CORNER); assert!(anchors(&app, line).iter().all(|a| !a.has_in() && !a.has_out()), "{:?}", anchors(&app, line)); app.run("edit.undo", json!({})).unwrap(); assert!(anchors(&app, line)[1].has_in(), "Corner undoes in one step"); // Connect closes the open path; a closed one isn't offered it. click(&mut app, "Connect"); assert!(matches!(kind(&app, line), NodeKind::Path { path, .. } if path.is_closed())); - let (_, texts) = bar(&mut app); - assert!(!has(&texts, "Connect") && has(&texts, "Corner"), "{texts:?}"); + let (_, named) = buttons(&mut app); + assert!(!named.iter().any(|(n, _)| n == "Connect") && named.iter().any(|(n, _)| n == TO_CORNER), "{named:?}"); +} + +/// With the Direct Selection tool, the bar's Smooth smooths the path's curvature: it opens the +/// Smooth slider, as Object › Path › Smooth… does, and changes nothing until the slider is +/// confirmed (#6784). Simplify opens its slider in the same way. +#[test] +fn direct_selection_smooth_opens_the_smooth_slider() { + for (name, kind) in [("Smooth", crate::dialogs::smooth_slider::KIND), ("Simplify", crate::dialogs::simplify_slider::KIND)] { + let mut app = app(); + // A jagged line of 40 anchor points, which Smooth changes at its opening level. + let anchors_in: Vec<_> = (0..40).map(|i| json!({"x": 50 + i * 5, "y": 150 + (i % 2) * 6})).collect(); + let line = id(app.run("path.create", json!({"anchors": anchors_in})).unwrap()); + app.run("tool.select", json!({"tool": "directSelection"})).unwrap(); + select(&mut app, &[line]); + let before = anchors(&app, line); + let undo = app.session.active().unwrap().history.undo.len(); + click_button(&mut app, name); + let d = app.ui.dialog.as_ref().unwrap_or_else(|| panic!("{name} opens its slider: {}", app.ui.status)); + assert_eq!(d.kind, kind, "{name}"); + assert_eq!(app.session.active().unwrap().history.undo.len(), undo, "{name} adds no undo step before it is confirmed"); + crate::dialogs::cancel(&mut app); + assert_eq!(anchors(&app, line), before, "{name}: canceling leaves the path as it was"); + if name != "Smooth" { + continue; + } + // Confirmed, the slider smooths the path as one undo step, which is not the anchor convert. + click_button(&mut app, name); + crate::dialogs::confirm(&mut app).unwrap(); + let history = &app.session.active().unwrap().history.undo; + assert_eq!(history.len(), undo + 1, "one undo step"); + assert_ne!(history.last().unwrap().label, "Convert Anchor Points"); + assert_ne!(anchors(&app, line), before, "Smooth changes the path's curvature"); + app.run("edit.undo", json!({})).unwrap(); + assert_eq!(anchors(&app, line), before, "undo restores the path"); + } } /// Anchors picked out with the Direct Selection tool keep the full set: Remove and Cut need them. @@ -323,11 +399,12 @@ fn direct_selected_anchors_still_offer_remove_and_cut() { let line = id(app.run("path.create", json!({"anchors": [{"x": 50, "y": 200}, {"x": 150, "y": 80}, {"x": 250, "y": 200}]})).unwrap()); app.run("tool.select", json!({"tool": "directSelection"})).unwrap(); app.run("select.anchors", json!({"id": line, "anchors": [[0, 1]]})).unwrap(); - let (_, texts) = bar(&mut app); - for label in ["Remove Anchor Points", "Connect", "Cut Path", "Corner", "Smooth"] { - assert!(has(&texts, label), "{label}: {texts:?}"); + let (_, named) = buttons(&mut app); + let names: Vec<&str> = named.iter().map(|(n, _)| n.as_str()).collect(); + for name in ["Remove Anchor Points", "Connect", "Cut Path", TO_CORNER, TO_SMOOTH] { + assert!(names.contains(&name), "{name}: {names:?}"); } - assert!(!has(&texts, "Edit Path"), "{texts:?}"); + assert!(!names.contains(&"Edit Path"), "{names:?}"); } /// Click the task bar's button left of More Options (Lock, or a basic shape's Shape Properties), diff --git a/docs/mcp.md b/docs/mcp.md index 6bebc86bab..2d2e9cc6bc 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5156,9 +5156,10 @@ round, such as a rectangle, stays as it is. Closed paths stay closed and open pa {"name":"run_command","arguments":{"command":"object.path.smooth","params":{"level":80}}} ``` -In the desktop app, Object › Path › Smooth and the canvas context menu's Smooth… (listed while the selection holds a -path) open the slider (`ui.menuDialog {command: "object.path.smooth"}`, dialog `smoothSlider` with field `level`) at -the Auto-Smooth level, and the slider previews the result until `ui.dialog.confirm`; `ui.smoothAuto` moves the open +In the desktop app, Object › Path › Smooth, the canvas context menu's Smooth… (listed while the selection holds a +path) and the Contextual Task Bar's Smooth (with a path selected whole with the Direct Selection tool) open the +slider (`ui.menuDialog {command: "object.path.smooth"}`, dialog `smoothSlider` with field `level`) at the +Auto-Smooth level, and the slider previews the result until `ui.dialog.confirm`; `ui.smoothAuto` moves the open slider back to the Auto-Smooth level. ## Editing a path with the Curvature tool diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7fdc7ef81f..0efc5b77ce 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -845,7 +845,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - While a Type tool (Type, Area Type, Type on a Path and their vertical versions) adds or edits type, the contextual task bar shows the font family menu, the font style menu, the Font Size combo and the Fill chip (); the Touch Type tool shows no bar, as the same page describes. Type selected with a selection tool shows the same three font controls beside its Create Outlines, conversion and Type on a Path items (). The controls act as the Character panel's do: on the characters a Type tool selects, else on every selected type object, with the size left blank where the sizes differ. VectorCraft's own rules: a Type tool's bar leaves out the object actions, the Stroke chip, Recolor Artwork and Lock; a Type tool shows no bar before it adds type or with other art selected; type selected with other art shows no font controls; the font controls go on a second row when one row would be wider than the canvas, and narrow to fit a canvas narrower than they are; while a Type tool edits type, the Fill chip shows the edited characters' fill ("?" where it differs). Evidence: `the_type_tools_show_font_and_fill_controls`, `the_type_tools_show_no_bar_without_type`, `selected_type_shows_font_controls_beside_its_actions`, `the_task_bars_font_size_sets_what_the_character_panel_would`, `the_type_tools_fill_chip_activates_the_fill`, `the_type_tools_bar_is_named_and_stays_on_the_canvas`, `selected_types_font_controls_take_a_second_row_on_a_narrow_canvas` and `the_type_tools_fill_chip_shows_the_edited_characters_fill` in `crates/ui-egui/src/tests/taskbar.rs`. - With a live rectangle, rounded rectangle, ellipse or polygon selected with the Selection tool, the contextual task bar shows a Shape Properties button in place of Lock. It opens a popup with the shape's rows from the Transform panel (corner radius, pie angles, or sides, angle, corner and radius), which edit it through `object.setLiveShape`. The overview describes this: when a shape drawn with a shape tool (Rectangle, Star) is selected, the bar offers to change its properties where Lock Object would be ([Contextual Task Bar overview](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/contextual-task-bar-overview.html)). Object › Lock and ⌘2 still lock the shape. Not done: stars, which the app draws as plain paths. Evidence: `a_basic_shape_shows_its_properties_in_place_of_lock`, `the_shape_properties_popup_edits_the_shape` and `other_selections_keep_lock` in `crates/ui-egui/src/tests/taskbar.rs`. - The contextual task bar has a Stroke chip beside the Fill chip, drawn with the paint the Stroke proxy shows (a "?" when the selected objects' strokes differ, as on the Fill chip); a click brings the Stroke proxy forward and shows the Swatches panel wherever it is docked, floating or closed, as a click on the Fill chip does for the Fill proxy. The reference app's bar has Fill and Stroke controls for changing an object's colors ([Contextual Task Bar overview](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/contextual-task-bar-overview.html)). Evidence: `the_task_bar_shows_a_stroke_chip_beside_fill` and `the_task_bar_chips_follow_the_proxies_and_show_swatches_anywhere` in `crates/ui-egui/src/canvas/tests.rs`. - - With anchor points selected with Direct Selection, the contextual task bar offers Remove Anchor Points, Connect (`path.join`), Cut Path, Corner and Smooth (`path.convertAnchors` with `to` set to `corner` or `smooth`), the commands of the Control bar's anchor buttons. As in Illustrator, whose bar has items that delete the selected anchors, join selected end points, split the path at the selected anchors, and make the selected anchors corner or smooth points ([Contextual Task Bar overview](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/contextual-task-bar-overview.html)). Not done: Simplify, which the bar offers only while no anchors are selected, and the bar's Smooth item that adjusts a path's curvature, a command the app doesn't have (Object › Path › Smooth). + - With anchor points selected with Direct Selection, the contextual task bar offers Remove Anchor Points, Connect (`path.join`), Cut Path, and Convert Selected Anchor Points to Corner and to Smooth (`path.convertAnchors` with `to` set to `corner` or `smooth`), the commands of the Control bar's anchor buttons; the two convert buttons show their icons alone, named by their tool tips as on the Control bar (VectorCraft's own choice). The overview lists items that delete the selected anchors, join selected end points, split the path at the selected anchors, and make the selected anchors corner or smooth points ([Contextual Task Bar overview](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/contextual-task-bar-overview.html)). With a path selected whole with Direct Selection, the bar also offers Simplify and Smooth, which open the Simplify and Smooth sliders as Object › Path › Simplify… and Smooth… do; the same overview names Smooth as adjusting the path's curvature (#6784). VectorCraft's own rule: while anchors are picked out, the bar offers the anchor items without Simplify and Smooth. Evidence: `direct_selection_smooth_opens_the_smooth_slider` in `crates/ui-egui/src/tests/taskbar.rs`. - Tool flyouts tear off: dragging or clicking the tear-off bar on a flyout's right side (or releasing the long press over it) floats its group as a strip of tool buttons, moved by the same bar and put back in the toolbar by the × at its top (`window.floatTools`). While a group floats, the presses that would open its flyout raise the strip instead. Floating strips are kept with the preferences and in user workspaces. Not done: turning a strip vertical, docking it. - Screen readers get a name for the Tools panel's tool buttons, flyout rows, floating strips and tear-off bars, and for the icon buttons, text buttons, toggles, checkboxes, radio buttons, tabs, chips, sliders, angle dials and combo boxes that panels and dialogs draw with `crates/ui-egui/src/widgets.rs`: the text, label or tool tip each one shows, or a name of its own where it shows none (the angle dial, the spinner, the preset arrow, the color wheel and the Reference Point's squares). The tool buttons, toggles, checkboxes, radio buttons, tabs and the Reference Point's nine squares also report whether they are on, an icon button that is lit, such as the chosen Align To button, reports that it is pressed, and the angle dial reports its angle. The status bar's First, Previous, Next and Last Artboard buttons have tool tips. - Tab does not stop on the regions that only the pointer uses: the custom title bar's background and the window's resize zones, the band at the top of a dialog that moves it, the Tools panel's grip, a flyout's and a floating strip's tear-off bar, the isolation bar's background, and the rulers and the box where they meet. From 99773c1d7aecec40a2c89873f2899942ba460ec2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 13:00:50 -0800 Subject: [PATCH 004/108] Actions: Load Actions reports steps with unknown command ids A step whose command id is not a built-in command, a command of an installed plug-in, a View menu step or a stop now loads as it is and is reported when the set loads: the ui.actionSet.load answer lists the action, step and id (unknownCommands, at most 1,000, and unknownCount), and the status bar names the first and the count. Commands inside a command.batch step are checked one by one. Control characters in the status text are replaced and long names are cut at 80 characters. An action with such a step included no longer plays: the error names the step and its id before any step runs, at every speed. An excluded step does not stop it. --- crates/ui-egui/src/i18n/ca.tsv | 2 + crates/ui-egui/src/i18n/cs.tsv | 2 + crates/ui-egui/src/i18n/de.tsv | 2 + crates/ui-egui/src/i18n/el.tsv | 2 + crates/ui-egui/src/i18n/es.tsv | 2 + crates/ui-egui/src/i18n/fi.tsv | 2 + crates/ui-egui/src/i18n/fr.tsv | 2 + crates/ui-egui/src/i18n/hi.tsv | 2 + crates/ui-egui/src/i18n/hu.tsv | 2 + crates/ui-egui/src/i18n/it.tsv | 2 + crates/ui-egui/src/i18n/ja.tsv | 2 + crates/ui-egui/src/i18n/ka.tsv | 2 + crates/ui-egui/src/i18n/ko.tsv | 2 + crates/ui-egui/src/i18n/nl.tsv | 2 + crates/ui-egui/src/i18n/pl.tsv | 2 + crates/ui-egui/src/i18n/pt-br.tsv | 2 + crates/ui-egui/src/i18n/ru.tsv | 2 + crates/ui-egui/src/i18n/sv.tsv | 2 + crates/ui-egui/src/i18n/tests.rs | 4 + crates/ui-egui/src/i18n/tr.tsv | 2 + crates/ui-egui/src/i18n/uk.tsv | 2 + crates/ui-egui/src/i18n/vi.tsv | 2 + crates/ui-egui/src/i18n/zh-hans.tsv | 2 + crates/ui-egui/src/i18n/zh-hant.tsv | 2 + crates/ui-egui/src/panels/actions.rs | 186 ++++++++++++++++++++- crates/ui-egui/src/panels/actions/files.rs | 50 +++++- docs/mcp.md | 16 +- docs/target-app-parity.md | 1 + 28 files changed, 296 insertions(+), 7 deletions(-) diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 6c3aa46c6d..58d2b0c4e7 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -5829,6 +5829,7 @@ digits Malayalam Malaiàlam @msg no action set to save no hi ha cap conjunt d’accions per desar @msg the action set file can't be read in full el fitxer de conjunt d’accions no es pot llegir sencer @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out S’ha carregat “{name}”: s’ha omès {n} pas|S’ha carregat “{name}”: s’han omès {n} passos +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` S’ha carregat “{name}”: {n} pas té una ordre desconeguda i s’ha conservat: “{action}”, pas {step}, `{command}`|S’ha carregat “{name}”: {n} passos tenen ordres desconegudes i s’han conservat; el primer: “{action}”, pas {step}, `{command}` @msg not an action set file no és un fitxer de conjunt d’accions @msg the action set file is larger than 8 MiB el fitxer de conjunt d’accions supera els 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: la referència superaria els {MAX_BYTES} bytes @@ -6319,6 +6320,7 @@ digits Malayalam Malaiàlam @msg truncated truncat @msg Unembedded to {_1} S’ha desincrustat a {_1} @msg unknown command `{0}` ordre desconeguda `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` el pas {step} de “{action}” executa l’ordre desconeguda `{command}` @msg unknown command `{0}`; did you mean `{1}`? ordre desconeguda `{0}`; volies dir `{1}`? @msg unknown control `{name}`: fillStroke, coloring, drawMode or screenMode control desconegut `{name}`: fillStroke, coloring, drawMode o screenMode @msg Unknown dimension mode Mode de dimensió desconegut diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index a80d4f6b2c..87fbf19781 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -5013,6 +5013,7 @@ imageTrace Outline Obrys @msg no action set to save žádná sada akcí k uložení @msg the action set file can't be read in full soubor sady akcí nelze přečíst celý @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Načteno „{name}“: vynechán {n} krok|Načteno „{name}“: vynechány {n} kroky|Načteno „{name}“: vynecháno {n} kroků +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Načteno „{name}“: {n} krok má neznámý příkaz a byl ponechán: „{action}“, krok {step}, `{command}`|Načteno „{name}“: {n} kroky mají neznámé příkazy a byly ponechány; první: „{action}“, krok {step}, `{command}`|Načteno „{name}“: {n} kroků má neznámé příkazy a bylo ponecháno; první: „{action}“, krok {step}, `{command}` @msg not an action set file není to soubor sady akcí @msg the action set file is larger than 8 MiB soubor sady akcí je větší než 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: reference by byla větší než {MAX_BYTES} bajtů @@ -5253,6 +5254,7 @@ imageTrace Outline Obrys @msg tool shortcuts must be a single key (optionally with Shift) zkratky nástrojů musí být jediná klávesa (volitelně se Shift) @msg truncated zkráceno @msg unknown command `{0}` neznámý příkaz `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` krok {step} akce „{action}“ spouští neznámý příkaz `{command}` @msg unknown command `{0}`; did you mean `{1}`? neznámý příkaz `{0}`; mysleli jste `{1}`? @msg unknown effect `{id}` neznámý efekt `{id}` @msg unknown format neznámý formát diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 3dc6542d44..3ffc857b4d 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -4628,6 +4628,7 @@ theme Appearance Erscheinungsbild @msg no action set to save kein Aktionssatz zum Speichern @msg the action set file can't be read in full die Aktionssatzdatei kann nicht vollständig gelesen werden @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out „{name}“ geladen: {n} Schritt wurde ausgelassen|„{name}“ geladen: {n} Schritte wurden ausgelassen +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` „{name}“ geladen: {n} Schritt hat einen unbekannten Befehl und wurde behalten: „{action}“, Schritt {step}, `{command}`|„{name}“ geladen: {n} Schritte haben unbekannte Befehle und wurden behalten; der erste: „{action}“, Schritt {step}, `{command}` @msg not an action set file keine Aktionssatzdatei @msg the action set file is larger than 8 MiB die Aktionssatzdatei ist größer als 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: die Referenz wäre größer als {MAX_BYTES} Byte @@ -4869,6 +4870,7 @@ theme Appearance Erscheinungsbild @msg tool shortcuts must be a single key (optionally with Shift) Tastaturbefehle für Werkzeuge müssen aus einer einzelnen Taste bestehen (optional mit Shift) @msg truncated abgeschnitten @msg unknown command `{0}` unbekannter Befehl `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` Schritt {step} von „{action}“ führt den unbekannten Befehl `{command}` aus @msg unknown command `{0}`; did you mean `{1}`? unbekannter Befehl `{0}`; meinten Sie `{1}`? @msg unknown effect `{id}` unbekannter Effekt `{id}` @msg unknown format unbekanntes Format diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 95158fc54c..7a38da4285 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -4660,6 +4660,7 @@ digits Malayalam Μαλαγιάλαμ @msg no action set to save δεν υπάρχει σύνολο ενεργειών για αποθήκευση @msg the action set file can't be read in full το αρχείο συνόλου ενεργειών δεν μπορεί να διαβαστεί ολόκληρο @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Φορτώθηκε το «{name}»: παραλείφθηκε {n} βήμα|Φορτώθηκε το «{name}»: παραλείφθηκαν {n} βήματα +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Φορτώθηκε το «{name}»: {n} βήμα έχει άγνωστη εντολή και διατηρήθηκε: «{action}», βήμα {step}, `{command}`|Φορτώθηκε το «{name}»: {n} βήματα έχουν άγνωστες εντολές και διατηρήθηκαν· το πρώτο: «{action}», βήμα {step}, `{command}` @msg not an action set file δεν είναι αρχείο συνόλου ενεργειών @msg the action set file is larger than 8 MiB το αρχείο συνόλου ενεργειών είναι μεγαλύτερο από 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: η αναφορά θα ήταν μεγαλύτερη από {MAX_BYTES} byte @@ -4894,6 +4895,7 @@ digits Malayalam Μαλαγιάλαμ @msg tool shortcuts must be a single key (optionally with Shift) οι συντομεύσεις εργαλείων πρέπει να περιλαμβάνουν ένα πλήκτρο (προαιρετικά με Shift) @msg truncated περικομμένο @msg unknown command `{0}` άγνωστη εντολή `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` το βήμα {step} της ενέργειας «{action}» εκτελεί την άγνωστη εντολή `{command}` @msg unknown command `{0}`; did you mean `{1}`? άγνωστη εντολή `{0}`· μήπως εννοείτε `{1}`; @msg unknown effect `{id}` άγνωστο εφέ `{id}` @msg unknown format άγνωστη μορφή diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 7041dcacb3..d7adb8d004 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -4704,6 +4704,7 @@ axis Both Ambos @msg no action set to save no hay ningún conjunto de acciones que guardar @msg the action set file can't be read in full el archivo de conjunto de acciones no se puede leer completo @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Se cargó “{name}”: se omitió {n} paso|Se cargó “{name}”: se omitieron {n} pasos +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Se cargó “{name}”: {n} paso tiene un comando desconocido y se conservó: “{action}”, paso {step}, `{command}`|Se cargó “{name}”: {n} pasos tienen comandos desconocidos y se conservaron; el primero: “{action}”, paso {step}, `{command}` @msg not an action set file no es un archivo de conjunto de acciones @msg the action set file is larger than 8 MiB el archivo de conjunto de acciones supera los 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: la referencia superaría los {MAX_BYTES} bytes @@ -4945,6 +4946,7 @@ axis Both Ambos @msg tool shortcuts must be a single key (optionally with Shift) los atajos de herramientas deben ser una sola tecla (opcionalmente con Shift) @msg truncated truncado @msg unknown command `{0}` comando desconocido `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` el paso {step} de “{action}” ejecuta el comando desconocido `{command}` @msg unknown command `{0}`; did you mean `{1}`? comando desconocido `{0}`; ¿quiso decir `{1}`? @msg unknown effect `{id}` efecto desconocido `{id}` @msg unknown format formato desconocido diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index c5f1bd4d48..60487a0fa0 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -4919,6 +4919,7 @@ imageTrace Outline Ääriviiva @msg no action set to save ei tallennettavaa toimintosarjaa @msg the action set file can't be read in full toimintosarjatiedostoa ei voi lukea kokonaan @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Ladattiin ”{name}”: jätettiin pois {n} vaihe|Ladattiin ”{name}”: jätettiin pois {n} vaihetta +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Ladattiin ”{name}”: {n} vaiheella on tuntematon komento, ja se säilytettiin: ”{action}”, vaihe {step}, `{command}`|Ladattiin ”{name}”: {n} vaiheella on tuntemattomia komentoja, ja ne säilytettiin; ensimmäinen: ”{action}”, vaihe {step}, `{command}` @msg not an action set file ei ole toimintosarjatiedosto @msg the action set file is larger than 8 MiB toimintosarjatiedosto on suurempi kuin 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: viite olisi suurempi kuin {MAX_BYTES} tavua @@ -5152,6 +5153,7 @@ imageTrace Outline Ääriviiva @msg tool shortcuts must be a single key (optionally with Shift) työkalujen pikanäppäinten on oltava yksittäinen näppäin (valinnaisesti Vaihto-näppäimen kanssa) @msg truncated katkaistu @msg unknown command `{0}` tuntematon komento `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` toiminnon ”{action}” vaihe {step} suorittaa tuntemattoman komennon `{command}` @msg unknown command `{0}`; did you mean `{1}`? tuntematon komento `{0}`; tarkoititko `{1}`? @msg unknown effect `{id}` tuntematon tehoste `{id}` @msg unknown format tuntematon muoto diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 4227df5602..9f5a19a16b 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -4693,6 +4693,7 @@ axis Both Les deux @msg no action set to save aucun jeu de scripts à enregistrer @msg the action set file can't be read in full le fichier de jeu de scripts ne peut pas être lu en entier @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out « {name} » chargé : {n} étape a été ignorée|« {name} » chargé : {n} étapes ont été ignorées +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` « {name} » chargé : {n} étape a une commande inconnue et a été conservée : « {action} », étape {step}, `{command}`|« {name} » chargé : {n} étapes ont des commandes inconnues et ont été conservées ; la première : « {action} », étape {step}, `{command}` @msg not an action set file ce n’est pas un fichier de jeu de scripts @msg the action set file is larger than 8 MiB le fichier de jeu de scripts dépasse 8 Mio @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}` : la référence dépasserait {MAX_BYTES} octets @@ -4934,6 +4935,7 @@ axis Both Les deux @msg tool shortcuts must be a single key (optionally with Shift) les raccourcis d’outils doivent être une seule touche (éventuellement avec Maj) @msg truncated tronqué @msg unknown command `{0}` commande inconnue `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` l’étape {step} de « {action} » exécute la commande inconnue `{command}` @msg unknown command `{0}`; did you mean `{1}`? commande inconnue `{0}` ; vouliez-vous dire `{1}` ? @msg unknown effect `{id}` effet inconnu `{id}` @msg unknown format format inconnu diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index 3b8986e5f1..bdbbd40674 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -7474,6 +7474,7 @@ antiAlias Sharp शार्प @msg not a Word document: its WordDocument stream doesn't start with a file information block वर्ड डॉक्यूमेंट नहीं: इसकी WordDocument धारा फ़ाइल सूचना ब्लॉक के साथ शुरू नहीं होती है @msg the action set file can't be read in full एक्शन सेट फ़ाइल पूरी तरह नहीं पढ़ी जा सकती @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out “{name}” लोड किया गया: {n} चरण छोड़ा गया|“{name}” लोड किया गया: {n} चरण छोड़े गए +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` “{name}” लोड किया गया: {n} चरण में अज्ञात आदेश है और उसे रखा गया: “{action}”, चरण {step}, `{command}`|“{name}” लोड किया गया: {n} चरणों में अज्ञात आदेश हैं और उन्हें रखा गया; पहला: “{action}”, चरण {step}, `{command}` @msg not an action set file एक एक्शन सेट फ़ाइल नहीं @msg not an EMF or WMF file नहीं एक EMF या WMF फ़ाइल @msg not an HP-GL file HP-GL फ़ाइल नहीं है @@ -8362,6 +8363,7 @@ antiAlias Sharp शार्प @msg unknown character style number field अज्ञात चरित्र स्टाइल संख्या क्षेत्र @msg unknown CMYK profile `{name}` अज्ञात CMYK प्रोफ़ाइल `{name}` @msg unknown command `{0}` अज्ञात आदेश `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` “{action}” का चरण {step} अज्ञात आदेश `{command}` चलाता है @msg unknown command `{0}`; did you mean `{1}`? अज्ञात आदेश `{0}`; क्या आपको `{1}` का मतलब है? @msg unknown control `{name}`: fillStroke, coloring, drawMode or screenMode अज्ञात नियंत्रण `{name}`: fillStroke, रंग, drawMode या screenMode @msg Unknown dimension mode अज्ञात आयाम मोड diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index cea96d098d..4a77763b65 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -5390,6 +5390,7 @@ imageTrace Outline Körvonal @msg no action set to save nincs menthető műveletkészlet @msg the action set file can't be read in full a műveletkészlet-fájl nem olvasható be teljesen @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out „{name}” betöltve; kihagyott lépések: {n} +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` „{name}” betöltve; megtartott lépések ismeretlen paranccsal: {n}; az első: „{action}”, lépés: {step}, `{command}` @msg not an action set file nem műveletkészlet-fájl @msg the action set file is larger than 8 MiB a műveletkészlet-fájl nagyobb 8 MiB-nál @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: a referencia nagyobb lenne {MAX_BYTES} bájtnál @@ -5762,6 +5763,7 @@ imageTrace Outline Körvonal @msg truncated csonka @msg Unembedded to {_1} Beágyazás megszüntetve, ide: {_1} @msg unknown command `{0}` ismeretlen parancs: `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` „{action}”, lépés: {step}: ismeretlen parancsot futtat: `{command}` @msg unknown command `{0}`; did you mean `{1}`? ismeretlen parancs: `{0}`; erre gondolt: `{1}`? @msg unknown effect `{id}` ismeretlen effektus: `{id}` @msg unknown format ismeretlen formátum diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 61ad0afce3..cb3a6b2a84 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -4756,6 +4756,7 @@ axis Both Entrambi @msg no action set to save nessun set di azioni da salvare @msg the action set file can't be read in full il file di set di azioni non può essere letto per intero @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Caricato “{name}”: {n} passaggio è stato omesso|Caricato “{name}”: {n} passaggi sono stati omessi +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Caricato “{name}”: {n} passaggio ha un comando sconosciuto ed è stato mantenuto: “{action}”, passaggio {step}, `{command}`|Caricato “{name}”: {n} passaggi hanno comandi sconosciuti e sono stati mantenuti; il primo: “{action}”, passaggio {step}, `{command}` @msg not an action set file non è un file di set di azioni @msg the action set file is larger than 8 MiB il file del set di azioni supera 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: il riferimento supererebbe {MAX_BYTES} byte @@ -4997,6 +4998,7 @@ axis Both Entrambi @msg tool shortcuts must be a single key (optionally with Shift) le scelte rapide degli strumenti devono essere un singolo tasto (eventualmente con Shift) @msg truncated troncato @msg unknown command `{0}` comando sconosciuto `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` il passaggio {step} di “{action}” esegue il comando sconosciuto `{command}` @msg unknown command `{0}`; did you mean `{1}`? comando sconosciuto `{0}`; forse intendevate `{1}`? @msg unknown effect `{id}` effetto sconosciuto `{id}` @msg unknown format formato sconosciuto diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index e624f78e06..2c43c9ed9f 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -4680,6 +4680,7 @@ swatch Bright Violet ビビッドバイオレット @msg objects can't be nested more than 32 deep オブジェクトは 32 階層より深く入れ子にできません @msg the SVG's elements are nested more than {0} deep SVG の要素が {0} 階層より深く入れ子になっています @msg unknown command `{0}` `{0}` は不明なコマンドです +@msg step {step} of “{action}” runs the unknown command `{command}` 「{action}」のステップ {step} は不明なコマンド `{command}` を実行します @msg unknown command `{0}`; did you mean `{1}`? `{0}` は不明なコマンドです。`{1}` のことですか? @msg `{what}` closes nothing `{what}` に対応する開始部分がありません @msg `{what}` closes something it didn't open `{what}` が対応しない開始部分を閉じています @@ -5025,6 +5026,7 @@ swatch Bright Violet ビビッドバイオレット @msg no action set to save 保存するアクションセットがありません @msg the action set file can't be read in full アクションセットファイルをすべて読み込めません @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out 「{name}」を読み込みました。{n} 個のステップは省きました +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` 「{name}」を読み込みました。不明なコマンドのステップ {n} 個はそのまま残しました。最初は「{action}」のステップ {step}、`{command}` です @msg not an action set file アクションセットファイルではありません @msg the action set file is larger than 8 MiB アクションセットファイルが 8 MiB を超えています @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: リファレンスが {MAX_BYTES} バイトを超えます diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 237b034f61..1e480b0c42 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -4386,6 +4386,7 @@ font-technology Variable ცვლადი @msg no action set to save შესანახი მოქმედებების ნაკრები არ არის @msg the action set file can't be read in full მოქმედებების ნაკრების ფაილის სრულად წაკითხვა შეუძლებელია @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out ჩაიტვირთა „{name}“; გამოტოვებული ნაბიჯები: {n} +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` ჩაიტვირთა „{name}“; შენახული ნაბიჯები უცნობი ბრძანებით: {n}; პირველი: „{action}“, ნაბიჯი {step}, `{command}` @msg not an action set file ეს არ არის მოქმედებების ნაკრების ფაილი @msg the action set file is larger than 8 MiB მოქმედებების ნაკრების ფაილი 8 MiB-ზე დიდია @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: ცნობარი {MAX_BYTES} ბაიტზე დიდი იქნებოდა @@ -4605,6 +4606,7 @@ font-technology Variable ცვლადი @msg tool shortcuts must be a single key (optionally with Shift) ხელსაწყოს მალსახმობი ერთი კლავიში უნდა იყოს (სურვილისამებრ Shift-ით) @msg truncated შეკვეცილია @msg unknown command `{0}` უცნობი ბრძანება `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` „{action}“, ნაბიჯი {step}: უცნობი ბრძანება `{command}` @msg unknown command `{0}`; did you mean `{1}`? უცნობი ბრძანება `{0}`; იქნებ `{1}` იგულისხმეთ? @msg unknown effect `{id}` უცნობი ეფექტი `{id}` @msg unknown format უცნობი ფორმატი diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 06e3e47e52..719d8242bc 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -4607,6 +4607,7 @@ theme Appearance 외관 @msg objects can't be nested more than 32 deep 개체는 32단계보다 깊게 중첩할 수 없습니다 @msg the SVG's elements are nested more than {0} deep SVG 요소가 {0}단계보다 깊게 중첩되어 있습니다 @msg unknown command `{0}` 알 수 없는 명령 `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` “{action}”의 단계 {step}에서 알 수 없는 명령 `{command}`을(를) 실행합니다 @msg unknown command `{0}`; did you mean `{1}`? 알 수 없는 명령 `{0}`: `{1}`을(를) 의미하셨습니까? @msg `{what}` closes nothing `{what}`이(가) 닫는 항목이 없습니다 @msg `{what}` closes something it didn't open `{what}`이(가) 열지 않은 항목을 닫습니다 @@ -4952,6 +4953,7 @@ theme Appearance 외관 @msg no action set to save 저장할 액션 세트가 없습니다 @msg the action set file can't be read in full 액션 세트 파일을 전부 읽을 수 없습니다 @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out “{name}”을(를) 불러왔습니다. 단계 {n}개를 제외했습니다 +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` “{name}”을(를) 불러왔습니다. 알 수 없는 명령이 있는 단계 {n}개를 그대로 두었습니다. 첫 번째: “{action}”, 단계 {step}, `{command}` @msg not an action set file 액션 세트 파일이 아닙니다 @msg the action set file is larger than 8 MiB 액션 세트 파일이 8 MiB보다 큽니다 @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: 참조가 {MAX_BYTES}바이트보다 커집니다 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 8b91f8f3b9..ecd89254ab 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5073,6 +5073,7 @@ imageTrace Outline Contour @msg no action set to save geen actieset om op te slaan @msg the action set file can't be read in full het actiesetbestand kan niet volledig worden gelezen @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out „{name}” geladen: {n} stap is weggelaten|„{name}” geladen: {n} stappen zijn weggelaten +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` „{name}” geladen: {n} stap heeft een onbekende opdracht en is behouden: „{action}”, stap {step}, `{command}`|„{name}” geladen: {n} stappen hebben onbekende opdrachten en zijn behouden; de eerste: „{action}”, stap {step}, `{command}` @msg not an action set file geen actiesetbestand @msg the action set file is larger than 8 MiB het actiesetbestand is groter dan 8 MiB @msg the action set file holds more than 1,000 actions het actiesetbestand bevat meer dan 1.000 acties @@ -5274,6 +5275,7 @@ imageTrace Outline Contour @msg tool shortcuts must be a single key (optionally with Shift) gereedschapsneltoetsen moeten uit één toets bestaan (eventueel met Shift) @msg truncated afgekapt @msg unknown command `{0}` onbekende opdracht `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` stap {step} van „{action}” voert de onbekende opdracht `{command}` uit @msg unknown command `{0}`; did you mean `{1}`? onbekende opdracht `{0}`; bedoelde je `{1}`? @msg unknown effect `{id}` onbekend effect `{id}` @msg unknown format onbekende indeling diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index ca34501a93..94d2bbe257 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -4837,6 +4837,7 @@ imageTrace Outline Kontur @msg no action set to save brak zestawu operacji do zapisania @msg the action set file can't be read in full nie można odczytać całego pliku zestawu operacji @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Wczytano „{name}”: pominięto {n} krok|Wczytano „{name}”: pominięto {n} kroki|Wczytano „{name}”: pominięto {n} kroków +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Wczytano „{name}”: {n} krok ma nieznane polecenie i został zachowany: „{action}”, krok {step}, `{command}`|Wczytano „{name}”: {n} kroki mają nieznane polecenia i zostały zachowane; pierwszy: „{action}”, krok {step}, `{command}`|Wczytano „{name}”: {n} kroków ma nieznane polecenia i zostało zachowanych; pierwszy: „{action}”, krok {step}, `{command}` @msg not an action set file to nie jest plik zestawu operacji @msg the action set file is larger than 8 MiB plik zestawu operacji jest większy niż 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: dokumentacja byłaby większa niż {MAX_BYTES} bajtów @@ -5080,6 +5081,7 @@ imageTrace Outline Kontur @msg tool shortcuts must be a single key (optionally with Shift) skróty narzędzi muszą być pojedynczym klawiszem (opcjonalnie z Shift) @msg truncated obcięty @msg unknown command `{0}` nieznane polecenie `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` krok {step} operacji „{action}” uruchamia nieznane polecenie `{command}` @msg unknown command `{0}`; did you mean `{1}`? nieznane polecenie `{0}`; czy chodziło o `{1}`? @msg unknown effect `{id}` nieznany efekt `{id}` @msg unknown format nieznany format diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 6006f84c90..71e997eb67 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -4162,6 +4162,7 @@ axis Both Ambos @msg no action set to save nenhum conjunto de ações para salvar @msg the action set file can't be read in full o arquivo de conjunto de ações não pode ser lido por inteiro @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out “{name}” carregado: {n} etapa foi omitida|“{name}” carregado: {n} etapas foram omitidas +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` “{name}” carregado: {n} etapa tem um comando desconhecido e foi mantida: “{action}”, etapa {step}, `{command}`|“{name}” carregado: {n} etapas têm comandos desconhecidos e foram mantidas; a primeira: “{action}”, etapa {step}, `{command}` @msg not an action set file não é um arquivo de conjunto de ações @msg the action set file is larger than 8 MiB o arquivo de conjunto de ações tem mais de 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: a referência teria mais de {MAX_BYTES} bytes @@ -4401,6 +4402,7 @@ axis Both Ambos @msg tool shortcuts must be a single key (optionally with Shift) os atalhos de ferramenta devem ser uma única tecla (opcionalmente com Shift) @msg truncated truncado @msg unknown command `{0}` comando desconhecido `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` a etapa {step} de “{action}” executa o comando desconhecido `{command}` @msg unknown command `{0}`; did you mean `{1}`? comando desconhecido `{0}`; você quis dizer `{1}`? @msg unknown effect `{id}` efeito desconhecido `{id}` @msg unknown format formato desconhecido diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index fd09504b42..27b940845f 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -4741,6 +4741,7 @@ axis Both Оба @msg no action set to save нет набора действий для сохранения @msg the action set file can't be read in full файл набора действий невозможно прочитать целиком @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Загружено «{name}»: пропущен {n} шаг|Загружено «{name}»: пропущено {n} шага|Загружено «{name}»: пропущено {n} шагов +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Загружено «{name}»: {n} шаг с неизвестной командой сохранён: «{action}», шаг {step}, `{command}`|Загружено «{name}»: {n} шага с неизвестными командами сохранены; первый: «{action}», шаг {step}, `{command}`|Загружено «{name}»: {n} шагов с неизвестными командами сохранены; первый: «{action}», шаг {step}, `{command}` @msg not an action set file это не файл набора действий @msg the action set file is larger than 8 MiB файл набора действий больше 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: справочник был бы больше {MAX_BYTES} байт @@ -4982,6 +4983,7 @@ axis Both Оба @msg tool shortcuts must be a single key (optionally with Shift) сочетания инструментов должны быть одной клавишей (необязательно с Shift) @msg truncated усечено @msg unknown command `{0}` неизвестная команда `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` шаг {step} действия «{action}» выполняет неизвестную команду `{command}` @msg unknown command `{0}`; did you mean `{1}`? неизвестная команда `{0}`; возможно, имелась в виду `{1}`? @msg unknown effect `{id}` неизвестный эффект `{id}` @msg unknown format неизвестный формат diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 4e7b7508ae..d925511b03 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -4605,6 +4605,7 @@ axis Both Båda @msg no action set to save ingen åtgärdsuppsättning att spara @msg the action set file can't be read in full filen med åtgärdsuppsättning kan inte läsas helt @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Läste in ”{name}”: {n} steg utelämnades|Läste in ”{name}”: {n} steg utelämnades +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Läste in ”{name}”: {n} steg har ett okänt kommando och behölls: ”{action}”, steg {step}, `{command}`|Läste in ”{name}”: {n} steg har okända kommandon och behölls; det första: ”{action}”, steg {step}, `{command}` @msg not an action set file inte en fil med åtgärdsuppsättning @msg the action set file is larger than 8 MiB filen med åtgärdsuppsättningen är större än 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: referensen skulle bli större än {MAX_BYTES} byte @@ -4839,6 +4840,7 @@ axis Both Båda @msg tool shortcuts must be a single key (optionally with Shift) kortkommandon för verktyg måste vara en enda tangent (eventuellt med Shift) @msg truncated avkortad @msg unknown command `{0}` okänt kommando `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` steg {step} i ”{action}” kör det okända kommandot `{command}` @msg unknown command `{0}`; did you mean `{1}`? okänt kommando `{0}`; menade du `{1}`? @msg unknown effect `{id}` okänd effekt `{id}` @msg unknown format okänt format diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 54b967701d..92557b6c96 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -2302,6 +2302,10 @@ const COUNTED_STATUS_MESSAGES: &[(&str, &str)] = &[ ("Downloaded 1 file", "Downloaded 2 files"), ("Exported 1 file to /out", "Exported 2 files to /out"), ("Loaded “Tidy”: 1 step was left out", "Loaded “Tidy”: 2 steps were left out"), + ( + "Loaded “Tidy”: 1 step has an unknown command and was kept: “Export”, step 4, `example.finish`", + "Loaded “Tidy”: 2 steps have unknown commands and were kept; the first: “Export”, step 4.2, `example.finish`", + ), ]; /// The link, font, export and action set status messages name a count of 1 in the singular and other counts in diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index ac23f62c74..abe5ae7c16 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4464,6 +4464,7 @@ axis Both Her İkisi @msg no action set to save kaydedilecek eylem seti yok @msg the action set file can't be read in full eylem seti dosyası tamamen okunamıyor @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out “{name}” yüklendi: {n} adım atlandı +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` “{name}” yüklendi: bilinmeyen komutlu {n} adım korundu; ilki: “{action}”, adım {step}, `{command}` @msg not an action set file bir eylem seti dosyası değil @msg the action set file is larger than 8 MiB eylem seti dosyası 8 MiB'den büyük @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: başvuru {MAX_BYTES} bayttan büyük olur @@ -4687,6 +4688,7 @@ axis Both Her İkisi @msg tool shortcuts must be a single key (optionally with Shift) araç kısayolları tek tuş olmalıdır (isteğe bağlı olarak Shift ile) @msg truncated kesik @msg unknown command `{0}` bilinmeyen komut `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` “{action}” eylemi, adım {step}: bilinmeyen `{command}` komutunu çalıştırıyor @msg unknown command `{0}`; did you mean `{1}`? bilinmeyen komut `{0}`; `{1}` mi demek istediniz? @msg unknown effect `{id}` bilinmeyen etki `{id}` @msg unknown format bilinmeyen format diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index ce8e8dcef6..0c78d9c359 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -4740,6 +4740,7 @@ axis Both Обидві @msg no action set to save немає набору дій для збереження @msg the action set file can't be read in full файл набору дій неможливо прочитати повністю @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Завантажено «{name}»: пропущено {n} крок|Завантажено «{name}»: пропущено {n} кроки|Завантажено «{name}»: пропущено {n} кроків +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Завантажено «{name}»: {n} крок із невідомою командою збережено: «{action}», крок {step}, `{command}`|Завантажено «{name}»: {n} кроки з невідомими командами збережено; перший: «{action}», крок {step}, `{command}`|Завантажено «{name}»: {n} кроків із невідомими командами збережено; перший: «{action}», крок {step}, `{command}` @msg not an action set file це не файл набору дій @msg the action set file is larger than 8 MiB файл набору дій більший за 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: довідник був би більшим за {MAX_BYTES} байтів @@ -4981,6 +4982,7 @@ axis Both Обидві @msg tool shortcuts must be a single key (optionally with Shift) поєднання інструментів має бути однією клавішею (необов’язково з Shift) @msg truncated усічено @msg unknown command `{0}` невідома команда `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` крок {step} дії «{action}» виконує невідому команду `{command}` @msg unknown command `{0}`; did you mean `{1}`? невідома команда `{0}`; можливо, ви мали на увазі `{1}`? @msg unknown effect `{id}` невідомий ефект `{id}` @msg unknown format невідомий формат diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 88d0185f95..2c98e16c73 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -5050,6 +5050,7 @@ theme Appearance Giao diện @msg no action set to save không có bộ hành động nào để lưu @msg the action set file can't be read in full không thể đọc hết tệp bộ hành động @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out Đã tải “{name}”: bỏ qua {n} bước +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` Đã tải “{name}”: giữ lại {n} bước có lệnh không xác định; bước đầu tiên: “{action}”, bước {step}, `{command}` @msg not an action set file không phải tệp bộ hành động @msg the action set file is larger than 8 MiB tệp bộ hành động lớn hơn 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: tài liệu tham khảo sẽ lớn hơn {MAX_BYTES} byte @@ -5490,6 +5491,7 @@ theme Appearance Giao diện @msg truncated bị cắt ngắn @msg Unembedded to {_1} Đã bỏ nhúng vào {_1} @msg unknown command `{0}` lệnh không xác định `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` bước {step} của “{action}” chạy lệnh không xác định `{command}` @msg unknown command `{0}`; did you mean `{1}`? lệnh không xác định `{0}`; ý bạn là `{1}`? @msg unknown effect `{id}` hiệu ứng không xác định `{id}` @msg unknown format định dạng không xác định diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 3a5f0ce687..f74c7e0fa5 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -4375,6 +4375,7 @@ imageTrace Outline 轮廓 @msg objects can't be nested more than 32 deep 对象的嵌套不能超过 32 层 @msg the SVG's elements are nested more than {0} deep SVG 的元素嵌套超过 {0} 层 @msg unknown command `{0}` 未知命令 `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` “{action}”的步骤 {step} 运行未知命令 `{command}` @msg unknown command `{0}`; did you mean `{1}`? 未知命令 `{0}`;您是否想输入 `{1}`? @msg `{what}` closes nothing `{what}` 没有可结束的内容 @msg `{what}` closes something it didn't open `{what}` 结束了并非由它开始的内容 @@ -4708,6 +4709,7 @@ imageTrace Outline 轮廓 @msg no action set to save 没有要存储的动作组 @msg the action set file can't be read in full 无法完整读取动作组文件 @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out 已载入“{name}”:已略过 {n} 个步骤 +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` 已载入“{name}”:保留了 {n} 个含未知命令的步骤;第一个:“{action}”,步骤 {step},`{command}` @msg not an action set file 不是动作组文件 @msg the action set file is larger than 8 MiB 动作组文件大于 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`:参考将大于 {MAX_BYTES} 字节 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index e2dd01a4de..5d8663d970 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -2116,6 +2116,7 @@ file-filter Templates 範本 @msg objects can't be nested more than 32 deep 物件的巢狀層級不能超過 32 層 @msg the SVG's elements are nested more than {0} deep SVG 的元素巢狀超過 {0} 層 @msg unknown command `{0}` 未知的指令 `{0}` +@msg step {step} of “{action}” runs the unknown command `{command}` 「{action}」的步驟 {step} 執行未知的指令 `{command}` @msg unknown command `{0}`; did you mean `{1}`? 未知的指令 `{0}`;您是指 `{1}` 嗎? @msg `{what}` closes nothing `{what}` 沒有可結束的內容 @msg `{what}` closes something it didn't open `{what}` 結束了並非由它開始的內容 @@ -2452,6 +2453,7 @@ file-filter Templates 範本 @msg no action set to save 沒有要儲存的動作組 @msg the action set file can't be read in full 無法完整讀取動作組檔案 @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out 已載入「{name}」:已略過 {n} 個步驟 +@msgplural Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`|Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}` 已載入「{name}」:保留了 {n} 個含未知指令的步驟;第一個:「{action}」,步驟 {step},`{command}` @msg not an action set file 不是動作組檔案 @msg the action set file is larger than 8 MiB 動作組檔案大於 8 MiB @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`:參考將大於 {MAX_BYTES} 位元組 diff --git a/crates/ui-egui/src/panels/actions.rs b/crates/ui-egui/src/panels/actions.rs index 1971834a07..610a1a61b3 100644 --- a/crates/ui-egui/src/panels/actions.rs +++ b/crates/ui-egui/src/panels/actions.rs @@ -84,6 +84,70 @@ impl Action { }) .collect() } + + /// The steps whose command `known` does not hold, in order, as (step index, the index of the + /// command in a `command.batch` step, command id). A `command.batch` step's own commands are + /// checked one by one, as playback runs them ([`Action::included_commands`]); a command of one + /// with no command id has the id "". With `included_only`, excluded steps are passed over. + pub(crate) fn unknown_commands<'a>( + &'a self, + known: &'a KnownCommands, + included_only: bool, + ) -> impl Iterator, &'a str)> + 'a { + self.steps.iter().enumerate().filter(move |(i, _)| !(included_only && self.excluded_steps.contains(i))).flat_map( + |(i, (command, params))| -> Vec<(usize, Option, &'a str)> { + match params.get("commands").and_then(Value::as_array) { + Some(steps) if command == "command.batch" => steps + .iter() + .enumerate() + .map(|(j, step)| (i, Some(j), step.get("command").and_then(Value::as_str).unwrap_or_default())) + .filter(|(_, _, id)| !known.has(id)) + .collect(), + _ if known.has(command) => vec![], + _ => vec![(i, None, command.as_str())], + } + }, + ) + } +} + +/// The command ids a step of an action can run now: the built-in engine commands, the commands the +/// installed plug-ins add, the View menu commands the app plays itself ([`crate::menus::plays_in_app`]) +/// and stops ([`STOP_STEP`]). +pub(crate) struct KnownCommands(std::collections::HashSet<&'static str>); + +impl KnownCommands { + /// The command ids known when it is called: a plug-in installed or removed later is not in it. + pub(crate) fn now() -> Self { + let engine = vectorcraft_engine::command_specs().iter().map(|c| c.id); + let plugins = vectorcraft_engine::cmd::plugin::command_specs().into_iter().map(|c| c.id); + Self(engine.chain(plugins).chain([STOP_STEP]).collect()) + } + + /// Whether a step can run command `id`. + pub(crate) fn has(&self, id: &str) -> bool { + self.0.contains(id) || crate::menus::plays_in_app(id) + } +} + +/// The one-based place of a step that [`Action::unknown_commands`] gives: `3` for the third step, +/// `3.2` for the second command of a `command.batch` third step. +pub(crate) fn step_place(step: usize, in_batch: Option) -> String { + match in_batch { + Some(j) => format!("{}.{}", step + 1, j + 1), + None => (step + 1).to_string(), + } +} + +/// `text` as a status message shows it: control characters become `�`, and text past 80 +/// characters ends in `…`. +pub(crate) fn shown_text(text: &str) -> String { + const MAX: usize = 80; + let mut shown: String = text.chars().take(MAX).map(|c| if c.is_control() { '\u{fffd}' } else { c }).collect(); + if text.chars().nth(MAX).is_some() { + shown.push('…'); + } + shown } /// An action id no other action in this run has. @@ -222,7 +286,10 @@ pub fn default_sets() -> Vec { /// Accelerated runs every included step at once as a single undoable batch → what `command.batch` /// returns, {results}. Step by Step and Pause For run the first step now, each as its own undo step, /// and leave the rest to [`tick_playback`] → {results: [the first step's result], pending: the steps -/// left}. While a paced playback is in progress, another action does not play. +/// left}. While a paced playback is in progress, another action does not play. An action with an +/// included step whose command is not known now ([`KnownCommands`]), a plug-in's command after the +/// plug-in was removed for one, does not play: the error names the first such step and its command, +/// and no step runs. An excluded step is not checked. /// /// An action with an included stop ([`STOP_STEP`]) plays up to the stop and waits there at any speed /// ([`continue_playback`]). At Accelerated, the steps between two stops are one undo step. → {results: @@ -240,6 +307,13 @@ pub fn play(app: &mut VectorcraftApp, set: usize, idx: usize) -> Result Result { /// Actions… would write as a file Load Actions… refuses (larger than 8 MiB, as a file with less /// white space or a name that gets a number can give) is refused too, and no set is added. /// +/// A step whose command is not known now ([`super::KnownCommands`]), excluded or not, and a command +/// of a `command.batch` step that is not, still loads as it is. The answer then also lists them, +/// and the status bar names the first and how many there are → `{…, unknownCommands: [{action, +/// actionIndex, step, stepIndex, batchStep?, command}] (at most 1,000), unknownCount: n}`. +/// /// An action set another app saved as text (`.aia`, read with `actionSet.read`) comes in with its /// actions and the steps that stand for a VectorCraft command ([`step_name`], [`step_commands`]), /// with no params; a step that is off in the file is excluded from playback. A set with no name is @@ -506,7 +512,47 @@ pub fn load_set(app: &mut VectorcraftApp, p: &Value) -> Result { set.name = free_set_name(&app.ui.action_sets, &set.name); // A number added to the name can make a file at the limit larger than it. super::edit_keeps_set_loadable(app, None, &set)?; + let (unknown, unknown_count, first) = unknown_commands(&set); let (name, actions) = (set.name.clone(), set.actions.len()); app.ui.action_sets.push(set); - Ok(json!({ "set": app.ui.action_sets.len() - 1, "name": name, "actions": actions })) + let mut answer = json!({ "set": app.ui.action_sets.len() - 1, "name": name, "actions": actions }); + if let Some((action, step, command)) = first { + app.status(crate::i18n::msg_n( + unknown_count as u64, + "Loaded “{name}”: {n} step has an unknown command and was kept: “{action}”, step {step}, `{command}`", + "Loaded “{name}”: {n} steps have unknown commands and were kept; the first: “{action}”, step {step}, `{command}`", + &[ + ("name", &super::shown_text(&name)), + ("action", &super::shown_text(&action)), + ("step", &step), + ("command", &super::shown_text(&command)), + ], + )); + answer["unknownCommands"] = json!(unknown); + answer["unknownCount"] = json!(unknown_count); + } + Ok(answer) +} + +/// The steps of `set` whose command is not known now ([`super::KnownCommands`]), excluded steps +/// included: the first [`MAX_SKIPPED`] as `[{action, actionIndex, step, stepIndex, batchStep?, +/// command}]` (`step` and `batchStep` count from 1, the indexes from 0), how many there are, and the +/// first one's action name, place ([`super::step_place`]) and command. +fn unknown_commands(set: &ActionSet) -> (Vec, usize, Option<(String, String, String)>) { + let known = super::KnownCommands::now(); + let (mut listed, mut count, mut first) = (vec![], 0usize, None); + for (a, action) in set.actions.iter().enumerate() { + for (step, in_batch, command) in action.unknown_commands(&known, false) { + count += 1; + first.get_or_insert_with(|| (action.name.clone(), super::step_place(step, in_batch), command.to_string())); + if listed.len() < MAX_SKIPPED { + let mut entry = json!({ "action": action.name, "actionIndex": a, "step": step + 1, "stepIndex": step, "command": command }); + if let Some(j) = in_batch { + entry["batchStep"] = json!(j + 1); + } + listed.push(entry); + } + } + } + (listed, count, first) } diff --git a/docs/mcp.md b/docs/mcp.md index 66c4cc0cff..3711621ddc 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3176,7 +3176,13 @@ already walks Image Trace. Short agent entry points: written, and the command returns the same error as a load of such a file. `ui.actionSet.load {path? | data?}` reads the file at `path`, else a picked one, or the file's text `data`, adds its set after the other sets and returns `{set, name, actions}`. A set named like one already in the panel gets the next free number (`Print 2`), and the - other sets and the current set stay as they are. An action set file (`.vcactions`) is JSON: + other sets and the current set stay as they are. A step whose command is not a built-in command, a command of an + installed plug-in, a View menu step or a stop, and such a command of a `command.batch` step, loads as it is, excluded + or not, and `ui.actionSet.save` writes it back. The answer then also has `unknownCommands: [{action, actionIndex, step, + stepIndex, batchStep?, command}]`, the first 1,000 such steps (`step` and `batchStep` count from 1, `actionIndex` and + `stepIndex` from 0, and `batchStep` is the command's place in a `command.batch` step), and `unknownCount`, how many + there are; the status bar names the first and the count, with control characters replaced and long names cut at 80 + characters. These are VectorCraft's own rules. An action set file (`.vcactions`) is JSON: `{"format": "vcactions", "version": 1 to 6, "name", "actions": [{"name", "steps": [{"command", "params", "excluded"?}]}]}`, each step a command id and its params as `command.batch` takes them, or a stop: the command `action.stop` with `{message, allowContinue}`. A Select Object step is the command `select.byNote` with `{note, caseSensitive, @@ -3255,8 +3261,12 @@ already walks Image Trace. Short agent entry points: made active, or that document was closed), the playback ends with a status and the rest do not play; a step that makes another document active itself does not end it. A name that no action has, or that more than one action in the sets looked in has, or whose every step is excluded, is an error, and - then nothing plays. So is an action played while another is still playing at Step by Step or Pause For. A - `command.batch` step, which an action played or a panel operation run as one batch records, plays as its own steps, + then nothing plays. So is an action played while another is still playing at Step by Step or Pause For. So is an + action with an included step whose command is not a built-in command, a command of an installed plug-in, a View menu + step or a stop at the time it plays, at every speed: the error names the first such step, as in step 2 of “Print” + runs the unknown command `example.finish`, and a command of a `command.batch` step by its place in the batch, as in + step 2.3. An excluded step is not checked. + A `command.batch` step, which an action played or a panel operation run as one batch records, plays as its own steps, here and in Batch…. An action with an included stop plays up to the stop at any speed and then waits, with its message box open, until `ui.action.continue` or `ui.action.stop`. At Accelerated the steps between two stops are one undoable batch each. The result is then `{results, pending, atStop?}`, with `atStop: true` when the action already diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 9a9b0d06ed..55b89a0cc5 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -751,6 +751,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Batch…: Override Save and Override Export name each file with the extension of the format the step writes, however the step spells the format (`.svg` and `SVG` give `.svg`, `png8` gives `.png`), in `action.batch`. - Batch…: Override Export writes the files of an Export for Screens or Export Assets step into a folder for each source file or data set inside the destination folder, under the names the export gives them (`action.batch`). The folder and file names drop trailing periods and spaces (`a..svg` gives `a`). When two source files would get the same name that way (compared without case), or a later file's folder or file would take the name of an output an earlier file wrote, of a source file in the destination folder or, for data sets, of a file already there, Batch adds `-2`, `-3`… to the later one's name. - Actions panel menu: Save Actions… writes the current action set with all its actions to a file, and Load Actions… adds the set from such a file to the panel ([Manage a set of actions](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/manage-a-set-of-actions.html); `ui.actionSet.save`, `ui.actionSet.load`). The file is VectorCraft's own action set file (`.vcactions`); a loaded set named like one in the panel gets the next free number. + - Actions panel menu: Load Actions… keeps a step whose command this build or its installed plug-ins do not have, and reports each one when the set loads: the `ui.actionSet.load` answer lists the action, step and command id (`unknownCommands`, `unknownCount`), and the status bar names the first and the count. An action with such a step included does not play, and the error names the step and its id before any step runs; an excluded one does not stop it. These are VectorCraft's own rules. Tests `panels::actions::tests::{load_actions_reports_steps_with_unknown_commands, load_actions_bounds_what_it_reports_of_unknown_commands, an_action_with_an_unknown_command_does_not_play}`. - Actions panel menu: Load Actions… also reads action sets saved as `.aia` files ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html); `actionSet.read`, `ui.actionSet.load`). VectorCraft's own rules: the set comes in with all its actions. A step with a label and no recorded values comes in as the one menu command with the step's label, when that command is directly in a top menu, is what its menu bar item runs with no values and opens no dialog. A step that is off in the file stays excluded from playback. The other steps, recorded menu items included, are left out, and the status bar says how many. - Actions panel: the panel menu's Action Options… renames the selected action and keeps its steps ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html): the menu item opens a dialog that renames the action or gives it a function key and color; `ui.action.options`). It also sets the action's function key and color. - Actions panel: Create New Action (bottom bar) and the panel menu's New Action… ask for the new action's name, set, function key and color, and Record adds the action and starts recording into it ([Create new actions](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/record-actions.html): the New Action dialog takes the action's name and the set it goes in; `ui.action.new`, `ui.action.play`). The function key (F1 to F15, with Ctrl or Command and Shift) plays the action. An action's function key plays the action even when a command has the same shortcut, and the command keeps it. VectorCraft's own rules, which the page does not cover: when several actions have the same key the first in panel order plays; a copied action has no key; New Action does not open while an action is recording. The color is kept with the action for Button Mode, which VectorCraft does not have yet. From 4129587abee1c7a80162129211e5f8e9c04570a2 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 15:22:55 -0800 Subject: [PATCH 005/108] Graphs: recolor, stroke and gradient edits on labels are kept for their kind A recolor of a graph (Invert and Complement on the proxy, the Edit Colors commands, Recolor Artwork, the color filters, Apply Nearest Swatch and the ink limit of Print Ink Fixes) stored the new paint of the series marks but not of the labels. stroke.set, the stroke weight steps, the gradient edits, Swap Fill and Stroke and Default Fill and Stroke stored nothing when they changed a label's characters. When the graph was drawn again, the labels went back to their stored style. - These commands now store, for every label of the kind they reach, the label's object rows when they change, and the fill, stroke, stroke weight, caps, joins, miter limit, dashes and stroke alignment of its characters when all of them show the change alike. - A gradient is stored without its placement, and each label fits it to its own box. A stroke weight and dashes are stored as a scaled label shows them. - When labels of one kind change differently, the frontmost one sets what the kind keeps. - On a pie with Legends in Wedges, the legend labels' fill is stored only when every legend label reached ends up with the same fill, so a recolor of the whole pie leaves them black or white by their wedge. - Axis lines, ticks and radar rings are not stored and are drawn again with their default paint. Docs: docs/mcp.md, the commands' params text, docs/target-app-parity.md. --- crates/engine/src/cmd/addons/color.rs | 6 +- crates/engine/src/cmd/appearance.rs | 15 +- crates/engine/src/cmd/colorcmds.rs | 10 +- crates/engine/src/cmd/freeform.rs | 2 +- crates/engine/src/cmd/gradient.rs | 4 +- crates/engine/src/cmd/graph.rs | 7 +- crates/engine/src/cmd/graph/generate.rs | 5 +- crates/engine/src/cmd/graph/series.rs | 165 ++++++++++++++++- crates/engine/src/cmd/graph/tests.rs | 237 ++++++++++++++++++++++++ crates/engine/src/cmd/paint.rs | 12 +- crates/engine/src/cmd/recolor.rs | 2 +- crates/engine/src/cmd/stroke.rs | 4 +- docs/mcp.md | 13 +- docs/target-app-parity.md | 2 +- 14 files changed, 443 insertions(+), 41 deletions(-) diff --git a/crates/engine/src/cmd/addons/color.rs b/crates/engine/src/cmd/addons/color.rs index fa8182c4c2..8701d379f7 100644 --- a/crates/engine/src/cmd/addons/color.rs +++ b/crates/engine/src/cmd/addons/color.rs @@ -43,7 +43,7 @@ pub fn specs() -> Vec { "Apply as Filter", ["Object", "Plug-ins", "Color Effects"], None, - "{effect: a colour adjustment's effect id (adjust.brightnessContrast, adjust.curves, adjust.hueSaturation, adjust.levels, adjust.shiftToColor, adjust.temperatureTint, addon.color.exposure, addon.color.desaturate, addon.color.duotone or addon.color.invert), params?: {…} (as effect.apply; missing keys take the dialog defaults), fill?: true, stroke?: true, includeImages?: true, includePatterns?: true, ids?: [id…] (default: the selection)} recolour the objects and everything inside them as the live effect would draw them, but in their colours, as edit.colors.invert does (fills, strokes, type, gradient meshes, embedded images and pattern tiles), as one undo step; their effects stay. Duotone links a colour to its one tone's swatch as the live effect does. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke (docs/mcp.md) → {changed}", + "{effect: a colour adjustment's effect id (adjust.brightnessContrast, adjust.curves, adjust.hueSaturation, adjust.levels, adjust.shiftToColor, adjust.temperatureTint, addon.color.exposure, addon.color.desaturate, addon.color.duotone or addon.color.invert), params?: {…} (as effect.apply; missing keys take the dialog defaults), fill?: true, stroke?: true, includeImages?: true, includePatterns?: true, ids?: [id…] (default: the selection)} recolour the objects and everything inside them as the live effect would draw them, but in their colours, as edit.colors.invert does (fills, strokes, type, gradient meshes, embedded images and pattern tiles), as one undo step; their effects stay. Duotone links a colour to its one tone's swatch as the live effect does. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke, and on a graph label the new paint of its characters and rows for every label of its kind (docs/mcp.md) → {changed}", has_selection, filter ), @@ -52,7 +52,7 @@ pub fn specs() -> Vec { "Print Ink Fixes", ["Object", "Plug-ins", "Color Effects"], None, - "{scope?: \"selection\" (the selection, or `ids`; by default, the document while nothing is selected) | \"document\" (every layer), inkLimit?: total ink % 1..400 (0 or left out: off), excludePureBlack?: true (black-only and grey colours keep their ink), removeWhiteOverprint?: false (white fills and strokes stop overprinting), overprintBlack?: black % 1..100 (black-only and grey fills and strokes this dark or darker overprint, as edit.colors.overprintBlack; 0 or left out: off), textOnly?: false (Overprint Black on type only), fill?: true, stroke?: true, ids?: [id…]} prepare a CMYK document's inks for print as one undo step: CMYK colours (solid, gradient stops, gradient meshes) with more total ink than inkLimit are scaled down to it (colours of spot swatches and Registration stay), white overprint is removed and black overprint set. Refused in RGB documents (File › Document Color Mode › CMYK Color first). On a path directly in a graph series, the graph also stores a paint the ink limit changes on the topmost visible fill or stroke (docs/mcp.md) → {changed, inkLimited: paints and meshes scaled, whiteOverprintRemoved: objects, blackOverprinted: objects}", + "{scope?: \"selection\" (the selection, or `ids`; by default, the document while nothing is selected) | \"document\" (every layer), inkLimit?: total ink % 1..400 (0 or left out: off), excludePureBlack?: true (black-only and grey colours keep their ink), removeWhiteOverprint?: false (white fills and strokes stop overprinting), overprintBlack?: black % 1..100 (black-only and grey fills and strokes this dark or darker overprint, as edit.colors.overprintBlack; 0 or left out: off), textOnly?: false (Overprint Black on type only), fill?: true, stroke?: true, ids?: [id…]} prepare a CMYK document's inks for print as one undo step: CMYK colours (solid, gradient stops, gradient meshes) with more total ink than inkLimit are scaled down to it (colours of spot swatches and Registration stay), white overprint is removed and black overprint set. Refused in RGB documents (File › Document Color Mode › CMYK Color first). On a path directly in a graph series, the graph also stores a paint the ink limit changes on the topmost visible fill or stroke, and on a graph label the new paint of its characters and rows for every label of its kind (docs/mcp.md) → {changed, inkLimited: paints and meshes scaled, whiteOverprintRemoved: objects, blackOverprinted: objects}", has_doc, print_fixes::run ), @@ -70,7 +70,7 @@ pub fn specs() -> Vec { "Apply Nearest Swatch", ["Object", "Plug-ins", "Color Effects"], None, - "{library?: as addon.color.nearestSwatch (default: \"document\"), fill?: true, stroke?: true, ids?: [id…] (default: the selection)} give each solid colour and gradient stop of the selected objects' fills and strokes (their type's and those of the objects inside them; gradient meshes too) the colour of its nearest swatch in the library, as addon.color.nearestSwatch finds it, as one undo step: a global or spot swatch's colour links to it. A library's swatches the colours take are added to the document's first, as swatch.library.add adds them (a spot colour stays spot); images and patterns keep their colours. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke (docs/mcp.md) → {changed: paints changed, swatches: [the document swatches the colours took], added: [swatches added to the document]}", + "{library?: as addon.color.nearestSwatch (default: \"document\"), fill?: true, stroke?: true, ids?: [id…] (default: the selection)} give each solid colour and gradient stop of the selected objects' fills and strokes (their type's and those of the objects inside them; gradient meshes too) the colour of its nearest swatch in the library, as addon.color.nearestSwatch finds it, as one undo step: a global or spot swatch's colour links to it. A library's swatches the colours take are added to the document's first, as swatch.library.add adds them (a spot colour stays spot); images and patterns keep their colours. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke, and on a graph label the new paint of its characters and rows for every label of its kind (docs/mcp.md) → {changed: paints changed, swatches: [the document swatches the colours took], added: [swatches added to the document]}", has_selection, nearest::apply ), diff --git a/crates/engine/src/cmd/appearance.rs b/crates/engine/src/cmd/appearance.rs index e30ba811d4..7395db5cea 100644 --- a/crates/engine/src/cmd/appearance.rs +++ b/crates/engine/src/cmd/appearance.rs @@ -508,9 +508,11 @@ fn require_targets(s: &Session, p: &Value, cmd: &str) -> Result> { /// One undo step (`label`) running `f` on each of `ids` with the item a fill (`fill`) or stroke /// edit aimed at `item` changes there (`None`: the topmost one; text then edits its characters). -/// What the edit changes on the topmost visible fill and stroke of graph series marks is stored on -/// their graphs in the same step ([`capture_series_changes`]). Nothing targeted is not an edit, and -/// when `f` leaves every target as it was, the document and its undo history stay as they are. +/// What the edit changes on the topmost visible fill and stroke of graph series marks, and on the +/// rows and characters of graph labels, is stored on their graphs in the same step +/// ([`capture_series_changes`], [`super::graph::capture_label_changes`]). Nothing targeted is not +/// an edit, and when `f` leaves every target as it was, the document and its undo history stay as +/// they are. pub(crate) fn edit_items( s: &mut Session, ids: &[NodeId], @@ -520,7 +522,12 @@ pub(crate) fn edit_items( fill: bool, f: impl FnMut(&mut Node, Option) -> Result<()>, ) -> Result<()> { - edit_items_then(s, ids, item, cmd, label, fill, f, |before, d, edited| Ok(capture_series_changes(before, d, edited))) + edit_items_then(s, ids, item, cmd, label, fill, f, |before, d, edited| { + let series = capture_series_changes(before, d, edited); + // The rows `f` edited are kept by `edit_items_then`. + let labels = super::graph::capture_label_changes(before, d, edited, false); + Ok(series || labels) + }) } /// [`edit_items`], then `after` on the document as it was before the edit, the edited document and diff --git a/crates/engine/src/cmd/colorcmds.rs b/crates/engine/src/cmd/colorcmds.rs index 6de2fbf9a2..7ad53d5bf5 100644 --- a/crates/engine/src/cmd/colorcmds.rs +++ b/crates/engine/src/cmd/colorcmds.rs @@ -36,7 +36,7 @@ pub fn specs() -> Vec { "Invert Colors", ["Edit", "Edit Colors"], None, - "{fill?: true, stroke?: true, includeImages?: true, includePatterns?: true, ids?} replace each colour by its RGB inverse (keeps the colour model) in fills, strokes, text, gradient meshes (with fills), colorized image fills (their pixels stay unchanged), other embedded images (a recoloured copy) and pattern tiles (a new pattern swatch; the original stays), as one undo step. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke (docs/mcp.md) → {changed, notChanged: {locked, hidden} (when the selection is everything select.all takes: the locked and hidden objects it left out whose colors would have changed; an object both hidden and locked counts as hidden), warning?: set when notChanged counts any object}", + "{fill?: true, stroke?: true, includeImages?: true, includePatterns?: true, ids?} replace each colour by its RGB inverse (keeps the colour model) in fills, strokes, text, gradient meshes (with fills), colorized image fills (their pixels stay unchanged), other embedded images (a recoloured copy) and pattern tiles (a new pattern swatch; the original stays), as one undo step. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke, and on a graph label the new paint of its characters and rows for every label of its kind (docs/mcp.md) → {changed, notChanged: {locked, hidden} (when the selection is everything select.all takes: the locked and hidden objects it left out whose colors would have changed; an object both hidden and locked counts as hidden), warning?: set when notChanged counts any object}", has_selection, |s, p| recolor(s, p, "edit.colors.invert", "Invert Colors", &invert) ), @@ -486,14 +486,16 @@ fn run_pass(s: &mut Session, p: &Value, cmd: &str, label: &str, pass: Recolor) - } /// Run `recolor` on `d` (it returns how many objects it changed) over `roots`, then store on their graphs what it changed -/// on the graph series marks among `roots` and inside them, so the marks keep their new paint when the graph is drawn -/// again. +/// on the graph series marks and graph labels among `roots` and inside them, so the marks and every label of a kind keep +/// their new paint when the graph is drawn again. pub(crate) fn keeping_series_paint(d: &mut Document, roots: &[NodeId], recolor: impl FnOnce(&mut Document) -> Result) -> Result { let marks = super::graph::series_marks_in(d, roots); - let before = (!marks.is_empty()).then(|| d.clone()); + let labels = super::graph::labels_in(d, roots); + let before = (!marks.is_empty() || !labels.is_empty()).then(|| d.clone()); let n = recolor(d)?; if let Some(before) = before.filter(|_| n > 0) { super::appearance::capture_series_changes(&before, d, &marks); + super::graph::capture_label_changes(&before, d, &labels, true); } Ok(n) } diff --git a/crates/engine/src/cmd/freeform.rs b/crates/engine/src/cmd/freeform.rs index bdba729211..5f2a5e4070 100644 --- a/crates/engine/src/cmd/freeform.rs +++ b/crates/engine/src/cmd/freeform.rs @@ -19,7 +19,7 @@ pub fn specs() -> Vec { "Add Freeform Point", [], None, - "{at: [x,y] (document coordinates), color? (default: the gradient's colour there; #rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), opacity?: 0..1 (or 0..100), spread?: 0..1 (or 0..100 %; the radius of pure colour around the point, a fraction of half the object's larger side; default 0), line?: true (join it to the selected point: extends the line ending there, else starts one), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), target?: \"object\"|\"contents\"} add a point to the freeform gradient (an unplaced one keeps its automatic points first) and select it. On a path directly in a graph series, the graph also stores the edited gradient when it is on the topmost visible fill or stroke, as for the other paint.freeform edits (docs/mcp.md); on a graph label's row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind → {index}", + "{at: [x,y] (document coordinates), color? (default: the gradient's colour there; #rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill), opacity?: 0..1 (or 0..100), spread?: 0..1 (or 0..100 %; the radius of pure colour around the point, a fraction of half the object's larger side; default 0), line?: true (join it to the selected point: extends the line ending there, else starts one), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), target?: \"object\"|\"contents\"} add a point to the freeform gradient (an unplaced one keeps its automatic points first) and select it. On a path directly in a graph series, the graph also stores the edited gradient when it is on the topmost visible fill or stroke, as for the other paint.freeform edits (docs/mcp.md); on a graph label's row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind; the points on a label's characters are not stored → {index}", has_doc, add_point ), diff --git a/crates/engine/src/cmd/gradient.rs b/crates/engine/src/cmd/gradient.rs index 54ca07da7e..8062d6110a 100644 --- a/crates/engine/src/cmd/gradient.rs +++ b/crates/engine/src/cmd/gradient.rs @@ -24,7 +24,7 @@ pub fn specs() -> Vec { "Gradient", ["Window", "Gradient"], None, - "{stroke?: bool (default: the targeted item's kind, else the active proxy), kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical, sweeps the stops once around the center, clockwise from the vector, with a seam where the last stop meets the first; diamond runs the stops from the center out to a square with a corner at the end of the vector; freeform places points on each object, coloured along the stops), mode?: points|lines (freeform: how the Gradient tool adds points), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (how the colours between the stops mix: in display RGB, perceptually (OKLab) so the steps look even, or around the hue wheel: hue, saturation and brightness each change evenly from one stop to the next, the hue angle falling with hue-clockwise (red, magenta, blue, cyan, green, yellow) and rising with hue-counterclockwise; two stops whose hues are less than half a color level apart keep that hue; a stop whose RGB numbers are less than half a color level apart is gray and takes the hue of the stop it mixes with, and black that stop's saturation too; these two methods are VectorCraft's own, and SVG and PDF exports draw their gradients as RGB images, CMYK and spot color stops included; SVG exports draw a Perceptual gradient as an image, and PDF exports do too unless it is linear, radial, conic or diamond, has spot color stops, every other stop is paper white or written in CMYK or gray (an export that converts colors to a CMYK destination profile writes RGB and Lab stops in CMYK, and so does a CMYK document unless the export converts colors to an RGB destination profile), it is not a dithered fill and its curve does not have too many stops: then PDF writes tints of one spot ink as a Separation shading in that ink, and spot inks mixed with other spot, CMYK or gray inks as a DeviceN shading; freeform gradients mix their own way), spread?: pad|repeat|reflect (linear, radial, conic and diamond: what the gradient paints past the ends of its stops: pad carries the end colors on; repeat and reflect run the stops `repeats` times along the vector (around the circle, for a conic) and on past both ends, reflect mirroring every other run; an error on a freeform gradient), repeats?: 1..100 (a whole number: how many times repeat and reflect run the stops along the vector; VectorCraft's own limit; pad keeps it unused), stops?: [{offset 0..1, color? (needed without swatch; #rrggbbaa and #rgba are refused), opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: colour swatch name (a global or spot colour or tint swatch links the stop, so swatch edits recolour it and a spot stop prints on its plate; a process colour just gives its colour), tint?: 0..100 (% of the linked swatch; default 100, or a tint swatch's own)}] (at least 2; a freeform gradient's points are recoloured along them), keepModel?: bool (as paint.setFill; a stop color the gradient already has keeps its model), angle?: deg counter-clockwise (0: the gradient runs left to right; radial, conic and diamond: the vector turns about the center), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep and is an error for the other kinds), reverse?: bool (the same ramp the other way round: the stops in reverse order, and a hue method turned the other way unless `method` is given too), dither?: bool (fills only: a linear, radial, conic or diamond gradient fill is drawn with fine noise that hides banding, and as pixels in SVG and PDF exports), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), ids?|id?, strokeMode?: within|along|across (strokes only: the gradient lies on the page and shows through the stroke, runs from the start of each subpath to its end, or runs from the stroke's left edge to its right all along it; with nothing selected, for the next object drawn; type characters' own strokes always paint within), target?: \"object\"|\"contents\"} edit the gradient in place (keeps its placement); solid/none paints become the default gradient. On a path directly in a graph series, the graph also stores the gradient when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind", + "{stroke?: bool (default: the targeted item's kind, else the active proxy), kind?: linear|radial|conic|diamond|freeform (conic, also accepted as angle or conical, sweeps the stops once around the center, clockwise from the vector, with a seam where the last stop meets the first; diamond runs the stops from the center out to a square with a corner at the end of the vector; freeform places points on each object, coloured along the stops), mode?: points|lines (freeform: how the Gradient tool adds points), method?: classic|perceptual|hue-clockwise|hue-counterclockwise (how the colours between the stops mix: in display RGB, perceptually (OKLab) so the steps look even, or around the hue wheel: hue, saturation and brightness each change evenly from one stop to the next, the hue angle falling with hue-clockwise (red, magenta, blue, cyan, green, yellow) and rising with hue-counterclockwise; two stops whose hues are less than half a color level apart keep that hue; a stop whose RGB numbers are less than half a color level apart is gray and takes the hue of the stop it mixes with, and black that stop's saturation too; these two methods are VectorCraft's own, and SVG and PDF exports draw their gradients as RGB images, CMYK and spot color stops included; SVG exports draw a Perceptual gradient as an image, and PDF exports do too unless it is linear, radial, conic or diamond, has spot color stops, every other stop is paper white or written in CMYK or gray (an export that converts colors to a CMYK destination profile writes RGB and Lab stops in CMYK, and so does a CMYK document unless the export converts colors to an RGB destination profile), it is not a dithered fill and its curve does not have too many stops: then PDF writes tints of one spot ink as a Separation shading in that ink, and spot inks mixed with other spot, CMYK or gray inks as a DeviceN shading; freeform gradients mix their own way), spread?: pad|repeat|reflect (linear, radial, conic and diamond: what the gradient paints past the ends of its stops: pad carries the end colors on; repeat and reflect run the stops `repeats` times along the vector (around the circle, for a conic) and on past both ends, reflect mirroring every other run; an error on a freeform gradient), repeats?: 1..100 (a whole number: how many times repeat and reflect run the stops along the vector; VectorCraft's own limit; pad keeps it unused), stops?: [{offset 0..1, color? (needed without swatch; #rrggbbaa and #rgba are refused), opacity? 0..1 (or 0..100), midpoint? 0.13..0.87, swatch?: colour swatch name (a global or spot colour or tint swatch links the stop, so swatch edits recolour it and a spot stop prints on its plate; a process colour just gives its colour), tint?: 0..100 (% of the linked swatch; default 100, or a tint swatch's own)}] (at least 2; a freeform gradient's points are recoloured along them), keepModel?: bool (as paint.setFill; a stop color the gradient already has keeps its model), angle?: deg counter-clockwise (0: the gradient runs left to right; radial, conic and diamond: the vector turns about the center), aspect?: % (radial, conic and diamond; a negative one mirrors a conic's sweep and is an error for the other kinds), reverse?: bool (the same ramp the other way round: the stops in reverse order, and a hue method turned the other way unless `method` is given too), dither?: bool (fills only: a linear, radial, conic or diamond gradient fill is drawn with fine noise that hides banding, and as pixels in SVG and PDF exports), item?: fill/stroke item index|null (omitted: the Appearance panel's active item when it is of the edited kind), ids?|id?, strokeMode?: within|along|across (strokes only: the gradient lies on the page and shows through the stroke, runs from the start of each subpath to its end, or runs from the stroke's left edge to its right all along it; with nothing selected, for the next object drawn; type characters' own strokes always paint within), target?: \"object\"|\"contents\"} edit the gradient in place (keeps its placement); solid/none paints become the default gradient. On a path directly in a graph series, the graph also stores the gradient when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, and on its characters their gradient without its placement, fitted to each label", has_doc, edit_gradient ), @@ -33,7 +33,7 @@ pub fn specs() -> Vec { "Gradient Vector", [], None, - "{start?: [x,y], end?: [x,y] (document coordinates; both or neither: omitted, the vector stays), aspect?: % (radial, conic and diamond: the extent's height / width across the vector, a negative one mirroring a conic's sweep and an error for the other kinds; default: kept), focal?: [x,y] (document coordinates) | null (radial: the focal point, where the first stop sits, pulled inside the extent ellipse; null centres it; default: it keeps its place in the ellipse; an error on a conic or diamond gradient), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (alias: index; omitted: the Appearance panel's active item when it is of the edited kind), target?: \"object\"|\"contents\", index?: appearance item index (as item)} set the gradient vector, aspect ratio and focal point (solid paints become the default gradient; type objects set it on their runs, in text space). On a path directly in a graph series, the graph also stores the gradient with its placement when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, with the gradient fitted to each label", + "{start?: [x,y], end?: [x,y] (document coordinates; both or neither: omitted, the vector stays), aspect?: % (radial, conic and diamond: the extent's height / width across the vector, a negative one mirroring a conic's sweep and an error for the other kinds; default: kept), focal?: [x,y] (document coordinates) | null (radial: the focal point, where the first stop sits, pulled inside the extent ellipse; null centres it; default: it keeps its place in the ellipse; an error on a conic or diamond gradient), ids?|id?, stroke?: bool (default: the targeted item's kind, else the active proxy), item?: fill/stroke item index|null (alias: index; omitted: the Appearance panel's active item when it is of the edited kind), target?: \"object\"|\"contents\", index?: appearance item index (as item)} set the gradient vector, aspect ratio and focal point (solid paints become the default gradient; type objects set it on their runs, in text space). On a path directly in a graph series, the graph also stores the gradient with its placement when it is on the topmost visible fill or stroke (docs/mcp.md); on a graph label's row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, and on its characters their gradient without the placement this command sets, fitted to each label", has_doc, set_gradient_geom ), diff --git a/crates/engine/src/cmd/graph.rs b/crates/engine/src/cmd/graph.rs index e283afd752..0413a55dbb 100644 --- a/crates/engine/src/cmd/graph.rs +++ b/crates/engine/src/cmd/graph.rs @@ -45,9 +45,10 @@ use generate::generate; #[cfg(test)] use series::default_series_color; pub(crate) use series::{ - LabelTextChange, capture_label_anti_alias, capture_label_object_opacity, capture_label_paragraphs, capture_label_rows, capture_label_styles, - capture_label_text, capture_series_object_opacity, capture_series_opacity, capture_series_top_paints, label_object_opacity_differs, - paint_targets, series_group_marks, series_group_marks_where, series_marks_in, series_object_opacity_differs, shown_paint, + LabelTextChange, capture_label_anti_alias, capture_label_changes, capture_label_object_opacity, capture_label_paragraphs, capture_label_rows, + capture_label_styles, capture_label_text, capture_series_object_opacity, capture_series_opacity, capture_series_top_paints, + label_object_opacity_differs, labels_in, paint_targets, series_group_marks, series_group_marks_where, series_marks_in, + series_object_opacity_differs, shown_paint, }; #[cfg(test)] diff --git a/crates/engine/src/cmd/graph/generate.rs b/crates/engine/src/cmd/graph/generate.rs index a789304b24..60217105d8 100644 --- a/crates/engine/src/cmd/graph/generate.rs +++ b/crates/engine/src/cmd/graph/generate.rs @@ -6,7 +6,7 @@ use super::labels::{ recolour_text, runs, shadow_of, }; use super::markers::{MARKER_BUDGET, marker_cost, marker_designs}; -use super::series::{series_marks, with_series_opacity}; +use super::series::{picks_legend_fill, series_marks, with_series_opacity}; use super::{ Arc, BezPath, Color, Document, GraphKind, GraphSpec, Justify, Node, NodeKind, Paint, PathData, Point, Rect, TickLength, ValueAxisSide, shapes, }; @@ -397,8 +397,7 @@ impl<'a> Plot<'a> { let at = ring.centre + dir(mid) * (ring.hole + (ring.rad - ring.hole) * 0.62); let t = self.b.label(Role::Legend, Point::new(at.x, at.y + self.ls * 0.35), &label, Justify::Center, true); // White on a dark wedge, unless the legend labels were given a colour of their own. - let own_colour = self.g.label_styles.legend.as_ref().is_some_and(|st| st.fill != Paint::solid(Color::BLACK)); - self.wedge_labels.push(if dark && !own_colour { recolour_text(&t, Color::WHITE) } else { t }); + self.wedge_labels.push(if dark && picks_legend_fill(self.g) { recolour_text(&t, Color::WHITE) } else { t }); } /// The pie's category name. diff --git a/crates/engine/src/cmd/graph/series.rs b/crates/engine/src/cmd/graph/series.rs index bfde9e881a..806d95047f 100644 --- a/crates/engine/src/cmd/graph/series.rs +++ b/crates/engine/src/cmd/graph/series.rs @@ -487,20 +487,27 @@ pub(crate) fn capture_label_anti_alias(doc: &mut Document, ids: &[NodeId], metho pub(crate) fn capture_label_styles(doc: &mut Document, ids: &[NodeId], change: &dyn Fn(&mut CharStyle)) -> bool { let mut changed = false; for (graph, role) in label_kinds(doc, ids) { - let Some(spec) = doc.node_mut(graph).and_then(|n| n.extras_if_any().and_then(|e| e.graph.as_deref_mut())) else { continue }; - let mut style = label_style(&spec.label_styles, role); - change(&mut style); - let slot = match role { - Role::Value => &mut spec.label_styles.values, - Role::Category => &mut spec.label_styles.categories, - Role::Legend => &mut spec.label_styles.legend, - }; - changed |= slot.as_ref() != Some(&style); - *slot = Some(style); + changed |= store_label_style(doc, graph, role, change); } changed } +/// Apply `change` to the style graph `graph` keeps for its labels of kind `role` (or the default one). Returns whether +/// the kept style changed. +fn store_label_style(doc: &mut Document, graph: NodeId, role: Role, change: &dyn Fn(&mut CharStyle)) -> bool { + let Some(spec) = doc.node_mut(graph).and_then(|n| n.extras_if_any().and_then(|e| e.graph.as_deref_mut())) else { return false }; + let mut style = label_style(&spec.label_styles, role); + change(&mut style); + let slot = match role { + Role::Value => &mut spec.label_styles.values, + Role::Category => &mut spec.label_styles.categories, + Role::Legend => &mut spec.label_styles.legend, + }; + let changed = slot.as_ref() != Some(&style); + *slot = Some(style); + changed +} + /// Keep a paragraph change made to all of the text of graph labels `ids` (Paragraph, on the whole graph or on labels /// picked with Group Selection) for every label of their kind, as [`capture_label_styles`] does for character /// formats. Returns whether kept attributes changed, or the error `change` returns for the kept attributes. @@ -668,6 +675,144 @@ pub(crate) fn capture_label_text( Ok(changed) } +/// The character fill and stroke attributes a kind of graph label keeps when a recolor, or a stroke or gradient edit +/// aimed at the characters, changes them on its labels ([`capture_label_changes`]). Each entry copies one attribute +/// from the first style to the second and returns whether they differed. +const RUN_PAINT: [fn(&CharStyle, &mut CharStyle) -> bool; 8] = [ + |a, b| keep(&a.fill, &mut b.fill), + |a, b| keep(&a.stroke, &mut b.stroke), + |a, b| keep(&a.stroke_width, &mut b.stroke_width), + |a, b| keep(&a.stroke_cap, &mut b.stroke_cap), + |a, b| keep(&a.stroke_join, &mut b.stroke_join), + |a, b| keep(&a.stroke_miter_limit, &mut b.stroke_miter_limit), + |a, b| keep(&a.stroke_dash, &mut b.stroke_dash), + |a, b| keep(&a.stroke_align, &mut b.stroke_align), +]; + +/// Copy `from` to `to`. Returns whether they differed. +fn keep(from: &T, to: &mut T) -> bool { + let differs = from != to; + if differs { + to.clone_from(from); + } + differs +} + +/// The [`RUN_PAINT`] attributes an edit changed on the characters of graph label `now` (`was`: the label before the +/// edit), as the label's style and the indexes of the changed entries. An attribute counts only when every character +/// of the label shows it alike, and the fill only when `fill` is set. A placed gradient is kept without its placement, +/// so it fits each label it lands on. The stroke weight and dashes are kept as the label shows them: the graph draws its +/// labels again without the label's own scale. +fn run_paint_change(was: &Node, now: &Node, fill: bool) -> Option<(CharStyle, Vec)> { + let (NodeKind::Text(was), NodeKind::Text(now)) = (&was.kind, &now.kind) else { return None }; + let first_now = &now.runs.first()?.style; + // Changed: some character showed something else before the edit, whichever run it is in. + let changed: Vec = RUN_PAINT + .iter() + .enumerate() + .filter(|(i, copy)| { + (fill || *i != 0) + && now.runs.iter().all(|r| !copy(first_now, &mut r.style.clone())) + && was.runs.iter().any(|r| copy(first_now, &mut r.style.clone())) + }) + .map(|(i, _)| i) + .collect(); + if changed.is_empty() { + return None; + } + let unplaced = crate::cmd::gradient::unplaced; + let mut style = first_now.clone(); + (style.fill, style.stroke) = (unplaced(&style.fill), unplaced(&style.stroke)); + // Character strokes are drawn in text space, scaled by the type's transform. + if let Some(k) = vectorcraft_doc::Scaling::factor(now.xf).filter(|k| k.is_finite() && *k > 1e-12) { + let mut st = style.stroke_layer(); + crate::inspect::scale_layer(&mut st, k); + style.set_stroke_layer(&st); + } + Some((style, changed)) +} + +/// Does graph `g` pick the fill of its legend labels itself, white on a dark wedge and black on the others: a pie with +/// Legends in Wedges whose legend labels keep no fill of their own? +pub(super) fn picks_legend_fill(g: &GraphSpec) -> bool { + g.kind == GraphKind::Pie + && g.legend + && g.pie_legend_in_wedges + && !g.label_styles.legend.as_ref().is_some_and(|st| st.fill != Paint::solid(Color::BLACK)) +} + +/// The graph labels among `roots` and inside them, for an edit that reaches graph labels without naming them. +pub(crate) fn labels_in(doc: &Document, roots: &[NodeId]) -> Vec { + let mut texts = Vec::new(); + for id in roots { + let Some(root) = doc.node(*id) else { continue }; + root.walk(&mut |n| { + if matches!(n.kind, NodeKind::Text(_)) { + texts.push(n.id); + } + }); + } + // Graph labels are type: without type among `roots`, the graph's labels are not looked up. + if texts.is_empty() { + return texts; + } + let labels = graph_labels(doc); + texts.retain(|id| labels.contains_key(id)); + // Nested roots (a graph and one of its labels) reach a label twice. + texts.sort_unstable(); + texts.dedup(); + texts +} + +/// Keep for every label of their kind what an edit changed on graph labels `ids` (`before`: the document before the +/// edit): with `rows`, the object rows ([`capture_label_rows`]) of the labels whose rows changed, and the character fill +/// and stroke attributes ([`RUN_PAINT`]) that changed on all of a label's characters, on the kind's kept style. The +/// frontmost label of a kind sets what that kind keeps, whatever order `ids` are in. On a graph that colors its legend +/// labels itself ([`picks_legend_fill`]), their fill is kept only when the legend labels among `ids` end up with one +/// fill. Called inside the same edit, so they undo together. Returns whether what a graph keeps changed. +pub(crate) fn capture_label_changes(before: &Document, doc: &mut Document, ids: &[NodeId], rows: bool) -> bool { + if !ids.iter().any(|id| doc.node(*id).is_some_and(|n| matches!(n.kind, NodeKind::Text(_)))) { + return false; + } + let labels = graph_labels(doc); + let mut picked: Vec = ids.iter().copied().filter(|id| labels.contains_key(id)).collect(); + // A later label's capture replaces an earlier one's: take them in paint order, each once. + picked.sort_by_cached_key(|id| doc.index_path(*id)); + picked.dedup(); + let picks_fill = |graph: NodeId| doc.node(graph).and_then(|n| n.extras().graph.as_deref()).is_some_and(picks_legend_fill); + // On a pie that colors its legend labels black or white by their wedge, a recolor of the whole pie flips them both + // ways: their fill is kept only when every legend label the edit reached ends up with the same one. + let mut wedge_fills: HashMap> = HashMap::new(); + for id in &picked { + let (Some(&(graph, Role::Legend)), Some(NodeKind::Text(t))) = (labels.get(id), doc.node(*id).map(|n| &n.kind)) else { continue }; + if picks_fill(graph) { + wedge_fills.entry(graph).or_default().extend(t.runs.iter().map(|r| r.style.fill.clone())); + } + } + let one_fill = |graph: NodeId| wedge_fills.get(&graph).is_none_or(|f| f.windows(2).all(|w| w[0] == w[1])); + let mut changed_rows = Vec::new(); + let mut characters = Vec::new(); + for (id, kind) in picked.iter().filter_map(|id| Some((*id, *labels.get(id)?))) { + let (Some(was), Some(now)) = (before.node(id), doc.node(id)) else { continue }; + if rows && label_rows(was) != label_rows(now) { + changed_rows.push(id); + } + let fill = kind.1 != Role::Legend || one_fill(kind.0); + characters.extend(run_paint_change(was, now, fill).map(|change| (kind, change))); + } + let mut changed = capture_label_rows(doc, &changed_rows); + for ((graph, role), (style, entries)) in &characters { + changed |= store_label_style(doc, *graph, *role, &|st| { + for i in entries { + if let Some(copy) = RUN_PAINT.get(*i) { + copy(style, st); + } + } + }); + } + changed +} + /// The graphs and kinds of label among `ids`, each once. fn label_kinds(doc: &Document, ids: &[NodeId]) -> Vec<(NodeId, Role)> { if ids.is_empty() { diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index bcd6f406ed..a4bcb7e637 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -5480,6 +5480,243 @@ fn a_graphic_style_on_a_label_is_kept_for_its_kind() { assert!(rows_of(&looks, "0").0.iter().any(|(fill, hex, _, _)| *fill && hex == "#0080ff"), "{looks:?}"); } +/// The character style of the first run of label `text` in group `grp`. +fn label_run_style(s: &Session, id: NodeId, grp: &str, text: &str) -> CharStyle { + let NodeKind::Text(t) = label_node(s, id, grp, text).kind else { panic!("{text} is not type") }; + t.runs[0].style.clone() +} + +/// A recolor of the whole graph (Invert or Complement on the proxy, an Edit Colors command, a color filter or Recolor +/// Artwork) is kept for the characters and the rows of every kind of label when the graph is drawn again, and undo takes +/// it back with its edit. +#[test] +fn recoloring_a_graph_keeps_its_labels_paint_for_every_kind() { + let cases = [ + ("paint.invert", json!({})), + ("paint.complement", json!({})), + ("edit.colors.invert", json!({})), + ("edit.colors.toGrayscale", json!({})), + ("addon.color.filter", json!({"effect": "addon.color.invert"})), + ("recolor.apply", json!({"map": {"#3366cc": "#00ff00", "#ff8000": "#8000ff"}})), + ]; + every_case(cases, |(cmd, params)| { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + // Characters of every label in a color that every case changes, and an orange fill row on the category labels. + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + s.execute("paint.setFill", &json!({"color": "#3366cc"})).unwrap(); + let c = text_id(&s, id, "Axes", "Q2"); + s.execute("appearance.addFill", &json!({"ids": [c.0]})).unwrap(); + s.execute("appearance.setItem", &json!({"ids": [c.0], "index": 0, "color": "#ff8000"})).unwrap(); + let was = spec(&s, id).label_styles; + let mut p = params.clone(); + if *cmd == "recolor.apply" { + // Recolor Artwork works on the selection. + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + } else { + p["ids"] = json!([id.0]); + } + s.execute(cmd, &p).unwrap(); + let hex = |p: &Paint| p.color().map(|c| c.to_hex()).unwrap_or_default(); + let characters = hex(&label_run_style(&s, id, "Axes", "4").fill); + assert_ne!(characters, "#3366cc", "{cmd} recolors the characters"); + let row = label_node(&s, id, "Axes", "Q2").appearance.items[0].paint().clone(); + assert_ne!(hex(&row), "#ff8000", "{cmd} recolors the row"); + let looks = label_looks(&mut s, id); + for t in ["0", "Q1", "2024"] { + assert!(looks.iter().any(|(x, _, fill)| x == t && *fill == characters), "{cmd}: {t}: {looks:?}"); + } + let rows = redrawn_label_rows(&mut s, id); + assert_eq!(rows_of(&rows, "Q1").0.first().map(|r| r.1.clone()), Some(hex(&row)), "{cmd}: {rows:?}"); + // Undo takes back the recolor and what the graph keeps (the two redraws are undone first). + for _ in 0..3 { + s.execute("edit.undo", &json!({})).unwrap(); + } + assert_eq!(spec(&s, id).label_styles, was, "{cmd}"); + }); +} + +/// A recolor of one label changes what the graph keeps for that kind of label only. +#[test] +fn recoloring_one_label_keeps_its_paint_for_its_kind_only() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + let v = text_id(&s, id, "Axes", "4"); + s.execute("edit.colors.invert", &json!({"ids": [v.0]})).unwrap(); + let looks = label_looks(&mut s, id); + assert!(looks.iter().any(|(t, _, fill)| t == "0" && fill == "#ffffff"), "{looks:?}"); + assert!(looks.iter().any(|(t, _, fill)| t == "Q1" && fill == "#000000"), "{looks:?}"); + assert!(looks.iter().any(|(t, _, fill)| t == "2024" && fill == "#000000"), "{looks:?}"); + let g = spec(&s, id).label_styles; + assert!(g.categories.is_none() && g.legend.is_none(), "{g:?}"); +} + +/// A recolor that leaves a label's first characters as they were and gives the rest the same fill is kept for its kind. +#[test] +fn a_recolor_that_evens_out_a_labels_characters_is_kept_for_its_kind() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + let q2 = text_id(&s, id, "Axes", "Q2"); + s.select_tool("type", crate::ViewInfo::default()).unwrap(); + for (start, end, hex) in [(0, 1, "#ff0000"), (1, 2, "#0000ff")] { + s.set_tool_option("textSelection", &json!({"id": q2.0, "start": start, "end": end})); + s.execute("paint.setFill", &json!({"color": hex})).unwrap(); + } + s.select_tool("selection", crate::ViewInfo::default()).unwrap(); + assert_eq!(spec(&s, id).label_styles.categories, None, "part of a label's text is not kept"); + s.execute("select.set", &json!({"ids": [q2.0]})).unwrap(); + s.execute("recolor.apply", &json!({"map": {"#0000ff": "#ff0000"}})).unwrap(); + let looks = label_looks(&mut s, id); + assert!(looks.iter().any(|(t, _, fill)| t == "Q1" && fill == "#ff0000"), "{looks:?}"); + assert!(looks.iter().any(|(t, _, fill)| t == "0" && fill == "#000000"), "{looks:?}"); +} + +/// Stroke options set with `stroke.set` and a gradient made with `paint.editGradient` on a label's characters are kept +/// for every label of its kind, the gradient without its placement. +#[test] +fn stroke_and_gradient_edits_on_a_labels_characters_are_kept_for_its_kind() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + let category = label_run_style(&s, id, "Axes", "Q1"); + let v = text_id(&s, id, "Axes", "4"); + s.execute("paint.setStroke", &json!({"ids": [v.0], "color": "#ff0000"})).unwrap(); + s.execute("stroke.set", &json!({"ids": [v.0], "weight": 3, "cap": "round"})).unwrap(); + s.execute("paint.editGradient", &json!({"ids": [v.0], "kind": "linear", "stroke": false})).unwrap(); + assert!(matches!(label_run_style(&s, id, "Axes", "4").fill, Paint::Gradient(_)), "the edit makes a gradient"); + label_looks(&mut s, id); + let st = label_run_style(&s, id, "Axes", "0"); + assert_eq!((st.stroke_width, st.stroke_cap), (3.0, vectorcraft_doc::LineCap::Round)); + assert!(matches!(&st.fill, Paint::Gradient(g) if g.geom.is_none()), "{:?}", st.fill); + assert_eq!(label_run_style(&s, id, "Axes", "Q1"), category, "the category labels are left as they were"); +} + +/// `stroke.set`, `stroke.weightUp` and `stroke.weightDown` given the whole graph are kept for every kind of label. +#[test] +fn stroke_weights_set_on_the_whole_graph_are_kept_for_its_labels() { + let cases = [("stroke.set", json!({"weight": 2}), 2.0), ("stroke.weightUp", json!({}), 2.0), ("stroke.weightDown", json!({}), 0.75)]; + every_case(cases, |(cmd, params, weight)| { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + s.execute("paint.setStroke", &json!({"ids": [id.0], "color": "#ff0000"})).unwrap(); + let mut p = params.clone(); + p["ids"] = json!([id.0]); + s.execute(cmd, &p).unwrap(); + assert_eq!(label_run_style(&s, id, "Axes", "4").stroke_width, *weight, "{cmd}"); + label_looks(&mut s, id); + for (grp, t) in [("Axes", "0"), ("Axes", "Q1"), ("Legend", "2024")] { + assert_eq!(label_run_style(&s, id, grp, t).stroke_width, *weight, "{cmd}: {t}"); + } + }); +} + +/// A stroke weight set on a scaled label is kept as the label shows it, since the graph draws its labels unscaled. +#[test] +fn a_stroke_weight_on_a_scaled_label_is_kept_as_it_shows() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + let v = text_id(&s, id, "Axes", "4"); + s.execute("select.set", &json!({"ids": [v.0]})).unwrap(); + s.execute("object.scale", &json!({"sx": 200, "sy": 200})).unwrap(); + s.execute("paint.setStroke", &json!({"ids": [v.0], "color": "#ff0000"})).unwrap(); + s.execute("stroke.set", &json!({"ids": [v.0], "weight": 3})).unwrap(); + assert_eq!(label_run_style(&s, id, "Axes", "4").stroke_width, 1.5, "drawn at twice its size"); + label_looks(&mut s, id); + assert_eq!(label_run_style(&s, id, "Axes", "0").stroke_width, 3.0); +} + +/// When the characters of two labels of one kind are recolored differently, the frontmost one sets what the kind +/// keeps, whatever order `ids` are in. +#[test] +fn the_frontmost_label_of_a_kind_sets_what_its_recolor_keeps() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + // Legend labels: the axes tell value and category labels apart by their order, so these are moved instead. + let (a, b) = (text_id(&s, id, "Legend", "2024"), text_id(&s, id, "Legend", "2025")); + s.execute("paint.setFill", &json!({"ids": [a.0], "color": "#ff0000"})).unwrap(); + s.execute("paint.setFill", &json!({"ids": [b.0], "color": "#0000ff"})).unwrap(); + // The label made first goes in front, so neither the order of `ids` nor the order the labels were made in decides. + let (front, back) = if a < b { (a, b) } else { (b, a) }; + s.execute("select.set", &json!({"ids": [front.0]})).unwrap(); + s.execute("object.arrange.bringToFront", &json!({})).unwrap(); + let path = |n: NodeId| s.doc().unwrap().doc.index_path(n); + assert!(path(front) > path(back), "{:?} {:?}", path(front), path(back)); + let front_fill = if front == a { "#00ffff" } else { "#ffff00" }; + s.execute("edit.colors.invert", &json!({"ids": [front.0, back.0]})).unwrap(); + let kept = spec(&s, id).label_styles.legend.unwrap().fill; + assert_eq!(kept.color().map(|c| c.to_hex()).as_deref(), Some(front_fill)); +} + +/// Apply Nearest Swatch and the ink limit of Print Ink Fixes on a label are kept for its kind. +#[test] +fn nearest_swatch_and_ink_limit_on_a_label_are_kept_for_its_kind() { + let cases = [ + ("addon.color.applyNearestSwatch", json!({"library": "web-safe-216"})), + ("addon.color.printFixes", json!({"scope": "selection", "inkLimit": 200})), + ]; + every_case(cases, |(cmd, params)| { + let mut s = Session::new(); + // Print Ink Fixes works on CMYK documents. + s.execute("file.new", &json!({"width": 800, "height": 800, "colorMode": "cmyk"})).unwrap(); + let id = graph(&mut s, "column"); + let v = text_id(&s, id, "Axes", "4"); + s.execute("paint.setFill", &json!({"ids": [v.0], "color": {"c": 90, "m": 80, "y": 70, "k": 60}})).unwrap(); + let was = label_run_style(&s, id, "Axes", "4").fill; + let mut p = params.clone(); + p["ids"] = json!([v.0]); + s.execute(cmd, &p).unwrap(); + let now = label_run_style(&s, id, "Axes", "4").fill; + assert_ne!(now, was, "{cmd} changes the fill"); + label_looks(&mut s, id); + assert_eq!(label_run_style(&s, id, "Axes", "0").fill, now, "{cmd}"); + }); +} + +/// Swap Fill and Stroke and Default Fill and Stroke on a label are kept for its kind. +#[test] +fn swap_and_default_fill_and_stroke_on_a_label_are_kept_for_its_kind() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = graph(&mut s, "column"); + let v = text_id(&s, id, "Axes", "4"); + s.execute("paint.setStroke", &json!({"ids": [v.0], "color": "#ff0000"})).unwrap(); + s.execute("paint.swap", &json!({"ids": [v.0]})).unwrap(); + let swapped = label_run_style(&s, id, "Axes", "4"); + label_looks(&mut s, id); + let st = label_run_style(&s, id, "Axes", "0"); + assert_eq!((&st.fill, &st.stroke), (&swapped.fill, &swapped.stroke)); + assert_eq!(st.fill.color().map(|c| c.to_hex()).as_deref(), Some("#ff0000")); + s.execute("paint.default", &json!({"ids": [text_id(&s, id, "Axes", "4").0]})).unwrap(); + label_looks(&mut s, id); + let st = label_run_style(&s, id, "Axes", "0"); + assert_eq!((st.fill.color().map(|c| c.to_hex()).as_deref(), st.stroke.is_none()), (Some("#000000"), true)); +} + +/// On a pie with Legends in Wedges, a recolor of the whole graph leaves the legend labels to the graph's black or white. +#[test] +fn a_recolor_leaves_wedge_legend_labels_their_contrast() { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 800, "height": 800})).unwrap(); + let id = make(&mut s, "pie", ",a,b\nP1,1,2"); + s.execute("graph.setType", &json!({"id": id.0, "pieLegend": "wedges"})).unwrap(); + s.execute("edit.colors.invert", &json!({"ids": [id.0]})).unwrap(); + assert_eq!(spec(&s, id).label_styles.legend, None); + s.execute("graph.setData", &json!({"id": id.0, "rows": [[1, 2]]})).unwrap(); + // The first series' black wedge is white now, so its label is black. + let NodeKind::Text(t) = label_node(&s, id, "Legend", "a").kind else { panic!("a is not type") }; + assert_eq!(t.runs[0].style.fill.color().map(|c| c.to_hex()).as_deref(), Some("#000000")); + // A recolor of one legend label gives the kind that label's fill. + s.execute("edit.colors.invert", &json!({"ids": [text_id(&s, id, "Legend", "a").0]})).unwrap(); + let kept = spec(&s, id).label_styles.legend.map(|st| st.fill); + assert_eq!(kept.and_then(|f| f.color()).map(|c| c.to_hex()).as_deref(), Some("#ffffff")); +} + #[test] fn pie_names_and_wedge_labels_keep_their_style() { let mut s = Session::new(); diff --git a/crates/engine/src/cmd/paint.rs b/crates/engine/src/cmd/paint.rs index c7159d563a..60c5180f40 100644 --- a/crates/engine/src/cmd/paint.rs +++ b/crates/engine/src/cmd/paint.rs @@ -39,7 +39,7 @@ pub fn specs() -> Vec { "Swap Fill and Stroke", [], Some("Shift+X"), - "{ids?|id?} swap the fill and stroke of the selection (type too) and of the defaults. On a path directly in a graph series, the graph also stores the swapped paints and the stroke weight (exceptions: docs/mcp.md)", + "{ids?|id?} swap the fill and stroke of the selection (type too) and of the defaults. On a path directly in a graph series, the graph also stores the swapped paints and the stroke weight, and on a graph label the swapped paints of its characters for every label of its kind (exceptions: docs/mcp.md)", has_doc, swap ), @@ -48,7 +48,7 @@ pub fn specs() -> Vec { "Default Fill and Stroke", [], Some("D"), - "{ids?|id?} white fill and 1 pt black stroke for the selection and the defaults; type gets black fill and no stroke. On a path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke (exceptions: docs/mcp.md)", + "{ids?|id?} white fill and 1 pt black stroke for the selection and the defaults; type gets black fill and no stroke. On a path directly in a graph series, the graph also stores the paint, weight, opacity and blend mode of the topmost visible fill and stroke, and on a graph label the black fill and no stroke of its characters for every label of its kind (exceptions: docs/mcp.md)", has_doc, default_paint ), @@ -96,7 +96,7 @@ pub fn proxy_specs() -> Vec { "Invert", [], None, - "{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, target?: \"object\"|\"contents\"} invert the active proxy's colours of the selection (or ids; groups recolour their contents) keeping each colour's model, as edit.colors.invert does; the Appearance panel's active fill/stroke item (appearance.setActiveItem) is inverted instead when it is of that kind and no ids are given; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's solid color changes for this instance only, and a gradient or pattern, or type whose characters differ in color, is refused; with nothing selected, invert the default. On a path directly in a graph series, the graph also stores the new color of the topmost visible fill or stroke (docs/mcp.md) → {changed}", + "{stroke?: bool (default: the active proxy), ids?|id?, item?: appearance item index|null, target?: \"object\"|\"contents\"} invert the active proxy's colours of the selection (or ids; groups recolour their contents) keeping each colour's model, as edit.colors.invert does; the Appearance panel's active fill/stroke item (appearance.setActiveItem) is inverted instead when it is of that kind and no ids are given; with an object of a dynamic symbol instance selected by Direct Selection and no ids, id or item, that object's solid color changes for this instance only, and a gradient or pattern, or type whose characters differ in color, is refused; with nothing selected, invert the default. On a path directly in a graph series, the graph also stores the new color of the topmost visible fill or stroke, and on a graph label the new color of its characters and rows for every label of its kind (docs/mcp.md) → {changed}", has_doc, |s, p| proxy_recolor(s, p, "paint.invert", "Invert", &super::colorcmds::invert) ), @@ -925,7 +925,8 @@ fn swap(s: &mut Session, p: &Value) -> Result { } // The swap writes the paint of the topmost fill and stroke, not their opacity. let kept = super::appearance::capture_series_writes(&before, d, &ids, (true, true), (false, false), true, false); - Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept)) + let labels = super::graph::capture_label_changes(&before, d, &ids, false); + Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels)) })?; } if s.paint.stroke.is_none() && !s.paint.fill.is_none() && s.paint.stroke_width == 0.0 { @@ -954,7 +955,8 @@ fn default_paint(s: &mut Session, p: &Value) -> Result { } } let kept = super::appearance::capture_series_writes(&before, d, &ids, (true, true), (true, true), false, false); - Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept)) + let labels = super::graph::capture_label_changes(&before, d, &ids, false); + Ok(super::appearance::count_changed(d, &before, &ids) + usize::from(kept || labels)) })?; } super::newart::reset(s); diff --git a/crates/engine/src/cmd/recolor.rs b/crates/engine/src/cmd/recolor.rs index db0c0ac367..5d7e1ab633 100644 --- a/crates/engine/src/cmd/recolor.rs +++ b/crates/engine/src/cmd/recolor.rs @@ -34,7 +34,7 @@ pub fn specs() -> Vec { "Recolor Artwork", ["Edit", "Edit Colors"], None, - "{map: rows [{from: [colour keys (recolor.colors) or \"#rrggbb\" (every colour shown as that hex)], to: colour (hex, key, {c,m,y,k} or {l,a,b}) | null (in from, to and groupColors, #rrggbbaa and #rgba are refused), exclude?: false (the row's colours are kept), tint?: 100 (percent; with limitTo, art linked to the global or spot swatch the new color is takes this share of its tint)}] | {\"key or #rrggbb\": colour, …} (one row per colour), method?: \"exact\" (default)|\"preserveTints\"|\"scaleTints\"|\"tintsShades\"|\"hueShift\" (how a row's colours take its new colour, relative to the row's darkest, average or most saturated colour), limitTo?: swatch library id or name; or \"document\" (the document's swatches): new colours snap to its nearest colour, group?: colour group to rewrite, groupColors?: [colour] (what `group` is rewritten with; default: the rows' new colours, in order, excluded rows left out), rename?: the group's new name, includeImages?: true, includePatterns?: true, globalAdjust?: {saturation?: 0, brightness?: 0, temperature?: 0, luminosity?: 0} (Global Adjust: percent from -100 to 100, 0 changes nothing; every colour a row that isn't excluded recolours, and the group's new colours, take the same change after the row's new colour: saturation scales HSB saturation by 1 + saturation/100, brightness moves HSB brightness that share of the way to full or to black, temperature adds 0.2 × temperature/100 to red and takes it from blue, luminosity moves Lab lightness that share of the way to 100 or 0 keeping a and b; with limitTo each row's new colour takes the change before it snaps to the library)} recolour the selection (gradients, text, meshes, image pixels and pattern tiles included; each new colour keeps the model of the one it replaces (model?: \"keep\" default | \"new\" (the new colour's own model, so a CMYK colour replacing RGB art gives CMYK art) | \"document\" (the document's colour mode)), except a library swatch's with limitTo: art takes the swatch itself, linked to a global or spot colour at its tints, and the swatch joins the document's swatches; art linked to a global swatch of `group` that is rewritten with its row's new color stays linked to it, at its tint, unless the row converts the color into the art's model; other recolored art, and art in a row linked to a global swatch of `group` that is rewritten with another color, keeps its row's new color and loses its swatch link) and the group, as one undo step. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke (docs/mcp.md) → {changed, swatches: [names added to the document's swatches], relinked?: with group, the other paints linked to its global swatches that took their new colors, note?: set when a colour kept a model other than its new colour's (see model), notChanged: {locked, hidden} (as edit.colors.invert), warning?: set when notChanged counts any object}", + "{map: rows [{from: [colour keys (recolor.colors) or \"#rrggbb\" (every colour shown as that hex)], to: colour (hex, key, {c,m,y,k} or {l,a,b}) | null (in from, to and groupColors, #rrggbbaa and #rgba are refused), exclude?: false (the row's colours are kept), tint?: 100 (percent; with limitTo, art linked to the global or spot swatch the new color is takes this share of its tint)}] | {\"key or #rrggbb\": colour, …} (one row per colour), method?: \"exact\" (default)|\"preserveTints\"|\"scaleTints\"|\"tintsShades\"|\"hueShift\" (how a row's colours take its new colour, relative to the row's darkest, average or most saturated colour), limitTo?: swatch library id or name; or \"document\" (the document's swatches): new colours snap to its nearest colour, group?: colour group to rewrite, groupColors?: [colour] (what `group` is rewritten with; default: the rows' new colours, in order, excluded rows left out), rename?: the group's new name, includeImages?: true, includePatterns?: true, globalAdjust?: {saturation?: 0, brightness?: 0, temperature?: 0, luminosity?: 0} (Global Adjust: percent from -100 to 100, 0 changes nothing; every colour a row that isn't excluded recolours, and the group's new colours, take the same change after the row's new colour: saturation scales HSB saturation by 1 + saturation/100, brightness moves HSB brightness that share of the way to full or to black, temperature adds 0.2 × temperature/100 to red and takes it from blue, luminosity moves Lab lightness that share of the way to 100 or 0 keeping a and b; with limitTo each row's new colour takes the change before it snaps to the library)} recolour the selection (gradients, text, meshes, image pixels and pattern tiles included; each new colour keeps the model of the one it replaces (model?: \"keep\" default | \"new\" (the new colour's own model, so a CMYK colour replacing RGB art gives CMYK art) | \"document\" (the document's colour mode)), except a library swatch's with limitTo: art takes the swatch itself, linked to a global or spot colour at its tints, and the swatch joins the document's swatches; art linked to a global swatch of `group` that is rewritten with its row's new color stays linked to it, at its tint, unless the row converts the color into the art's model; other recolored art, and art in a row linked to a global swatch of `group` that is rewritten with another color, keeps its row's new color and loses its swatch link) and the group, as one undo step. On a path directly in a graph series, the graph also stores the new paint of the topmost visible fill and stroke, and on a graph label the new paint of its characters and rows for every label of its kind (docs/mcp.md) → {changed, swatches: [names added to the document's swatches], relinked?: with group, the other paints linked to its global swatches that took their new colors, note?: set when a colour kept a model other than its new colour's (see model), notChanged: {locked, hidden} (as edit.colors.invert), warning?: set when notChanged counts any object}", has_doc, apply ), diff --git a/crates/engine/src/cmd/stroke.rs b/crates/engine/src/cmd/stroke.rs index c5e5ba2a5c..14282c5112 100644 --- a/crates/engine/src/cmd/stroke.rs +++ b/crates/engine/src/cmd/stroke.rs @@ -22,7 +22,7 @@ pub fn specs() -> Vec { "Stroke Options", ["Window", "Stroke"], None, - "{weight?: pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?, align?: center|inside|outside, dash?: [d,g,…]|null (a 0 dash with a round or projecting cap draws dots or squares; a new pattern keeps the current offset and alignment), dashOffset? (exact dashes only), alignDashes?: bool (true: dashes fitted to corners and path ends, every run between them holding whole periods with a dash centred on each corner and end; false, the default for a new pattern: exact lengths), startArrow?, endArrow?: Arrow|ArrowOpen|LineArrow|Barbed|Concave|DoubleArrow|HalfArrowLeft|HalfArrowRight|Chevron|Feather|Swallowtail|Triangle|TriangleOpen|TriangleReverse|TriangleBar|Kite|Leaf|Drop|Circle|CircleOpen|HalfCircle|Oval|Target|Square|SquareOpen|Tag|TagOpen|Diamond|DiamondOpen|Hexagon|HexagonOpen|Star|Cross|Plus|Bar|DoubleBar|DotOnBar|Slash|DoubleSlash|Bracket|Fork|null|{custom: name} (a custom arrowhead of the arrowheads file, stroke.arrowheads.list)|{Custom: {name, path}} (a custom head with its art, as document.inspect reports one; refused when the path fills no area, parts thinner than a millionth of a head unit counting as none, or has more than 4096 anchors, more than 4096 subpaths or a point more than 64 head units from the tip) (HalfArrowLeft/Right: one barb, left or right of the direction the head points), arrowAlign?: \"extend\" (tip past the end point, default)|\"tip\" (tip on the end point; the stroke is shortened), profile?: \"uniform\"|\"lens\"|\"taperStart\"|\"taperEnd\"|\"pinch\"|\"teardrop\"|\"wave\"|a saved profile's name (stroke.widthProfile.list), widthPoints?, gradientMode? (as document.inspect reports them in strokeOptions, so those read back unchanged; ignored here: a custom profile is set with the Width tool, gradientMode with paint.editGradient), item?: stroke item index|null (omitted: the Appearance panel's active item if it is a stroke, else the top stroke, created when missing), ids?|id?, target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection)} Without a stroke item, type takes weight, cap, join, miterLimit, align (around its glyph outlines; the type stays live) and the dash options as its characters' stroke (every run; text.setRangeStyle `strokeOptions` styles a range), and images and symbol instances (also in groups) are left alone. With nothing selected (and no ids) they set up the next object drawn (appearance.newArt; weight always does). On a path directly in a graph series, the graph also stores a weight it changes on the topmost visible stroke (docs/mcp.md); on a graph label's stroke row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind → {objects: how many objects took the stroke options}", + "{weight?: pt, cap?: butt|round|square, join?: miter|round|bevel, miterLimit?, align?: center|inside|outside, dash?: [d,g,…]|null (a 0 dash with a round or projecting cap draws dots or squares; a new pattern keeps the current offset and alignment), dashOffset? (exact dashes only), alignDashes?: bool (true: dashes fitted to corners and path ends, every run between them holding whole periods with a dash centred on each corner and end; false, the default for a new pattern: exact lengths), startArrow?, endArrow?: Arrow|ArrowOpen|LineArrow|Barbed|Concave|DoubleArrow|HalfArrowLeft|HalfArrowRight|Chevron|Feather|Swallowtail|Triangle|TriangleOpen|TriangleReverse|TriangleBar|Kite|Leaf|Drop|Circle|CircleOpen|HalfCircle|Oval|Target|Square|SquareOpen|Tag|TagOpen|Diamond|DiamondOpen|Hexagon|HexagonOpen|Star|Cross|Plus|Bar|DoubleBar|DotOnBar|Slash|DoubleSlash|Bracket|Fork|null|{custom: name} (a custom arrowhead of the arrowheads file, stroke.arrowheads.list)|{Custom: {name, path}} (a custom head with its art, as document.inspect reports one; refused when the path fills no area, parts thinner than a millionth of a head unit counting as none, or has more than 4096 anchors, more than 4096 subpaths or a point more than 64 head units from the tip) (HalfArrowLeft/Right: one barb, left or right of the direction the head points), arrowAlign?: \"extend\" (tip past the end point, default)|\"tip\" (tip on the end point; the stroke is shortened), profile?: \"uniform\"|\"lens\"|\"taperStart\"|\"taperEnd\"|\"pinch\"|\"teardrop\"|\"wave\"|a saved profile's name (stroke.widthProfile.list), widthPoints?, gradientMode? (as document.inspect reports them in strokeOptions, so those read back unchanged; ignored here: a custom profile is set with the Width tool, gradientMode with paint.editGradient), item?: stroke item index|null (omitted: the Appearance panel's active item if it is a stroke, else the top stroke, created when missing), ids?|id?, target?: \"object\"|\"contents\", aligned?: bool (index and item are rows of the first target's stack: each other target edits its equal one, as the Appearance panel does for a mixed selection)} Without a stroke item, type takes weight, cap, join, miterLimit, align (around its glyph outlines; the type stays live) and the dash options as its characters' stroke (every run; text.setRangeStyle `strokeOptions` styles a range), and images and symbol instances (also in groups) are left alone. With nothing selected (and no ids) they set up the next object drawn (appearance.newArt; weight always does). On a path directly in a graph series, the graph also stores a weight it changes on the topmost visible stroke (docs/mcp.md); on a graph label's stroke row, the graph stores the label's topmost visible fill and stroke rows for every label of its kind, and on its characters the stroke options they take → {objects: how many objects took the stroke options}", has_doc, stroke_set ), @@ -31,7 +31,7 @@ pub fn specs() -> Vec { "Stroke Weight Up", [], Some("Cmd+Alt+."), - "{ids?|id?} raise each selected stroke's weight by one step of Units › Stroke (a quarter unit below one unit, then whole units; up to 1000 pt), each from its own weight: the selected objects' active or top stroke, type's stroked characters; objects without a stroke are left alone. With nothing selected (and no ids), the weight of the next object drawn. On a path directly in a graph series, the graph also stores the new weight of the topmost visible stroke (docs/mcp.md) → {objects}", + "{ids?|id?} raise each selected stroke's weight by one step of Units › Stroke (a quarter unit below one unit, then whole units; up to 1000 pt), each from its own weight: the selected objects' active or top stroke, type's stroked characters; objects without a stroke are left alone. With nothing selected (and no ids), the weight of the next object drawn. On a path directly in a graph series, the graph also stores the new weight of the topmost visible stroke, and on a graph label the new weight of its characters' stroke or its stroke row for every label of its kind (docs/mcp.md) → {objects}", has_doc, |s, p| stroke_step(s, p, true) ), diff --git a/docs/mcp.md b/docs/mcp.md index 992a3078fa..f8049365ef 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -807,8 +807,17 @@ commands store it too when they are given a series group, the graph or a group t leaves as it was keeps what the graph stores. When one command changes several paths of a series, the frontmost of them sets what the graph stores. A gradient is stored with its placement, and every path of the series takes that placement when the graph is drawn again. The graph does not store a stroke's dashes, caps, joins, arrowheads, width -profile or brush. These commands do not store the colors they give a graph's axes and labels, which are drawn again -with the paint they had. +profile or brush. On a graph label, given the label or something that holds it, these commands, `paint.swap` and +`paint.default` store what they change for every label of its kind: the label's object rows, as the `appearance.*` +commands store them, and the fill, stroke, stroke weight, caps, joins, miter limit, dashes and stroke alignment of its +characters when all of its characters show them alike. A gradient on the characters is stored without its placement +(its vector, aspect ratio, focal point and freeform points), and each label fits it to its own box when the graph is +drawn again, so `paint.setGradientGeom` and the `paint.freeform.*` edits do not store the placement they set there. A +stroke weight and dashes are stored as the label shows them, also on a label that was scaled. When the characters of +labels of one kind change differently, the frontmost label sets what the kind keeps. On a pie with Legends in Wedges +whose legend labels have no fill of their own, the legend labels' fill is stored only when every legend label the +command reaches ends up with the same fill. Otherwise they are drawn again in black, or white on a dark wedge. These commands do not store the colors they give a graph's axis lines, ticks and radar rings, +which are drawn again with their default paint. `text.setFormat` without `start` and `end`, on a graph or on its labels, stores the character and paragraph attributes it sets for each kind of label it reaches (value axis numbers, category labels, legend labels), and every label of that diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 8f87c83072..8a003daee9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1088,7 +1088,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Blend spine Anchor Point tool (#2544):** on a selected blend, dragging a spine corner makes symmetric Smooth handles; the tool displays and picks existing spine handles when switched to, drags one independently or retracts it on click, and clicking a point with handles retracts both. The spine is edited live without moving its key objects. Windows native canvas checks and screenshots reviewed: symmetric and independent handles, corner/retraction, Shift constraints and perpendicular reshaping, tool switching, key preservation, Undo/Redo, save/reopen, hidden handles and overlapping Path/Blend priority (PR #2643). Behaviour reference: [public path-editing documentation](https://helpx.adobe.com/illustrator/using/adjust-path-segments.html). - **Blend steps of brushed strokes:** the steps interpolate the pen pressure, tilt, bearing and rotation recorded with the Paintbrush, so a Calligraphic, Scatter or Art brush that varies with the pen changes gradually from one key to the next. A key without a recording counts as half pressure, half tilt and 0°, as brushes read it, and angles turn the shorter way round. When the blend starts a key's path at another anchor (an open path run from its end, a closed one turned to another start), the key's recordings, width profile and arrowheads turn with the path. Different brushes still switch halfway (VectorCraft's own rule; strokes blend their options, as [Blended objects overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blended-objects-overview.html) describes; `crates/doc/src/blend.rs`, `pen_pressure_tilt_and_angles_interpolate_for_brushes`, `stroke_profiles_turn_with_a_key_path_started_elsewhere`). - **Path editing (#494):** the handles shown are the handles that drag: Direct Selection drags those of a path selected as a whole (as the Pen leaves it), the Anchor Point tool and Pen+Alt no longer grab handles that Show handles when multiple anchors are selected hides, a handle shorter than the tolerance leaves its anchor to be picked, and the anchor tools pick within Selection & Anchor Display › Tolerance. A dragged segment keeps a smooth anchor at either end smooth. With Direct Selection, the Pen, the Curvature and the anchor tools, a path selected as a whole shows all its anchors selected, and the Control bar and the Properties panel offer Convert (corner, smooth) for them too; Remove and Cut wait for anchors direct-selected (#504). A handle drag gathers its snap targets once per drag (it took 21 ms per pointer move on a 20,000-path document, now 1 ms; `vectorcraft-cli perf` measures handle and segment drags on a 5,000-anchor path). Join merges the selected anchor points that lie on one another, as after Average, into one anchor (#1582, fixes #1533), and removes the merged anchors in one pass over the path, so a long run of them no longer moves the anchors after it once per merge (`cmd::path::tests::a_long_run_before_many_other_anchors_merges_in_one_pass`); Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J, the "Create corner or smooth join" shortcut of [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)) moves two open path ends to their midpoint and joins them there, a corner or smooth point as its dialog's Points choice asks, in one undo step. - - **Graphs:** Column, Stacked Column, Bar, Stacked Bar, Line, Area, Scatter, Pie and Radar graph tools with Graph Data and Graph Type. A series starts in greyscale; Group Selection's fill and stroke, the paint, weight, opacity and blend mode of a mark's top visible fill or stroke row after an Appearance command or a graphic style (each given a mark or its series picked with Group Selection), the Eyedropper, Default Fill and Stroke or Swap Fill and Stroke, the paint or stroke weight a stroke weight, gradient or recolor command changes there, and a mark's object opacity and blend mode, are kept separately on the graph and reapplied when its data, type or size changes, and through save, open and undo. A series that draws Filled Lines bands keeps no stroke paint or weight: its bands are drawn again with their 0.25 pt black outline. Graph Type's Override Calculated Values (both `axisMin` and `axisMax`) uses exactly that value-axis range, split into the tick count (5 when automatic). Line graphs take Edge-to-Edge Lines (off by default: the points sit at the centres of their categories; graphs saved before the option keep their edge-to-edge lines), and radar graphs follow Mark Data Points and Connect Data Points. Blank cells (an empty CSV cell or `null`) are values left out, not zeros: columns, bars and stacked segments skip them, lines and scatter lines break around them and the value axis ignores them, while area, pie and radar draw them as 0; a number in straight quotes is a label, and the data window writes it back quoted. Graph types combine: Graph Type on series picked with Group Selection (or `series` indexes) draws them as their own type, with column, stacked column, line and area mixing on the vertical value axis and bar and stacked bar on the horizontal one; stacked columns take one slot of the cluster, lines draw in front of columns and areas behind. The value axis goes on the left, the right or both sides (column, stacked column, line, area and scatter graphs; bar graphs keep theirs along the bottom), and Separate Scales gives the series assigned to the right axis a scale of their own with its own tick values. Each value axis takes tick marks of no, short or full (across the plot) length and a count per division, and a prefix and suffix for its numbers; the category axis takes tick marks too (none by default), at or between its labels. Graph designs: Object › Graph › Design lists the designs with a preview of the selected one, and New Design (the selected art), Rename, Delete Design, Paste Design (a copy back to edit) and Select Unused, and Marker draws the data points and legend swatches of line, scatter and radar series with a design, scaled so its backmost object fills the default marker's square. Graph Data transposes rows and columns and switches a scatter graph's x and y, and a `|` in a category or series label starts a new line. Pie graphs take Legends in Wedges, Position (Even, Ratio sized by area, Stacked on one centre) and Sort (None, All, First). Graph Type takes column and cluster widths up to 1000% (overlapping past 100%) with First Row and First Column in Front (First Row orders each series' categories; across series the series order decides, so series stay one group each for Group Selection), draws filled lines, adds drop shadows behind columns, bars, lines and wedges, and puts the legend in rows across the top. Text formatted with the Character, Paragraph, Appearance, Transparency or Graphic Styles controls or the Eyedropper, on the whole graph or on labels picked with Group Selection, is kept per kind of label (value axis numbers, category labels, legend labels) through the graph being drawn again, the paint, weight, opacity and blend mode of a label's topmost visible fill and stroke rows and its object opacity and blend mode included. Object › Graph › Data opens a worksheet: cells picked with a click and edited above the sheet (Tab moves right, Enter down, the arrows between cells), Import Data from a tab-separated text file, Transpose, Switch x/y, Cell Style (decimals shown, column width), Revert and Apply. `graph.setData` returns and takes the data as CSV with each value written exactly, not rounded to two decimals, so applying the returned CSV changes nothing (#1485). + - **Graphs:** Column, Stacked Column, Bar, Stacked Bar, Line, Area, Scatter, Pie and Radar graph tools with Graph Data and Graph Type. A series starts in greyscale; Group Selection's fill and stroke, the paint, weight, opacity and blend mode of a mark's top visible fill or stroke row after an Appearance command or a graphic style (each given a mark or its series picked with Group Selection), the Eyedropper, Default Fill and Stroke or Swap Fill and Stroke, the paint or stroke weight a stroke weight, gradient or recolor command changes there, and a mark's object opacity and blend mode, are kept separately on the graph and reapplied when its data, type or size changes, and through save, open and undo. A series that draws Filled Lines bands keeps no stroke paint or weight: its bands are drawn again with their 0.25 pt black outline. Graph Type's Override Calculated Values (both `axisMin` and `axisMax`) uses exactly that value-axis range, split into the tick count (5 when automatic). Line graphs take Edge-to-Edge Lines (off by default: the points sit at the centres of their categories; graphs saved before the option keep their edge-to-edge lines), and radar graphs follow Mark Data Points and Connect Data Points. Blank cells (an empty CSV cell or `null`) are values left out, not zeros: columns, bars and stacked segments skip them, lines and scatter lines break around them and the value axis ignores them, while area, pie and radar draw them as 0; a number in straight quotes is a label, and the data window writes it back quoted. Graph types combine: Graph Type on series picked with Group Selection (or `series` indexes) draws them as their own type, with column, stacked column, line and area mixing on the vertical value axis and bar and stacked bar on the horizontal one; stacked columns take one slot of the cluster, lines draw in front of columns and areas behind. The value axis goes on the left, the right or both sides (column, stacked column, line, area and scatter graphs; bar graphs keep theirs along the bottom), and Separate Scales gives the series assigned to the right axis a scale of their own with its own tick values. Each value axis takes tick marks of no, short or full (across the plot) length and a count per division, and a prefix and suffix for its numbers; the category axis takes tick marks too (none by default), at or between its labels. Graph designs: Object › Graph › Design lists the designs with a preview of the selected one, and New Design (the selected art), Rename, Delete Design, Paste Design (a copy back to edit) and Select Unused, and Marker draws the data points and legend swatches of line, scatter and radar series with a design, scaled so its backmost object fills the default marker's square. Graph Data transposes rows and columns and switches a scatter graph's x and y, and a `|` in a category or series label starts a new line. Pie graphs take Legends in Wedges, Position (Even, Ratio sized by area, Stacked on one centre) and Sort (None, All, First). Graph Type takes column and cluster widths up to 1000% (overlapping past 100%) with First Row and First Column in Front (First Row orders each series' categories; across series the series order decides, so series stay one group each for Group Selection), draws filled lines, adds drop shadows behind columns, bars, lines and wedges, and puts the legend in rows across the top. Text formatted with the Character, Paragraph, Appearance, Transparency or Graphic Styles controls or the Eyedropper, or recolored, given Swap Fill and Stroke or Default Fill and Stroke, or given stroke options or a gradient, on the whole graph or on labels picked with Group Selection, is kept per kind of label (value axis numbers, category labels, legend labels) through the graph being drawn again, the paint, weight, opacity and blend mode of a label's topmost visible fill and stroke rows and its object opacity and blend mode included. Object › Graph › Data opens a worksheet: cells picked with a click and edited above the sheet (Tab moves right, Enter down, the arrows between cells), Import Data from a tab-separated text file, Transpose, Switch x/y, Cell Style (decimals shown, column width), Revert and Apply. `graph.setData` returns and takes the data as CSV with each value written exactly, not rounded to two decimals, so applying the returned CSV changes nothing (#1485). An Eyedropper pick that includes transparency and leaves a mark's top fill or stroke row without paint, or removes that row when the source has no row of that kind, where that row had paint before, also replaces the opacity and blend mode the graph keeps for that kind of row in the series; a row that had no paint before the pick leaves them as they are. - **Graph column designs:** Object › Graph › Column (`graph.column`) draws the columns, bars or stacked segments and the legend swatch of the series picked with Group Selection with a graph design: Vertically Scaled stretches it to each column's length, Uniformly Scaled scales it both ways and centers it, Repeating stacks a copy for each Each Design Represents value and chops or scales the last one (For Fractions), and Sliding keeps the part above the design's guide line in proportion and stretches the part below. The dialog lists the designs with a preview; the choice is saved with the graph and follows the design's rename and delete. Type in a column design that holds a `%` followed by two digits shows each column's value in place of the `%` and the digits: the first digit is the least number of places before the decimal point (zeros are added in front; 0 gives as many as the value needs), and the second digit sets the places after it, rounded. Unless it is inside a group that clips or has its own opacity or appearance, or inside a blend, compound shape, envelope, repeat or intertwined objects, the type keeps its size and is drawn once per column in a repeating design. The legend swatch leaves it out. From b097c2a957b4c53f8d37b56f7e78d66c495d2aa4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 16:30:17 -0800 Subject: [PATCH 006/108] .ai export: the masked pieces of a warped image no longer hide one another A raster mesh warp with Preserve Shape Using Transparency cuts an image into pieces with opacity masks and puts them in a knockout group, each piece knocking out its triangle. The reader gives the pieces no such mark, so each knocked out all that its image paints without its mask, and the file opened with most of the image hidden. The group of such pieces is now written without knockout. An image whose pixels are partly transparent draws its alpha twice only where neighboring pieces overlap. --- crates/eps/src/ai_editing/tests.rs | 27 ++++++++++++++++++++++++++- crates/eps/src/ai_editing/writer.rs | 19 ++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index b433e6e1f0..04ec867063 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -7398,16 +7398,19 @@ fn the_pieces_of_a_warped_image_are_written_as_the_parts_they_show() { } /// The pieces of a warped image that Preserve Shape Using Transparency cuts with opacity masks that -/// clip are written as the parts their masks show, and the file reads back drawing as it did. +/// clip are written as the parts their masks show, in a group without knockout, and the file reads +/// back drawing as it did. #[test] fn masked_pieces_of_a_warped_image_are_written_as_the_parts_they_show() { // GUARDS: each masked piece of a warped image was written with all of the image's samples. + // GUARDS: the pieces' knockout group read back with each piece hiding the pieces below it. let doc = photo_doc(|d| { let photo = speckled_photo(d); let NodeKind::Image(im) = &photo.kind else { panic!("not an image") }; let bend = |p: vectorcraft_geom::Point| vectorcraft_geom::Point::new(p.x, p.y + 12.0 * ((p.x - 20.0) / 128.0 * std::f64::consts::PI).sin()); vectorcraft_doc::live::mesh_warp_image(&photo, im, &bend, 4, false, true) }); + assert_eq!(doc.layers[0].children().unwrap()[0].knockout, vectorcraft_doc::Knockout::On); let sizes = sample_sizes(&doc); assert_eq!(sizes.len(), 32, "{sizes:?}"); assert_eq!(sizes[0], SPECKLED_WHOLE, "the first piece holds the whole image"); @@ -7422,6 +7425,28 @@ fn masked_pieces_of_a_warped_image_are_written_as_the_parts_they_show() { assert!((st.bad_pixels as f64) < 0.005 * st.pixels as f64, "{} of {} pixels differ", st.bad_pixels, st.pixels); } +/// The masked pieces of a warped image whose pixels are half transparent read back drawing as they +/// did, except where neighboring pieces overlap: there the image's alpha draws twice. +#[test] +fn masked_pieces_of_a_translucent_warped_image_read_back_but_for_their_overlaps() { + // GUARDS: the pieces' knockout group read back with each piece hiding the pieces below it + // (8,942 of 20,000 pixels differed). + let doc = photo_doc(|d| { + let px = image::RgbaImage::from_fn(64, 64, |x, y| image::Rgba([(x * 4) as u8, (y * 4) as u8, ((x * 7 + y * 13) % 256) as u8, 128])); + let photo = image_node(d, ImageBlob::png(png_of(px.into())), (64, 64), Affine::new([2.0, 0.0, 0.0, 2.0, 20.0, 10.0]), None); + let NodeKind::Image(im) = &photo.kind else { panic!("not an image") }; + let bend = |p: vectorcraft_geom::Point| vectorcraft_geom::Point::new(p.x, p.y + 12.0 * ((p.x - 20.0) / 128.0 * std::f64::consts::PI).sin()); + vectorcraft_doc::live::mesh_warp_image(&photo, im, &bend, 4, false, true) + }); + let back = read_back(&doc); + let st = vectorcraft_testkit::raster::perceptual_diff( + &vectorcraft_testkit::raster::render_artboard(&doc), + &vectorcraft_testkit::raster::render_artboard(&back), + 8.0, + ); + assert!((st.bad_pixels as f64) < 0.05 * st.pixels as f64, "{} of {} pixels differ", st.bad_pixels, st.pixels); +} + /// An image with a live Warp keeps its pixels whole once, and its drawn look's pieces are each the /// part of them they show: it reads back as the image with its Warp live. #[test] diff --git a/crates/eps/src/ai_editing/writer.rs b/crates/eps/src/ai_editing/writer.rs index de6c40b7b5..570c65daa2 100644 --- a/crates/eps/src/ai_editing/writer.rs +++ b/crates/eps/src/ai_editing/writer.rs @@ -648,7 +648,14 @@ impl<'a> Writer<'a> { } self.effects(n); self.state(n.locked, !n.visible); - let xy = Xy::of(n); + let mut xy = Xy::of(n); + if masked_warp_pieces(n) { + // The reader gives the pieces no mark, and a knockout group's member then knocks out + // what it paints without its opacity mask: each piece would hide the pieces below it. + // Without knockout, a partly transparent image draws its alpha twice only where the + // pieces overlap. + xy.knockout = Knockout::Off; + } let start = self.body.len(); match &n.kind { NodeKind::Layer { .. } => {} @@ -1659,6 +1666,16 @@ fn clip_path(n: &Node) -> Option<(PathData, FillRule)> { path.subpaths.iter().any(|sp| !sp.anchors.is_empty()).then_some((path, rule)) } +/// Is `n` a knockout group of the pieces of a mesh-warped image cut by opacity masks +/// ([`vectorcraft_doc::live::mesh_warp_image`] with Preserve Shape Using Transparency)? Each piece +/// knocks out its triangle ([`Node::knockout_outline`]); read from the data, a piece knocks out all +/// that its image paints instead. +fn masked_warp_pieces(n: &Node) -> bool { + n.knockout == Knockout::On + && matches!(&n.kind, NodeKind::Group { children, clip: false } + if !children.is_empty() && children.iter().all(|c| c.extras().warp_piece && c.extras().mask.is_some())) +} + /// `text`'s lines on `%_` lines, as a part of the data that readers of the printed form skip (an /// opacity mask's art, a pattern's tile) has them. An image's samples stay as they are after an /// `XI` without `%_`, and `%_%%EndData` ends them, as in the files users sent. Samples hidden From c88da287e72f40a2b2f0e67701c9e7a52f358c46 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 16:34:27 -0800 Subject: [PATCH 007/108] Graphs: the label gradient test places the gradient before the redraw drops its placement The test now sets the edited label's gradient vector and aspect with paint.setGradientGeom and checks that the gradient is placed before the graph redraws, so the later check that the kept gradient has no placement fails if the redraw keeps it. --- crates/engine/src/cmd/graph/tests.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/graph/tests.rs b/crates/engine/src/cmd/graph/tests.rs index 1f128009f8..ea47c82112 100644 --- a/crates/engine/src/cmd/graph/tests.rs +++ b/crates/engine/src/cmd/graph/tests.rs @@ -5692,8 +5692,9 @@ fn a_recolor_that_evens_out_a_labels_characters_is_kept_for_its_kind() { assert!(looks.iter().any(|(t, _, fill)| t == "0" && fill == "#000000"), "{looks:?}"); } -/// Stroke options set with `stroke.set` and a gradient made with `paint.editGradient` on a label's characters are kept -/// for every label of its kind, the gradient without its placement. +/// Stroke options set with `stroke.set` and a gradient made with `paint.editGradient` and placed with +/// `paint.setGradientGeom` on a label's characters are kept for every label of its kind, the gradient without its +/// placement. #[test] fn stroke_and_gradient_edits_on_a_labels_characters_are_kept_for_its_kind() { let mut s = Session::new(); @@ -5704,7 +5705,10 @@ fn stroke_and_gradient_edits_on_a_labels_characters_are_kept_for_its_kind() { s.execute("paint.setStroke", &json!({"ids": [v.0], "color": "#ff0000"})).unwrap(); s.execute("stroke.set", &json!({"ids": [v.0], "weight": 3, "cap": "round"})).unwrap(); s.execute("paint.editGradient", &json!({"ids": [v.0], "kind": "linear", "stroke": false})).unwrap(); - assert!(matches!(label_run_style(&s, id, "Axes", "4").fill, Paint::Gradient(_)), "the edit makes a gradient"); + let placement = json!({"ids": [v.0], "stroke": false, "start": [100, 100], "end": [200, 100], "aspect": 50}); + s.execute("paint.setGradientGeom", &placement).unwrap(); + let fill = label_run_style(&s, id, "Axes", "4").fill; + assert!(matches!(&fill, Paint::Gradient(g) if g.geom.is_some()), "the edited label's gradient is placed: {fill:?}"); label_looks(&mut s, id); let st = label_run_style(&s, id, "Axes", "0"); assert_eq!((st.stroke_width, st.stroke_cap), (3.0, vectorcraft_doc::LineCap::Round)); From f3d04df7b8eb25d1ace5d05ff380838c8a3bb4a3 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 17:24:24 -0800 Subject: [PATCH 008/108] i18n: Dutch has a row for the messages the untranslated report lists The Dutch catalog lacked a row for 1,813 of the status and error messages that the untranslated report finds in the sources, so the status bar showed those messages in English. - nl.tsv gains 1,813 `@msg` rows: the errors of commands and their parameter checks, scripts, file import and export, printing and plug-ins. The translations are VectorCraft's own, written from the English meaning with the catalog's conventions and its existing feature names. Placeholders, parameter names, command ids and literal values stay as the English writes them. - The untranslated report lists 41 Dutch messages after the change: the composite font errors, the justification spacing error and the `connect` end error, which open #7211, #7116 and #7330 translate, and three unknown-parameter and range errors that open #7353 rewrites so that a catalog row can match them. Menu strings, `tl!` literals and undo labels are unchanged. - The row for `{k} has control characters{_1}` does not match the message for a multi-line File Info field, where the last placeholder is empty. - docs/localization-parity.md's Dutch row and a line in docs/target-app-parity.md give the new counts. --- crates/ui-egui/src/i18n/nl.tsv | 1818 ++++++++++++++++++++++++++++++++ docs/localization-parity.md | 2 +- docs/target-app-parity.md | 1 + 3 files changed, 1820 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 7ce152334e..1398564f5a 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5557,6 +5557,1824 @@ imageTrace Outline Contour @msg missing panel layout ontbrekende paneelindeling @msg unsupported native docking operation niet-ondersteunde systeemeigen dokbewerking @msg this kind of brush has no options dialog yet dit soort penseel heeft nog geen dialoogvenster met opties + +# Status and error messages: the script engine's own errors, command parameters, file readers and +# writers, dialogs, panels and add-ons. Names in backticks, command ids, double-quoted values and +# bare true, false and null stay as the English writes them. +@msg 'caller', 'callee' and 'arguments' cannot be used on strict mode functions 'caller', 'callee' en 'arguments' kunnen niet worden gebruikt bij functies in strikte modus +@msg A profile supports one Revolve effect. Edit the existing effect's options instead. Een profiel ondersteunt één effect Draaien. Bewerk in plaats daarvan de opties van het bestaande effect. +@msg Add Points at Crossings: a path went missing Punten toevoegen bij kruisingen: er is een pad verdwenen +@msg Alignment must be one of the choices De uitlijning moet een van de keuzes zijn +@msg Boolean.prototype.{name} was called on a value that is not a Boolean Boolean.prototype.{name} is aangeroepen op een waarde die geen Boolean is +@msg CMYK images whose samples couldn't be read in CMYK were imported in RGB CMYK-afbeeldingen waarvan de samples niet in CMYK konden worden gelezen, zijn in RGB geïmporteerd +@msg CSS options: {e} CSS-opties: {e} +@msg CSV has a header but no data rows De CSV heeft een koptekst maar geen gegevensrijen +@msg CSV holds NUL bytes: save it as UTF-8, or as UTF-16 with a byte-order mark De CSV bevat NUL-bytes: sla het bestand op als UTF-8, of als UTF-16 met een byte-order mark +@msg CSV is empty De CSV is leeg +@msg CSV is larger than {MAX_CSV_BYTES} bytes De CSV is groter dan {MAX_CSV_BYTES} bytes +@msg CSV is not UTF-16 De CSV is geen UTF-16 +@msg CSV is not UTF-8 De CSV is geen UTF-8 +@msg CSV would be larger than {MAX_CSV_BYTES} bytes De CSV zou groter worden dan {MAX_CSV_BYTES} bytes +@msg Cannot write to the location of “{name}”; choose where to save it Kan niet schrijven naar de locatie van „{name}”; kies waar je het wilt opslaan +@msg Choose original artwork, not a dimension's generated paths Kies de oorspronkelijke illustratie, niet de gegenereerde paden van een maatlijn +@msg Contour: select paths or shapes Omtrek: selecteer paden of vormen +@msg Contour: the Offset Path effect is not available Omtrek: het effect Pad verschuiven is niet beschikbaar +@msg Create needs fills, strokes or both Maken heeft vullingen, contouren of beide nodig +@msg DCS files can only be placed linked: use File › Place with Link on DCS-bestanden kunnen alleen gekoppeld worden geplaatst: gebruik Bestand › Plaatsen met Koppeling ingeschakeld +@msg DXF options: {e} DXF-opties: {e} +@msg DXF scale must be a positive number up to {_1}, not {scale} De DXF-schaal moet een positief getal tot en met {_1} zijn, niet {scale} +@msg DXF {field} `{s}`: {allowed} DXF {field} `{s}`: {allowed} +@msg Date.prototype method called on a value that is not a Date object Een methode van Date.prototype is aangeroepen op een waarde die geen Date-object is +@msg Dimension is locked or hidden De maatlijn is vergrendeld of verborgen +@msg Dimension mode does not match its source De modus van de maatlijn komt niet overeen met de bron ervan +@msg Draw Inside needs exactly one selected path, compound path or text Binnen tekenen heeft precies één geselecteerd pad, samengesteld pad of tekstobject nodig +@msg EPS Save writes all artwork: use document.export for selected-only EPS Opslaan als EPS schrijft alle illustraties: gebruik document.export voor een EPS met alleen de selectie +@msg EPS flattener: {e} EPS-afvlakker: {e} +@msg EPS options: {e} EPS-opties: {e} +@msg EPS {field} `{s}`: {allowed} EPS {field} `{s}`: {allowed} +@msg Error.prototype.toString was called on a value that is not an object Error.prototype.toString is aangeroepen op een waarde die geen object is +@msg Export for Screens writes png, png8, jpg, webp, gif, tiff, bmp, tga, psd, svg, svgz, pdf, eps, ai or vectorcraft Exporteren voor schermen schrijft png, png8, jpg, webp, gif, tiff, bmp, tga, psd, svg, svgz, pdf, eps, ai of vectorcraft +@msg Flare click coordinates must be finite numbers De klikcoördinaten van de flare moeten eindige getallen zijn +@msg Function.prototype.toString was called on a value that is not a function Function.prototype.toString is aangeroepen op een waarde die geen functie is +@msg HTML Text applies to object slices of type only HTML-tekst geldt alleen voor objectslices van tekst +@msg Identify Objects By is XML ID: the name must be a valid XML ID (start with a letter, underscore or colon; no spaces) Objecten identificeren op staat op XML-id: de naam moet een geldige XML-id zijn (begin met een letter, onderstrepingsteken of dubbele punt; geen spaties) +@msg Image Trace failed: internal error: its thread stopped (please report this bug) Afbeelding traceren is mislukt: interne fout: de thread ervan is gestopt (meld deze bug alsjeblieft) +@msg Image Trace failed: {e} Afbeelding traceren is mislukt: {e} +@msg Image Trace finished, but its document was closed Afbeelding traceren is voltooid, maar het document ervan is gesloten +@msg Image Trace finished, but the image or its settings changed meanwhile: trace it again Afbeelding traceren is voltooid, maar de afbeelding of de instellingen ervan zijn intussen gewijzigd: traceer de afbeelding opnieuw +@msg Import SVG Filter reads SVG files, not SVGZ SVG-filter importeren leest SVG-bestanden, geen SVGZ +@msg Invalid dimension offset Ongeldige verschuiving van de maatlijn +@msg Invalid point Ongeldig punt +@msg JSON.parse: {why} (at offset {at}) JSON.parse: {why} (op positie {at}) +@msg JSON.stringify cannot write a structure that contains itself JSON.stringify kan geen structuur schrijven die zichzelf bevat +@msg Join: a subpath went missing Verbinden: er is een subpad verdwenen +@msg Line Gap must be a number De lijnafstand moet een getal zijn +@msg Lock Workspace is not available in VectorCraft Werkruimte vergrendelen is niet beschikbaar in VectorCraft +@msg Move Panel to New Window is not available: floating panels stay in the main window Paneel naar nieuw venster verplaatsen is niet beschikbaar: zwevende panelen blijven in het hoofdvenster +@msg Namespace.prototype.toString needs a Namespace Namespace.prototype.toString heeft een Namespace nodig +@msg New Document profiles need the preferences folder, which this run doesn't have Profielen voor nieuwe documenten hebben de voorkeurenmap nodig, die deze sessie niet heeft +@msg Number.prototype.{name} was called on a value that is not a number Number.prototype.{name} is aangeroepen op een waarde die geen getal is +@msg Object.create's prototype must be an object or null Het prototype van Object.create moet een object of null zijn +@msg Object.{function} was given a value that is not an object Object.{function} kreeg een waarde die geen object is +@msg Offset Path: the path is too complex to offset Pad verschuiven: het pad is te complex om te verschuiven +@msg Offset Path: {e} Pad verschuiven: {e} +@msg PDF content is incomplete or exceeds the reader's limits; no document was imported De PDF-inhoud is onvolledig of overschrijdt de limieten van de lezer; er is geen document geïmporteerd +@msg PDF flattener: {e} PDF-afvlakker: {e} +@msg PDF options: {e} PDF-opties: {e} +@msg QName.prototype.toString needs a QName QName.prototype.toString heeft een QName nodig +@msg Recolor Artwork is no longer open Artwork herkleuren is niet meer geopend +@msg RegExp.prototype.{name} was called on a value that is not a RegExp object RegExp.prototype.{name} is aangeroepen op een waarde die geen RegExp-object is +@msg SVG is not UTF-8, UTF-16 or ISO 8859-1 De SVG is geen UTF-8, UTF-16 of ISO 8859-1 +@msg Save writes one artboard: name one, or export several with document.export Opslaan schrijft één tekengebied: noem er een, of exporteer er meerdere met document.export +@msg Select a dimension first Selecteer eerst een maatlijn +@msg Select dimensions to update Selecteer maatlijnen om bij te werken +@msg Select only dimensions Selecteer alleen maatlijnen +@msg Select two or more objects, or a group Selecteer twee of meer objecten, of een groep +@msg Shaper needs 1–64 source paths Shaper heeft 1–64 bronpaden nodig +@msg Stencil Bridges: the selected art is too large or too detailed to bridge Sjabloonbruggen: de geselecteerde illustratie is te groot of te gedetailleerd om te overbruggen +@msg String.prototype.toString was called on a value that is not a string String.prototype.toString is aangeroepen op een waarde die geen string is +@msg Switch x/y is for scatter graphs x/y omwisselen is bedoeld voor spreidingsgrafieken +@msg Text options: {e} Tekstopties: {e} +@msg The link is inside a symbol, graph design, pattern or opacity mask and has no place on the canvas De koppeling zit in een symbool, grafiekontwerp, patroon of dekkingmasker en heeft geen plaats op het canvas +@msg The {name} profile could not be read, so the new document has the default settings: {reason} Het profiel {name} kon niet worden gelezen, dus heeft het nieuwe document de standaardinstellingen: {reason} +@msg Trap: more than {_1} pairs of objects lie close enough to trap, or too many objects share a horizontal range; trap fewer objects at a time Overbrugging: meer dan {_1} paren objecten liggen dicht genoeg bij elkaar om te overbruggen, of te veel objecten delen een horizontaal bereik; overbrug minder objecten tegelijk +@msg Weed Box and Lines: no weeding line fits outside the art, and the weed box is off Wiedkader en wiedlijnen: er past geen wiedlijn buiten de illustratie en het wiedkader is uitgeschakeld +@msg \\ at end of pattern \\ aan het einde van het patroon +@msg `alignOn` cannot be empty `alignOn` mag niet leeg zijn +@msg `alignOn` must be a string `alignOn` moet een string zijn +@msg `align` is start, center or end `align` is start, center of end +@msg `align` must be a string `align` moet een string zijn +@msg `anchors` must be an array of [subpath, anchor] pairs `anchors` moet een array van paren [subpad, anker] zijn +@msg `anchors` must list anchor indices (0, 1, 2…), not {k} `anchors` moet ankerindexen bevatten (0, 1, 2…), niet {k} +@msg `anchors` must list anchor indices (0, 1, 2…), not {v} `anchors` moet ankerindexen bevatten (0, 1, 2…), niet {v} +@msg `answer` for this {kind} dialog must be one of: {_1} `answer` voor dit dialoogvenster {kind} moet een van de volgende zijn: {_1} +@msg `answers` has more than {MAX_ANSWERS} answers `answers` heeft meer dan {MAX_ANSWERS} antwoorden +@msg `answers` is larger than 1 MiB `answers` is groter dan 1 MiB +@msg `answers` must be a list of answers `answers` moet een lijst met antwoorden zijn +@msg `artboard` must be the index of an artboard of the document `artboard` moet de index van een tekengebied van het document zijn +@msg `artboardsAt` must be [x, y] `artboardsAt` moet [x, y] zijn +@msg `artboards` must be a list of artboard indices `artboards` moet een lijst met tekengebiedindexen zijn +@msg `artboards` names an artboard the document does not have `artboards` noemt een tekengebied dat het document niet heeft +@msg `artboards` names an artboard twice `artboards` noemt een tekengebied twee keer +@msg `asset` is the asset id (see assets.list) `asset` is de asset-id (zie assets.list) +@msg `at` must be [x, y] (got {at}) `at` moet [x, y] zijn (kreeg {at}) +@msg `at` must be a byte offset `at` moet een bytepositie zijn +@msg `at` must be a point [x, y] `at` moet een punt [x, y] zijn +@msg `autoLeading` must be a number `autoLeading` moet een getal zijn +@msg `background` must be "", "matte" or #rrggbb `background` moet "", "matte" of #rrggbb zijn +@msg `beside` needs `side` `beside` heeft `side` nodig +@msg `burasagari` must be "none", "standard" or "forced" `burasagari` moet "none", "standard" of "forced" zijn +@msg `center` must be [x, y] `center` moet [x, y] zijn +@msg `charAlign` must be "romanBaseline", "emBoxTop", "emBoxCenter", "emBoxBottom", "icfTop" or "icfBottom" `charAlign` moet "romanBaseline", "emBoxTop", "emBoxCenter", "emBoxBottom", "icfTop" of "icfBottom" zijn +@msg `charDirection` must be "default", "leftToRight" or "rightToLeft" `charDirection` moet "default", "leftToRight" of "rightToLeft" zijn +@msg `clearStroke` requires `stroke: false`, `ids: []` and no `stop` `clearStroke` vereist `stroke: false`, `ids: []` en geen `stop` +@msg `clear` must be a list of type object ids, not {v} `clear` moet een lijst met id’s van tekstobjecten zijn, niet {v} +@msg `clear` must list type objects; {_1} is not one `clear` moet tekstobjecten bevatten; {_1} is er geen +@msg `clear` must not list `id` `clear` mag `id` niet bevatten +@msg `code` must be a whole number `code` moet een geheel getal zijn +@msg `colorMode` must be one of rgb, cmyk `colorMode` moet een van rgb, cmyk zijn +@msg `color` needs a `rule` to make the theme from `color` heeft een `rule` nodig om het thema mee te maken +@msg `colors` does not apply to the {name} reduction `colors` geldt niet voor de reductie {name} +@msg `colors` is empty `colors` is leeg +@msg `colors` must be a whole number from 2 to 256 `colors` moet een geheel getal van 2 tot 256 zijn +@msg `colors` must be at least 9 for the uniform reduction `colors` moet minstens 9 zijn voor de uniforme reductie +@msg `colors` must be between 1 and {MAX_THEME_COLORS} (got {n}) `colors` moet tussen 1 en {MAX_THEME_COLORS} liggen (kreeg {n}) +@msg `columnType` is vertical, uniform, repeating or sliding `columnType` is vertical, uniform, repeating of sliding +@msg `columns` must be a whole number 1..50 `columns` moet een geheel getal 1..50 zijn +@msg `commands` must not be empty `commands` mag niet leeg zijn +@msg `contents` goes with `to` `contents` hoort bij `to` +@msg `corners` must be sharp, round or square, not `{other}` `corners` moet sharp, round of square zijn, niet `{other}` +@msg `corners` must list anchor indices (0, 1, 2…), not {v} `corners` moet ankerindexen bevatten (0, 1, 2…), niet {v} +@msg `count` must be a whole number from 0 to {MAX_COUNT} `count` moet een geheel getal van 0 tot {MAX_COUNT} zijn +@msg `count` must be a whole number from 1 to 100 `count` moet een geheel getal van 1 tot 100 zijn +@msg `dataBase64` is larger than the module limit `dataBase64` is groter dan de modulelimiet +@msg `dataBase64` is not valid base64 `dataBase64` is geen geldige base64 +@msg `defaultsOnly` cannot be combined with `ids`, `reverse` or `append` `defaultsOnly` kan niet worden gecombineerd met `ids`, `reverse` of `append` +@msg `depth` and `childLimit` slice the summary: pass `summary: true` `depth` en `childLimit` beperken de samenvatting: geef `summary: true` op +@msg `design` is a design name, or null for plain columns `design` is de naam van een ontwerp, of null voor gewone kolommen +@msg `design` is a design name, or null for the default marker `design` is de naam van een ontwerp, of null voor de standaardmarkering +@msg `destinationFolder` is required when destination is `folder` `destinationFolder` is vereist wanneer de bestemming `folder` is +@msg `destination` must be `none`, `saveAndClose` or `folder` `destination` moet `none`, `saveAndClose` of `folder` zijn +@msg `diameter` must be from 0.1 to 2500 pt `diameter` moet van 0,1 tot 2500 pt zijn +@msg `digits` must be one of {_1} `digits` moet een van {_1} zijn +@msg `dimImages` is a percentage or false `dimImages` is een percentage of false +@msg `direction` must be "auto", "leftToRight" or "rightToLeft" `direction` moet "auto", "leftToRight" of "rightToLeft" zijn +@msg `ditherAmount` must be a number from 0 to 100 `ditherAmount` moet een getal van 0 tot 100 zijn +@msg `each` is the value one design stands for, more than 0 `each` is de waarde waar één ontwerp voor staat, meer dan 0 +@msg `end` must be "start" or "end" `end` moet "start" of "end" zijn +@msg `ends` applies to joining exactly two paths `ends` geldt voor het verbinden van precies twee paden +@msg `event` must be one of {_1} `event` moet een van {_1} zijn +@msg `every` must be "all", "odd" or "even", not {v} `every` moet "all", "odd" of "even" zijn, niet {v} +@msg `expand` must be true or false `expand` moet true of false zijn +@msg `fidelity` must be from {lo} to {hi} pt `fidelity` moet van {lo} tot {hi} pt zijn +@msg `files` must be 1 to 1000 paths of font files the last text.findFontFiles search found `files` moet 1 tot 1000 paden van lettertypebestanden bevatten die de laatste zoekopdracht van text.findFontFiles heeft gevonden +@msg `focal` and `radius` cannot be used together `focal` en `radius` kunnen niet samen worden gebruikt +@msg `focal` must be an array of [subpath, anchor] pairs `focal` moet een array van paren [subpad, anker] zijn +@msg `focal` names [{si}, {ai}], which is not an anchor of the path `focal` noemt [{si}, {ai}], en dat is geen anker van het pad +@msg `folder` must be an absolute folder path `folder` moet een absoluut mappad zijn +@msg `fontAxes` must be an object of axis tags and values, such as {"wght"} `fontAxes` moet een object met astags en waarden zijn, zoals {"wght"} +@msg `format` must be a string `format` moet een string zijn +@msg `format` must be one of {_1} `format` moet een van {_1} zijn +@msg `fractions` is chop or scale `fractions` is chop of scale +@msg `from` and `to` must differ `from` en `to` moeten verschillen +@msg `from` has an empty frame `from` heeft een leeg kader +@msg `from` must be a non-negative integer `from` moet een niet-negatief geheel getal zijn +@msg `from` must be area type or type on a path `from` moet vlaktekst of tekst op een pad zijn +@msg `gid` must be a glyph id, not {v} `gid` moet een glyph-id zijn, niet {v} +@msg `glyphAlternate` belongs to one character, not to a character style (text.setGlyphAlternate sets it) `glyphAlternate` hoort bij één teken, niet bij een tekenstijl (text.setGlyphAlternate stelt het in) +@msg `glyphAlternate` takes only null, which takes a glyph choice away (text.setGlyphAlternate makes one) `glyphAlternate` accepteert alleen null, dat een glyphkeuze wegneemt (text.setGlyphAlternate maakt er een) +@msg `group` must be one of {_1} `group` moet een van {_1} zijn +@msg `group` must be the Objects on Path group of `member` and `target` `group` moet de groep Objecten op pad van `member` en `target` zijn +@msg `guide` must be a guide index (guide.list) `guide` moet een hulplijnindex zijn (guide.list) +@msg `hAlign` must be default, left, center or right `hAlign` moet default, left, center of right zijn +@msg `id` is an object id, not {v} `id` is een object-id, niet {v} +@msg `id` must be a node id `id` moet een knooppunt-id zijn +@msg `id` must be an object id, not {v} `id` moet een object-id zijn, niet {v} +@msg `ids` must name Objects on Path groups or objects in them `ids` moet groepen Objecten op pad of objecten daarin noemen +@msg `ids` takes at most {MAX_INSPECT_IDS} ids `ids` accepteert maximaal {MAX_INSPECT_IDS} id’s +@msg `imageMap` must be none, rectangle or polygon `imageMap` moet none, rectangle of polygon zijn +@msg `includeArtboardFill` must be true or false `includeArtboardFill` moet true of false zijn +@msg `includeSubdirs` must be true or false `includeSubdirs` moet true of false zijn +@msg `index` must be a point index `index` moet een puntindex zijn +@msg `index` must be a whole number or null `index` moet een geheel getal of null zijn +@msg `indices` must be a non-empty array of item indices `indices` moet een niet-lege array van itemindexen zijn +@msg `item` needs `index` `item` heeft `index` nodig +@msg `items` is a list of {kind, item} `items` is een lijst van {kind, item} +@msg `items` is empty `items` is leeg +@msg `items` must be a list of {id, points} `items` moet een lijst van {id, points} zijn +@msg `items` must be a list of {{id, anchors?}}, not {v} `items` moet een lijst van {{id, anchors?}} zijn, niet {v} +@msg `items` must be an array of {id, anchors} `items` moet een array van {id, anchors} zijn +@msg `items` must be an array of {{id, corners?}}, not {v} `items` moet een array van {{id, corners?}} zijn, niet {v} +@msg `kashida` must be "none", "short", "medium", "long" or "stylistic" `kashida` moet "none", "short", "medium", "long" of "stylistic" zijn +@msg `kerningBefore` belongs to a line's first character, not to a character style (text.setRangeStyle sets it) `kerningBefore` hoort bij het eerste teken van een regel, niet bij een tekenstijl (text.setRangeStyle stelt het in) +@msg `kind` is one of {_1} `kind` is een van {_1} +@msg `kind` must be "round", "invertedRound" or "chamfer", not {v} `kind` moet "round", "invertedRound" of "chamfer" zijn, niet {v} +@msg `kind` must be `text`, `visibility`, `image` or `graph` `kind` moet `text`, `visibility`, `image` of `graph` zijn +@msg `kind` must be a string `kind` moet een string zijn +@msg `kind` must be image, noImage or htmlText `kind` moet image, noImage of htmlText zijn +@msg `kinsokuType` must be "pushInFirst", "pushOutFirst" or "pushOutOnly" `kinsokuType` moet "pushInFirst", "pushOutFirst" of "pushOutOnly" zijn +@msg `kinsoku` must be "none", "hard" or "soft" `kinsoku` moet "none", "hard" of "soft" zijn +@msg `label` must be a non-empty name of at most 200 characters `label` moet een niet-lege naam van maximaal 200 tekens zijn +@msg `language` must be a language name or tag, such as "Turkish" or "tr" `language` moet een taalnaam of -tag zijn, zoals "Turkish" of "tr" +@msg `leader` must be a string `leader` moet een string zijn +@msg `leadingModel` must be "romanBaseline" or "emBoxTop" `leadingModel` moet "romanBaseline" of "emBoxTop" zijn +@msg `leading` must be from 0.1 to 5000, or null for Auto `leading` moet van 0,1 tot 5000 zijn, of null voor Automatisch +@msg `length` must be a number of at most 1000000 pt either way `length` moet een getal van maximaal 1000000 pt in beide richtingen zijn +@msg `line` must be true or false `line` moet true of false zijn +@msg `max` must be 1 to {MAX_SUGGESTIONS} `max` moet 1 tot {MAX_SUGGESTIONS} zijn +@msg `minAngle` ({min_angle}°) can't be more than `maxAngle` ({max_angle}°) `minAngle` ({min_angle}°) mag niet groter zijn dan `maxAngle` ({max_angle}°) +@msg `mode` must be "handles", "straight" or "smooth" `mode` moet "handles", "straight" of "smooth" zijn +@msg `mode` must be "straight", "bezier" or "arc" `mode` moet "straight", "bezier" of "arc" zijn +@msg `mode` must be one of {_1} `mode` moet een van {_1} zijn +@msg `mojikumi` must be "none", "yakumonoHankaku", "gyomatsuYakumonoHankaku", "gyomatsuYakumonoZenkaku", "yakumonoZenkaku" or "lineEndHalf" `mojikumi` moet "none", "yakumonoHankaku", "gyomatsuYakumonoHankaku", "gyomatsuYakumonoZenkaku", "yakumonoZenkaku" of "lineEndHalf" zijn +@msg `name` must be a name that is not empty `name` moet een naam zijn die niet leeg is +@msg `name` must not be empty `name` mag niet leeg zijn +@msg `names` is a list of preset names `names` is een lijst met namen van voorinstellingen +@msg `names` lists preset names `names` bevat namen van voorinstellingen +@msg `names` must be a list of names `names` moet een lijst met namen zijn +@msg `names` must be a list of swatch names `names` moet een lijst met staalnamen zijn +@msg `names` must be an array of style names `names` moet een array van stijlnamen zijn +@msg `new` is a design name, or true `new` is de naam van een ontwerp, of true +@msg `origin` must be [x, y] in points `origin` moet [x, y] in punten zijn +@msg `path` must be a folder `path` moet een map zijn +@msg `path` must be a path object `path` moet een padobject zijn +@msg `picks` must be an array (got {v}) `picks` moet een array zijn (kreeg {v}) +@msg `picks` must hold 1 to {MAX_PICKS} picks (got {_1}) `picks` moet 1 tot {MAX_PICKS} keuzes bevatten (kreeg {_1}) +@msg `pivot` must be a whole number from 0 to 8 `pivot` moet een geheel getal van 0 tot 8 zijn +@msg `points` must be a list of [x, y] points `points` moet een lijst met punten [x, y] zijn +@msg `points` must be a list of point indexes `points` moet een lijst met puntindexen zijn +@msg `points` must be an array of point indices `points` moet een array van puntindexen zijn +@msg `points` must be point indexes `points` moet uit puntindexen bestaan +@msg `points` must hold from 2 to 100000 points `points` moet 2 tot 100000 punten bevatten +@msg `port` must be "in" or "out" `port` moet "in" of "out" zijn +@msg `position` is above or below `position` is above of below +@msg `preset` must be a string `preset` moet een string zijn +@msg `radius` must be 0 or more `radius` moet 0 of meer zijn +@msg `ratio` must be from 0.1 to 0.5 `ratio` moet van 0,1 tot 0,5 zijn +@msg `rect` must be [x, y, width, height] `rect` moet [x, y, breedte, hoogte] zijn +@msg `rect` must be [x, y, width, height] with a positive size `rect` moet [x, y, breedte, hoogte] met een positieve grootte zijn +@msg `rect` must be [x0, y0, x1, y1] (got {r}) `rect` moet [x0, y0, x1, y1] zijn (kreeg {r}) +@msg `relation` must be overlap, inside or outside `relation` moet overlap, inside of outside zijn +@msg `replace` must be a string `replace` moet een string zijn +@msg `reversed` must be true or false `reversed` moet true of false zijn +@msg `rotate` must be a finite number `rotate` moet een eindig getal zijn +@msg `rows` must be lists of numbers or nulls, not {r} `rows` moet uit lijsten met getallen of null-waarden bestaan, niet {r} +@msg `rule` must be nonZero or evenOdd `rule` moet nonZero of evenOdd zijn +@msg `scale` must be a number from 0.001 to 1000 `scale` moet een getal van 0,001 tot 1000 zijn +@msg `scale` must be a number in (0, 100] `scale` moet een getal in (0, 100] zijn +@msg `scope.{key}` must be a non-empty array `scope.{key}` moet een niet-lege array zijn +@msg `scope` must be "document", {artboards} or {layers} `scope` moet "document", {artboards} of {layers} zijn +@msg `scope` must be "selection" or "document", not {other} `scope` moet "selection" of "document" zijn, niet {other} +@msg `script` must be a string `script` moet een string zijn +@msg `seriesIndexes` is a non-empty list of series indexes `seriesIndexes` is een niet-lege lijst met reeksindexen +@msg `seriesIndexes` needs a `type` or a `valueAxis` `seriesIndexes` heeft een `type` of een `valueAxis` nodig +@msg `shift` must be a number of points `shift` moet een aantal punten zijn +@msg `showCenter` must be true or false `showCenter` moet true of false zijn +@msg `side` must be "left", "right", "top" or "bottom" `side` moet "left", "right", "top" of "bottom" zijn +@msg `side` places the artboard: leave out x, y, width and height `side` plaatst het tekengebied: laat x, y, width en height weg +@msg `singleWordJustification` must be "fullJustify", "alignLeft", "alignCenter" or "alignRight" `singleWordJustification` moet "fullJustify", "alignLeft", "alignCenter" of "alignRight" zijn +@msg `size` is a percentage of the base text's size, 1 to 100 `size` is een percentage van de grootte van de basistekst, 1 tot 100 +@msg `source` and `target` are the same object `source` en `target` zijn hetzelfde object +@msg `source` is the only path in series group `target` `source` is het enige pad in reeksgroep `target` +@msg `source` must be `folder` or `datasets` `source` moet `folder` of `datasets` zijn +@msg `spacing` makes more than {MAX_COUNT} lines across the box `spacing` levert meer dan {MAX_COUNT} lijnen over het kader op +@msg `spacing` must be a number `spacing` moet een getal zijn +@msg `spacing` must be a number of points, 0 or more, or "auto" `spacing` moet een aantal punten zijn, 0 of meer, of "auto" +@msg `spacing` must be more than 0 and at most {MAX_DISTANCE} pt `spacing` moet meer dan 0 en maximaal {MAX_DISTANCE} pt zijn +@msg `start` must be a finite number `start` moet een eindig getal zijn +@msg `starts` must be an array of anchor indices (or nulls) `starts` moet een array van ankerindexen (of null-waarden) zijn +@msg `status` must be linked, embedded, missing or modified, or a list of them `status` moet linked, embedded, missing of modified zijn, of een lijst daarvan +@msg `stop` must be a stop index `stop` moet een stopindex zijn +@msg `story` styles the whole story: give no `start` or `end` `story` maakt het hele artikel op: geef geen `start` of `end` +@msg `story` takes the whole story: give no `start` or `end` `story` neemt het hele artikel: geef geen `start` of `end` +@msg `strokeMode` applies to strokes (stroke: true) `strokeMode` geldt voor contouren (stroke: true) +@msg `style` must be roman or japanese `style` moet roman of japanese zijn +@msg `subpaths` must be two integer indices `subpaths` moet uit twee gehele indexen bestaan +@msg `symbol` must be a symbol name `symbol` moet een symboolnaam zijn +@msg `target` must be "object" or "contents", not {v} `target` moet "object" of "contents" zijn, niet {v} +@msg `target` must be an object of the same Objects on Path group as `member` `target` moet een object zijn uit dezelfde groep Objecten op pad als `member` +@msg `tint` applies to global and spot colours `tint` geldt voor globale kleuren en steunkleuren +@msg `tint` goes with a global or spot `swatch` `tint` hoort bij een `swatch` met een globale kleur of steunkleur +@msg `tint` must be a number (%) `tint` moet een getal zijn (%) +@msg `tint` needs a global or spot colour `tint` heeft een globale kleur of steunkleur nodig +@msg `to` is already threaded `to` is al gekoppeld +@msg `to` is the design's new name `to` is de nieuwe naam van het ontwerp +@msg `to` must be [x, y] `to` moet [x, y] zijn +@msg `to` must be a closed path, area type or type on a path other than `from` `to` moet een gesloten pad, vlaktekst of tekst op een pad zijn, anders dan `from` +@msg `to` must be a whole number `to` moet een geheel getal zijn +@msg `to` takes the rows of one object's stack, not aligned rows `to` accepteert de rijen van de stapel van één object, geen uitgelijnde rijen +@msg `tolerance` must be from 0 to 100 pt `tolerance` moet van 0 tot 100 pt zijn +@msg `useLab` must be true or false `useLab` moet true of false zijn +@msg `vAlign` must be default, top, middle, baseline or bottom `vAlign` moet default, top, middle, baseline of bottom zijn +@msg `values` must be a list `values` moet een lijst zijn +@msg `values` must be an object `values` moet een object zijn +@msg `values` must name hex, rgb, cmyk, lab or gray `values` moet hex, rgb, cmyk, lab of gray noemen +@msg `values` names a kind twice `values` noemt een soort twee keer +@msg `version` must be 0 or {_1} `version` moet 0 of {_1} zijn +@msg `version` must be 0 or {newest} `version` moet 0 of {newest} zijn +@msg `warichuAlign` must be one of {_1} `warichuAlign` moet een van {_1} zijn +@msg `warichuLines` must be a whole number from {_1} to {_2} `warichuLines` moet een geheel getal van {_1} tot {_2} zijn +@msg `weight` must be from 0.01 to 1000 pt `weight` moet van 0,01 tot 1000 pt zijn +@msg `weights` must be a list of {_1} numbers, one per row (got {v}) `weights` moet een lijst met {_1} getallen zijn, één per rij (kreeg {v}) +@msg `xml` must be a string `xml` moet een string zijn +@msg `{KEY}` entry {n} gives the paragraph at byte {start} of {_1} other indents than an entry before it `{KEY}`, item {n}, geeft de alinea op byte {start} van {_1} andere inspringingen dan een eerder item +@msg `{KEY}` entry {n} must be an object `{KEY}`, item {n}, moet een object zijn +@msg `{KEY}` entry {n} sets neither `leftIndent` nor `firstLineIndent` `{KEY}`, item {n}, stelt noch `leftIndent` noch `firstLineIndent` in +@msg `{KEY}` entry {n}: `id` must be an object id `{KEY}`, item {n}: `id` moet een object-id zijn +@msg `{KEY}` entry {n}: `start` must be a byte offset `{KEY}`, item {n}: `start` moet een bytepositie zijn +@msg `{KEY}` entry {n}: `{k}` must be a number from -{MAX_PARA} to {MAX_PARA} pt `{KEY}`, item {n}: `{k}` moet een getal van -{MAX_PARA} tot {MAX_PARA} pt zijn +@msg `{KEY}` entry {n}: no paragraph of {_1} starts at byte {start} `{KEY}`, item {n}: er begint geen alinea van {_1} op byte {start} +@msg `{KEY}` entry {n}: unknown key `{k}` `{KEY}`, item {n}: onbekende sleutel `{k}` +@msg `{KEY}` entry {n}: {_1} is not a type object `{KEY}`, item {n}: {_1} is geen tekstobject +@msg `{KEY}` is empty `{KEY}` is leeg +@msg `{KEY}` must be a list `{KEY}` moet een lijst zijn +@msg `{KEY}` takes at most {MAX_PARAGRAPH_INDENTS} entries (got {_1}) `{KEY}` accepteert maximaal {MAX_PARAGRAPH_INDENTS} items (kreeg {_1}) +@msg `{KEY}` takes no `{other}` beside it `{KEY}` accepteert geen `{other}` ernaast +@msg `{_1}` can't be edited or removed `{_1}` kan niet worden bewerkt of verwijderd +@msg `{_1}` is built in and always listed `{_1}` is ingebouwd en staat altijd in de lijst +@msg `{_1}` is not a font file the last text.findFontFiles search found `{_1}` is geen lettertypebestand dat de laatste zoekopdracht van text.findFontFiles heeft gevonden +@msg `{_1}` would be overwritten by the package: choose a different folder or name `{_1}` zou door het pakket worden overschreven: kies een andere map of naam +@msg `{base}` is larger than {_1} MB `{base}` is groter dan {_1} MB +@msg `{base}` is not in the DCS file's folder `{base}` staat niet in de map van het DCS-bestand +@msg `{file}` has no art to place `{file}` heeft geen illustratie om te plaatsen +@msg `{file}` is over {_1} MB `{file}` is groter dan {_1} MB +@msg `{f}` belongs to a VectorCraft that is running `{f}` hoort bij een VectorCraft die actief is +@msg `{f}` is the copy of a document open now `{f}` is de kopie van een document dat nu geopend is +@msg `{id}` is no writable format (see document.formats) `{id}` is geen schrijfbare indeling (zie document.formats) +@msg `{id}` isn't a loaded library `{id}` is geen geladen bibliotheek +@msg `{key}` has no colours `{key}` heeft geen kleuren +@msg `{key}` holds more than {MAX_EDIT_WORDS} words `{key}` bevat meer dan {MAX_EDIT_WORDS} woorden +@msg `{key}` is a design name `{key}` is de naam van een ontwerp +@msg `{key}` is a design name or a list of them `{key}` is de naam van een ontwerp of een lijst daarvan +@msg `{key}` is longer than {MAX_NAME} characters `{key}` is langer dan {MAX_NAME} tekens +@msg `{key}` is out of range `{key}` valt buiten het bereik +@msg `{key}` must be 0 or more `{key}` moet 0 of meer zijn +@msg `{key}` must be [min, desired, max] or {{min?, desired?, max?}}, in percent `{key}` moet [min, desired, max] of {{min?, desired?, max?}} zijn, in procenten +@msg `{key}` must be [x, y] numbers `{key}` moet uit getallen [x, y] bestaan +@msg `{key}` must be a list of words `{key}` moet een lijst met woorden zijn +@msg `{key}` must be a list, not {v} `{key}` moet een lijst zijn, niet {v} +@msg `{key}` must be a non-negative integer `{key}` moet een niet-negatief geheel getal zijn +@msg `{key}` must be a number or null, not {v} `{key}` moet een getal of null zijn, niet {v} +@msg `{key}` must be a number {_1}..{_2} `{key}` moet een getal {_1}..{_2} zijn +@msg `{key}` must be a whole number of 0 or more `{key}` moet een geheel getal van 0 of meer zijn +@msg `{key}` must be a whole number of at least 0, not {n} `{key}` moet een geheel getal van minstens 0 zijn, niet {n} +@msg `{key}` must be an appearance item index (paint order) or null `{key}` moet de index van een vormgevingsitem (verfvolgorde) of null zijn +@msg `{key}` must be an array of asset ids (see assets.list) `{key}` moet een array van asset-id’s zijn (zie assets.list) +@msg `{key}` must be from 0 to 180 degrees, not {a} `{key}` moet van 0 tot 180 graden zijn, niet {a} +@msg `{key}` must be from 0 to {MAX_DISTANCE} pt `{key}` moet van 0 tot {MAX_DISTANCE} pt zijn +@msg `{key}` must be from 0.01 to 1000 pt `{key}` moet van 0,01 tot 1000 pt zijn +@msg `{key}` must be from {_1} to {shift_max} `{key}` moet van {_1} tot {shift_max} zijn +@msg `{key}` must be from {lo} to {hi}, not {v} `{key}` moet van {lo} tot {hi} zijn, niet {v} +@msg `{key}` must be one of auto, always, never `{key}` moet een van auto, always, never zijn +@msg `{key}` must be one of miter, round, bevel `{key}` moet een van miter, round, bevel zijn +@msg `{key}` must be one word of at most {_1} characters `{key}` moet één woord van maximaal {_1} tekens zijn +@msg `{key}` must hold single words of at most {_1} characters `{key}` moet losse woorden van maximaal {_1} tekens bevatten +@msg `{key}` must name an object attached to the path of an Objects on Path group `{key}` moet een object noemen dat aan het pad van een groep Objecten op pad is gekoppeld +@msg `{key}` names an object that is hidden or locked `{key}` noemt een object dat verborgen of vergrendeld is +@msg `{key}`: not a colour: {v} `{key}`: geen kleur: {v} +@msg `{k}.family` is required `{k}.family` is vereist +@msg `{k}` is a number 0..1 `{k}` is een getal 0..1 +@msg `{k}` is true or false `{k}` is true of false +@msg `{k}` isn't an export setting: {_1} `{k}` is geen exportinstelling: {_1} +@msg `{k}` must be a byte offset `{k}` moet een bytepositie zijn +@msg `{k}` must be a number `{k}` moet een getal zijn +@msg `{k}` must be a number of points `{k}` moet een aantal punten zijn +@msg `{k}` must be a string `{k}` moet een string zijn +@msg `{k}` must be a whole number `{k}` moet een geheel getal zijn +@msg `{k}` must be from {lo} to {hi} for {key} `{k}` moet van {lo} tot {hi} zijn voor {key} +@msg `{k}` must be {what}, not {v} `{k}` moet {what} zijn, niet {v} +@msg `{l}` isn't a global or spot colour `{l}` is geen globale kleur of steunkleur +@msg `{m}` isn't a bitmap: use clipboard.importSvg, importPdf or importText `{m}` is geen bitmap: gebruik clipboard.importSvg, importPdf of importText +@msg `{name}` can't be deleted `{name}` kan niet worden verwijderd +@msg `{name}` can't be duplicated `{name}` kan niet worden gedupliceerd +@msg `{name}` can't be edited `{name}` kan niet worden bewerkt +@msg `{name}` can't be edited this way `{name}` kan niet op deze manier worden bewerkt +@msg `{name}` can't be renamed `{name}` kan geen andere naam krijgen +@msg `{name}` can't name a folder `{name}` kan geen naam van een map zijn +@msg `{name}` has no art to place `{name}` heeft geen illustratie om te plaatsen +@msg `{name}` has no text to place `{name}` heeft geen tekst om te plaatsen +@msg `{name}` in the Word document is not UTF-8 or UTF-16 text `{name}` in het Word-document is geen UTF-8- of UTF-16-tekst +@msg `{name}` in the Word document is not well-formed XML: {e} `{name}` in het Word-document is geen welgevormde XML: {e} +@msg `{name}` in the Word document nests elements more than {MAX_NESTING} deep `{name}` in het Word-document nest elementen meer dan {MAX_NESTING} niveaus diep +@msg `{name}` is a built-in preset and is read-only: save it under another name `{name}` is een ingebouwde voorinstelling en is alleen-lezen: sla deze onder een andere naam op +@msg `{name}` is a built-in preset: save under another name `{name}` is een ingebouwde voorinstelling: sla op onder een andere naam +@msg `{name}` is a built-in profile and stays `{name}` is een ingebouwd profiel en blijft bestaan +@msg `{name}` is a file of its own, which can only be found next to the DCS file's path `{name}` is een afzonderlijk bestand, dat alleen naast het pad van het DCS-bestand kan worden gevonden +@msg `{name}` is a tint of `{base}`: edit `{base}` (a tint swatch only takes a new name) `{name}` is een tint van `{base}`: bewerk `{base}` (een tintstaal accepteert alleen een nieuwe naam) +@msg `{name}` is a working space: choose another with edit.colorSettings first `{name}` is een werkruimte: kies eerst een andere met edit.colorSettings +@msg `{name}` is built in and stays `{name}` is ingebouwd en blijft bestaan +@msg `{name}` takes a paint of its own kind (colour, gradient or pattern) `{name}` accepteert een verf van zijn eigen soort (kleur, verloop of patroon) +@msg `{name}`: {_1}: {e} `{name}`: {_1}: {e} +@msg `{n}` can't be deleted `{n}` kan niet worden verwijderd +@msg `{n}` can't be merged `{n}` kan niet worden samengevoegd +@msg `{n}` can't be moved `{n}` kan niet worden verplaatst +@msg `{n}` is not a colour swatch `{n}` is geen kleurstaal +@msg `{n}` isn't a solid colour `{n}` is geen effen kleur +@msg `{n}`: colour groups hold solid colours only `{n}`: kleurgroepen bevatten alleen effen kleuren +@msg `{other}` doesn't trace an image `{other}` traceert geen afbeelding +@msg `{s}`: the step's references copy in more than {_1} MB of values `{s}`: de verwijzingen van de stap kopiëren meer dan {_1} MB aan waarden +@msg `{tag}` is not an axis tag: a tag is four characters, such as "wght" `{tag}` is geen astag: een tag bestaat uit vier tekens, zoals "wght" +@msg `{to}` is empty or already used `{to}` is leeg of al in gebruik +@msg `{u}` is no Unicode character `{u}` is geen Unicode-teken +@msg `{what}` is longer than {MAX_TEXT} bytes `{what}` is langer dan {MAX_TEXT} bytes +@msg `{what}` must be text `{what}` moet tekst zijn +@msg `{word}` isn't in the custom dictionary `{word}` staat niet in het aangepaste woordenboek +@msg a CMap has too many mappings een CMap heeft te veel toewijzingen +@msg a DXF drawing has one origin: pass useArtboards: true for one drawing per artboard een DXF-tekening heeft één oorsprong: geef useArtboards: true op voor één tekening per tekengebied +@msg a PDF presets file with over {_1} presets een bestand met PDF-voorinstellingen met meer dan {_1} voorinstellingen +@msg a \\u escape needs four hexadecimal digits een \\u-escape heeft vier hexadecimale cijfers nodig +@msg a batch preview cannot switch documents een batchvoorvertoning kan niet van document wisselen +@msg a brush named `{nn}` exists er bestaat al een penseel met de naam `{nn}` +@msg a comma in an XPath expression must separate function arguments een komma in een XPath-expressie moet functieargumenten scheiden +@msg a container of the listed objects is gone een container van de vermelde objecten is verdwenen +@msg a content stream can't be read een inhoudsstroom kan niet worden gelezen +@msg a content stream isn't a stream een inhoudsstroom is geen stroom +@msg a design holds at most {_1} objects een ontwerp bevat maximaal {_1} objecten +@msg a design needs a name een ontwerp heeft een naam nodig +@msg a dictionary grew too large een woordenboek is te groot geworden +@msg a document holds at most {_1} SVG filters een document bevat maximaal {_1} SVG-filters +@msg a document keeps at most {_1} graph designs een document bewaart maximaal {_1} grafiekontwerpen +@msg a document keeps at most {_1} saved selections een document bewaart maximaal {_1} opgeslagen selecties +@msg a document keeps at most {_1} views een document bewaart maximaal {_1} weergaven +@msg a document links at most {MAX_SVG_SCRIPTS} JavaScript files een document koppelt maximaal {MAX_SVG_SCRIPTS} JavaScript-bestanden +@msg a document with unsaved changes has no recovery copy een document met niet-opgeslagen wijzigingen heeft geen herstelkopie +@msg a feConvolveMatrix filter's order is {x}×{y}, which overflows the kernel-size multiply usvg makes de orde van een feConvolveMatrix-filter is {x}×{y}, waardoor de vermenigvuldiging van de kernelgrootte in usvg overloopt +@msg a font's data is too large de gegevens van een lettertype zijn te groot +@msg a font's subroutines are too large de subroutines van een lettertype zijn te groot +@msg a function declaration without a name een functiedeclaratie zonder naam +@msg a gradient preset is already called {n} er heet al een verloopvoorinstelling {n} +@msg a graph has at most {_1} series, so it transposes with at most that many categories een grafiek heeft maximaal {_1} reeksen, dus kan hij met hoogstens zoveel categorieën worden getransponeerd +@msg a host value has too many entries een hostwaarde heeft te veel items +@msg a host value is nested too deep een hostwaarde is te diep genest +@msg a layer can't be merged into its own sublayer een laag kan niet in zijn eigen sublaag worden samengevoegd +@msg a layer's form box isn't an array het kader van het formulier van een laag is geen array +@msg a layer's form can't be read het formulier van een laag kan niet worden gelezen +@msg a layer's form has no box het formulier van een laag heeft geen kader +@msg a layer's form has no dictionary het formulier van een laag heeft geen woordenboek +@msg a legend draws at most {MAX_CHIPS} swatches een legenda tekent maximaal {MAX_CHIPS} stalen +@msg a linked JavaScript file is outside the read roots een gekoppeld JavaScript-bestand staat buiten de leesroots +@msg a name names one asset: give multiple: false, or one object een naam noemt één asset: geef multiple: false, of één object +@msg a namespace declaration uses a reserved prefix or URI een naamruimtedeclaratie gebruikt een gereserveerd voorvoegsel of een gereserveerde URI +@msg a namespace qualifier is undefined een naamruimtekwalificatie is niet gedefinieerd +@msg a namespace with an empty URI cannot have a prefix een naamruimte met een lege URI kan geen voorvoegsel hebben +@msg a number has no digits een getal heeft geen cijfers +@msg a number's exponent has no digits de exponent van een getal heeft geen cijfers +@msg a number's fraction has no digits het breukdeel van een getal heeft geen cijfers +@msg a page can't be read een pagina kan niet worden gelezen +@msg a page object is used by something else een paginaobject wordt door iets anders gebruikt +@msg a page thumbnail must be RGB pixels, 1 to {THUMBNAIL_SIZE} a side (got {w} × {h}) een paginaminiatuur moet uit RGB-pixels bestaan, 1 tot {THUMBNAIL_SIZE} per zijde (kreeg {w} × {h}) +@msg a pattern layer doesn't end what it starts een patroonlaag sluit niet af wat hij begint +@msg a pattern layer's colors hold something else de kleuren van een patroonlaag bevatten iets anders +@msg a pattern named `{n}` exists er bestaat al een patroon met de naam `{n}` +@msg a plug-in with id {_1} is already installed er is al een plug-in met id {_1} geïnstalleerd +@msg a preset named `{n}` exists er bestaat al een voorinstelling met de naam `{n}` +@msg a print presets file with over {_1} presets een bestand met afdrukvoorinstellingen met meer dan {_1} voorinstellingen +@msg a profile is already called {n} er heet al een profiel {n} +@msg a property descriptor cannot have both a value or writable and a get or set een eigenschapsdescriptor kan niet zowel value of writable als get of set hebben +@msg a property descriptor must be an object een eigenschapsdescriptor moet een object zijn +@msg a property's {name} must be a function or undefined de {name} van een eigenschap moet een functie of undefined zijn +@msg a row can't go into itself een rij kan niet in zichzelf worden geplaatst +@msg a series goes on the left or the right value axis een reeks hoort op de linker- of de rechterwaardeas +@msg a start must be an anchor index ≥ 0 or null een start moet een ankerindex ≥ 0 of null zijn +@msg a stream in it would decode to more than 256 MB, or its decode parameters can't be applied een stroom erin zou tot meer dan 256 MB worden gedecodeerd, of de decodeerparameters ervan kunnen niet worden toegepast +@msg a string holds a control character een string bevat een besturingsteken +@msg a string holds an escape sequence JSON does not have een string bevat een escapereeks die JSON niet kent +@msg a string is not closed een string is niet afgesloten +@msg a style named `{name}` already exists er bestaat al een stijl met de naam `{name}` +@msg a style named `{to}` already exists er bestaat al een stijl met de naam `{to}` +@msg a swatch needs a colour, gradient or pattern een staal heeft een kleur, verloop of patroon nodig +@msg a symbol named `{n}` already exists er bestaat al een symbool met de naam `{n}` +@msg a theme has 1 to {THEME_SIZE} colours een thema heeft 1 tot {THEME_SIZE} kleuren +@msg a theme is already called {name} (replace: "{name}" overwrites it) er heet al een thema {name} (replace: "{name}" overschrijft het) +@msg a toolbar name has at most {MAX_NAME} characters de naam van een werkbalk heeft maximaal {MAX_NAME} tekens +@msg a view named `{_1}` exists er bestaat al een weergave met de naam `{_1}` +@msg a view named `{name}` exists er bestaat al een weergave met de naam `{name}` +@msg a workspace keeps at most {MAX} toolbars een werkruimte bewaart maximaal {MAX} werkbalken +@msg a {_1} series can't go in a {_2} graph een reeks van het type {_1} kan niet in een grafiek van het type {_2} staan +@msg aiVersion {v}: "pdf" (PDF-compatible, the default) or "7" (legacy .ai, version 7) aiVersion {v}: "pdf" (PDF-compatibel, de standaard) of "7" (oude .ai, versie 7) +@msg already editing an opacity mask er wordt al een dekkingmasker bewerkt +@msg already editing another object's opacity mask het dekkingmasker van een ander object wordt al bewerkt +@msg already in pattern editing mode de patroonbewerkingsmodus is al actief +@msg an SVG filter is named by its id: give `xml` with `name` een SVG-filter wordt bij zijn id genoemd: geef `xml` met `name` +@msg an XML element has two attributes with the same name een XML-element heeft twee attributen met dezelfde naam +@msg an XML value cannot be inserted into itself or its descendants een XML-waarde kan niet in zichzelf of in zijn afstammelingen worden ingevoegd +@msg an XML value's children cannot be assigned by position de onderliggende elementen van een XML-waarde kunnen niet op positie worden toegewezen +@msg an XML value's children cannot be deleted by position de onderliggende elementen van een XML-waarde kunnen niet op positie worden verwijderd +@msg an XMLList converts to XML only when it has one item een XMLList wordt alleen naar XML geconverteerd wanneer deze één item heeft +@msg an XPath node test is missing er ontbreekt een XPath-knooppunttest +@msg an XPath operand is missing er ontbreekt een XPath-operand +@msg an XPath operator is missing er ontbreekt een XPath-operator +@msg an XPath predicate or step cannot follow here hier kan geen XPath-predicaat of -stap volgen +@msg an XPath predicate or step follows a value that is not a node-set een XPath-predicaat of -stap volgt op een waarde die geen knooppuntenset is +@msg an XPath step is missing er ontbreekt een XPath-stap +@msg an artboard is listed twice een tekengebied staat twee keer in de lijst +@msg an empty artboard has no width or height to scale to een leeg tekengebied heeft geen breedte of hoogte om naar te schalen +@msg an image couldn't be decoded and is missing from the picture een afbeelding kon niet worden gedecodeerd en ontbreekt in het beeld +@msg an image is too large for DXF and was left out een afbeelding is te groot voor DXF en is weggelaten +@msg an image of {_1} MB, at most {_2} MB een afbeelding van {_1} MB, maximaal {_2} MB +@msg an image of {declared_w} × {declared_h} pixels is too large to draw een afbeelding van {declared_w} × {declared_h} pixels is te groot om te tekenen +@msg an image of {width} × {height} pixels is too large to draw een afbeelding van {width} × {height} pixels is te groot om te tekenen +@msg an image of {w} × {h} pixels is too large to convert (at most {_1} pixels) een afbeelding van {w} × {h} pixels is te groot om te converteren (maximaal {_1} pixels) +@msg an index must be a whole number een index moet een geheel getal zijn +@msg an inline graphic has no glyphs een inline afbeelding heeft geen glyphs +@msg an invisible text form can't be read een formulier met onzichtbare tekst kan niet worden gelezen +@msg an object is missing er ontbreekt een object +@msg an object's header is missing de kop van een object ontbreekt +@msg an overprinting form can't be read een overdrukkend formulier kan niet worden gelezen +@msg an unread object has no readable bounds een ongelezen object heeft geen leesbare grenzen +@msg an unread object holds a frame of threaded type een ongelezen object bevat een kader van gekoppelde tekst +@msg an unread object is missing from its layer een ongelezen object ontbreekt in zijn laag +@msg anchor `smooth` must be true or false `smooth` van het anker moet true of false zijn +@msg anchor `{key}` must be [x, y] `{key}` van het anker moet [x, y] zijn +@msg anchor `{key}` must be a number `{key}` van het anker moet een getal zijn +@msg angle and roundness must be finite hoek en ronding moeten eindig zijn +@msg angles must be a list as long as pins (degrees or null) angles moet een lijst zijn die even lang is als pins (graden of null) +@msg appearance must be flat|center|edge appearance moet flat|center|edge zijn +@msg apply is "fill" or "stroke", not `{other}` apply is "fill" of "stroke", niet `{other}` +@msg apply was called on a value that is not a function apply is aangeroepen op een waarde die geen functie is +@msg area must be a closed polygon of 3 to 100000 [x, y] points area moet een gesloten polygoon van 3 tot 100000 punten [x, y] zijn +@msg area type in a thread cannot use Dynamic Text: {frames} vlaktekst in gekoppelde tekst kan geen dynamische tekst gebruiken: {frames} +@msg area type needs a path that encloses an area vlaktekst heeft een pad nodig dat een oppervlak omsluit +@msg area type {_1} is named twice vlaktekst {_1} wordt twee keer genoemd +@msg array literal too long arrayliteral te lang +@msg arrowAlign must be extend|tip, got {o} arrowAlign moet extend|tip zijn, kreeg {o} +@msg arrowScale must be [start, end] arrowScale moet [start, end] zijn +@msg artboard is a 0-based index artboard is een index die bij 0 begint +@msg artboard must be a 0-based index artboard moet een index zijn die bij 0 begint +@msg artboard {i} doesn't print tekengebied {i} wordt niet afgedrukt +@msg artboardLayout must be {layout?, columns?, spacing?, rightToLeft?} artboardLayout moet {layout?, columns?, spacing?, rightToLeft?} zijn +@msg artboardLayout.columns must be 1 or more artboardLayout.columns moet 1 of meer zijn +@msg artboardLayout.layout must be gridByRow, gridByColumn, row or column artboardLayout.layout moet gridByRow, gridByColumn, row of column zijn +@msg artboardLayout.rightToLeft must be true or false artboardLayout.rightToLeft moet true of false zijn +@msg artboardLayout.spacing must be 0–{MAX_SPACING} pt artboardLayout.spacing moet 0–{MAX_SPACING} pt zijn +@msg artboards must be a non-empty list artboards moet een niet-lege lijst zijn +@msg artboards must be a number artboards moet een getal zijn +@msg asset `{_1}` has no art to export asset `{_1}` heeft geen illustratie om te exporteren +@msg assignment to a constant binding toewijzing aan een constante binding +@msg at least one row that isn't excluded needs a weight above 0 minstens één rij die niet is uitgesloten heeft een gewicht boven 0 nodig +@msg at most {MAX_KEYWORDS} keywords maximaal {MAX_KEYWORDS} trefwoorden +@msg at most {MAX_MATCHES} matches are kept er worden maximaal {MAX_MATCHES} overeenkomsten bewaard +@msg at most {MAX_POINTS} points maximaal {MAX_POINTS} punten +@msg at most {MAX_QUEUE} files maximaal {MAX_QUEUE} bestanden +@msg at must be [x, y] at moet [x, y] zijn +@msg at/rect lie outside the canvas at/rect liggen buiten het canvas +@msg attribute must be size|leading|tracking|kerning|baselineShift attribute moet size|leading|tracking|kerning|baselineShift zijn +@msg attrs must be an object attrs moet een object zijn +@msg automation path rejected: the folder's name isn't valid text automatiseringspad geweigerd: de naam van de map is geen geldige tekst +@msg automation path rejected: {_1} isn't valid text automatiseringspad geweigerd: {_1} is geen geldige tekst +@msg automation path rejected: {why}: {path} automatiseringspad geweigerd: {why}: {path} +@msg axis must be "vertical", "horizontal" or an angle in degrees, not `{given}` axis moet "vertical", "horizontal" of een hoek in graden zijn, niet `{given}` +@msg backgroundContents must be transparent or white backgroundContents moet transparent of white zijn +@msg bad AES key ongeldige AES-sleutel +@msg bad `runs`: {e} ongeldige `runs`: {e} +@msg bad arrowScale ongeldige arrowScale +@msg bad base64 ongeldige base64 +@msg bad color {c} ongeldige kleur {c} +@msg bad colour ongeldige kleur +@msg bad colour in `colors` ongeldige kleur in `colors` +@msg bad colour {v} ongeldige kleur {v} +@msg bad colour {v} in groupColors ongeldige kleur {v} in groupColors +@msg bad cross-reference entry ongeldig item in de kruisverwijzingstabel +@msg bad cross-reference table ongeldige kruisverwijzingstabel +@msg bad current colour {v} ongeldige huidige kleur {v} +@msg bad dataBase64 ongeldige dataBase64 +@msg bad edit ongeldige bewerking +@msg bad fill {v} ongeldige vulling {v} +@msg bad fit: {e} ongeldige passing: {e} +@msg bad model {other} (keep, new or document) ongeldig model {other} (keep, new of document) +@msg bad new colour {v} ongeldige nieuwe kleur {v} +@msg bad object ongeldig object +@msg bad object number ongeldig objectnummer +@msg bad offset ongeldige positie +@msg bad path data: {e} ongeldige padgegevens: {e} +@msg bad point {v}: expected [x, y] ongeldig punt {v}: verwacht [x, y] +@msg bad point {v}: expected [x, y] or [x, y, pressure] ongeldig punt {v}: verwacht [x, y] of [x, y, pressure] +@msg bad reference ongeldige verwijzing +@msg bad trailer size ongeldige grootte in de trailer +@msg bad {k} colour ongeldige kleur voor {k} +@msg batches cannot nest batches kunnen niet worden genest +@msg bind something to a variable first koppel eerst iets aan een variabele +@msg bleed must be 0–{MAX_BLEED} pt: a number, [top, bottom, left, right] or {{top, bottom, left, right}} bleed moet 0–{MAX_BLEED} pt zijn: een getal, [top, bottom, left, right] of {{top, bottom, left, right}} +@msg blend must be a mode name blend moet de naam van een modus zijn +@msg both sides of an XPath | must select nodes beide zijden van een XPath-| moeten knooppunten selecteren +@msg brush must be a name or null brush moet een naam of null zijn +@msg by must be a number by moet een getal zijn +@msg can't add page thumbnails: {why} kan geen paginaminiaturen toevoegen: {why} +@msg can't add the editing data for other apps: {why} kan de bewerkingsgegevens voor andere apps niet toevoegen: {why} +@msg can't edit the written PDF: {why} kan de geschreven PDF niet bewerken: {why} +@msg can't encrypt the PDF: {why} kan de PDF niet versleutelen: {why} +@msg can't linearise the PDF: {why} kan de PDF niet lineariseren: {why} +@msg can't open `{_1}`: {_2} kan `{_1}` niet openen: {_2} +@msg can't open `{_1}`: {e} kan `{_1}` niet openen: {e} +@msg can't open `{name}`: not a format VectorCraft reads (see document.formats) kan `{name}` niet openen: geen indeling die VectorCraft leest (zie document.formats) +@msg can't place `{name}`: not a format VectorCraft reads (see document.formats) kan `{name}` niet plaatsen: geen indeling die VectorCraft leest (zie document.formats) +@msg can't read back the written PDF: {e} kan de geschreven PDF niet teruglezen: {e} +@msg can't read this Word document: {why} kan dit Word-document niet lezen: {why} +@msg can't write .{e} images: use .png, .jpg, .gif, .webp, .tif or .bmp kan geen .{e}-afbeeldingen schrijven: gebruik .png, .jpg, .gif, .webp, .tif of .bmp +@msg can't write PDF layers, overprint or invisible text: {why} kan geen PDF-lagen, overdruk of onzichtbare tekst schrijven: {why} +@msg can't write the file's copyright: {why} kan het copyright van het bestand niet schrijven: {why} +@msg can't write the file's modification date: {why} kan de wijzigingsdatum van het bestand niet schrijven: {why} +@msg can't write the pages' user units: {why} kan de gebruikerseenheden van de pagina’s niet schrijven: {why} +@msg canceled geannuleerd +@msg cannot convert the object to a primitive value kan het object niet naar een primitieve waarde converteren +@msg cannot convert undefined or null to an object kan undefined of null niet naar een object converteren +@msg cannot distort a zero-size or non-finite bounding box kan een selectiekader zonder grootte of met niet-eindige afmetingen niet vervormen +@msg cannot move an object into itself kan een object niet in zichzelf verplaatsen +@msg case must be upper|lower|title|sentence case moet upper|lower|title|sentence zijn +@msg category `{c}`: one of {_1} categorie `{c}`: een van {_1} +@msg center must be [x, y] center moet [x, y] zijn +@msg character dimensions cannot be represented with the source text transform tekenafmetingen kunnen niet worden weergegeven met de teksttransformatie van de bron +@msg character dimensions cannot be represented with the target text transform tekenafmetingen kunnen niet worden weergegeven met de teksttransformatie van het doel +@msg choose at least one artboard kies minstens één tekengebied +@msg choose at least one status kies minstens één status +@msg clip must be true or false clip moet true of false zijn +@msg clippingMask must be true or false clippingMask moet true of false zijn +@msg closed must be a boolean closed moet een boolean zijn +@msg collapsed must be true or false collapsed moet true of false zijn +@msg color.profile: no RGB or CMYK profile is called “{profile}” color.profile: er is geen RGB- of CMYK-profiel met de naam „{profile}” +@msg colorMode must be rgb or cmyk, not `{m}` colorMode moet rgb of cmyk zijn, niet `{m}` +@msg colorModel must be {own} (the document's mode), grayscale or bitmap colorModel moet {own} (de modus van het document), grayscale of bitmap zijn +@msg colour groups can't go into colour groups kleurgroepen kunnen niet in kleurgroepen worden geplaatst +@msg colour, mode and spot apply to solid-colour swatches only colour, mode en spot gelden alleen voor stalen met een effen kleur +@msg column {column}: `{cell}` is a `%` column of graph data files, which are not read kolom {column}: `{cell}` is een `%`-kolom van grafiekgegevensbestanden, die niet worden gelezen +@msg column {column}: `{cell}` names `{name}`, which is a {_1} variable kolom {column}: `{cell}` noemt `{name}`, en dat is een variabele van het type {_1} +@msg column {column}: `{cell}` names no variable kolom {column}: `{cell}` noemt geen variabele +@msg column {column}: the variable name is longer than {MAX_NAME} characters kolom {column}: de naam van de variabele is langer dan {MAX_NAME} tekens +@msg column: true floats the whole column and takes no onto, above or below column: true laat de hele kolom zweven en accepteert geen onto, above of below +@msg command must be a shape.* command command moet een shape.*-opdracht zijn +@msg commands[{i}]: missing `command` commands[{i}]: `command` ontbreekt +@msg composer must be "singleLine" or "everyLine" composer moet "singleLine" of "everyLine" zijn +@msg compound shapes take paths, compound paths, groups, compound shapes, type, blends and envelopes samengestelde vormen accepteren paden, samengestelde paden, groepen, samengestelde vormen, tekst, mengsels en omvormingen +@msg compound {_1} must contain exactly one open path to join samengesteld object {_1} moet precies één open pad bevatten om te verbinden +@msg connect needs a path other than the one extended connect heeft een ander pad nodig dan het pad dat wordt verlengd +@msg connect needs id connect heeft id nodig +@msg connect path has no open end het pad van connect heeft geen open uiteinde +@msg continuation must be an array of path chunks continuation moet een array van padstukken zijn +@msg continuation requires points continuation vereist points +@msg copy needs path: the file to copy into the document's folder copy heeft path nodig: het bestand dat naar de map van het document wordt gekopieerd +@msg copy takes images only: relink placed documents where their files are copy accepteert alleen afbeeldingen: koppel geplaatste documenten opnieuw op de plek waar hun bestanden staan +@msg copying a file isn't available on the web een bestand kopiëren is niet beschikbaar op het web +@msg copyrightStatus must be unknown, copyrighted or publicDomain copyrightStatus moet unknown, copyrighted of publicDomain zijn +@msg copyrightUrl must be a URL (no spaces, at most 2048 characters) copyrightUrl moet een URL zijn (geen spaties, maximaal 2048 tekens) +@msg corners must be 4 [x, y] points (TL, TR, BR, BL) corners moet uit 4 punten [x, y] bestaan (LB, RB, RO, LO) +@msg counterPer `{c}`: item or file counterPer `{c}`: item of file +@msg crop `{_1}`: only PDF pages have art, trim, bleed and media boxes; use "crop" or "bounding" crop `{_1}`: alleen PDF-pagina’s hebben art-, trim-, bleed- en mediakaders; gebruik "crop" of "bounding" +@msg crop rectangle doesn't overlap the image de bijsnijdrechthoek overlapt de afbeelding niet +@msg cross-reference and object streams aren't supported kruisverwijzings- en objectstromen worden niet ondersteund +@msg damaged compressed data: {e} beschadigde gecomprimeerde gegevens: {e} +@msg dash lengths must be numbers, got {v} streeplengten moeten getallen zijn, kreeg {v} +@msg dash must be a list of lengths or null, got {v} dash moet een lijst met lengten of null zijn, kreeg {v} +@msg data key `{k}`: letters, digits, -, _ and . (not name or vc-…) gegevenssleutel `{k}`: letters, cijfers, -, _ en . (niet name of vc-…) +@msg data must be an object of key: value, not {v} data moet een object van sleutel: waarde zijn, niet {v} +@msg data set `{name}` holds a value for `{var}`, which the library doesn't declare gegevensset `{name}` bevat een waarde voor `{var}`, die de bibliotheek niet declareert +@msg data set `{name}` holds two values for `{var}` gegevensset `{name}` bevat twee waarden voor `{var}` +@msg data set `{name}` is declared twice gegevensset `{name}` is twee keer gedeclareerd +@msg data takes at most {MAX_DATA} keys at once data accepteert maximaal {MAX_DATA} sleutels tegelijk +@msg dataset `{name}` already exists gegevensset `{name}` bestaat al +@msg dataset `{to}` already exists gegevensset `{to}` bestaat al +@msg date `{d}`: YYYY-MM-DD datum `{d}`: YYYY-MM-DD +@msg decoded data is too large de gedecodeerde gegevens zijn te groot +@msg define a variable first definieer eerst een variabele +@msg detect must be true or false detect moet true of false zijn +@msg direct-select anchor points of a path selecteer met directe selectie ankerpunten van een pad +@msg distance must be > 0 distance moet > 0 zijn +@msg dx and dy give the arrow's direction dx en dy geven de richting van de pijl +@msg dx and dy must be numbers dx en dy moeten getallen zijn +@msg dxf fitTo must be [width, height], positive dxf fitTo moet [breedte, hoogte] zijn, positief +@msg dxf must be an object of DXF import options dxf moet een object met DXF-importopties zijn +@msg dxf scale must be a positive number up to {_1}, not {s} dxf scale moet een positief getal tot en met {_1} zijn, niet {s} +@msg dxf unit `{u}`: a unit such as mm, cm, in or pt dxf unit `{u}`: een eenheid zoals mm, cm, in of pt +@msg dxf: {e} dxf: {e} +@msg each format is an object {format, scale?, suffix?} elke indeling is een object {format, scale?, suffix?} +@msg each item needs an id elk item heeft een id nodig +@msg each match needs `kind` elke overeenkomst heeft `kind` nodig +@msg each match needs a `name` elke overeenkomst heeft een `name` nodig +@msg each of `fonts` is {family, style?}; 1 to 1000 of them elk item van `fonts` is {family, style?}; 1 tot 1000 stuks +@msg each of `items` is {kind, item} elk item van `items` is {kind, item} +@msg each of `items` is {{id, corners?}} with an object id, not {it} elk item van `items` is {{id, corners?}} met een object-id, niet {it} +@msg each path chunk must contain 1 to 4096 points elk padstuk moet 1 tot 4096 punten bevatten +@msg each pick is {{at: [x, y]}} or {{rect: [x0, y0, x1, y1]}} (got {v}) elke keuze is {{at: [x, y]}} of {{rect: [x0, y0, x1, y1]}} (kreeg {v}) +@msg each row needs `from` elke rij heeft `from` nodig +@msg each stop needs a position elke stop heeft een positie nodig +@msg each subpath needs an anchors array elk subpad heeft een array anchors nodig +@msg each weight must be a number of 0 or more (got {v}) elk gewicht moet een getal van 0 of meer zijn (kreeg {v}) +@msg easingType must be easeIn, easeOut, easeInOut or easeOutIn easingType moet easeIn, easeOut, easeInOut of easeOutIn zijn +@msg editingData must be true or false editingData moet true of false zijn +@msg editingData must be true, false or "always" editingData moet true, false of "always" zijn +@msg edits overlap bewerkingen overlappen elkaar +@msg effects of objects whose appearances differ can't be moved together effecten van objecten met een verschillende vormgeving kunnen niet samen worden verplaatst +@msg empty header in column {_1} lege koptekst in kolom {_1} +@msg encoding `{_1}`: utf8 or utf16 codering `{_1}`: utf8 of utf16 +@msg ends must be two of "first" and "last" ends moet uit twee waarden "first" en "last" bestaan +@msg every numbered name for the result is taken elke genummerde naam voor het resultaat is al in gebruik +@msg expanded SVG styles exceed the import size limit uitgevouwen SVG-stijlen overschrijden de groottelimiet voor importeren +@msg export presets file is larger than {MAX_PRESET_FILE_BYTES} bytes het bestand met exportvoorinstellingen is groter dan {MAX_PRESET_FILE_BYTES} bytes +@msg exportText must be editable or appearance exportText moet editable of appearance zijn +@msg exportType must be movieClip or graphic, not `{s}` exportType moet movieClip of graphic zijn, niet `{s}` +@msg extend needs id extend heeft id nodig +@msg featureChanges lists at most {MAX_FEATURE_CHANGES} tags featureChanges bevat maximaal {MAX_FEATURE_CHANGES} tags +@msg featureChanges must be a list of tags featureChanges moet een lijst met tags zijn +@msg features must be a list of tags features moet een lijst met tags zijn +@msg fidelity must be 0..100 fidelity moet 0..100 zijn +@msg files must be {name, dataBase64} files moet {name, dataBase64} zijn +@msg finally table {t} out of range finally-tabel {t} buiten het bereik +@msg fit must be none|autoHeight|shrinkText|block, got {id} fit moet none|autoHeight|shrinkText|block zijn, kreeg {id} +@msg flags cannot be given with a RegExp object flags kunnen niet samen met een RegExp-object worden opgegeven +@msg flattener: {e} afvlakker: {e} +@msg flattenerPreset `{name}`: high, medium, low or a saved one (see flattener.presets.list) flattenerPreset `{name}`: high, medium, low of een opgeslagen voorinstelling (zie flattener.presets.list) +@msg flipProfile must be along|across, got {o} flipProfile moet along|across zijn, kreeg {o} +@msg folders `{f}`: none, rows, format, item or itemFormat folders `{f}`: none, rows, format, item of itemFormat +@msg folders deeper than {MAX_BATCH_DEPTH} levels mappen dieper dan {MAX_BATCH_DEPTH} niveaus +@msg folders deeper than {MAX_DEPTH} levels mappen dieper dan {MAX_DEPTH} niveaus +@msg font family `{family}` is not available lettertypefamilie `{family}` is niet beschikbaar +@msg font family `{tf}` is not available lettertypefamilie `{tf}` is niet beschikbaar +@msg format `{f}`: pdf or postscript format `{f}`: pdf of postscript +@msg format `{f}`: text or json format `{f}`: text of json +@msg format is `{format}` de indeling is `{format}` +@msg formats must be an array of rows, not {v} formats moet een array van rijen zijn, niet {v} +@msg frequency must be between 1 and 300 lines per inch frequency moet tussen 1 en 300 lijnen per inch liggen +@msg from and to must be finite from en to moeten eindig zijn +@msg from must be [x0, y0, x1, y1] from moet [x0, y0, x1, y1] zijn +@msg function declaration index out of range index van functiedeclaratie buiten het bereik +@msg give `before` or `after`, not both geef `before` of `after`, niet beide +@msg give `char`, `text`, `code` or `unicode` geef `char`, `text`, `code` of `unicode` +@msg give `colors`, or `color` and `rule` geef `colors`, of `color` en `rule` +@msg give `count` or `spacing`, not both geef `count` of `spacing`, niet beide +@msg give `event`, such as onclick geef `event`, zoals onclick +@msg give `file`, the JavaScript file's path or URL geef `file`, het pad of de URL van het JavaScript-bestand +@msg give `fill` and/or `stroke` geef `fill` en/of `stroke` +@msg give `fill`, `stroke` or both geef `fill`, `stroke` of beide +@msg give `folder` geef `folder` +@msg give `fonts`, or open a document geef `fonts`, of open een document +@msg give `from` or `indices`, not both geef `from` of `indices`, niet beide +@msg give `id` (no text is being edited) geef `id` (er wordt geen tekst bewerkt) +@msg give `id` and `anchors`, or `items`, not both geef `id` en `anchors`, of `items`, niet beide +@msg give `id` or `guide`, not both geef `id` of `guide`, niet beide +@msg give `length` or `to` geef `length` of `to` +@msg give `matches`: [{kind, name, target}] geef `matches`: [{kind, name, target}] +@msg give `name` (or edit a pattern) geef `name` (of bewerk een patroon) +@msg give `name` or `names` geef `name` of `names` +@msg give `name`, an SVG filter's name geef `name`, de naam van een SVG-filter +@msg give `path` (a .wasm file) or `dataBase64` (the module) geef `path` (een .wasm-bestand) of `dataBase64` (de module) +@msg give `path`, `data` or `dataBase64` geef `path`, `data` of `dataBase64` +@msg give `path`, `data`, `dataBase64` or `csv` geef `path`, `data`, `dataBase64` of `csv` +@msg give `path`, `xml` or `dataBase64` geef `path`, `xml` of `dataBase64` +@msg give `path`, an SVG file, or `svg`, SVG text geef `path`, een SVG-bestand, of `svg`, SVG-tekst +@msg give `script`, the JavaScript the event runs ("" removes the event) geef `script`, de JavaScript die de gebeurtenis uitvoert ("" verwijdert de gebeurtenis) +@msg give `text` (the reading) or `remove` geef `text` (de lezing) of `remove` +@msg give `x` and `y` (and a `tolerance` of 0 or more) geef `x` en `y` (en een `tolerance` van 0 of meer) +@msg give `xml`, one SVG element geef `xml`, één SVG-element +@msg give a mode or r/g/b, c/m/y/k, gray or tint adjustments geef een modus of aanpassingen voor r/g/b, c/m/y/k, gray of tint +@msg give a name, or paint the active proxy with a saved preset geef een naam, of verf de actieve proxy met een opgeslagen voorinstelling +@msg give a name, or select a stroke with a saved profile geef een naam, of selecteer een contour met een opgeslagen profiel +@msg give a pattern name or select an object painted with a pattern geef de naam van een patroon of selecteer een object dat met een patroon is geverfd +@msg give at least one of clip, invert, disabled, linked geef minstens een van clip, invert, disabled, linked +@msg give color, none, swatch or gradient geef color, none, swatch of gradient +@msg give dataBase64 geef dataBase64 +@msg give either at (a click) or area (a path drawn around the overlaps) geef at (een klik) of area (een pad dat rond de overlappingen is getekend) +@msg give exactly one of `at`, `rect` and `points` geef precies een van `at`, `rect` en `points` +@msg give exactly one of `path`, `data` and `dataBase64` geef precies een van `path`, `data` en `dataBase64` +@msg give formats or a preset, not both geef formats of een voorinstelling, niet beide +@msg give index or indexes, not both geef index of indexes, niet beide +@msg give newName or delete geef newName of delete +@msg give offset or by geef offset of by +@msg give one element geef één element +@msg give one of `to`, `rect` or `at` geef een van `to`, `rect` of `at` +@msg give one of assets, layers, selection or fullDocument geef een van assets, layers, selection of fullDocument +@msg give only one of onto, above, below, icon and a column place geef slechts een van onto, above, below, icon en een kolomplaats +@msg give opacity or blend geef opacity of blend +@msg give origin: [x, y], or reset: true geef origin: [x, y], of reset: true +@msg give overprintFill, overprintStroke, showCenter, imageMap, url or note geef overprintFill, overprintStroke, showCenter, imageMap, url of note +@msg give path (a file) or folder geef path (een bestand) of folder +@msg give path, or name and dataBase64 geef path, of name en dataBase64 +@msg give paths or files geef paths of files +@msg give rows, rowHeight, columns or columnWidth geef rows, rowHeight, columns of columnWidth +@msg give svg, or dataBase64 of an SVG or SVGZ file geef svg, of dataBase64 van een SVG- of SVGZ-bestand +@msg give text geef text +@msg give the asset a name geef de asset een naam +@msg give the preset a `name` geef de voorinstelling een `name` +@msg give the preset a name geef de voorinstelling een naam +@msg give the preset a name (1–64 characters) geef de voorinstelling een naam (1–64 tekens) +@msg give the settings to change, e.g. {"formats"}]} geef de instellingen die moeten worden gewijzigd, bijv. {"formats"}]} +@msg give the style a name geef de stijl een naam +@msg give two or more style `names` geef twee of meer `names` van stijlen +@msg give two or more swatches geef twee of meer stalen +@msg give x, y, or a handle's length or angle geef x, y, of de lengte of hoek van een handgreep +@msg give {key, value} or {values} geef {key, value} of {values} +@msg global must be true or false global moet true of false zijn +@msg glyph {_1} is not drawn for {ch} with the character's style (such as All Caps, Small Caps or a numeral system) glyph {_1} wordt niet getekend voor {ch} met de stijl van het teken (zoals hoofdletters, kleinkapitalen of een cijfersysteem) +@msg glyph {g} is not an alternate of {ch} in {_1} {_2} glyph {g} is geen alternatief voor {ch} in {_1} {_2} +@msg gradient must be "objects" or "mesh" gradient moet "objects" of "mesh" zijn +@msg grays must be "profile" or "black", not `{g}` grays moet "profile" of "black" zijn, niet `{g}` +@msg gridColors must be a preset name or two colours gridColors moet de naam van een voorinstelling of twee kleuren zijn +@msg gridSize must be small, medium or large gridSize moet small, medium of large zijn +@msg guide {g} is not selected hulplijn {g} is niet geselecteerd +@msg handle must be 0..3 handle moet 0..3 zijn +@msg handler at {_1} expects {_2} values but its range starts with {d} de handler op {_1} verwacht {_2} waarden, maar het bereik ervan begint met {d} +@msg handler depth too large handlerdiepte te groot +@msg handler range {_1}..{_2} out of range handlerbereik {_1}..{_2} buiten het bereik +@msg hiddenLayers must be true or false hiddenLayers moet true of false zijn +@msg hiddenObjects {v}: "layer" (the default), "omit" or "visible" hiddenObjects {v}: "layer" (de standaard), "omit" of "visible" +@msg highlight a layer to merge into markeer een laag om in samen te voegen +@msg highlight two or more rows in one layer or group markeer twee of meer rijen in één laag of groep +@msg highlight two or more rows to merge markeer twee of meer rijen om samen te voegen +@msg hvcC hvcC +@msg icon docks a panel in the icon column: use window.panel.dock icon dockt een paneel in de pictogramkolom: gebruik window.panel.dock +@msg id must be a dimension id id moet de id van een maatlijn zijn +@msg image has no bounds de afbeelding heeft geen grenzen +@msg image {_1} is linked already afbeelding {_1} is al gekoppeld +@msg imageMap `{m}`: none, client or server imageMap `{m}`: none, client of server +@msg images in a spot ink whose samples couldn't be read were imported in RGB afbeeldingen in een steunkleurinkt waarvan de samples niet konden worden gelezen, zijn in RGB geïmporteerd +@msg images past the most pixels one file may hold were left out afbeeldingen boven het maximale aantal pixels dat één bestand mag bevatten, zijn weggelaten +@msg images too large to read were left out afbeeldingen die te groot zijn om te lezen, zijn weggelaten +@msg index out of range index buiten het bereik +@msg indexes may hold at most {MAX_GUIDE_INDEXES} entries indexes mag maximaal {MAX_GUIDE_INDEXES} items bevatten +@msg indexes must be an array of guide indexes indexes moet een array van hulplijnindexen zijn +@msg instances must be 1..1000 instances moet 1..1000 zijn +@msg instruction out of range instructie buiten het bereik +@msg instruction {pc} ({op}) pops below the stack instructie {pc} ({op}) haalt meer van de stack dan erop staat +@msg instruction {pc} reached with stack depths {seen} and {d} instructie {pc} bereikt met stackdiepten {seen} en {d} +@msg invalid `color` ongeldige `color` +@msg invalid anchor index {v}: expected a non-negative integer ongeldige ankerindex {v}: verwacht een niet-negatief geheel getal +@msg invalid anchor reference {v}: expected [subpath, anchor] ongeldige ankerverwijzing {v}: verwacht [subpad, anker] +@msg invalid angle ongeldige hoek +@msg invalid array length ongeldige arraylengte +@msg invalid brush: {e} ongeldig penseel: {e} +@msg invalid color ongeldige kleur +@msg invalid colour {c} ongeldige kleur {c} +@msg invalid delta ongeldige delta +@msg invalid group ongeldige groep +@msg invalid object id {v}: expected a non-negative integer ongeldige object-id {v}: verwacht een niet-negatief geheel getal +@msg invalid point ongeldig punt +@msg invalid regular expression flag '{_1}' ongeldige vlag '{_1}' voor reguliere expressie +@msg invalid regular expression: {m} ongeldige reguliere expressie: {m} +@msg invalid size ongeldige grootte +@msg invalid t ongeldige t +@msg invalid time value ongeldige tijdwaarde +@msg invalid tolerance ongeldige tolerantie +@msg is a confirm's answer, whose `value` must be true or false is het antwoord op een confirm, waarvan `value` true of false moet zijn +@msg is a prompt's answer, whose `value` must be a string or null is het antwoord op een prompt, waarvan `value` een string of null moet zijn +@msg is an alert's answer, whose `value` must be "ok" is het antwoord op een alert, waarvan `value` "ok" moet zijn +@msg is longer than 16 KiB is langer dan 16 KiB +@msg it draws its image through a clipping path het tekent zijn afbeelding door een knippad +@msg it draws no image het tekent geen afbeelding +@msg it is larger than {MAX_DICTIONARY_FILE_BYTES} bytes het is groter dan {MAX_DICTIONARY_FILE_BYTES} bytes +@msg it isn't a file het is geen bestand +@msg it names {_1} plates, and at most {MAX_PLATES} are read het noemt {_1} platen, en er worden er maximaal {MAX_PLATES} gelezen +@msg its art is too long or too detailed for a head de illustratie ervan is te lang of te gedetailleerd voor een kop +@msg its art paints nothing de illustratie ervan verft niets +@msg its artboards all lie beyond the canvas (more than {_1} pt from the origin) alle tekengebieden ervan liggen buiten het canvas (meer dan {_1} pt van de oorsprong) +@msg its clipping masks are nested too deeply de knipmaskers ervan zijn te diep genest +@msg its image is too large to read de afbeelding ervan is te groot om te lezen +@msg its metadata has no description de metagegevens ervan hebben geen beschrijving +@msg its metadata has no direct length de metagegevens ervan hebben geen directe lengte +@msg its plates are too large: more than {MAX_SAMPLES} pixels together de platen ervan zijn te groot: samen meer dan {MAX_SAMPLES} pixels +@msg its plates are too large: {_1} plates of {w} × {h} pixels de platen ervan zijn te groot: {_1} platen van {w} × {h} pixels +@msg its plates can't be kept together de platen ervan kunnen niet bij elkaar worden gehouden +@msg its shapes could not be combined into one de vormen ervan konden niet tot één vorm worden gecombineerd +@msg join two different paths verbind twee verschillende paden +@msg jump to {pc}, past the end sprong naar {pc}, voorbij het einde +@msg justify must be auto|left|center|right|justifyAll justify moet auto|left|center|right|justifyAll zijn +@msg kbps must be a positive number, not {kbps} kbps moet een positief getal zijn, niet {kbps} +@msg keywords must be a list of words or a comma-separated string keywords moet een lijst met woorden of een door komma’s gescheiden string zijn +@msg keywords must be at most {MAX_KEYWORD} characters, without control characters keywords mogen maximaal {MAX_KEYWORD} tekens lang zijn, zonder besturingstekens +@msg kind must be 1, 2 or 3, or give a preset `name` (see perspective.presets.list) kind moet 1, 2 of 3 zijn, of geef de `name` van een voorinstelling (zie perspective.presets.list) +@msg kind must be graphic, fillColor, strokeColor, fillGradient, strokeGradient, fillPattern, strokePattern, charStyle or paraStyle kind moet graphic, fillColor, strokeColor, fillGradient, strokeGradient, fillPattern, strokePattern, charStyle of paraStyle zijn +@msg knockout must be "on", "off", "neutral" or a bool, not {v} knockout moet "on", "off", "neutral" of een boolean zijn, niet {v} +@msg layer `{name}` has no art to export laag `{name}` heeft geen illustratie om te exporteren +@msg layer must name a layer or sublayer layer moet een laag of sublaag noemen +@msg layers can't be intertwined: select the objects in them lagen kunnen niet worden verstrengeld: selecteer de objecten erin +@msg layers go only at the top level or in layers, objects in layers and groups lagen staan alleen op het hoogste niveau of in lagen, objecten in lagen en groepen +@msg layers must be true or false layers moet true of false zijn +@msg layout must be gridByRow, gridByColumn, row or column layout moet gridByRow, gridByColumn, row of column zijn +@msg leading must be a number or "auto" leading moet een getal of "auto" zijn +@msg left/right must be non-negative widths left/right moeten niet-negatieve breedten zijn +@msg legacyNameEncoding must be one of {_1} legacyNameEncoding moet een van {_1} zijn +@msg level `{t}`: 2 or 3 niveau `{t}`: 2 of 3 +@msg line {line}: more than {MAX_CSV_COLS} columns regel {line}: meer dan {MAX_CSV_COLS} kolommen +@msg line {line}: unclosed quote regel {line}: niet-afgesloten aanhalingsteken +@msg line {line}: value for `{var}` must match its variable kind regel {line}: de waarde voor `{var}` moet bij het soort variabele passen +@msg lineEndings `{other}`: lf or crlf lineEndings `{other}`: lf of crlf +@msg loading profiles from disk isn't available in the browser profielen van schijf laden is niet beschikbaar in de browser +@msg localize: the first argument must be a localization object or a string localize: het eerste argument moet een lokalisatieobject of een string zijn +@msg margin: a {m} pt margin leaves no imageable area on the paper marge: een marge van {m} pt laat geen afdrukbaar gebied op het papier over +@msg matrix must be finite and invertible, depth finite matrix moet eindig en inverteerbaar zijn, depth eindig +@msg matte: {e} mat: {e} +@msg member is for order front, forward, backward or back member is bedoeld voor order front, forward, backward of back +@msg missing `artboards` `artboards` ontbreekt +@msg missing `at` [x, y] `at` [x, y] ontbreekt +@msg missing `attrs` `attrs` ontbreekt +@msg missing `color` or `opacity` `color` of `opacity` ontbreekt +@msg missing `colors` `colors` ontbreekt +@msg missing `commands` `commands` ontbreekt +@msg missing `destinationFolder` `destinationFolder` ontbreekt +@msg missing `effect` id de id `effect` ontbreekt +@msg missing `family` `family` ontbreekt +@msg missing `find` `find` ontbreekt +@msg missing `gid` (a glyph id, or null for the default glyph) `gid` ontbreekt (een glyph-id, of null voor de standaardglyph) +@msg missing `group` `group` ontbreekt +@msg missing `id` `id` ontbreekt +@msg missing `id`: give one, or select one type object `id` ontbreekt: geef er een, of selecteer één tekstobject +@msg missing `index` (a point index, or null to clear) `index` ontbreekt (een puntindex, of null om te wissen) +@msg missing `index` (a stop index, or null to clear) `index` ontbreekt (een stopindex, of null om te wissen) +@msg missing `index` (an item index or null) `index` ontbreekt (een itemindex of null) +@msg missing `item` `item` ontbreekt +@msg missing `library` `library` ontbreekt +@msg missing `library` (see graphicStyle.libraries) `library` ontbreekt (zie graphicStyle.libraries) +@msg missing `library` (see swatch.library.list) `library` ontbreekt (zie swatch.library.list) +@msg missing `map` (rows [{from, to}] or {current}) `map` ontbreekt (rijen [{from, to}] of {current}) +@msg missing `matrix` [a,b,c,d,e,f] `matrix` [a,b,c,d,e,f] ontbreekt +@msg missing `name` (see gradient.presets.list) `name` ontbreekt (zie gradient.presets.list) +@msg missing `offset` (a distance in points) `offset` ontbreekt (een afstand in punten) +@msg missing `path` `path` ontbreekt +@msg missing `path` (a path object id) `path` ontbreekt (de id van een padobject) +@msg missing `picks` `picks` ontbreekt +@msg missing `rule` `rule` ontbreekt +@msg missing `source` id de id `source` ontbreekt +@msg missing `start` (the byte offset of a character) `start` ontbreekt (de bytepositie van een teken) +@msg missing `status`: linked, embedded, missing or modified `status` ontbreekt: linked, embedded, missing of modified +@msg missing `target` id de id `target` ontbreekt +@msg missing `text` `text` ontbreekt +@msg missing `to` `to` ontbreekt +@msg missing `to` (an index) `to` ontbreekt (een index) +@msg missing `to`: a non-negative integer `to` ontbreekt: een niet-negatief geheel getal +@msg missing `type` `type` ontbreekt +@msg missing `value` `value` ontbreekt +@msg missing `word` `word` ontbreekt +@msg missing `{key}` `{key}` ontbreekt +@msg missing `{k}` `{k}` ontbreekt +@msg missing anchor anker ontbreekt +@msg missing anchors ankers ontbreken +@msg missing anchors [[subpath, anchor]…] anchors [[subpad, anker]…] ontbreekt +@msg missing array `{key}` array `{key}` ontbreekt +@msg missing case case ontbreekt +@msg missing color color ontbreekt +@msg missing commands commands ontbreekt +@msg missing destination folder doelmap ontbreekt +@msg missing from from ontbreekt +@msg missing group group ontbreekt +@msg missing id or ids id of ids ontbreekt +@msg missing ids ids ontbreekt +@msg missing indexes indexes ontbreekt +@msg missing matrix [a,b,c,d,e,f] matrix [a,b,c,d,e,f] ontbreekt +@msg missing name name ontbreekt +@msg missing op op ontbreekt +@msg missing or invalid `color` `color` ontbreekt of is ongeldig +@msg missing or unknown `tool` `tool` ontbreekt of is onbekend +@msg missing point punt ontbreekt +@msg missing point [x,y] punt [x,y] ontbreekt +@msg missing point `{key}` ([x, y]) punt `{key}` ([x, y]) ontbreekt +@msg missing points points ontbreekt +@msg missing points [[x,y]…] points [[x,y]…] ontbreekt +@msg missing segment segment ontbreekt +@msg missing stops stops ontbreekt +@msg missing subpaths subpaths ontbreekt +@msg missing target target ontbreekt +@msg missing to to ontbreekt +@msg missing x, y x, y ontbreekt +@msg mode is set, add or toggle, not `{other}` mode is set, add of toggle, niet `{other}` +@msg mode must be "cmyk" or "rgb" mode moet "cmyk" of "rgb" zijn +@msg mode must be area|onPath, got {o} mode moet area|onPath zijn, kreeg {o} +@msg more than 10000 linked files: package dependencies in smaller parts meer dan 10000 gekoppelde bestanden: verpak de afhankelijkheden in kleinere delen +@msg more than 256 commands meer dan 256 opdrachten +@msg more than {MAX_BATCH_FILES} data sets meer dan {MAX_BATCH_FILES} gegevenssets +@msg more than {MAX_BATCH_FILES} files meer dan {MAX_BATCH_FILES} bestanden +@msg more than {MAX_CSV_ROWS} data rows meer dan {MAX_CSV_ROWS} gegevensrijen +@msg more than {MAX_FILES} images meer dan {MAX_FILES} afbeeldingen +@msg more than {MAX_IMPORT} presets meer dan {MAX_IMPORT} voorinstellingen +@msg moved must be [[x,y]…] moved moet [[x,y]…] zijn +@msg must be an object with `kind` and `value` moet een object met `kind` en `value` zijn +@msg must have `kind` alert, confirm or prompt moet `kind` alert, confirm of prompt hebben +@msg must have exactly `kind` and `value` moet precies `kind` en `value` hebben +@msg name (a toolbar's name) is required name (de naam van een werkbalk) is vereist +@msg name (a toolbar's name) must be a string name (de naam van een werkbalk) moet een string zijn +@msg name must be a toolbar's name name moet de naam van een werkbalk zijn +@msg names is empty names is leeg +@msg names must be an array of symbol names names moet een array van symboolnamen zijn +@msg need `anchor` or `segment` + `t` `anchor` of `segment` + `t` is nodig +@msg need at least one anchor er is minstens één anker nodig +@msg need at least one point er is minstens één punt nodig +@msg need at least two points er zijn minstens twee punten nodig +@msg needs a closing quote after the name heeft een afsluitend aanhalingsteken na de naam nodig +@msg needs a name heeft een naam nodig +@msg needs a name of at most 64 bytes heeft een naam van maximaal 64 bytes nodig +@msg needs a name of letters, digits and _, or a quoted name heeft een naam van letters, cijfers en _ nodig, of een naam tussen aanhalingstekens +@msg needs a name without control characters heeft een naam zonder besturingstekens nodig +@msg needs points heeft punten nodig +@msg nesting too deep te diep genest +@msg nineSlice must be true or false nineSlice moet true of false zijn +@msg nineSliceGuides must be [left, top, right, bottom], each -16..16, with left + right < 1 and top + bottom < 1 nineSliceGuides moet [left, top, right, bottom] zijn, elk -16..16, met left + right < 1 en top + bottom < 1 +@msg no HP-GL format geen HP-GL-indeling +@msg no New Document profile called `{shown}` ({_1}) geen profiel voor nieuwe documenten met de naam `{shown}` ({_1}) +@msg no PDF preset named `{n}` geen PDF-voorinstelling met de naam `{n}` +@msg no SVG filter at index {k} geen SVG-filter op index {k} +@msg no action set is current er is geen actieset actief +@msg no active data set geen actieve gegevensset +@msg no appearance item {index} geen vormgevingsitem {index} +@msg no arrowheads file here hier is geen bestand met pijlpunten +@msg no artboard {_1} geen tekengebied {_1} +@msg no artboard {artboard} (0-based; the document has {_1}) geen tekengebied {artboard} (begint bij 0; het document heeft er {_1}) +@msg no asset {id} geen asset {id} +@msg no asset {id} (see assets.list) geen asset {id} (zie assets.list) +@msg no assets to export geen assets om te exporteren +@msg no assets yet: collect art for export first (assets.add) nog geen assets: verzamel eerst illustraties voor export (assets.add) +@msg no brush named `{n}` geen penseel met de naam `{n}` +@msg no character at byte {start} geen teken op byte {start} +@msg no character has code {code} geen teken heeft code {code} +@msg no colour geen kleur +@msg no colour group `{group}` geen kleurgroep `{group}` +@msg no colour group `{name}` geen kleurgroep `{name}` +@msg no custom arrowhead {name} (see stroke.arrowheads.list) geen aangepaste pijlpunt {name} (zie stroke.arrowheads.list) +@msg no data sets geen gegevenssets +@msg no dataset named `{from}` geen gegevensset met de naam `{from}` +@msg no dataset named `{name}` geen gegevensset met de naam `{name}` +@msg no datasets geen gegevenssets +@msg no design named `{name}` geen ontwerp met de naam `{name}` +@msg no design named `{n}` geen ontwerp met de naam `{n}` +@msg no design named `{old}` geen ontwerp met de naam `{old}` +@msg no encoder for {_1} yet nog geen encoder voor {_1} +@msg no export preset `{name}` (see document.exportPresets.list) geen exportvoorinstelling `{name}` (zie document.exportPresets.list) +@msg no file to open geen bestand om te openen +@msg no folder: pass `path` or set Preferences › Plug-ins & Scratch Disks › Additional Plug-ins Folder geen map: geef `path` op of stel Voorkeuren › Plug-ins & Scratchschijven › Extra map met plug-ins in +@msg no fonts to look for: they are all available geen lettertypen om te zoeken: ze zijn allemaal beschikbaar +@msg no formats to export geen indelingen om te exporteren +@msg no gradient preset `{name}` (see gradient.presets.list) geen verloopvoorinstelling `{name}` (zie gradient.presets.list) +@msg no graphic style `{n}` in `{_1}` geen grafische stijl `{n}` in `{_1}` +@msg no graphic style library `{key}` (see graphicStyle.libraries) geen bibliotheek met grafische stijlen `{key}` (zie graphicStyle.libraries) +@msg no guide selected geen hulplijn geselecteerd +@msg no guide selected (or give an index) geen hulplijn geselecteerd (of geef een index) +@msg no guide {i} geen hulplijn {i} +@msg no images in the folder geen afbeeldingen in de map +@msg no instructions geen instructies +@msg no item at index {_1} geen item op index {_1} +@msg no item at index {from} geen item op index {from} +@msg no item at one of the indices {idx} geen item op een van de indexen {idx} +@msg no layer geen laag +@msg no layer to rename geen laag om te hernoemen +@msg no layer {id} (see layer.list) geen laag {id} (zie layer.list) +@msg no layers to export geen lagen om te exporteren +@msg no library `{key}` geen bibliotheek `{key}` +@msg no metafile format geen metafile-indeling +@msg no object {_1} geen object {_1} +@msg no objects geen objecten +@msg no parent layer geen bovenliggende laag +@msg no perspective grid preset named `{b}` (see perspective.presets.list) geen voorinstelling voor het perspectiefraster met de naam `{b}` (zie perspective.presets.list) +@msg no perspective grid preset named `{n}` geen voorinstelling voor het perspectiefraster met de naam `{n}` +@msg no point selected (give `index`) geen punt geselecteerd (geef `index`) +@msg no preset called `{from}` (see file.newPresets) geen voorinstelling met de naam `{from}` (zie file.newPresets) +@msg no preset called `{name}` (see file.newPresets) geen voorinstelling met de naam `{name}` (zie file.newPresets) +@msg no preset named `{n}` geen voorinstelling met de naam `{n}` +@msg no print preset named `{b}` (see print.presets.list) geen afdrukvoorinstelling met de naam `{b}` (zie print.presets.list) +@msg no print preset named `{name}` (presets: {_1}) geen afdrukvoorinstelling met de naam `{name}` (voorinstellingen: {_1}) +@msg no print preset named `{n}` geen afdrukvoorinstelling met de naam `{n}` +@msg no profile named `{name}` geen profiel met de naam `{name}` +@msg no random numbers ({e}) geen willekeurige getallen ({e}) +@msg no readable files in the folder geen leesbare bestanden in de map +@msg no recovery copy `{f}` (see file.recovery.list) geen herstelkopie `{f}` (zie file.recovery.list) +@msg no rows geen rijen +@msg no saved PDF preset named `{name}` geen opgeslagen PDF-voorinstelling met de naam `{name}` +@msg no saved export preset `{name}` geen opgeslagen exportvoorinstelling `{name}` +@msg no saved gradient preset called {name} geen opgeslagen verloopvoorinstelling met de naam {name} +@msg no saved gradient presets geen opgeslagen verloopvoorinstellingen +@msg no saved preset called `{name}` geen opgeslagen voorinstelling met de naam `{name}` +@msg no saved presets to export (name [Default] in `names` to export it) geen opgeslagen voorinstellingen om te exporteren (noem [Default] in `names` om die te exporteren) +@msg no saved presets to export (name built-in ones in `names`) geen opgeslagen voorinstellingen om te exporteren (noem ingebouwde in `names`) +@msg no saved print preset named `{name}` geen opgeslagen afdrukvoorinstelling met de naam `{name}` +@msg no saved profile called {name} geen opgeslagen profiel met de naam {name} +@msg no saved selection `{name}` geen opgeslagen selectie `{name}` +@msg no saved theme called {name} (see colorTheme.list) geen opgeslagen thema met de naam {name} (zie colorTheme.list) +@msg no saved views geen opgeslagen weergaven +@msg no selected or given object has a visible 3D effect geen enkel geselecteerd of opgegeven object heeft een zichtbaar 3D-effect +@msg no series {i} geen reeks {i} +@msg no slice {n} in the image (see slice.list) geen slice {n} in de afbeelding (zie slice.list) +@msg no source art geen bronillustratie +@msg no stop {i} (the gradient has {n}) geen stop {i} (het verloop heeft er {n}) +@msg no style `{name}` geen stijl `{name}` +@msg no such artboard {v} tekengebied {v} bestaat niet +@msg no such assets (see assets.list) deze assets bestaan niet (zie assets.list) +@msg no such frame anchor, or the frame would reach past the canvas dit kaderanker bestaat niet, of het kader zou voorbij het canvas reiken +@msg no such objects deze objecten bestaan niet +@msg no such path anchor, or the path would reach past the canvas dit padanker bestaat niet, of het pad zou voorbij het canvas reiken +@msg no such rows deze rijen bestaan niet +@msg no swatch `{keep}` geen staal `{keep}` +@msg no swatch `{n}` geen staal `{n}` +@msg no swatch `{n}` (swatches and colour groups move separately) geen staal `{n}` (stalen en kleurgroepen worden apart verplaatst) +@msg no swatch library `{key}` (see swatch.library.list) geen stalenbibliotheek `{key}` (zie swatch.library.list) +@msg no swatch library `{key}` (see swatch.library.list; "document": the document's swatches) geen stalenbibliotheek `{key}` (zie swatch.library.list; "document": de stalen van het document) +@msg no swatch library `{key}` (see swatch.library.list; "{DOCUMENT_SWATCHES}": the document's swatches) geen stalenbibliotheek `{key}` (zie swatch.library.list; "{DOCUMENT_SWATCHES}": de stalen van het document) +@msg no swatch named `{n}` geen staal met de naam `{n}` +@msg no swatch or colour group `{n}` geen staal of kleurgroep `{n}` +@msg no swatch or colour group `{n}` in `{_1}` geen staal of kleurgroep `{n}` in `{_1}` +@msg no symbol named `{_1}` geen symbool met de naam `{_1}` +@msg no symbol named `{name}` geen symbool met de naam `{name}` +@msg no text objects selected geen tekstobjecten geselecteerd +@msg no toolbar named `{_1}` geen werkbalk met de naam `{_1}` +@msg no toolbar named `{name}` geen werkbalk met de naam `{name}` +@msg no tracing preset `{preset}` (see imageTrace.presets) geen traceervoorinstelling `{preset}` (zie imageTrace.presets) +@msg no user library folder here (save with a path, or without one to get the data) hier is geen map voor gebruikersbibliotheken (sla op met een pad, of zonder pad om de gegevens te krijgen) +@msg no variable named `{from}` geen variabele met de naam `{from}` +@msg no variable named `{name}` geen variabele met de naam `{name}` +@msg no variable named `{var}` geen variabele met de naam `{var}` +@msg no variable named `{v}` geen variabele met de naam `{v}` +@msg no view named `{name}` geen weergave met de naam `{name}` +@msg node {_1} already has the text variable `{_2}` knooppunt {_1} heeft de tekstvariabele `{_2}` al +@msg node {_1} is not a graph knooppunt {_1} is geen grafiek +@msg node {_1} is not an image knooppunt {_1} is geen afbeelding +@msg node {_1} is not type knooppunt {_1} is geen tekst +@msg not a DCS file geen DCS-bestand +@msg not a PDF presets file (format `{_1}`) geen bestand met PDF-voorinstellingen (indeling `{_1}`) +@msg not a PDF presets file: {e} geen bestand met PDF-voorinstellingen: {e} +@msg not a RegExp object geen RegExp-object +@msg not a Word document: its WordDocument stream doesn't start with a file information block geen Word-document: de WordDocument-stroom ervan begint niet met een blok met bestandsinformatie +@msg not a Word document: its compound file has no WordDocument stream geen Word-document: het samengestelde bestand ervan heeft geen WordDocument-stroom +@msg not a Word document: its main part is not a WordprocessingML document geen Word-document: het hoofdonderdeel ervan is geen WordprocessingML-document +@msg not a Word document: its package has no main document part geen Word-document: het pakket ervan heeft geen hoofddocumentonderdeel +@msg not a closed path geen gesloten pad +@msg not a flattener presets file (format `{_1}`) geen bestand met afvlakkervoorinstellingen (indeling `{_1}`) +@msg not a flattener presets file: {e} geen bestand met afvlakkervoorinstellingen: {e} +@msg not a layer or group geen laag of groep +@msg not a library file: {e} geen bibliotheekbestand: {e} +@msg not a mesh envelope point geen punt van een netomvorming +@msg not a perspective grid presets file (format `{_1}`) geen bestand met voorinstellingen voor het perspectiefraster (indeling `{_1}`) +@msg not a perspective grid presets file: {e} geen bestand met voorinstellingen voor het perspectiefraster: {e} +@msg not a print presets file (format `{_1}`) geen bestand met afdrukvoorinstellingen (indeling `{_1}`) +@msg not a print presets file: {e} geen bestand met afdrukvoorinstellingen: {e} +@msg not a regular expression geen reguliere expressie +@msg not a stored or deflated central record geen opgeslagen of met deflate gecomprimeerd centraal record +@msg not a valid SVGZ file: {e} geen geldig SVGZ-bestand: {e} +@msg not an RTF file: it doesn't start with {\\rtf geen RTF-bestand: het begint niet met {\\rtf +@msg not an action set: the text doesn't start with /version and a number geen actieset: de tekst begint niet met /version en een getal +@msg not an image VectorCraft reads (see document.formats) geen afbeelding die VectorCraft leest (zie document.formats) +@msg not area type (text in a frame) outside perspective geen vlaktekst (tekst in een kader) buiten perspectief +@msg not editing an opacity mask er wordt geen dekkingmasker bewerkt +@msg not type on a path outside perspective geen tekst op een pad buiten perspectief +@msg nothing prints er wordt niets afgedrukt +@msg nothing to bind niets om te koppelen +@msg nothing to change niets om te wijzigen +@msg nothing to change: give dx, dy, hScale, vScale or rotation niets om te wijzigen: geef dx, dy, hScale, vScale of rotation +@msg nothing to crop niets om bij te snijden +@msg nothing to export niets om te exporteren +@msg nothing to export: the document has no visible art niets om te exporteren: het document heeft geen zichtbare illustraties +@msg nothing to mark niets om te markeren +@msg nothing to print: every artboard picked is blank niets om af te drukken: elk gekozen tekengebied is leeg +@msg nothing to print: the document has no art that prints niets om af te drukken: het document heeft geen illustraties die worden afgedrukt +@msg nothing to repeat niets om te herhalen +@msg numbers out of order in {_1} quantifier getallen in de verkeerde volgorde in kwantor {_1} +@msg object is not a path het object is geen pad +@msg object transparency cannot be sampled onto highlighted characters; disable Transparency in Eyedropper Options or select the whole object objecttransparantie kan niet op gemarkeerde tekens worden overgenomen; schakel Transparantie uit in Opties voor pipet of selecteer het hele object +@msg object {_1} can't be set as point type object {_1} kan niet als punttekst worden gezet +@msg object {_1} has lost its file's contents: relink it object {_1} is de inhoud van zijn bestand kwijt: koppel het opnieuw +@msg object {_1} has no path object {_1} heeft geen pad +@msg object {_1} has no size object {_1} heeft geen grootte +@msg object {_1} is hidden or locked, or on a locked artboard object {_1} is verborgen of vergrendeld, of staat op een vergrendeld tekengebied +@msg object {_1} is not a placed document object {_1} is geen geplaatst document +@msg object {_1} is not an Intertwine group object {_1} is geen groep Verstrengelen +@msg object {_1} is not an image object {_1} is geen afbeelding +@msg object {_1} is not an image or a linked file object {_1} is geen afbeelding of gekoppeld bestand +@msg object {_1} is not an image or a placed document object {_1} is geen afbeelding of geplaatst document +@msg object {_1} is not in this Intertwine group object {_1} zit niet in deze groep Verstrengelen +@msg object {_1} needs a 3D effect object {_1} heeft een 3D-effect nodig +@msg object {_1} needs a 3D effect at index {index} object {_1} heeft een 3D-effect op index {index} nodig +@msg object {_1}: a hollow Extrude & Bevel has no caps: turn on Cap to map a graphic object {_1}: een holle Extruderen en afschuinen heeft geen kappen: schakel Kap in om een afbeelding toe te wijzen +@msg object {_1}: with a depth of 0 the object has one face: map its graphics onto the front object {_1}: met een diepte van 0 heeft het object één vlak: wijs de afbeeldingen ervan toe aan de voorkant +@msg object {_1}: {_2} object {_1}: {_2} +@msg object {_1}: {e} object {_1}: {e} +@msg object {_1}: {name} at index {index} has no lighting presets; set its lights with effect.setParams object {_1}: {name} op index {index} heeft geen belichtingsvoorinstellingen; stel de lichten ervan in met effect.setParams +@msg object {id} has anchors 0–{_1} for `corners`, not {past} object {id} heeft de ankers 0–{_1} voor `corners`, niet {past} +@msg object {id} has {n} anchors, so no anchor {past} object {id} heeft {n} ankers, dus geen anker {past} +@msg objects must be none, move or copy objects moet none, move of copy zijn +@msg objects were left out er zijn objecten weggelaten +@msg offset out of range positie buiten het bereik +@msg on must be true or false on moet true of false zijn +@msg only groups, layers, type and images have a Contents (Characters) row alleen groepen, lagen, tekst en afbeeldingen hebben een rij Inhoud (Tekens) +@msg only interior mesh lines can be deleted alleen binnenste netlijnen kunnen worden verwijderd +@msg only solid colours can be added (not gradients or patterns) alleen effen kleuren kunnen worden toegevoegd (geen verlopen of patronen) +@msg only solid-colour swatches can be spot colours alleen stalen met een effen kleur kunnen steunkleuren zijn +@msg only this Affinity file's embedded preview could be read: use File › Open to see it with its warning, or export SVG or PDF from Affinity first alleen de ingesloten voorvertoning van dit Affinity-bestand kon worden gelezen: gebruik Bestand › Openen om die met de bijbehorende waarschuwing te bekijken, of exporteer eerst SVG of PDF vanuit Affinity +@msg only this Affinity file's embedded preview could be read; use File › Open to see it with its warning alleen de ingesloten voorvertoning van dit Affinity-bestand kon worden gelezen; gebruik Bestand › Openen om die met de bijbehorende waarschuwing te bekijken +@msg onto, above, below, icon and a column place belong to window.panel.float and window.panel.dock onto, above, below, icon en een kolomplaats horen bij window.panel.float en window.panel.dock +@msg onto, above, below, icon and a column place take no anchor, side, zone or before onto, above, below, icon en een kolomplaats accepteren geen anchor, side, zone of before +@msg onto, above, below, icon and a column place take no x, y, width or height onto, above, below, icon en een kolomplaats accepteren geen x, y, width of height +@msg opacity must be a number opacity moet een getal zijn +@msg open a document to look for its linked files open een document om de gekoppelde bestanden ervan te zoeken +@msg operand too large operand te groot +@msg options must be an object (see file.formatOptions) options moet een object zijn (zie file.formatOptions) +@msg order is a whole number from 0 to {others}, not `{v}` order is een geheel getal van 0 tot {others}, niet `{v}` +@msg order must be leftToRight or rightToLeft order moet leftToRight of rightToLeft zijn +@msg orientation must be portrait or landscape, not `{o}` orientation moet portrait of landscape zijn, niet `{o}` +@msg outlineText {v}: true or false outlineText {v}: true of false +@msg output intent profile: {e} profiel van de uitvoerintentie: {e} +@msg output.destination: no RGB or CMYK profile is called “{name}” output.destination: er is geen RGB- of CMYK-profiel met de naam „{name}” +@msg output.destination: {_1} files are CMYK, and “{name}” is an RGB profile output.destination: {_1}-bestanden zijn CMYK, en „{name}” is een RGB-profiel +@msg output.destination: {e} output.destination: {e} +@msg output.inks: no ink is set to print output.inks: er is geen inkt ingesteld om af te drukken +@msg output.outputIntent: no profile is called “{name}”, and a {std} output intent embeds its profile output.outputIntent: er is geen profiel met de naam „{name}”, en een uitvoerintentie voor {std} sluit haar profiel in +@msg output.outputIntent: no profile is called “{name}”: a {std} output intent embeds a profile, or names a registered printing condition (outputConditionId and registry) output.outputIntent: er is geen profiel met de naam „{name}”: een uitvoerintentie voor {std} sluit een profiel in, of noemt een geregistreerde drukconditie (outputConditionId en registry) +@msg output.outputIntent: {std} files print in CMYK, and “{name}” is an RGB profile output.outputIntent: {std}-bestanden worden in CMYK afgedrukt, en „{name}” is een RGB-profiel +@msg output.outputIntent: “{name}” is a grey profile, which can't be a {std} output intent output.outputIntent: „{name}” is een grijsprofiel, dat geen uitvoerintentie voor {std} kan zijn +@msg overlap: {o} pt is half a tile or more overlap: {o} pt is een halve tegel of meer +@msg overlapping Shaper paths must be in the same layer or group overlappende Shaper-paden moeten in dezelfde laag of groep staan +@msg overlapping edits overlappende bewerkingen +@msg page art conflicts with image data for {key} de pagina-illustratie is in strijd met de afbeeldingsgegevens voor {key} +@msg page art conflicts with pattern {name} de pagina-illustratie is in strijd met patroon {name} +@msg page art conflicts with swatch {name} de pagina-illustratie is in strijd met staal {name} +@msg page art is missing image data for {key} in de pagina-illustratie ontbreken afbeeldingsgegevens voor {key} +@msg page art is missing pattern {name} in de pagina-illustratie ontbreekt patroon {name} +@msg page art is missing swatch {name} in de pagina-illustratie ontbreekt staal {name} +@msg page must be a whole number from 1 page moet een geheel getal vanaf 1 zijn +@msg page thumbnail: {e} paginaminiatuur: {e} +@msg page {page} of the PDF has no objects pagina {page} van de PDF heeft geen objecten +@msg page {page}: `{file}` has {n} {artboards} pagina {page}: `{file}` heeft {n} {artboards} +@msg page {page}: `{name}` has {n} {pages} pagina {page}: `{name}` heeft {n} {pages} +@msg pages must be a range such as "2-3" or a page number, not {v} pages moet een bereik zoals "2-3" of een paginanummer zijn, niet {v} +@msg pages: {e} pagina’s: {e} +@msg panel position must be finite de paneelpositie moet eindig zijn +@msg parameters must be an object de parameters moeten een object zijn +@msg params must be an object params moet een object zijn +@msg passwords can have up to {MAX_PASSWORD} bytes wachtwoorden mogen maximaal {MAX_PASSWORD} bytes hebben +@msg path chunks must share their boundary point padstukken moeten hun grenspunt delen +@msg path has no open end het pad heeft geen open uiteinde +@msg paths must be strings paths moet uit strings bestaan +@msg pdfCompatible: false needs every artboard to keep the editable artwork pdfCompatible: false vereist dat elk tekengebied de bewerkbare illustratie behoudt +@msg pdfCompatible: false needs the artboards to keep the editable artwork when useArtboards is false pdfCompatible: false vereist dat de tekengebieden de bewerkbare illustratie behouden wanneer useArtboards false is +@msg pdfs `{m}`: single or multiple pdfs `{m}`: single of multiple +@msg pickColorFrom is "artwork" or "swatches", not {v} pickColorFrom is "artwork" of "swatches", niet {v} +@msg pins and moved must be non-empty lists of the same length pins en moved moeten niet-lege lijsten van dezelfde lengte zijn +@msg pins must be [[x,y]…] pins moet [[x,y]…] zijn +@msg pins must be finite pins moet eindig zijn +@msg place is above, below or inside, not `{other}` place is above, below of inside, niet `{other}` +@msg plane must be left|right|ground plane moet left|right|ground zijn +@msg plane must be left|right|ground|none plane moet left|right|ground|none zijn +@msg point is outside the mesh het punt ligt buiten het net +@msg point x must be a number x van het punt moet een getal zijn +@msg point y must be a number y van het punt moet een getal zijn +@msg points must be [t, left, right] with non-negative widths points moet uit [t, left, right] met niet-negatieve breedten bestaan +@msg points must be [x,y] pairs points moet uit paren [x,y] bestaan +@msg points must be a non-empty [[x,y,pressure?]…] list points moet een niet-lege lijst [[x,y,pressure?]…] zijn +@msg points must be a non-empty list of finite [x,y] points moet een niet-lege lijst van eindige [x,y] zijn +@msg points must be an array or null points moet een array of null zijn +@msg points must be finite points moet eindig zijn +@msg points must be finite [x,y] pairs points moet uit eindige paren [x,y] bestaan +@msg points must be finite canvas points points moet uit eindige canvaspunten bestaan +@msg points must contain 1–4096 coordinates points moet 1–4096 coördinaten bevatten +@msg position must be normal, superscript or subscript position moet normal, superscript of subscript zijn +@msg position must be topLeft, topRight, bottomLeft or bottomRight position moet topLeft, topRight, bottomLeft of bottomRight zijn +@msg positions must be between 0 and 100000 pt positions moeten tussen 0 en 100000 pt liggen +@msg ppi must be a positive number, not {ppi} ppi moet een positief getal zijn, niet {ppi} +@msg ppi must be between 1 and 2400 ppi moet tussen 1 en 2400 liggen +@msg preserve `{v}` is not transforms|bounds|fileDimensions|fit|fill preserve `{v}` is niet transforms|bounds|fileDimensions|fit|fill +@msg preserveShape must be clippingMask|transparency preserveShape moet clippingMask|transparency zijn +@msg preset `{id}`: mobile or density preset `{id}`: mobile of density +@msg preset must be standard, diffuse, topLeft or right preset moet standard, diffuse, topLeft of right zijn +@msg preset must be the name of a print preset preset moet de naam van een afdrukvoorinstelling zijn +@msg previewMode must be default, pixel or overprint previewMode moet default, pixel of overprint zijn +@msg print settings: {e} afdrukinstellingen: {e} +@msg procedures nest too deeply procedures zijn te diep genest +@msg procedures nested too deeply procedures te diep genest +@msg quotes must be {double?, single?} quotes moet {double?, single?} zijn +@msg quotes.{k} must be an opening and a closing quote, e.g. "“”" quotes.{k} moet een openend en een sluitend aanhalingsteken zijn, bijv. "“”" +@msg range out of order in character class bereik in de verkeerde volgorde in tekenklasse +@msg rasterEffectsPpi must be 1–2400 (72 screen, 150 medium, 300 high) rasterEffectsPpi moet 1–2400 zijn (72 scherm, 150 gemiddeld, 300 hoog) +@msg rating must be a whole number from 0 to {MAX_RATING} rating moet een geheel getal van 0 tot {MAX_RATING} zijn +@msg rect and {k} contradict each other: give the area or the artboards rect en {k} spreken elkaar tegen: geef het gebied of de tekengebieden +@msg rect applies to raster formats, not {_1} rect geldt voor rasterindelingen, niet voor {_1} +@msg rect is [x, y, width, height] in points rect is [x, y, breedte, hoogte] in punten +@msg rect must be [x, y, width, height] rect moet [x, y, breedte, hoogte] zijn +@msg rect must be [x, y, width, height] with a positive width and height rect moet [x, y, breedte, hoogte] met een positieve breedte en hoogte zijn +@msg rect needs finite numbers and a positive width and height rect heeft eindige getallen en een positieve breedte en hoogte nodig +@msg redraw needs id redraw heeft id nodig +@msg redraw within must be a finite distance of 0 or more within van redraw moet een eindige afstand van 0 of meer zijn +@msg reduce of an empty array with no initial value reduce van een lege array zonder beginwaarde +@msg registration must be 0..8 registration moet 0..8 zijn +@msg regular expression flag '{_1}' given twice vlag '{_1}' voor reguliere expressie twee keer opgegeven +@msg release a layer or a group geef een laag of een groep vrij +@msg replace keeps the replaced object's place and transform: drop template, at and rect replace behoudt de plaats en de transformatie van het vervangen object: laat template, at en rect weg +@msg replace: select the one object to replace replace: selecteer het ene object dat moet worden vervangen +@msg resolution must be a number or screen|medium|high resolution moet een getal of screen|medium|high zijn +@msg resolution must be between 1 and 2400 ppi resolution moet tussen 1 en 2400 ppi liggen +@msg rotation must be a number of degrees rotation moet een aantal graden zijn +@msg rotation must be finite rotation moet eindig zijn +@msg rows and cols must be 1..50 rows en cols moeten 1..50 zijn +@msg rows and columns must be 1..500 rows en columns moeten 1..500 zijn +@msg rows of objects whose appearances differ can't be reordered together rijen van objecten met een verschillende vormgeving kunnen niet samen opnieuw worden geordend +@msg sampled text would exceed the canvas (coordinates out of range) de overgenomen tekst zou buiten het canvas vallen (coördinaten buiten het bereik) +@msg save the document first: Package collects a saved document sla het document eerst op: Verpakken verzamelt een opgeslagen document +@msg save the document first: copy puts the file in its folder sla het document eerst op: copy plaatst het bestand in de map ervan +@msg savedPreset: {e} savedPreset: {e} +@msg scale `{s}`: a factor such as 2x, a width (100w), a height (100h) or a resolution (72ppi) scale `{s}`: een factor zoals 2x, een breedte (100w), een hoogte (100h) of een resolutie (72ppi) +@msg scale must be a number above 0, at most 64 scale moet een getal boven 0 zijn, maximaal 64 +@msg scale must be non-zero scale mag niet nul zijn +@msg scope must be selection or all (got {other}) scope moet selection of all zijn (kreeg {other}) +@msg scribble is too long de krabbel is te lang +@msg segment does not exist het segment bestaat niet +@msg select a Shaper group selecteer een Shaper-groep +@msg select a blend to set easing or color shift selecteer een mengsel om de versnelling of de kleurverschuiving in te stellen +@msg select a compound shape selecteer een samengestelde vorm +@msg select a graph selecteer een grafiek +@msg select a group or layer with visible, unlocked members selecteer een groep of laag met zichtbare, ontgrendelde leden +@msg select a layer selecteer een laag +@msg select a text object selecteer een tekstobject +@msg select an SVG filter selecteer een SVG-filter +@msg select an image (or an Image Trace group) selecteer een afbeelding (of een groep Afbeelding traceren) +@msg select an image, or pass id selecteer een afbeelding, of geef id op +@msg select an object (or pass `id`) selecteer een object (of geef `id` op) +@msg select an object with a 3D effect selecteer een object met een 3D-effect +@msg select an object with a 3D effect, or give its id in ids selecteer een object met een 3D-effect, of geef de id ervan in ids +@msg select an object with a freeform gradient selecteer een object met een verloop in vrije vorm +@msg select an object with an opacity mask selecteer een object met een dekkingmasker +@msg select area type selecteer vlaktekst +@msg select area type (text in a frame) selecteer vlaktekst (tekst in een kader) +@msg select area type and closed paths (at least one area type object) selecteer vlaktekst en gesloten paden (minstens één vlaktekstobject) +@msg select area type whose first line can fit its frame selecteer vlaktekst waarvan de eerste regel in het kader past +@msg select artwork to add its colours selecteer illustraties om de kleuren ervan toe te voegen +@msg select artwork to make a group of its colours selecteer illustraties om een groep van de kleuren ervan te maken +@msg select artwork to recolour, or give a colour `group` selecteer illustraties om te herkleuren, of geef een `group` met kleuren +@msg select exactly two path ends to join selecteer precies twee paduiteinden om te verbinden +@msg select members of a compound shape selecteer leden van een samengestelde vorm +@msg select objects or give ids selecteer objecten of geef ids +@msg select objects to align to the guide selecteer objecten om op de hulplijn uit te lijnen +@msg select one Intertwine group selecteer één groep Verstrengelen +@msg select one image or pass id selecteer één afbeelding of geef id op +@msg select one layer, group or object to rename selecteer één laag, groep of object om te hernoemen +@msg select paths selecteer paden +@msg select paths or compound paths selecteer paden of samengestelde paden +@msg select rows or objects to collect selecteer rijen of objecten om te verzamelen +@msg select something to export selecteer iets om te exporteren +@msg select something to export (or turn off selectedOnly) selecteer iets om te exporteren (of schakel selectedOnly uit) +@msg select text to redefine the style from selecteer tekst om de stijl mee opnieuw te definiëren +@msg select the art and, on top of it, the mask object selecteer de illustratie en, daarbovenop, het maskerobject +@msg select the art for the design selecteer de illustratie voor het ontwerp +@msg select the art for the pattern tile selecteer de illustratie voor de patroontegel +@msg select the art to add first selecteer eerst de illustratie die moet worden toegevoegd +@msg select the art to collect (or give its ids) selecteer de illustratie die moet worden verzameld (of geef de id’s ervan) +@msg select the art to weed selecteer de illustratie die moet worden gewied +@msg select the banner, or mark every artboard selecteer de banner, of markeer elk tekengebied +@msg select the content and a path on top selecteer de inhoud en een pad erbovenop +@msg select the images to relink, or pass ids selecteer de afbeeldingen die opnieuw moeten worden gekoppeld, of geef ids op +@msg select the images, or pass ids selecteer de afbeeldingen, of geef ids op +@msg select the linked images or placed documents, or pass ids selecteer de gekoppelde afbeeldingen of geplaatste documenten, of geef ids op +@msg select the object to copy from selecteer het object waarvan moet worden gekopieerd +@msg select the objects (or give their ids) selecteer de objecten (of geef de id’s ervan) +@msg select the objects to attach to the path selecteer de objecten die aan het pad moeten worden gekoppeld +@msg select the objects to bind selecteer de objecten die moeten worden gekoppeld +@msg select two or more objects to intertwine selecteer twee of meer objecten om te verstrengelen +@msg select two or more slices to combine selecteer twee of meer slices om te combineren +@msg select type on a path selecteer tekst op een pad +@msg select type on a path or area type selecteer tekst op een pad of vlaktekst +@msg selection `{m}`: one or each selection `{m}`: one of each +@msg settings is an object of document.exportForScreens params settings is een object met parameters van document.exportForScreens +@msg settings must be an object settings moet een object zijn +@msg show `{show}`: all, missing, modified or embedded show `{show}`: all, missing, modified of embedded +@msg show must be true or false show moet true of false zijn +@msg side is left or right, not `{v}` side is left of right, niet `{v}` +@msg size must be "small", "medium", "large" or a number of points over 0 up to {_1} size moet "small", "medium", "large" of een aantal punten boven 0 tot en met {_1} zijn +@msg size must be positive size moet positief zijn +@msg sizeMode is "fixed" or "pressure", not `{other}` sizeMode is "fixed" of "pressure", niet `{other}` +@msg sizeMode is "fixed" or "pressure", not {other} sizeMode is "fixed" of "pressure", niet {other} +@msg sizeVariation must be 0 or more sizeVariation moet 0 of meer zijn +@msg smallCaps must be true or false smallCaps moet true of false zijn +@msg sort `{x}`: name, kind or status sort `{x}`: name, kind of status +@msg source paths are too large for Shaper de bronpaden zijn te groot voor Shaper +@msg source text transform is collapsed or unrepresentable de teksttransformatie van de bron is samengevallen of kan niet worden weergegeven +@msg spot, mode and group apply to solid colours only spot, mode en group gelden alleen voor effen kleuren +@msg status `{s}`: linked, embedded, missing or modified status `{s}`: linked, embedded, missing of modified +@msg steps must be 1..1000 steps moet 1..1000 zijn +@msg steps must be 1..{MAX_STEPS} steps moet 1..{MAX_STEPS} zijn +@msg stop {i}: `plates` must be four numbers from 0 to 1 (C, M, Y, K) stop {i}: `plates` moet uit vier getallen van 0 tot 1 bestaan (C, M, Y, K) +@msg stopped before the archive was finished gestopt voordat het archief klaar was +@msg strokeMode must be within|along|across, got {m} strokeMode moet within|along|across zijn, kreeg {m} +@msg strokeOptions must be an object of stroke.set options strokeOptions moet een object met opties van stroke.set zijn +@msg strokeWidth must be a positive number of pixels strokeWidth moet een positief aantal pixels zijn +@msg subpath {si} is not an open subpath subpad {si} is geen open subpad +@msg subpaths required when joining the same path subpaths is vereist bij het verbinden van hetzelfde pad +@msg swatchConflict must be "merge" or "add", not {v} swatchConflict moet "merge" of "add" zijn, niet {v} +@msg table must be true or false table moet true of false zijn +@msg takes one name accepteert één naam +@msg target text transform is collapsed or unrepresentable de teksttransformatie van het doel is samengevallen of kan niet worden weergegeven +@msg text must be {characterSet?, platform?, removeLineReturns?, removeParagraphReturns?, replaceSpaces?} text moet {characterSet?, platform?, removeLineReturns?, removeParagraphReturns?, replaceSpaces?} zijn +@msg text transform is collapsed or unrepresentable de teksttransformatie is samengevallen of kan niet worden weergegeven +@msg text.replaceSpaces must be a whole number from 2 to 100 text.replaceSpaces moet een geheel getal van 2 tot 100 zijn +@msg text.{key} `{v}`: use "{_1}" or "{_2}" text.{key} `{v}`: gebruik "{_1}" of "{_2}" +@msg textureImage: give {path} or {name, dataBase64} of an image file, or a texture as effect.list gives it textureImage: geef {path} of {name, dataBase64} van een afbeeldingsbestand, of een textuur zoals effect.list die geeft +@msg textureImage: {e} textureImage: {e} +@msg that makes more than {MAX_PIECES} slices dat levert meer dan {MAX_PIECES} slices op +@msg that makes too many pieces (at most 100000) or dash steps: simplify the dash pattern or make the dashes longer dat levert te veel stukken (maximaal 100000) of streepstappen op: vereenvoudig het streeppatroon of maak de strepen langer +@msg that object is not in the overlap dat object ligt niet in de overlapping +@msg the Affinity document has no page with a size het Affinity-document heeft geen pagina met een grootte +@msg the CMYK image couldn't be written de CMYK-afbeelding kon niet worden geschreven +@msg the Layers panel is not shown het paneel Lagen wordt niet getoond +@msg the Layers panel's search, filter or Show Layers Only hides its row de zoekopdracht, het filter of Alleen lagen weergeven van het paneel Lagen verbergt de rij ervan +@msg the Objects on Path group is hidden or locked de groep Objecten op pad is verborgen of vergrendeld +@msg the PDF security settings were saved without their passwords: give openPassword or permissionsPassword again, or security without passwordRequired to export unprotected de PDF-beveiligingsinstellingen zijn zonder hun wachtwoorden opgeslagen: geef openPassword of permissionsPassword opnieuw, of security zonder passwordRequired om onbeveiligd te exporteren +@msg the RTF file has too many paragraphs or formatting changes to place as type (at most {MAX_PARAGRAPHS} paragraphs and {MAX_RUNS} runs) het RTF-bestand heeft te veel alinea’s of opmaakwijzigingen om als tekst te plaatsen (maximaal {MAX_PARAGRAPHS} alinea’s en {MAX_RUNS} runs) +@msg the RTF file is too large to place as type (at most {_1} MB) het RTF-bestand is te groot om als tekst te plaatsen (maximaal {_1} MB) +@msg the SVG expands to more than {0} nested SVG images de SVG wordt uitgevouwen tot meer dan {0} geneste SVG-afbeeldingen +@msg the SVG expands to more than {0} objects de SVG wordt uitgevouwen tot meer dan {0} objecten +@msg the SVG file is larger than {MAX_IMPORT_BYTES} bytes het SVG-bestand is groter dan {MAX_IMPORT_BYTES} bytes +@msg the SVG has no drawable objects de SVG heeft geen tekenbare objecten +@msg the SVGZ file unpacks to more than {_1} MB het SVGZ-bestand wordt uitgepakt tot meer dan {_1} MB +@msg the Word document has more than {MAX_PAGES} pages of properties, too many to place het Word-document heeft meer dan {MAX_PAGES} pagina’s met eigenschappen, te veel om te plaatsen +@msg the Word document has more than {MAX_RUNS} runs of character or paragraph properties, too many to place het Word-document heeft meer dan {MAX_RUNS} runs met teken- of alinea-eigenschappen, te veel om te plaatsen +@msg the Word document has more than {_1} MB of formatting properties, too many to place het Word-document heeft meer dan {_1} MB aan opmaakeigenschappen, te veel om te plaatsen +@msg the Word document has too much text or formatting to place as type (at most {MAX_PARAGRAPHS} paragraphs, {MAX_RUNS} runs and {_1} MB of text) het Word-document heeft te veel tekst of opmaak om als tekst te plaatsen (maximaal {MAX_PARAGRAPHS} alinea’s, {MAX_RUNS} runs en {_1} MB tekst) +@msg the Word document has too much text to place as type (at most {_1} MB) het Word-document heeft te veel tekst om als tekst te plaatsen (maximaal {_1} MB) +@msg the Word document is encrypted or protected with a password; save it without one to place it het Word-document is versleuteld of met een wachtwoord beveiligd; sla het zonder wachtwoord op om het te plaatsen +@msg the Word document is too large to place (its {name} stream holds more than {_1} MB) het Word-document is te groot om te plaatsen (de stroom {name} ervan bevat meer dan {_1} MB) +@msg the Word document was last saved with fast save, which VectorCraft doesn't read; save it again with fast save turned off het Word-document is het laatst opgeslagen met snel opslaan, wat VectorCraft niet leest; sla het opnieuw op met snel opslaan uitgeschakeld +@msg the Word document was saved by Word 6.0 or Word 95, which VectorCraft doesn't read; save it as a Word 97-2003 document het Word-document is opgeslagen door Word 6.0 of Word 95, wat VectorCraft niet leest; sla het op als een Word 97-2003-document +@msg the Word document's text is made of more than {MAX_PIECES} pieces, too many to place de tekst van het Word-document bestaat uit meer dan {MAX_PIECES} stukken, te veel om te plaatsen +@msg the XML operation needs an XML or XMLList value de XML-bewerking heeft een XML- of XMLList-waarde nodig +@msg the XPath expression does not evaluate to a node-set de XPath-expressie levert geen knooppuntenset op +@msg the XPath expression ends early de XPath-expressie eindigt te vroeg +@msg the XPath expression has an unmatched ) de XPath-expressie heeft een ) zonder tegenhanger +@msg the XPath expression has an unmatched ] de XPath-expressie heeft een ] zonder tegenhanger +@msg the XPath expression has an unmatched closing bracket de XPath-expressie heeft een sluithaakje zonder tegenhanger +@msg the XPath expression selects a namespace node, which is not an XML value de XPath-expressie selecteert een naamruimteknooppunt, en dat is geen XML-waarde +@msg the XPath expression selects the root node, which is not an XML value de XPath-expressie selecteert het hoofdknooppunt, en dat is geen XML-waarde +@msg the XPath function {name} needs a node-set de XPath-functie {name} heeft een knooppuntenset nodig +@msg the XPath function {name} takes the wrong number of arguments de XPath-functie {name} krijgt het verkeerde aantal argumenten +@msg the XPath name functions need a node-set de XPath-naamfuncties hebben een knooppuntenset nodig +@msg the XPath prefix {shown} is not bound to a namespace het XPath-voorvoegsel {shown} is niet aan een naamruimte gebonden +@msg the XPath variable ${shown} is not bound de XPath-variabele ${shown} is niet gebonden +@msg the action set ids are not a list de id’s van de actieset zijn geen lijst +@msg the active paint is not a gradient de actieve verf is geen verloop +@msg the argument list is not an object de argumentenlijst is geen object +@msg the art of a graph design in a graph series is drawn again from the design: edit the design to change it de illustratie van een grafiekontwerp in een grafiekreeks wordt opnieuw vanuit het ontwerp getekend: bewerk het ontwerp om het te wijzigen +@msg the artboards don't fit on the canvas: fewer artboards, less spacing or a smaller size de tekengebieden passen niet op het canvas: minder tekengebieden, minder tussenruimte of een kleinere grootte +@msg the artwork is too large for EPS: what follows 256 MB of PostScript was left out de illustratie is te groot voor EPS: wat na 256 MB PostScript komt, is weggelaten +@msg the banner has no width or height de banner heeft geen breedte of hoogte +@msg the bitmaps hold more pixels than one file may de bitmaps bevatten meer pixels dan één bestand mag bevatten +@msg the character's size can't be measured de grootte van het teken kan niet worden gemeten +@msg the code runs past its last instruction de code loopt voorbij de laatste instructie +@msg the compound shape is too complex to expand de samengestelde vorm is te complex om uit te breiden +@msg the container of the listed objects is gone de container van de vermelde objecten is verdwenen +@msg the copy `{user_id}` can't be read as a library de kopie `{user_id}` kan niet als bibliotheek worden gelezen +@msg the copy would leave the canvas de kopie zou buiten het canvas vallen +@msg the curve tolerance must be from 0.01 to 10 points de curvetolerantie moet van 0,01 tot 10 punten zijn +@msg the custom dictionary couldn't be saved to {_1}: {e} het aangepaste woordenboek kon niet worden opgeslagen in {_1}: {e} +@msg the custom dictionary {_1} can't be read ({why}), so it is left as it is het aangepaste woordenboek {_1} kan niet worden gelezen ({why}), dus blijft het zoals het is +@msg the cut cannot be made on this art: {e} de snede kan niet in deze illustratie worden gemaakt: {e} +@msg the data isn't an EMF or WMF picture de gegevens zijn geen EMF- of WMF-afbeelding +@msg the data isn't an EPS or PostScript picture de gegevens zijn geen EPS- of PostScript-afbeelding +@msg the deferred paste is no longer available het uitgestelde plakken is niet meer beschikbaar +@msg the design is too big to draw at every data point of this graph het ontwerp is te groot om bij elk gegevenspunt van deze grafiek te tekenen +@msg the design is too big to draw in every column of this graph het ontwerp is te groot om in elke kolom van deze grafiek te tekenen +@msg the dialog it was opened over is no longer open het dialoogvenster waarboven het is geopend, is niet meer geopend +@msg the dictionary stack overflowed de woordenboekstack is overgelopen +@msg the document already has an SVG filter named {name} het document heeft al een SVG-filter met de naam {name} +@msg the document has another SVG filter named {name}: use svgFilter.apply, or svgFilter.define with `replace` to edit it het document heeft een ander SVG-filter met de naam {name}: gebruik svgFilter.apply, of svgFilter.define met `replace` om het te bewerken +@msg the document has no SVG filter named {name} het document heeft geen SVG-filter met de naam {name} +@msg the document has no SVG filter named {r} het document heeft geen SVG-filter met de naam {r} +@msg the document has no color swatches het document heeft geen kleurstalen +@msg the document's swatches hold {_1} colors; the document reduction takes at most 255 de stalen van het document bevatten {_1} kleuren; de documentreductie accepteert er maximaal 255 +@msg the editing data's hash has no place de hash van de bewerkingsgegevens heeft geen plaats +@msg the entities the document declares expand to too much text de entiteiten die het document declareert, worden tot te veel tekst uitgevouwen +@msg the envelope's content has no bounds de inhoud van de omvorming heeft geen grenzen +@msg the envelope's mesh is malformed het net van de omvorming is misvormd +@msg the file holds no `variableSets` element het bestand bevat geen element `variableSets` +@msg the file is larger than {_1} MB het bestand is groter dan {_1} MB +@msg the file is too large het bestand is te groot +@msg the file isn't valid SVG: {e} het bestand is geen geldige SVG: {e} +@msg the file names no plate het bestand noemt geen plaat +@msg the file was updated or encrypted already het bestand is al bijgewerkt of versleuteld +@msg the first character of a line has no character before it to kern: it moves only up and down (dy) het eerste teken van een regel heeft geen teken ervoor om mee te kernen: het beweegt alleen omhoog en omlaag (dy) +@msg the font {_1} is not available het lettertype {_1} is niet beschikbaar +@msg the format has no file extension de indeling heeft geen bestandsextensie +@msg the function's prototype is not an object het prototype van de functie is geen object +@msg the graphic can't be read: {e} de afbeelding kan niet worden gelezen: {e} +@msg the graphic is empty de afbeelding is leeg +@msg the graphic's data is damaged de gegevens van de afbeelding zijn beschadigd +@msg the graphic's document has no artboard het document van de afbeelding heeft geen tekengebied +@msg the grommet inset is too large for the banner de afstand van de zeilringen tot de rand is te groot voor de banner +@msg the guide is hidden or locked de hulplijn is verborgen of vergrendeld +@msg the header `{cell}` for `{name}` would read back as the variable `{other}`: rename one of them de koptekst `{cell}` voor `{name}` zou worden teruggelezen als de variabele `{other}`: geef een van beide een andere naam +@msg the hem is too deep for the banner de zoom is te diep voor de banner +@msg the image `{path}` isn't followed: {r} de afbeelding `{path}` wordt niet gevolgd: {r} +@msg the image has no embedded pixels de afbeelding heeft geen ingesloten pixels +@msg the image is empty de afbeelding is leeg +@msg the image is fully transparent de afbeelding is volledig transparant +@msg the image is not on an artboard; pass rect de afbeelding staat niet op een tekengebied; geef rect op +@msg the image's pixels are missing de pixels van de afbeelding ontbreken +@msg the image's pixels aren't in the document de pixels van de afbeelding staan niet in het document +@msg the image's pixels can't be read: {e} de pixels van de afbeelding kunnen niet worden gelezen: {e} +@msg the image's transparency doesn't fit it de transparantie van de afbeelding past er niet bij +@msg the job would print more than {MAX_PAGES} pages de taak zou meer dan {MAX_PAGES} pagina’s afdrukken +@msg the job would print more than {_1} pages de taak zou meer dan {_1} pagina’s afdrukken +@msg the layers hold no art to mask de lagen bevatten geen illustratie om te maskeren +@msg the layout moved de indeling is verplaatst +@msg the library has a group `{name}` already de bibliotheek heeft al een groep `{name}` +@msg the library has no group `{name}` de bibliotheek heeft geen groep `{name}` +@msg the library has no item `{item}` de bibliotheek heeft geen item `{item}` +@msg the library has no item `{other}` de bibliotheek heeft geen item `{other}` +@msg the library holds {MAX_GROUPS} groups already de bibliotheek bevat al {MAX_GROUPS} groepen +@msg the library holds {MAX_ITEMS} items of this kind already de bibliotheek bevat al {MAX_ITEMS} items van dit soort +@msg the library's file is outside the read roots het bestand van de bibliotheek staat buiten de leesroots +@msg the line is too long, or the paths it passes too many, to check de lijn is te lang, of de paden die hij passeert zijn te talrijk, om te controleren +@msg the method needs an XML value de methode heeft een XML-waarde nodig +@msg the name is empty de naam is leeg +@msg the object has no fill, stroke or effect het object heeft geen vulling, contour of effect +@msg the object has no graphic style (pass `name`) het object heeft geen grafische stijl (geef `name` op) +@msg the objects don't match the plan de objecten komen niet overeen met het plan +@msg the open and permissions passwords must differ het wachtwoord voor openen en het wachtwoord voor machtigingen moeten verschillen +@msg the operand stack overflowed de operandstack is overgelopen +@msg the page has no area de pagina heeft geen oppervlak +@msg the page's type in an unread object's box isn't in its page art de tekst van de pagina in het kader van een ongelezen object zit niet in de pagina-illustratie ervan +@msg the paint behind the proxy is not a gradient de verf achter de proxy is geen verloop +@msg the paint is not a freeform gradient (apply one with paint.editGradient {kind}) de verf is geen verloop in vrije vorm (pas er een toe met paint.editGradient {kind}) +@msg the parameters or body do not form one function de parameters of de body vormen niet één functie +@msg the parent must be a layer or sublayer het bovenliggende item moet een laag of sublaag zijn +@msg the pasted SVG filter {name} draws differently from the document's filter of that name, and no free name fits it het geplakte SVG-filter {name} tekent anders dan het filter met die naam in het document, en er is geen vrije naam die past +@msg the path can't be extended het pad kan niet worden verlengd +@msg the path can't be inside one of the objects to attach het pad kan niet in een van de te koppelen objecten zitten +@msg the path has no segments to measure het pad heeft geen segmenten om te meten +@msg the path is empty het pad is leeg +@msg the path is too short to shorten that much het pad is te kort om zoveel in te korten +@msg the paths are too many or too tangled to find where they cross de paden zijn te talrijk of te verward om te vinden waar ze elkaar kruisen +@msg the pen table holds more than 255 pens de pennentabel bevat meer dan 255 pennen +@msg the picture has no objects de afbeelding heeft geen objecten +@msg the plates can't be kept de platen kunnen niet worden behouden +@msg the position table does not match the instructions de positietabel komt niet overeen met de instructies +@msg the program runs too long het programma loopt te lang +@msg the program uses too much memory het programma gebruikt te veel geheugen +@msg the prompt's text is longer than {MAX_PROMPT_BYTES} bytes de tekst van de prompt is langer dan {MAX_PROMPT_BYTES} bytes +@msg the radix must be between 2 and 36 het grondtal moet tussen 2 en 36 liggen +@msg the rectangle must have a width and a height de rechthoek moet een breedte en een hoogte hebben +@msg the rectangle needs a size and must lie on the canvas de rechthoek heeft een grootte nodig en moet op het canvas liggen +@msg the rectangle or line reaches too many paths to check de rechthoek of lijn raakt te veel paden om te controleren +@msg the right side of 'in' is not an object de rechterkant van 'in' is geen object +@msg the right side of 'instanceof' is not a function de rechterkant van 'instanceof' is geen functie +@msg the selected art has no width de geselecteerde illustratie heeft geen breedte +@msg the selected art is nested more than {MAX_DEPTH} levels deep de geselecteerde illustratie is meer dan {MAX_DEPTH} niveaus diep genest +@msg the selected art is too large to measure de geselecteerde illustratie is te groot om te meten +@msg the selection draws nothing de selectie tekent niets +@msg the selection has no area de selectie heeft geen oppervlakte +@msg the selection has no art to export de selectie heeft geen illustratie om te exporteren +@msg the selection has no bounds de selectie heeft geen grenzen +@msg the selection has no graphic style de selectie heeft geen grafische stijl +@msg the selection has no outlines to weed around de selectie heeft geen omtrekken om omheen te wieden +@msg the slice would leave the canvas de slice zou buiten het canvas vallen +@msg the spacing makes more than {MAX_GROMMETS} grommets de tussenruimte levert meer dan {MAX_GROMMETS} zeilringen op +@msg the spot colour couldn't be added de steunkleur kon niet worden toegevoegd +@msg the subpath has no ends to extend (it is closed or a single point) het subpad heeft geen uiteinden om te verlengen (het is gesloten of een enkel punt) +@msg the symbols are nested too deeply to expand their instances de symbolen zijn te diep genest om hun instanties uit te breiden +@msg the text file is too large to place as type (at most {_1} MB) het tekstbestand is te groot om als tekst te plaatsen (maximaal {_1} MB) +@msg the text is empty de tekst is leeg +@msg the text is over {_1} MB de tekst is groter dan {_1} MB +@msg the top object must be a path het bovenste object moet een pad zijn +@msg the trace was cancelled de tracering is geannuleerd +@msg the trailer has no size de trailer heeft geen grootte +@msg the type object is flattened to nothing het tekstobject is tot niets afgevlakt +@msg the value bind was called on is not a function de waarde waarop bind is aangeroepen, is geen functie +@msg the value is not a constructor de waarde is geen constructor +@msg the value is not a function de waarde is geen functie +@msg the value is not a valid XML name de waarde is geen geldige XML-naam +@msg the value is not an XML attribute name de waarde is geen XML-attribuutnaam +@msg the value is not an XML name de waarde is geen XML-naam +@msg the value of axis `{tag}` must be a number or null de waarde van as `{tag}` moet een getal of null zijn +@msg the variable library declares more than {MAX_LIBRARY_DATASETS} data sets de variabelenbibliotheek declareert meer dan {MAX_LIBRARY_DATASETS} gegevenssets +@msg the variable library declares more than {MAX_LIBRARY_ENTITIES} entities de variabelenbibliotheek declareert meer dan {MAX_LIBRARY_ENTITIES} entiteiten +@msg the variable library declares more than {MAX_LIBRARY_VARIABLES} variables de variabelenbibliotheek declareert meer dan {MAX_LIBRARY_VARIABLES} variabelen +@msg the variable library declares no variables de variabelenbibliotheek declareert geen variabelen +@msg the variable library is larger than {MAX_LIBRARY_BYTES} bytes de variabelenbibliotheek is groter dan {MAX_LIBRARY_BYTES} bytes +@msg the variable library is not UTF-8 de variabelenbibliotheek is geen UTF-8 +@msg the variable library is not well-formed XML: {e} de variabelenbibliotheek is geen welgevormde XML: {e} +@msg the variable library nests elements more than {MAX_LIBRARY_NESTING} deep de variabelenbibliotheek nest elementen meer dan {MAX_LIBRARY_NESTING} niveaus diep +@msg the variable library's document type declaration holds something other than entities of plain text de documenttypedeclaratie van de variabelenbibliotheek bevat iets anders dan entiteiten van platte tekst +@msg the variable library's entities expand to more than {MAX_LIBRARY_BYTES} bytes de entiteiten van de variabelenbibliotheek worden tot meer dan {MAX_LIBRARY_BYTES} bytes uitgevouwen +@msg the weeding lines cross the art's outlines too many times to measure; use fewer lines de wiedlijnen kruisen de omtrekken van de illustratie te vaak om te meten; gebruik minder lijnen +@msg the weeding lines pass too close to too many outline segments to measure; use fewer lines or a smaller gap de wiedlijnen lopen te dicht langs te veel omtreksegmenten om te meten; gebruik minder lijnen of een kleinere tussenruimte +@msg the weeding lines would be more than {max_pieces} pieces de wiedlijnen zouden uit meer dan {max_pieces} stukken bestaan +@msg the window has no dock het venster heeft geen dock +@msg the written PDF has no catalog de geschreven PDF heeft geen catalogus +@msg the written PDF has no cross-reference table de geschreven PDF heeft geen kruisverwijzingstabel +@msg the written PDF's metadata can't be edited de metagegevens van de geschreven PDF kunnen niet worden bewerkt +@msg the {_1} plate lies outside the file de plaat {_1} ligt buiten het bestand +@msg there are no colour swatches to draw er zijn geen kleurstalen om te tekenen +@msg there is already a design named `{name}` er is al een ontwerp met de naam `{name}` +@msg there is already a design named `{to}` er is al een ontwerp met de naam `{to}` +@msg there is already a toolbar named `{name}` er is al een werkbalk met de naam `{name}` +@msg there is already a toolbar named `{to}` er is al een werkbalk met de naam `{to}` +@msg there is no banner to mark er is geen banner om te markeren +@msg there is no library: create one first er is geen bibliotheek: maak er eerst een +@msg these paths are too degenerate for Shaper deze paden zijn te gedegenereerd voor Shaper +@msg this is a binary DXF file, which can't be read: save it from the CAD app as an ASCII DXF and open that dit is een binair DXF-bestand, dat niet kan worden gelezen: sla het vanuit de CAD-app op als ASCII-DXF en open dat bestand +@msg this warp's points can't be edited: use Reset with Mesh first de punten van deze verdraaiing kunnen niet worden bewerkt: gebruik eerst Herstellen met mesh +@msg thumbnail: no page {v} (the {what} has {count}) miniatuur: geen pagina {v} ({what} heeft er {count}) +@msg tileRange of {what}: {e} tileRange van {what}: {e} +@msg title can't be empty title mag niet leeg zijn +@msg to (the new name) is required to (de nieuwe naam) is vereist +@msg to must be fill or stroke to moet fill of stroke zijn +@msg to must be smooth or corner to moet smooth of corner zijn +@msg toExponential() digits must be between 0 and 20 het aantal cijfers van toExponential() moet tussen 0 en 20 liggen +@msg toFixed() digits must be between 0 and 20 het aantal cijfers van toFixed() moet tussen 0 en 20 liggen +@msg toISOString is not a function toISOString is geen functie +@msg toPrecision() argument must be between 1 and 21 het argument van toPrecision() moet tussen 1 en 21 liggen +@msg toSource: a getter cannot be written as source toSource: een getter kan niet als broncode worden geschreven +@msg toSource: an array with properties besides its elements, a property that is not enumerable or another prototype cannot be written as source toSource: een array met eigenschappen naast zijn elementen, een niet-opsombare eigenschap of een ander prototype kan niet als broncode worden geschreven +@msg toSource: an object with a property that is not enumerable, or whose prototype is not Object.prototype, cannot be written as source toSource: een object met een niet-opsombare eigenschap, of waarvan het prototype niet Object.prototype is, kan niet als broncode worden geschreven +@msg toSource: the source is too long toSource: de broncode is te lang +@msg toSource: the value contains itself toSource: de waarde bevat zichzelf +@msg toSource: the value has too many entries toSource: de waarde heeft te veel items +@msg toSource: the value is nested too deep toSource: de waarde is te diep genest +@msg toString is not a function toString is geen functie +@msg too large for a zip archive: package to a folder te groot voor een zip-archief: verpak naar een map +@msg too many Shaper edits te veel Shaper-bewerkingen +@msg too many `points` (at most 100000) te veel `points` (maximaal 100000) +@msg too many arguments te veel argumenten +@msg too many characters: at most {MAX_CHARS} te veel tekens: maximaal {MAX_CHARS} +@msg too many dots for this size: lower the frequency te veel punten voor deze grootte: verlaag de frequentie +@msg too many filters over one file te veel filters over één bestand +@msg too many overlapping paths for Shaper te veel overlappende paden voor Shaper +@msg too many quantifiers te veel kwantoren +@msg too many saved clips te veel opgeslagen knippaden +@msg too many saved graphics states te veel opgeslagen grafische toestanden +@msg toolbar (a toolbar's name) must be a string toolbar (de naam van een werkbalk) moet een string zijn +@msg toolbar name can't be empty de naam van een werkbalk mag niet leeg zijn +@msg transparentImages {v}: "flatten" (the default) or "omit" transparentImages {v}: "flatten" (de standaard) of "omit" +@msg turn on at least one side schakel minstens één zijde in +@msg two saved selections would be named `{_1}` twee opgeslagen selecties zouden de naam `{_1}` krijgen +@msg type dimension cannot be represented with this text transform de tekstmaatlijn kan niet worden weergegeven met deze teksttransformatie +@msg type dimension must be finite de tekstmaatlijn moet eindig zijn +@msg unexpected resources onverwachte resources +@msg unknown CMYK profile `{name}` onbekend CMYK-profiel `{name}` +@msg unknown File Info field `{k}` onbekend veld `{k}` van Bestandsinfo +@msg unknown OpenType feature `{t}` (liga, calt, dlig, smcp, frac, onum, tnum, ordn, swsh, ss01–ss20, salt, titl, pnum, lnum, sups, subs, numr, dnom, aalt; prefix - to turn off; swsh, ss01–ss20, salt, titl, pnum, lnum, sups, subs, numr, dnom and aalt take an alternate's number as `tag=N` with N from 0 to {_1}, as `salt=2`) onbekende OpenType-functie `{t}` (liga, calt, dlig, smcp, frac, onum, tnum, ordn, swsh, ss01–ss20, salt, titl, pnum, lnum, sups, subs, numr, dnom, aalt; zet er - voor om uit te schakelen; swsh, ss01–ss20, salt, titl, pnum, lnum, sups, subs, numr, dnom en aalt accepteren het nummer van een alternatief als `tag=N` met N van 0 tot {_1}, zoals `salt=2`) +@msg unknown OpenType feature `{t}` in featureChanges (the tags `features` takes) onbekende OpenType-functie `{t}` in featureChanges (de tags die `features` accepteert) +@msg unknown PDF preset `{name}` (presets: {_1}) onbekende PDF-voorinstelling `{name}` (voorinstellingen: {_1}) +@msg unknown Warp style onbekende warpstijl +@msg unknown alignToPath `{a}` onbekende alignToPath `{a}` +@msg unknown arrowhead {v} onbekende pijlpunt {v} +@msg unknown artboardLayout key `{k}` (layout, columns, spacing, rightToLeft) onbekende sleutel `{k}` van artboardLayout (layout, columns, spacing, rightToLeft) +@msg unknown attribute `{attribute}` onbekend kenmerk `{attribute}` +@msg unknown attribute `{k}` onbekend kenmerk `{k}` +@msg unknown axis `{other}` (vertical|horizontal|free) onbekende as `{other}` (vertical|horizontal|free) +@msg unknown blend mode `{b}` onbekende vermengingsmodus `{b}` +@msg unknown blend mode {b} onbekende vermengingsmodus {b} +@msg unknown brush type `{o}` onbekend penseeltype `{o}` +@msg unknown category `{c}` onbekende categorie `{c}` +@msg unknown category `{c}` ({_1}) onbekende categorie `{c}` ({_1}) +@msg unknown character `{c}` onbekend teken `{c}` +@msg unknown character style number field onbekend getalveld van een tekenstijl +@msg unknown dither `{d}` (diffusion, pattern, noise or none) onbekende dither `{d}` (diffusion, pattern, noise of none) +@msg unknown effect `{e}` onbekend effect `{e}` +@msg unknown end {e} onbekend uiteinde {e} +@msg unknown flattenerPreset `{name}` (High Resolution, Medium Resolution, Low Resolution or a saved one: see flattener.presets.list) onbekende flattenerPreset `{name}` (High Resolution, Medium Resolution, Low Resolution of een opgeslagen voorinstelling: zie flattener.presets.list) +@msg unknown format `{f}` (vcswatches, gpl, ase or css) onbekende indeling `{f}` (vcswatches, gpl, ase of css) +@msg unknown from {f} onbekende from {f} +@msg unknown graph type `{t}` onbekend grafiektype `{t}` +@msg unknown grid colours `{name}` (one of {_1}) onbekende rasterkleuren `{name}` (een van {_1}) +@msg unknown gridType `{t}` onbekende gridType `{t}` +@msg unknown highlight `{v}` onbekende markering `{v}` +@msg unknown intent `{i}` onbekende intentie `{i}` +@msg unknown issue kind {id} onbekend soort probleem {id} +@msg unknown issue kind {v} onbekend soort probleem {v} +@msg unknown knockout state {k} onbekende knockoutstatus {k} +@msg unknown language `{language}` (one of {_1}) onbekende taal `{language}` (een van {_1}) +@msg unknown language `{l}` (one of {_1}) onbekende taal `{l}` (een van {_1}) +@msg unknown method `{m}` ({_1}) onbekende methode `{m}` ({_1}) +@msg unknown mode `{other}` (gray, rgb, hsb, lab, cmyk or web) onbekende modus `{other}` (gray, rgb, hsb, lab, cmyk of web) +@msg unknown mode `{other}` (mono|cmyk) onbekende modus `{other}` (mono|cmyk) +@msg unknown mode `{other}` (rgb|cmyk|gray|global) onbekende modus `{other}` (rgb|cmyk|gray|global) +@msg unknown mode `{other}` (set, add, subtract) onbekende modus `{other}` (set, add, subtract) +@msg unknown mode `{o}` onbekende modus `{o}` +@msg unknown mode {m} onbekende modus {m} +@msg unknown model `{other}` onbekend model `{other}` +@msg unknown model `{other}` (keep, new or document) onbekend model `{other}` (keep, new of document) +@msg unknown op {o} onbekende op {o} +@msg unknown order `{o}`: toggle, front, forward, backward or back onbekende volgorde `{o}`: toggle, front, forward, backward of back +@msg unknown overprints `{v}` (preserve, simulate or discard) onbekende overprints `{v}` (preserve, simulate of discard) +@msg unknown panel onbekend paneel +@msg unknown panel `{panel}` onbekend paneel `{panel}` +@msg unknown parameter `{key}` onbekende parameter `{key}` +@msg unknown pieLegend `{v}` (none, standard or wedges) onbekende pieLegend `{v}` (none, standard of wedges) +@msg unknown piePosition `{v}` (even, ratio or stacked) onbekende piePosition `{v}` (even, ratio of stacked) +@msg unknown pieSort `{v}` (none, all or first) onbekende pieSort `{v}` (none, all of first) +@msg unknown plate `{n}` onbekende plaat `{n}` +@msg unknown preference `{k}` onbekende voorkeur `{k}` +@msg unknown profile {id} (see stroke.widthProfile.list) onbekend profiel {id} (zie stroke.widthProfile.list) +@msg unknown proof target `{t}` onbekend proefdoel `{t}` +@msg unknown quotes key `{k}` (double, single) onbekende sleutel `{k}` van quotes (double, single) +@msg unknown reduction `{reduction}` (selective, perceptual, adaptive, web, gray, blackWhite, uniform or document) onbekende reductie `{reduction}` (selective, perceptual, adaptive, web, gray, blackWhite, uniform of document) +@msg unknown resolution `{v}` onbekende resolutie `{v}` +@msg unknown rule `{rule}` ({_1}) onbekende regel `{rule}` ({_1}) +@msg unknown rule `{r}` (see color.harmony) onbekende regel `{r}` (zie color.harmony) +@msg unknown setting `{k}` onbekende instelling `{k}` +@msg unknown shape `{v}` (circle|ellipse|square|diamond|line) onbekende vorm `{v}` (circle|ellipse|square|diamond|line) +@msg unknown spacing `{o}` (smooth|steps|distance) onbekende spacing `{o}` (smooth|steps|distance) +@msg unknown tileType `{t}` ({_1}) onbekende tileType `{t}` ({_1}) +@msg unknown units onbekende eenheden +@msg unknown units `{u}` onbekende eenheden `{u}` +@msg unknown value axis `{v}` (left, right or both) onbekende waardeas `{v}` (left, right of both) +@msg unknown variation `{v}` (tintsShades|warmCool|vividMuted) onbekende variatie `{v}` (tintsShades|warmCool|vividMuted) +@msg unknown warp style `{s}` onbekende warpstijl `{s}` +@msg unknown {key} `{v}` (none, short or full) onbekende {key} `{v}` (none, short of full) +@msg unknown {key} profile `{n}` onbekend {key}-profiel `{n}` +@msg unknown {k} key `{key}` (size, position) onbekende sleutel `{key}` van {k} (size, position) +@msg unmatched ')' ')' zonder tegenhanger +@msg unreadable object onleesbaar object +@msg unsafe destination file name onveilige naam voor het doelbestand +@msg unterminated character class niet-afgesloten tekenklasse +@msg unterminated group niet-afgesloten groep +@msg use paths or compound paths gebruik paden of samengestelde paden +@msg useArtboards must be true or false, not {v} useArtboards moet true of false zijn, niet {v} +@msg value for `{var}` must match its variable kind de waarde voor `{var}` moet bij het soort variabele passen +@msg variable `{_1}` is already defined variabele `{_1}` is al gedefinieerd +@msg variable `{name}` has no `trait` variabele `{name}` heeft geen `trait` +@msg variable `{name}` is already defined variabele `{name}` is al gedefinieerd +@msg variable `{name}` is declared twice variabele `{name}` is twee keer gedeclareerd +@msg variable `{to}` already exists variabele `{to}` bestaat al +@msg view is required view is vereist +@msg view must be one of {_1} view moet een van {_1} zijn +@msg warpStyle can only edit an applied Warp effect warpStyle kan alleen een toegepast warpeffect bewerken +@msg width and height must be more than 0 and at most {limit} width en height moeten meer dan 0 en maximaal {limit} zijn +@msg width factors must be finite breedtefactoren moeten eindig zijn +@msg width must be positive width moet positief zijn +@msg width out of range breedte buiten het bereik +@msg width/height must be > 0 width/height moeten > 0 zijn +@msg with no hem and no grommets there is nothing to mark zonder zoom en zonder zeilringen is er niets om te markeren +@msg wordGap and lineGap need area type in the selection wordGap en lineGap hebben vlaktekst in de selectie nodig +@msg x and y must be finite numbers x en y moeten eindige getallen zijn +@msg x and y must be given together x en y moeten samen worden opgegeven +@msg xpath needs its variables as an object xpath heeft zijn variabelen als object nodig +@msg xpath needs the expression as a string xpath heeft de expressie als string nodig +@msg zone needs an anchor: dock beside a panel with anchor, or in a new dock column with side (Start or End) zone heeft een anker nodig: dock naast een paneel met anchor, of in een nieuwe dockkolom met side (Start of End) +@msg zoom must be positive zoom moet positief zijn +@msg {C}: no effect at index {list} {C}: geen effect op index {list} +@msg {DEFAULT_PRESET} is protected and stays {DEFAULT_PRESET} is beveiligd en blijft bestaan +@msg {DEFAULT_PRESET} is protected: save the settings under another name {DEFAULT_PRESET} is beveiligd: sla de instellingen onder een andere naam op +@msg {GRANT_NOT_REMOVED}, and its settings and cache can't be moved back from {_1} to {_2}: {e} {GRANT_NOT_REMOVED}, en de instellingen en cache ervan kunnen niet van {_1} naar {_2} worden teruggezet: {e} +@msg {LABEL} produced an empty result {LABEL} heeft een leeg resultaat opgeleverd +@msg {_1} MB of document, at most {_2} MB {_1} MB aan document, maximaal {_2} MB +@msg {_1} MB of images, at most {_2} MB {_1} MB aan afbeeldingen, maximaal {_2} MB +@msg {_1} bytes of RGBA data for a {width} × {height} image {_1} bytes aan RGBA-gegevens voor een afbeelding van {width} × {height} +@msg {_1} can't be read, or changed since it was read: relink or update it first {_1} kan niet worden gelezen, of is gewijzigd sinds het is gelezen: koppel het eerst opnieuw of werk het eerst bij +@msg {_1} can't go into {into} {_1} kan niet in {into} worden geplaatst +@msg {_1} can't limit printing to low resolution: choose PDF 1.4 or later, or allow high-resolution printing {_1} kan afdrukken niet tot lage resolutie beperken: kies PDF 1.4 of later, of sta afdrukken in hoge resolutie toe +@msg {_1} files can't be opened yet {_1}-bestanden kunnen nog niet worden geopend +@msg {_1} files can't be password-protected: remove the passwords or choose no standard {_1}-bestanden kunnen niet met een wachtwoord worden beveiligd: verwijder de wachtwoorden of kies geen standaard +@msg {_1} files can't be {_2} {_1}-bestanden kunnen niet {_2} zijn +@msg {_1} files can't carry editing data: turn off preserveEditing {_1}-bestanden kunnen geen bewerkingsgegevens bevatten: schakel preserveEditing uit +@msg {_1} files can't have PDF layers: turn off createLayers {_1}-bestanden kunnen geen PDF-lagen hebben: schakel createLayers uit +@msg {_1} files need a creation date, and this platform has no clock to give one {_1}-bestanden hebben een aanmaakdatum nodig, en dit platform heeft geen klok om er een te geven +@msg {_1} is not a folder: {e} {_1} is geen map: {e} +@msg {_1} isn't a path {_1} is geen pad +@msg {_1} options: {e} opties voor {_1}: {e} +@msg {_1} paints nothing to rasterize {_1} verft niets om te rasteriseren +@msg {_1} passwords can have up to {MAX_LEGACY_PASSWORD} ASCII characters (PDF 1.7 and later take any) wachtwoorden voor {_1} mogen maximaal {MAX_LEGACY_PASSWORD} ASCII-tekens hebben (PDF 1.7 en later accepteren alle tekens) +@msg {_1} with linked images or an image map writes several files: use document.export {_1} met gekoppelde afbeeldingen of een imagemap schrijft meerdere bestanden: gebruik document.export +@msg {_1} writes one file per artboard here: use document.export, or name one artboard {_1} schrijft hier één bestand per tekengebied: gebruik document.export, of noem één tekengebied +@msg {_1} × {_2} pixels is too large for {_3} (at most {max} pixels a side): lower the scale {_1} × {_2} pixels is te groot voor {_3} (maximaal {max} pixels per zijde): verlaag de schaal +@msg {_1}: belongs to another account {_1}: hoort bij een ander account +@msg {_1}: not a folder of its own {_1}: geen eigen map +@msg {_1}: not a plain file {_1}: geen gewoon bestand +@msg {_1}: {_2} and {_3} are in the way {_1}: {_2} en {_3} staan in de weg +@msg {code}: {0} {code}: {0} +@msg {dest}: {e} {dest}: {e} +@msg {dir}: {e} {dir}: {e} +@msg {doc} has no folder {doc} heeft geen map +@msg {file} isn't linked {file} is niet gekoppeld +@msg {file} names more than one linked JavaScript file {file} noemt meer dan één gekoppeld JavaScript-bestand +@msg {folder} is not a package folder {folder} is geen pakketmap +@msg {folder}: more than {max} files and folders {folder}: meer dan {max} bestanden en mappen +@msg {folder}: {e} {folder}: {e} +@msg {g} is not a Live Paint group {g} is geen Live Paint-groep +@msg {id} is not a slice {id} is geen slice +@msg {key} must be 0–{MAX_ADD_AROUND} pt {key} moet 0–{MAX_ADD_AROUND} pt zijn +@msg {key} must be [x,y] {key} moet [x,y] zijn +@msg {key} must be a percentage {min}..100 {key} moet een percentage {min}..100 zijn +@msg {key} must be a positive number, not {n} {key} moet een positief getal zijn, niet {n} +@msg {key} must be a positive number, not {v} {key} moet een positief getal zijn, niet {v} +@msg {key} must be one of {_1} {key} moet een van {_1} zijn +@msg {key} must be {_1}, got {s} {key} moet {_1} zijn, kreeg {s} +@msg {key} must name a floating panel {key} moet een zwevend paneel noemen +@msg {key} must name a panel in another group {key} moet een paneel in een andere groep noemen +@msg {key} must name a panel that shows {key} moet een paneel noemen dat wordt getoond +@msg {key} must name a registered panel {key} moet een geregistreerd paneel noemen +@msg {kind} files have no transparency, and the file would have {what}: flatten it first (object.flattenTransparency) {kind}-bestanden hebben geen transparantie, en het bestand zou {what} bevatten: vlak het eerst af (object.flattenTransparency) +@msg {kind} images can't be opened (see document.formats) {kind}-afbeeldingen kunnen niet worden geopend (zie document.formats) +@msg {k} `{v}` is not one of the choices {k} `{v}` is geen van de keuzes +@msg {k} has control characters{_1} {k} bevat besturingstekens{_1} +@msg {k} is too long (at most {MAX_TEXT} characters) {k} is te lang (maximaal {MAX_TEXT} tekens) +@msg {k} must be > 0 {k} moet > 0 zijn +@msg {k} must be a number (pt) or a length such as "210 mm" {k} moet een getal (pt) of een lengte zoals "210 mm" zijn +@msg {k} must be a number from {min} to {max} {k} moet een getal van {min} tot {max} zijn +@msg {k} must be a number or "auto" {k} moet een getal of "auto" zijn +@msg {k} must be a string {k} moet een string zijn +@msg {k} must be text {k} moet tekst zijn +@msg {k} must be true or false {k} moet true of false zijn +@msg {k} must be {{size?, position?}} {k} moet {{size?, position?}} zijn +@msg {k}: a custom arrowhead's path needs an area to fill and at most {most} anchors and {most} subpaths, each anchor within {far} head units of its tip {k}: het pad van een aangepaste pijlpunt heeft een oppervlak om te vullen nodig en maximaal {most} ankers en {most} subpaden, elk anker binnen {far} kopeenheden van de punt +@msg {k}: bad custom arrowhead path: {e} {k}: ongeldig pad van een aangepaste pijlpunt: {e} +@msg {k}: bad custom arrowhead: {e} {k}: ongeldige aangepaste pijlpunt: {e} +@msg {k}: can't read `{s}` as a length {k}: kan `{s}` niet als lengte lezen +@msg {k}: custom must be a name {k}: custom moet een naam zijn +@msg {label} must be a number at most {max} {label} moet een getal van maximaal {max} zijn +@msg {label} must be a number from -1296 to 1296 {label} moet een getal van -1296 tot 1296 zijn +@msg {label} must be a number from 1 to 10000 {label} moet een getal van 1 tot 10000 zijn +@msg {name} `{s}`: {ids} {name} `{s}`: {ids} +@msg {name} is built in and can't be deleted {name} is ingebouwd en kan niet worden verwijderd +@msg {name} must be a number {name} moet een getal zijn +@msg {name}: CRC or size mismatch {name}: CRC of grootte komt niet overeen +@msg {name}: only this Affinity file's embedded preview could be read; use File › Open to see it with its warning, or export SVG or PDF from Affinity before placing {name}: alleen de ingesloten voorvertoning van dit Affinity-bestand kon worden gelezen; gebruik Bestand › Openen om die met de bijbehorende waarschuwing te bekijken, of exporteer SVG of PDF vanuit Affinity voordat je plaatst +@msg {name}: {e} {name}: {e} +@msg {native}; its embedded preview can't be read either ({e}) {native}; de ingesloten voorvertoning ervan kan ook niet worden gelezen ({e}) +@msg {path}: copy takes a DCS file only when its plates are inside it; relink to it where its plate files are {path}: copy accepteert een DCS-bestand alleen wanneer de platen erin zitten; koppel het opnieuw op de plek waar de plaatbestanden staan +@msg {path}: larger than {_1} MB {path}: groter dan {_1} MB +@msg {saving} failed: {e} {saving} is mislukt: {e} +@msg {shown} is not an XPath 1.0 function {shown} is geen XPath 1.0-functie +@msg {std} files are CMYK, and the file would have colours in {_1} {std}-bestanden zijn CMYK, en het bestand zou kleuren in {_1} bevatten +@msg {std} files embed their fonts, and the file would have one that isn't {std}-bestanden sluiten hun lettertypen in, en het bestand zou er een bevatten dat niet is ingesloten +@msg {target} is the file this document was read from, and reading it left things out ({what}): writing over it would lose them for good. Write another file instead, or pass acknowledgeLoss: true to replace it anyway {target} is het bestand waaruit dit document is gelezen, en bij het lezen zijn dingen weggelaten ({what}): door eroverheen te schrijven zouden die voorgoed verloren gaan. Schrijf in plaats daarvan een ander bestand, of geef acknowledgeLoss: true op om het toch te vervangen +@msg {ty} brushes need selected art (or params.{k}) {ty}-penselen hebben een geselecteerde illustratie nodig (of params.{k}) +@msg {v} is not an asset id {v} is geen asset-id +@msg {v} names no layer or sublayer {v} noemt geen laag of sublaag +@msg {what} can't be intertwined {what} kan niet worden verstrengeld +@msg {what} doesn't fit the paper with its bleed and marks {what} past niet op het papier met de afloop en de tekens ervan +@msg {what} is not a function {what} is geen functie +@msg {what} would print more than {MAX_COPIES_PER_SHEET} copies on a sheet: scale it up {what} zou meer dan {MAX_COPIES_PER_SHEET} exemplaren op een vel afdrukken: schaal het omhoog +@msg {what} would print on more than {MAX_TILES} tiles: scale it down {what} zou op meer dan {MAX_TILES} tegels worden afgedrukt: schaal het omlaag +@msg {what} {i} out of range {what} {i} buiten het bereik + Ruler Origin Lineaaloorsprong Reset Ruler Origin Lineaaloorsprong herstellen Column Width: Kolombreedte: diff --git a/docs/localization-parity.md b/docs/localization-parity.md index cd8dc33f30..b4cf0013bf 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -51,7 +51,7 @@ plus review. Native-speaker review is human work and isn't in the hours. |---|---|---|---| | Traditional Chinese (Taiwan) | `zh-hant` | 4,892 rows, 790 of them `@msg` (counted 2026-10-21): menus, `tl!` literals and messages complete when counted (80% overall) | partial | | Italian | `it` | 4,011 / 4,020 | full | -| Dutch | `nl` | 7,299 rows, 1,609 of them `@msg` and 47 `@msgplural` (counted 2026-11-13 on `main` at `9a1a158a3`): in `COMPLETE_MESSAGES`, and the untranslated report lists the same missing messages for it as for German; one/other plurals | full | +| Dutch | `nl` | 3,447 `@msg` and 48 `@msgplural` rows (counted 2026-11-13): in `COMPLETE_MESSAGES`, and the untranslated report lists 41 missing messages for it; one/other plurals | full | | Danish | `da` | 5,279 rows, 750 of them `@msg` (counted 2026-10-21): menus and `tl!` literals complete when counted; its messages are partial; one/other plurals | full | | Russian | `ru` | 4,009 / 4,020 | full | | Ukrainian | `uk` | 4,009 / 4,020 (one/few/many plurals) | full | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f3707717e6..7cbfdea2d3 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -885,6 +885,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The status bar translates the limits a plug-in run can exceed (its instruction, time and memory budgets and its output size) and the error of a plug-in removal that leaves the plug-in's grant in the plug-in store, in every language that translates every message. The untranslated-strings report also lists messages that an error or a status takes from a `&str` constant (`plugin_limit_errors_are_translated`, `message_scan_reads_messages_held_in_constants`). - The status bar translates the plug-in host's other errors (manifest, module and run checks, the output an importer, exporter or effect returns, and the approval a plug-in's permissions need) in every language that translates every message. A JSON object or array inside a message stays as written, and a message that wraps another one, such as `plug-in manifest: {0}`, is matched by its own row before a row that starts with a placeholder. The reasons inside these errors (what is wrong with a parameter's spec or dialog keys, the value a parameter needs, what is wrong with an object, stroke, paint or effect in a plug-in's output) are translated with them, and the untranslated-strings report lists the reasons the plug-in host's error helpers take (`plugin_messages_are_translated_in_every_complete_catalog`, `plugin_errors_translate_with_their_values`, `plugin_error_reasons_are_translated_with_the_error`, `message_scan_reads_plugin_helpers`, `templates_that_start_with_text_match_first`). - The status bar translates the errors a script's `File` and `Folder` objects, `vc.run`, `$.evalFile`, the `$` object's properties and functions, `alert`, `confirm` and `prompt`, `vc.document` and `vc.log` raise, the limits a run can pass, and the errors of Drop Script Engine, and the line for a run that fails (a syntax error, a thrown error, a limit, a stop or an internal error, with the script's name, the line and column, the included file it is in and the files left written), in every language that translates every message. The script's name, paths, numbers, command ids and the text a script throws itself are shown as they are. A failure with no line and column, such as an error in code `eval` compiled, is shown with one colon after the script's name (`an_error_without_a_place_names_the_script_and_kind`). A message template that names a value twice matches only when both places hold the same text, so the line for a failed run is not taken for the message inside it (`a_repeated_placeholder_matches_the_same_text`). The untranslated-strings report also lists the messages the script host's `fail`, `value` and `over` helpers take and the errors the script interpreter throws, and a constant's text comes from the file or crate that declares it, so the Scripts menu's headers are not listed as messages (`script_errors_are_translated`, `script_host_errors_are_translated`, `message_scan_reads_script_interpreter_errors`, `message_scan_reads_constants_of_the_file_and_its_crate`, `message_scan_skips_test_modules_with_any_test_cfg`). + - The Dutch catalog (`crates/ui-egui/src/i18n/nl.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,447 `@msg` rows in all. The report lists 41 Dutch messages: the composite font errors, the justification spacing error and the `connect` end error, which open #7211, #7116 and #7330 translate, and three unknown-parameter and range errors (``unknown parameter `{within}{key}`; {why}``, ``unknown parameter `{within}settings.{format}`; {why}`` and `{name} must be {lo}–{hi}{unit} (got {v})`), which open #7353 rewrites so that a catalog row can match them. The row for `{k} has control characters{_1}` does not match the File Info error for a multi-line field, where the last placeholder is empty. A native speaker has not reviewed the wording. - Localised UI: menus (in-window and native), panels, dialogs, toolbar and Preferences read from per-language catalogs (`crates/ui-egui/src/i18n`, see `docs/development.md`); Traditional Chinese (Taiwan), Simplified Chinese (mainland), Japanese, Korean, Vietnamese, German, Spanish, French, Italian, Polish, Brazilian Portuguese, Russian, Ukrainian, Georgian and Catalan ship complete, and Czech covers every menu label (and more), with system-locale detection on macOS, Windows, Linux and the web (the browser's languages, or `?lang=`), a Language preference and, on macOS, a VectorCraft ▸ Language menu. Names are never translated (fonts and their styles, layers, artboards, saved presets, user libraries, custom workspaces, recent files, plug-ins). The counts that Package's status and question, the folder search of Missing Fonts and Find Linked Files, the modified and missing linked file prompts and the CSS Properties panel's notes show use the interface language's plural forms instead of a fixed "(s)" form. Evidence: `the_missing_links_note_uses_each_count_form` in `crates/ui-egui/src/dialogs/tests_package.rs`, `the_modified_links_question_uses_each_count_form` in `crates/ui-egui/src/dialogs/missing_links.rs`, `search_counts_use_each_count_form` in `crates/ui-egui/src/dialogs/missing_fonts/tests.rs` and `the_unnamed_objects_note_uses_each_count_form` in `crates/ui-egui/src/panels/tests_css_properties.rs`. The status bar's messages for relinked, replaced, updated and embedded images, broken links, linked files that can't be read or changed on disk, images that can't be decoded, added and unavailable fonts, copied CSS, downloads and exports with their notes name one item in the singular and more in the plural, in English and in each language's plural forms (`counted_status_messages_take_the_plural_form` in `crates/ui-egui/src/i18n/tests.rs`). From 00c0c1d6ea03cdf048f71c2c3ed50764d8898a59 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 17:26:47 -0800 Subject: [PATCH 009/108] Learn: steps get check boxes, and skill rings fill as tutorials are finished Each step of a Learn tutorial now has a check box that marks it done once the tutorial's practice sample is open, and Finish tutorial marks every step done. A skill's ring fills by the share of its tutorials finished, its count shows tutorials finished of all, and a finished tutorial has a check mark in its skill's list. Screen readers get the count and the finished state as the rows' values. The progress is saved with the UI preferences and read leniently: an unknown tutorial, a step a tutorial does not have, a repeated entry or a value of the wrong kind is skipped without resetting other preferences. Reset progress under the list of skills clears it. A finished tutorial can be finished again after a restart without reopening its sample. - learn.markStep marks or clears one step; learn.resetProgress clears the progress; learn.list adds done and total per skill and finished and completedSteps per tutorial. Both new commands are in the UI command catalogs, and bad params are errors that change nothing. - New labels and messages have rows in every catalog. - Docs: docs/mcp.md, docs/target-app-parity.md and docs/ui-parity.md. --- crates/mcp/src/ui_catalog.rs | 16 +- crates/ui-egui/src/i18n/bg.tsv | 6 + crates/ui-egui/src/i18n/bs.tsv | 6 + crates/ui-egui/src/i18n/ca.tsv | 6 + crates/ui-egui/src/i18n/cs.tsv | 6 + crates/ui-egui/src/i18n/da.tsv | 6 + crates/ui-egui/src/i18n/de.tsv | 6 + crates/ui-egui/src/i18n/el.tsv | 6 + crates/ui-egui/src/i18n/es.tsv | 6 + crates/ui-egui/src/i18n/fi.tsv | 6 + crates/ui-egui/src/i18n/fr.tsv | 6 + crates/ui-egui/src/i18n/hi.tsv | 6 + crates/ui-egui/src/i18n/hu.tsv | 6 + crates/ui-egui/src/i18n/id.tsv | 6 + crates/ui-egui/src/i18n/it.tsv | 6 + crates/ui-egui/src/i18n/ja.tsv | 6 + crates/ui-egui/src/i18n/ka.tsv | 6 + crates/ui-egui/src/i18n/ko.tsv | 6 + crates/ui-egui/src/i18n/nl.tsv | 6 + crates/ui-egui/src/i18n/pl.tsv | 6 + crates/ui-egui/src/i18n/pt-br.tsv | 6 + crates/ui-egui/src/i18n/ru.tsv | 6 + crates/ui-egui/src/i18n/sv.tsv | 6 + crates/ui-egui/src/i18n/tr.tsv | 6 + crates/ui-egui/src/i18n/uk.tsv | 6 + crates/ui-egui/src/i18n/vi.tsv | 6 + crates/ui-egui/src/i18n/zh-hans.tsv | 6 + crates/ui-egui/src/i18n/zh-hant.tsv | 6 + crates/ui-egui/src/menus/ui_commands.rs | 16 +- crates/ui-egui/src/panels/learn.rs | 223 +++++++++++---- crates/ui-egui/src/panels/learn/progress.rs | 122 +++++++++ crates/ui-egui/src/panels/learn/tests.rs | 289 +++++++++++++++++++- crates/ui-egui/src/state.rs | 6 +- docs/mcp.md | 37 ++- docs/target-app-parity.md | 5 +- docs/ui-parity.md | 2 +- 36 files changed, 807 insertions(+), 71 deletions(-) create mode 100644 crates/ui-egui/src/panels/learn/progress.rs diff --git a/crates/mcp/src/ui_catalog.rs b/crates/mcp/src/ui_catalog.rs index 2388e9d10d..331d13c393 100644 --- a/crates/mcp/src/ui_catalog.rs +++ b/crates/mcp/src/ui_catalog.rs @@ -666,7 +666,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "learn.list", "List Tutorials", "", - "{} the Learn panel's skills in the order its Skills tab lists them: {skills: [{id, title, tutorials: [{id, title, steps: number of steps}]}]}", + "{} the Learn panel's skills in the order its Skills tab lists them, with the progress its rings, counts and check marks show: {skills: [{id, title, done: number of its tutorials finished, total: number of its tutorials, tutorials: [{id, title, steps: number of steps, finished: bool, completedSteps: [zero-based indexes of the steps marked done, every step once finished]}]}]}", ), ( "learn.skills", @@ -692,11 +692,17 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{tutorial: id (see learn.list)} open that tutorial's practice sample as a new untitled document, which becomes the active one, and move the Learn view to the tutorial, as its View more button does; each call opens another copy and open documents stay as they are; a missing, non-string or unknown id is an error and changes nothing; returns {tutorial, index, title} of the new document", ), + ( + "learn.markStep", + "Mark Tutorial Step", + "", + "{tutorial: id (see learn.list), step: zero-based step number, complete?: bool} mark a step of a tutorial whose sample learn.openSample opened as done (true, omitted or null) or not done (false), as the check box before the step does; marking does not finish the tutorial; a missing, non-string or unknown id, a missing step or one the tutorial does not have, a complete that is not true or false, a tutorial whose sample was not opened, or a finished tutorial is an error and changes nothing; the preferences keep the marks; returns {tutorial, step, complete}", + ), ( "learn.finish", "Finish Tutorial", "", - "{tutorial: id (see learn.list)} mark a tutorial whose sample learn.openSample opened as finished, as its Finish tutorial button does; finishing it again keeps one entry; a missing, non-string or unknown id, or a tutorial whose sample was not opened, is an error and changes nothing; returns {tutorial, finished: true, next: id of the next tutorial in its skill, or null after the skill's last one}", + "{tutorial: id (see learn.list)} mark a tutorial whose sample learn.openSample opened as finished, with all its steps done, as its Finish tutorial button does; finishing it again keeps one entry, and needs no sample after a restart; a missing, non-string or unknown id, or a tutorial not finished whose sample was not opened, is an error and changes nothing; the preferences keep the tutorials finished; returns {tutorial, finished: true, next: id of the next tutorial in its skill, or null after the skill's last one}", ), ( "learn.next", @@ -704,6 +710,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{tutorial: id (see learn.list)} show the Learn panel on the tutorial after a finished one in the same skill, as its Next Up button does, without opening a sample; a missing, non-string or unknown id, a tutorial not finished, or a skill's last tutorial is an error and changes nothing; returns {skill, tutorial, title} of the next tutorial", ), + ( + "learn.resetProgress", + "Reset Learn Progress", + "", + "{} clear the Learn panel's progress, every tutorial finished and every step marked done, as Reset progress under the list of skills does; open documents, opened practice samples and the Learn view stay as they are; returns what learn.list returns", + ), ("window.brightness", "UI Brightness", "", "{brightness: dark|mediumDark|mediumLight|light}"), ( "window.workspace", diff --git a/crates/ui-egui/src/i18n/bg.tsv b/crates/ui-egui/src/i18n/bg.tsv index 899f177897..86417ebae8 100644 --- a/crates/ui-egui/src/i18n/bg.tsv +++ b/crates/ui-egui/src/i18n/bg.tsv @@ -6858,6 +6858,12 @@ breakText Glyphs Глифи @msg open the practice sample of `{id}` first (see learn.openSample) първо отворете примерния файл за упражнение на `{id}` (вижте learn.openSample) @msg finish `{id}` first (see learn.finish) първо завършете `{id}` (вижте learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` е последният урок в своето умение + Reset progress Нулиране на напредъка + Mark Tutorial Step Отбелязване на стъпка от урока + Reset Learn Progress Нулиране на напредъка в обучението +@msg missing `step` (see learn.show) липсва `step` (вижте learn.show) +@msg `step` must be a step number from 0 to {last} `step` трябва да е номер на стъпка от 0 до {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` е завършен (вижте learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Обновяване на отложените ефекти diff --git a/crates/ui-egui/src/i18n/bs.tsv b/crates/ui-egui/src/i18n/bs.tsv index 3667c25b1c..182484b918 100644 --- a/crates/ui-egui/src/i18n/bs.tsv +++ b/crates/ui-egui/src/i18n/bs.tsv @@ -6911,6 +6911,12 @@ shape Open Otvoren @msg open the practice sample of `{id}` first (see learn.openSample) prvo otvorite uzorak za vježbu tutorijala `{id}` (vidi learn.openSample) @msg finish `{id}` first (see learn.finish) prvo završite `{id}` (vidi learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` je posljednji tutorijal u svojoj vještini + Reset progress Vrati napredak na početno + Mark Tutorial Step Označi korak tutorijala + Reset Learn Progress Vrati napredak učenja na početno +@msg missing `step` (see learn.show) nedostaje `step` (vidi learn.show) +@msg `step` must be a step number from 0 to {last} `step` mora biti broj koraka od 0 do {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` je završen (vidi learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Osvježi odgođene efekte diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 24db0fa430..74a547f25c 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -7443,6 +7443,12 @@ breakText Glyphs Glifs @msg open the practice sample of `{id}` first (see learn.openSample) obriu primer la mostra de pràctica de `{id}` (vegeu learn.openSample) @msg finish `{id}` first (see learn.finish) acabeu primer `{id}` (vegeu learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` és l’últim tutorial de la seva habilitat + Reset progress Restableix el progrés + Mark Tutorial Step Marca el pas del tutorial + Reset Learn Progress Restableix el progrés d’aprenentatge +@msg missing `step` (see learn.show) falta `step` (vegeu learn.show) +@msg `step` must be a step number from 0 to {last} `step` ha de ser un número de pas de 0 a {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` està acabat (vegeu learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Actualitza els efectes ajornats diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index dc435f1d7e..803c13530f 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -7462,6 +7462,12 @@ breakText Glyphs Glyfy @msg open the practice sample of `{id}` first (see learn.openSample) nejprve otevřete cvičnou ukázku kurzu `{id}` (viz learn.openSample) @msg finish `{id}` first (see learn.finish) nejprve dokončete `{id}` (viz learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` je poslední výukový kurz své dovednosti + Reset progress Obnovit postup + Mark Tutorial Step Označit krok výukového kurzu + Reset Learn Progress Obnovit postup učení +@msg missing `step` (see learn.show) chybí `step` (viz learn.show) +@msg `step` must be a step number from 0 to {last} `step` musí být číslo kroku od 0 do {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` je dokončen (viz learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Obnovit odložené efekty diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index fa9365b849..c6eeb8acdd 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -6873,6 +6873,12 @@ breakText Glyphs Glyffer @msg open the practice sample of `{id}` first (see learn.openSample) åbn først øvelseseksemplet til `{id}` (se learn.openSample) @msg finish `{id}` first (see learn.finish) afslut først `{id}` (se learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` er den sidste vejledning i sin færdighed + Reset progress Nulstil fremskridt + Mark Tutorial Step Markér trin i vejledning + Reset Learn Progress Nulstil læringsfremskridt +@msg missing `step` (see learn.show) `step` mangler (se learn.show) +@msg `step` must be a step number from 0 to {last} `step` skal være et trinnummer fra 0 til {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` er afsluttet (se learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Opdatér udskudte effekter diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 5016bbd953..ada29f122e 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -7058,6 +7058,12 @@ breakText Glyphs Glyphen @msg open the practice sample of `{id}` first (see learn.openSample) öffnen Sie zuerst die Übungsdatei von `{id}` (siehe learn.openSample) @msg finish `{id}` first (see learn.finish) schließen Sie zuerst `{id}` ab (siehe learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` ist das letzte Lernprogramm seiner Fertigkeit + Reset progress Fortschritt zurücksetzen + Mark Tutorial Step Schritt des Lernprogramms markieren + Reset Learn Progress Lernfortschritt zurücksetzen +@msg missing `step` (see learn.show) `step` fehlt (siehe learn.show) +@msg `step` must be a step number from 0 to {last} `step` muss eine Schrittnummer von 0 bis {last} sein +@msg `{id}` is finished (see learn.resetProgress) `{id}` ist abgeschlossen (siehe learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Zurückgestellte Effekte aktualisieren diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index d316f7d704..fb1acc726c 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -7415,6 +7415,12 @@ breakText Glyphs Γλύφοι @msg open the practice sample of `{id}` first (see learn.openSample) ανοίξτε πρώτα το δείγμα εξάσκησης του `{id}` (δείτε learn.openSample) @msg finish `{id}` first (see learn.finish) ολοκληρώστε πρώτα το `{id}` (δείτε learn.finish) @msg `{id}` is the last tutorial in its skill το `{id}` είναι ο τελευταίος οδηγός εκμάθησης της δεξιότητάς του + Reset progress Επαναφορά προόδου + Mark Tutorial Step Σήμανση βήματος οδηγού εκμάθησης + Reset Learn Progress Επαναφορά προόδου εκμάθησης +@msg missing `step` (see learn.show) λείπει το `step` (δείτε learn.show) +@msg `step` must be a step number from 0 to {last} το `step` πρέπει να είναι αριθμός βήματος από 0 έως {last} +@msg `{id}` is finished (see learn.resetProgress) το `{id}` έχει ολοκληρωθεί (δείτε learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Ανανέωση εφέ σε αναμονή diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index 4cfeea4854..285c875e57 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -7406,6 +7406,12 @@ breakText Glyphs Glifos @msg open the practice sample of `{id}` first (see learn.openSample) abre primero la muestra de práctica de `{id}` (consulta learn.openSample) @msg finish `{id}` first (see learn.finish) termina primero `{id}` (consulta learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` es el último tutorial de su habilidad + Reset progress Restablecer progreso + Mark Tutorial Step Marcar paso del tutorial + Reset Learn Progress Restablecer progreso de aprendizaje +@msg missing `step` (see learn.show) falta `step` (consulta learn.show) +@msg `step` must be a step number from 0 to {last} `step` debe ser un número de paso de 0 a {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` está terminado (consulta learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Actualizar efectos aplazados diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index a1ddf6101f..64bf27101c 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -7497,6 +7497,12 @@ breakText Glyphs Merkit @msg open the practice sample of `{id}` first (see learn.openSample) avaa ensin opetusohjelman `{id}` harjoitustiedosto (ks. learn.openSample) @msg finish `{id}` first (see learn.finish) viimeistele ensin `{id}` (ks. learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` on taitonsa viimeinen opetusohjelma + Reset progress Palauta edistyminen + Mark Tutorial Step Merkitse opetusohjelman vaihe + Reset Learn Progress Palauta oppimisen edistyminen +@msg missing `step` (see learn.show) `step` puuttuu (ks. learn.show) +@msg `step` must be a step number from 0 to {last} `step` on oltava vaiheen numero, vähintään 0 ja enintään {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` on viimeistelty (ks. learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Päivitä lykätyt tehosteet diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 706c83909e..1083a30317 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7457,6 +7457,12 @@ breakText Glyphs Glyphes @msg open the practice sample of `{id}` first (see learn.openSample) ouvrez d’abord le fichier d’exercice de `{id}` (voir learn.openSample) @msg finish `{id}` first (see learn.finish) terminez d’abord `{id}` (voir learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` est le dernier tutoriel de sa compétence + Reset progress Réinitialiser la progression + Mark Tutorial Step Marquer une étape du tutoriel + Reset Learn Progress Réinitialiser la progression d’apprentissage +@msg missing `step` (see learn.show) `step` manquant (voir learn.show) +@msg `step` must be a step number from 0 to {last} `step` doit être un numéro d’étape de 0 à {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` est terminé (voir learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Actualiser les effets différés diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index dc28724be2..7635b07ff5 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -8853,6 +8853,12 @@ theme Appearance अपीयरेंस @msg open the practice sample of `{id}` first (see learn.openSample) पहले `{id}` का अभ्यास नमूना खोलें (learn.openSample देखें) @msg finish `{id}` first (see learn.finish) पहले `{id}` पूरा करें (learn.finish देखें) @msg `{id}` is the last tutorial in its skill `{id}` अपने कौशल का अंतिम ट्यूटोरियल है + Reset progress प्रगति रीसेट करें + Mark Tutorial Step ट्यूटोरियल चरण चिह्नित करें + Reset Learn Progress सीखने की प्रगति रीसेट करें +@msg missing `step` (see learn.show) लापता `step` (learn.show देखें) +@msg `step` must be a step number from 0 to {last} `step` 0 से {last} तक की चरण संख्या होनी चाहिए +@msg `{id}` is finished (see learn.resetProgress) `{id}` पूरा हो चुका है (learn.resetProgress देखें) # Deferred plug-in effects Refresh Deferred Effects स्थगित इफ़ेक्ट्स रिफ्रेश करें diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index ab06863782..a0e672a705 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -7446,6 +7446,12 @@ breakText Glyphs Glifák @msg open the practice sample of `{id}` first (see learn.openSample) előbb nyissa meg a gyakorló mintafájlt ehhez: `{id}` (lásd: learn.openSample) @msg finish `{id}` first (see learn.finish) előbb fejezze be ezt: `{id}` (lásd: learn.finish) @msg `{id}` is the last tutorial in its skill a készsége utolsó oktatóanyaga: `{id}` + Reset progress Előrehaladás visszaállítása + Mark Tutorial Step Oktatóanyag lépésének megjelölése + Reset Learn Progress Tanulási előrehaladás visszaállítása +@msg missing `step` (see learn.show) hiányzik: `step` (lásd: learn.show) +@msg `step` must be a step number from 0 to {last} a `step` értéke 0 és {last} közötti lépésszám legyen +@msg `{id}` is finished (see learn.resetProgress) befejezve: `{id}` (lásd: learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Elhalasztott effektusok frissítése diff --git a/crates/ui-egui/src/i18n/id.tsv b/crates/ui-egui/src/i18n/id.tsv index 4900aa3cbf..1136a7459f 100644 --- a/crates/ui-egui/src/i18n/id.tsv +++ b/crates/ui-egui/src/i18n/id.tsv @@ -6873,6 +6873,12 @@ breakText Glyphs Glif @msg open the practice sample of `{id}` first (see learn.openSample) buka contoh latihan `{id}` terlebih dahulu (lihat learn.openSample) @msg finish `{id}` first (see learn.finish) selesaikan `{id}` terlebih dahulu (lihat learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` adalah tutorial terakhir dalam keterampilannya + Reset progress Atur ulang kemajuan + Mark Tutorial Step Tandai langkah tutorial + Reset Learn Progress Atur ulang kemajuan belajar +@msg missing `step` (see learn.show) `step` tidak ada (lihat learn.show) +@msg `step` must be a step number from 0 to {last} `step` harus berupa nomor langkah dari 0 sampai {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` sudah selesai (lihat learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Segarkan efek yang ditunda diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 5ef768e629..4cae508e8a 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -7092,6 +7092,12 @@ breakText Glyphs Glifi @msg open the practice sample of `{id}` first (see learn.openSample) apri prima l’esempio di esercitazione di `{id}` (vedi learn.openSample) @msg finish `{id}` first (see learn.finish) termina prima `{id}` (vedi learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` è l’ultimo tutorial della sua competenza + Reset progress Reimposta i progressi + Mark Tutorial Step Segna il passaggio del tutorial + Reset Learn Progress Reimposta i progressi di apprendimento +@msg missing `step` (see learn.show) manca `step` (vedi learn.show) +@msg `step` must be a step number from 0 to {last} `step` deve essere un numero di passaggio da 0 a {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` è terminato (vedi learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Aggiorna effetti rimandati diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index f2a1ffc1e1..51233fbb7e 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -7158,6 +7158,12 @@ breakText Glyphs 字形 @msg open the practice sample of `{id}` first (see learn.openSample) 先に `{id}` の練習用サンプルを開いてください (learn.openSample を参照) @msg finish `{id}` first (see learn.finish) 先に `{id}` を完了してください (learn.finish を参照) @msg `{id}` is the last tutorial in its skill `{id}` はこのスキルの最後のチュートリアルです + Reset progress 進行状況をリセット + Mark Tutorial Step チュートリアルの手順をマーク + Reset Learn Progress 学習の進行状況をリセット +@msg missing `step` (see learn.show) `step` が指定されていません (learn.show を参照) +@msg `step` must be a step number from 0 to {last} `step` は 0 から {last} までの手順番号にしてください +@msg `{id}` is finished (see learn.resetProgress) `{id}` は完了しています (learn.resetProgress を参照) # Deferred plug-in effects Refresh Deferred Effects 保留中の効果を更新 diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 0a0f488707..29abf68529 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -7576,6 +7576,12 @@ font-script Japanese იაპონური @msg open the practice sample of `{id}` first (see learn.openSample) ჯერ გახსენით `{id}` გაკვეთილის სავარჯიშო ნიმუში (იხ. learn.openSample) @msg finish `{id}` first (see learn.finish) ჯერ დაასრულეთ `{id}` (იხ. learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` თავისი უნარის ბოლო გაკვეთილია + Reset progress პროგრესის ჩამოყრა + Mark Tutorial Step გაკვეთილის ნაბიჯის მონიშვნა + Reset Learn Progress სწავლის პროგრესის ჩამოყრა +@msg missing `step` (see learn.show) აკლია `step` (იხ. learn.show) +@msg `step` must be a step number from 0 to {last} `step` უნდა იყოს ნაბიჯის ნომერი 0-დან {last}-მდე +@msg `{id}` is finished (see learn.resetProgress) `{id}` დასრულებულია (იხ. learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects გადადებული ეფექტების განახლება diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 5344b0124b..fed356f036 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -7053,6 +7053,12 @@ breakText Glyphs 글리프 @msg open the practice sample of `{id}` first (see learn.openSample) 먼저 `{id}`의 연습용 샘플을 여세요(learn.openSample 참조) @msg finish `{id}` first (see learn.finish) 먼저 `{id}`을(를) 완료하세요(learn.finish 참조) @msg `{id}` is the last tutorial in its skill `{id}`은(는) 해당 기술의 마지막 튜토리얼입니다 + Reset progress 진행률 재설정 + Mark Tutorial Step 튜토리얼 단계 표시 + Reset Learn Progress 학습 진행률 재설정 +@msg missing `step` (see learn.show) `step`이 없습니다(learn.show 참조) +@msg `step` must be a step number from 0 to {last} `step`은 0에서 {last} 사이의 단계 번호여야 합니다 +@msg `{id}` is finished (see learn.resetProgress) `{id}`은(는) 완료되었습니다(learn.resetProgress 참조) # Deferred plug-in effects Refresh Deferred Effects 보류된 효과 새로 고침 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 7ce152334e..c69cdf48f6 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -7495,6 +7495,12 @@ breakText Glyphs Glyphs @msg open the practice sample of `{id}` first (see learn.openSample) open eerst het oefenbestand van `{id}` (zie learn.openSample) @msg finish `{id}` first (see learn.finish) voltooi eerst `{id}` (zie learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` is de laatste tutorial van zijn vaardigheid + Reset progress Voortgang opnieuw instellen + Mark Tutorial Step Stap van tutorial markeren + Reset Learn Progress Leervoortgang opnieuw instellen +@msg missing `step` (see learn.show) `step` ontbreekt (zie learn.show) +@msg `step` must be a step number from 0 to {last} `step` moet een stapnummer van 0 tot en met {last} zijn +@msg `{id}` is finished (see learn.resetProgress) `{id}` is voltooid (zie learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Uitgestelde effecten vernieuwen diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index ab70dfa4db..2e7981d7b5 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -7319,6 +7319,12 @@ breakText Glyphs Glify @msg open the practice sample of `{id}` first (see learn.openSample) najpierw otwórz przykład do ćwiczeń samouczka `{id}` (patrz learn.openSample) @msg finish `{id}` first (see learn.finish) najpierw zakończ `{id}` (patrz learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` to ostatni samouczek swojej umiejętności + Reset progress Resetuj postępy + Mark Tutorial Step Oznacz krok samouczka + Reset Learn Progress Resetuj postępy nauki +@msg missing `step` (see learn.show) brak `step` (patrz learn.show) +@msg `step` must be a step number from 0 to {last} `step` musi być numerem kroku od 0 do {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` jest zakończony (patrz learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Odśwież odroczone efekty diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index 67bd16ba24..7d9f428a42 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -7535,6 +7535,12 @@ swatch Yellow Green Verde-amarelado @msg open the practice sample of `{id}` first (see learn.openSample) abra primeiro a amostra de prática de `{id}` (veja learn.openSample) @msg finish `{id}` first (see learn.finish) conclua primeiro `{id}` (veja learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` é o último tutorial da sua habilidade + Reset progress Redefinir progresso + Mark Tutorial Step Marcar Etapa do Tutorial + Reset Learn Progress Redefinir Progresso de Aprendizagem +@msg missing `step` (see learn.show) falta `step` (veja learn.show) +@msg `step` must be a step number from 0 to {last} `step` deve ser um número de etapa de 0 a {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` está concluído (veja learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Atualizar Efeitos Adiados diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 2302b75e01..0458b563a9 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -7551,6 +7551,12 @@ shape Open Открытый @msg open the practice sample of `{id}` first (see learn.openSample) сначала откройте учебный пример урока `{id}` (см. learn.openSample) @msg finish `{id}` first (see learn.finish) сначала завершите `{id}` (см. learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` является последним уроком своего навыка + Reset progress Сбросить прогресс + Mark Tutorial Step Отметить шаг урока + Reset Learn Progress Сбросить прогресс обучения +@msg missing `step` (see learn.show) отсутствует `step` (см. learn.show) +@msg `step` must be a step number from 0 to {last} `step` должен быть номером шага от 0 до {last} +@msg `{id}` is finished (see learn.resetProgress) урок `{id}` завершён (см. learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Обновить отложенные эффекты diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index ef2265d001..fa09da320c 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -8900,6 +8900,12 @@ digits Hindi Hindi @msg open the practice sample of `{id}` first (see learn.openSample) öppna först övningsexemplet för `{id}` (se learn.openSample) @msg finish `{id}` first (see learn.finish) slutför först `{id}` (se learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` är den sista självstudien i sin färdighet + Reset progress Återställ framsteg + Mark Tutorial Step Markera steg i självstudie + Reset Learn Progress Återställ inlärningsframsteg +@msg missing `step` (see learn.show) `step` saknas (se learn.show) +@msg `step` must be a step number from 0 to {last} `step` måste vara ett stegnummer från 0 till {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` är slutförd (se learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Uppdatera uppskjutna effekter diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index d22c3b961f..5abbb2584d 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -7418,6 +7418,12 @@ breakText Glyphs Glifler @msg open the practice sample of `{id}` first (see learn.openSample) önce `{id}` öğreticisinin alıştırma örneğini açın (bkz. learn.openSample) @msg finish `{id}` first (see learn.finish) önce `{id}` öğreticisini bitirin (bkz. learn.finish) @msg `{id}` is the last tutorial in its skill `{id}`, becerisinin son öğreticisidir + Reset progress İlerlemeyi sıfırla + Mark Tutorial Step Öğretici Adımını İşaretle + Reset Learn Progress Öğrenme İlerlemesini Sıfırla +@msg missing `step` (see learn.show) `step` eksik (bkz. learn.show) +@msg `step` must be a step number from 0 to {last} `step`, 0 ile {last} arasında bir adım numarası olmalıdır +@msg `{id}` is finished (see learn.resetProgress) `{id}` bitirildi (bkz. learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Ertelenen Efektleri Yenile diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 8df23cab71..333331cb40 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -7072,6 +7072,12 @@ breakText Glyphs Гліфи @msg open the practice sample of `{id}` first (see learn.openSample) спочатку відкрийте навчальний приклад уроку `{id}` (див. learn.openSample) @msg finish `{id}` first (see learn.finish) спочатку завершіть `{id}` (див. learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` є останнім уроком своєї навички + Reset progress Скинути прогрес + Mark Tutorial Step Позначити крок уроку + Reset Learn Progress Скинути прогрес навчання +@msg missing `step` (see learn.show) відсутній `step` (див. learn.show) +@msg `step` must be a step number from 0 to {last} `step` має бути номером кроку від 0 до {last} +@msg `{id}` is finished (see learn.resetProgress) урок `{id}` завершено (див. learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Оновити відкладені ефекти diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 0ac99661db..28e14811a0 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -7073,6 +7073,12 @@ breakText Glyphs Glyph @msg open the practice sample of `{id}` first (see learn.openSample) hãy mở tệp mẫu thực hành của `{id}` trước (xem learn.openSample) @msg finish `{id}` first (see learn.finish) hãy hoàn tất `{id}` trước (xem learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` là hướng dẫn cuối cùng trong kỹ năng của nó + Reset progress Đặt lại tiến độ + Mark Tutorial Step Đánh dấu bước hướng dẫn + Reset Learn Progress Đặt lại tiến độ học +@msg missing `step` (see learn.show) thiếu `step` (xem learn.show) +@msg `step` must be a step number from 0 to {last} `step` phải là số bước từ 0 đến {last} +@msg `{id}` is finished (see learn.resetProgress) `{id}` đã hoàn tất (xem learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects Làm mới hiệu ứng bị hoãn diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 3658ca1241..86b14c02a2 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -7301,6 +7301,12 @@ breakText Glyphs 字形 @msg open the practice sample of `{id}` first (see learn.openSample) 请先打开 `{id}` 的练习示例 (请参阅 learn.openSample) @msg finish `{id}` first (see learn.finish) 请先完成 `{id}` (请参阅 learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` 是其技能的最后一个教程 + Reset progress 重置进度 + Mark Tutorial Step 标记教程步骤 + Reset Learn Progress 重置学习进度 +@msg missing `step` (see learn.show) 缺少 `step` (请参阅 learn.show) +@msg `step` must be a step number from 0 to {last} `step` 必须是 0 到 {last} 之间的步骤编号 +@msg `{id}` is finished (see learn.resetProgress) `{id}` 已完成 (请参阅 learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects 刷新延迟的效果 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 9306fdaf21..dbf26dafb7 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -7108,6 +7108,12 @@ breakText Glyphs 字符 @msg open the practice sample of `{id}` first (see learn.openSample) 請先開啟 `{id}` 的練習範例 (請參閱 learn.openSample) @msg finish `{id}` first (see learn.finish) 請先完成 `{id}` (請參閱 learn.finish) @msg `{id}` is the last tutorial in its skill `{id}` 是其技能的最後一個教學課程 + Reset progress 重設進度 + Mark Tutorial Step 標記教學課程步驟 + Reset Learn Progress 重設學習進度 +@msg missing `step` (see learn.show) 未提供 `step` (請參閱 learn.show) +@msg `step` must be a step number from 0 to {last} `step` 必須是 0 到 {last} 之間的步驟編號 +@msg `{id}` is finished (see learn.resetProgress) `{id}` 已完成 (請參閱 learn.resetProgress) # Deferred plug-in effects Refresh Deferred Effects 重新整理延後的效果 diff --git a/crates/ui-egui/src/menus/ui_commands.rs b/crates/ui-egui/src/menus/ui_commands.rs index 093a395841..59279e31e0 100644 --- a/crates/ui-egui/src/menus/ui_commands.rs +++ b/crates/ui-egui/src/menus/ui_commands.rs @@ -667,7 +667,7 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "learn.list", "List Tutorials", "", - "{} the Learn panel's skills in the order its Skills tab lists them: {skills: [{id, title, tutorials: [{id, title, steps: number of steps}]}]}", + "{} the Learn panel's skills in the order its Skills tab lists them, with the progress its rings, counts and check marks show: {skills: [{id, title, done: number of its tutorials finished, total: number of its tutorials, tutorials: [{id, title, steps: number of steps, finished: bool, completedSteps: [zero-based indexes of the steps marked done, every step once finished]}]}]}", ), ( "learn.skills", @@ -693,11 +693,17 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{tutorial: id (see learn.list)} open that tutorial's practice sample as a new untitled document, which becomes the active one, and move the Learn view to the tutorial, as its View more button does; each call opens another copy and open documents stay as they are; a missing, non-string or unknown id is an error and changes nothing; returns {tutorial, index, title} of the new document", ), + ( + "learn.markStep", + "Mark Tutorial Step", + "", + "{tutorial: id (see learn.list), step: zero-based step number, complete?: bool} mark a step of a tutorial whose sample learn.openSample opened as done (true, omitted or null) or not done (false), as the check box before the step does; marking does not finish the tutorial; a missing, non-string or unknown id, a missing step or one the tutorial does not have, a complete that is not true or false, a tutorial whose sample was not opened, or a finished tutorial is an error and changes nothing; the preferences keep the marks; returns {tutorial, step, complete}", + ), ( "learn.finish", "Finish Tutorial", "", - "{tutorial: id (see learn.list)} mark a tutorial whose sample learn.openSample opened as finished, as its Finish tutorial button does; finishing it again keeps one entry; a missing, non-string or unknown id, or a tutorial whose sample was not opened, is an error and changes nothing; returns {tutorial, finished: true, next: id of the next tutorial in its skill, or null after the skill's last one}", + "{tutorial: id (see learn.list)} mark a tutorial whose sample learn.openSample opened as finished, with all its steps done, as its Finish tutorial button does; finishing it again keeps one entry, and needs no sample after a restart; a missing, non-string or unknown id, or a tutorial not finished whose sample was not opened, is an error and changes nothing; the preferences keep the tutorials finished; returns {tutorial, finished: true, next: id of the next tutorial in its skill, or null after the skill's last one}", ), ( "learn.next", @@ -705,6 +711,12 @@ pub const UI_COMMANDS: &[(&str, &str, &str, &str)] = &[ "", "{tutorial: id (see learn.list)} show the Learn panel on the tutorial after a finished one in the same skill, as its Next Up button does, without opening a sample; a missing, non-string or unknown id, a tutorial not finished, or a skill's last tutorial is an error and changes nothing; returns {skill, tutorial, title} of the next tutorial", ), + ( + "learn.resetProgress", + "Reset Learn Progress", + "", + "{} clear the Learn panel's progress, every tutorial finished and every step marked done, as Reset progress under the list of skills does; open documents, opened practice samples and the Learn view stay as they are; returns what learn.list returns", + ), ("window.brightness", "UI Brightness", "", "{brightness: dark|mediumDark|mediumLight|light}"), ( "window.workspace", diff --git a/crates/ui-egui/src/panels/learn.rs b/crates/ui-egui/src/panels/learn.rs index ee7967c8a3..6bd927ed70 100644 --- a/crates/ui-egui/src/panels/learn.rs +++ b/crates/ui-egui/src/panels/learn.rs @@ -1,17 +1,21 @@ //! Learn panel (Window › Learn, and Explore tutorials at the right end of the app bar): short //! hands-on tutorials grouped by skill ([`catalog::SKILLS`]). The For you tab holds the Get started //! section with the Quick skill guide card, which opens the Skills tab. The Skills tab lists each -//! skill with an empty progress ring and its count of tutorials; a skill lists its tutorials, and a +//! skill with a progress ring that fills as its tutorials are finished and the count of tutorials +//! finished of all; a skill lists its tutorials, each finished one with a check mark, and a //! tutorial previews its numbered steps. A tool's name in a step is a link that shows where the tool //! is ([`locate`]). Back goes up one level. Under the steps, View more opens the tutorial's practice -//! sample as a new untitled document; Finish tutorial then marks it finished, and Next Up shows the -//! next tutorial in the same skill. `learn.list` lists the tutorials, `learn.skills` shows the list -//! of skills, `learn.show` opens one tutorial, `learn.locateTool` shows where a tool is, -//! `learn.openSample`, `learn.finish` and `learn.next` run the three practice controls, and -//! `window.learn` shows or hides the panel. +//! sample as a new untitled document; the check box before each step then marks it done, Finish +//! tutorial marks the tutorial finished with all its steps, and Next Up shows the next tutorial in +//! the same skill. The preferences keep the progress ([`progress`]); Reset progress under the +//! skills clears it. `learn.list` lists the tutorials with their progress, `learn.skills` shows the +//! list of skills, `learn.show` opens one tutorial, `learn.locateTool` shows where a tool is, +//! `learn.openSample`, `learn.markStep`, `learn.finish` and `learn.next` run the practice controls, +//! `learn.resetProgress` clears the progress, and `window.learn` shows or hides the panel. pub mod catalog; pub mod locate; +pub mod progress; pub mod samples; use egui::{Sense, Stroke, Ui, vec2}; @@ -40,12 +44,10 @@ pub struct View { pub tutorial: Option<&'static str>, } -/// The tutorials whose samples View more opened, and the tutorials finished, in the order they -/// were finished. Each id is listed once. +/// The tutorials whose samples View more opened while the app runs. Each id is listed once. #[derive(Clone, Debug, Default, PartialEq, Eq)] pub struct Practice { pub opened: Vec<&'static str>, - pub finished: Vec<&'static str>, } pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { @@ -113,17 +115,26 @@ fn skills(app: &mut VectorcraftApp, ui: &mut Ui) { } crate::widgets::subheader(ui, skill.title); for tutorial in skill.tutorials { - if row(ui, tutorial.title, None).clicked() { + if row(ui, tutorial.title, Mark::Check(app.ui.learn_progress.is_finished(tutorial.id))).clicked() { app.ui.learn.tutorial = Some(tutorial.id); } } return; } for skill in catalog::SKILLS { - if row(ui, skill.title, Some(skill.tutorials.len())).clicked() { + let ring = Mark::Ring { done: app.ui.learn_progress.done(skill), total: skill.tutorials.len() }; + if row(ui, skill.title, ring).clicked() { app.ui.learn.skill = Some(skill.id); } } + if !app.ui.learn_progress.is_empty() { + ui.add_space(6.0); + if ui.button(tl!("Reset progress")).clicked() + && let Err(e) = app.run("learn.resetProgress", json!({})) + { + app.status(e); + } + } } /// The Back button above a skill's tutorials and a tutorial's steps; true when it was clicked. @@ -131,15 +142,26 @@ fn back(ui: &mut Ui) -> bool { crate::widgets::icon_button(ui, "chevron-left", tl!("Back"), false, 22.0).clicked() } -/// A tutorial's title and its numbered steps. The tool's name in a step is a blue link: a click, or -/// Enter or Space while it has the keyboard focus, shows where the tool is (`learn.locateTool`). -fn steps(app: &mut VectorcraftApp, ui: &mut Ui, tutorial: &catalog::Tutorial) { +/// A tutorial's title and its numbered steps, each with a check box that shows whether it is done. +/// The check boxes can be changed once the tutorial's sample is open and until it is finished +/// (`learn.markStep`). The tool's name in a step is a blue link: a click, or Enter or Space while it +/// has the keyboard focus, shows where the tool is (`learn.locateTool`). +fn steps(app: &mut VectorcraftApp, ui: &mut Ui, tutorial: &'static catalog::Tutorial) { let t = Tokens::get(ui.ctx()); ui.label(egui::RichText::new(tutorial.title).size(13.0).color(t.text_strong)); ui.add_space(4.0); + let markable = app.ui.learn_practice.opened.contains(&tutorial.id) && !app.ui.learn_progress.is_finished(tutorial.id); let mut locate = None; + let mut marked = None; for (i, step) in tutorial.steps.iter().enumerate() { + let mut done = app.ui.learn_progress.step_done(tutorial, i); ui.horizontal_top(|ui| { + let resp = ui.add_enabled(markable, egui::Checkbox::without_text(&mut done)); + let name = format!("{}. {}", i + 1, step.plain()); + resp.widget_info(|| egui::WidgetInfo::selected(egui::Role::CheckBox, markable, done, &name)); + if resp.changed() { + marked = Some((i, done)); + } ui.label(egui::RichText::new(format!("{}.", i + 1)).color(t.text_dim)); let (Some(tool), Some((before, name, after))) = (step.tool, step.tool_name()) else { ui.add(egui::Label::new(egui::RichText::new(step.text).color(t.text)).wrap()); @@ -160,6 +182,11 @@ fn steps(app: &mut VectorcraftApp, ui: &mut Ui, tutorial: &catalog::Tutorial) { }); ui.add_space(2.0); } + if let Some((step, complete)) = marked + && let Err(e) = app.run("learn.markStep", json!({ "tutorial": tutorial.id, "step": step, "complete": complete })) + { + app.status(e); + } if let Some(tool) = locate { if let Err(e) = app.run("learn.locateTool", json!({ "tool": tool })) { app.status(e); @@ -192,12 +219,11 @@ fn practice(app: &mut VectorcraftApp, ui: &mut Ui, tutorial: &'static catalog::T if ui.button(tl!("View more")).clicked() { run = Some(("learn.openSample", params.clone())); } - let done = &app.ui.learn_practice; - if done.opened.contains(&id) && !done.finished.contains(&id) && ui.button(tl!("Finish tutorial")).clicked() { + if app.ui.learn_practice.opened.contains(&id) && !app.ui.learn_progress.is_finished(id) && ui.button(tl!("Finish tutorial")).clicked() { run = Some(("learn.finish", params.clone())); } }); - if app.ui.learn_practice.finished.contains(&id) { + if app.ui.learn_progress.is_finished(id) { ui.add_space(6.0); match catalog::next(id) { Some(next) => { @@ -223,46 +249,112 @@ fn practice(app: &mut VectorcraftApp, ui: &mut Ui, tutorial: &'static catalog::T } } -/// A clickable row: `title`, and for a skill (`tutorials`) a progress ring before it and the -/// count of tutorials done of all after it. No progress is kept yet, so the ring is empty. -fn row(ui: &mut Ui, title: &str, tutorials: Option) -> egui::Response { +/// What a row shows before its title. +#[derive(Clone, Copy, Debug, PartialEq, Eq)] +enum Mark { + /// A skill: a progress ring that fills as its tutorials are finished, and after the title the + /// count of tutorials finished of all. + Ring { done: usize, total: usize }, + /// A tutorial: a check mark once it is finished (true). + Check(bool), +} + +/// The radius of a row's progress ring or check mark. +const MARK_RADIUS: f32 = 7.0; + +/// A clickable row: `title`, with `mark` before it. Screen readers get the count of a skill's +/// tutorials finished, or Finished for a finished tutorial, as the row's value. +fn row(ui: &mut Ui, title: &str, mark: Mark) -> egui::Response { let t = Tokens::get(ui.ctx()); let (rect, resp) = ui.allocate_exact_size(vec2(ui.available_width(), ROW_HEIGHT), Sense::click()); if resp.hovered() { ui.painter().rect_filled(rect, egui::CornerRadius::same(4), t.hover); } + let painter = ui.painter().with_clip_rect(rect); let mut left = rect.left() + 6.0; let mut right = rect.right() - 6.0; let chevron = egui::Rect::from_center_size(egui::pos2(right - 6.0, rect.center().y), vec2(12.0, 12.0)); crate::icons::paint(ui, "chevron-right", chevron, t.text_dim); right = chevron.left() - 6.0; - if let Some(total) = tutorials { - ui.painter().circle_stroke(egui::pos2(left + 8.0, rect.center().y), 7.0, Stroke::new(2.0, t.border)); - left += 24.0; - let count = ui.painter().layout_no_wrap(format!("0/{total}"), egui::FontId::proportional(11.5), t.text_dim); - right -= count.size().x; - ui.painter().galley(egui::pos2(right, rect.center().y - count.size().y / 2.0), count, t.text_dim); - right -= 6.0; - } - let name = ui.painter().layout(title.to_string(), egui::FontId::proportional(12.5), t.text, f32::INFINITY); + let at = egui::pos2(left + 8.0, rect.center().y); + left += 24.0; + let value = match mark { + Mark::Ring { done, total } => { + ring(&painter, &t, at, done, total); + let count = painter.layout_no_wrap(format!("{done}/{total}"), egui::FontId::proportional(11.5), t.text_dim); + right -= count.size().x; + painter.galley(egui::pos2(right, rect.center().y - count.size().y / 2.0), count, t.text_dim); + right -= 6.0; + Some(format!("{done}/{total}")) + } + Mark::Check(finished) => { + check(&painter, &t, at, finished); + finished.then(|| tl!("Finished").to_string()) + } + }; + let name = painter.layout(title.to_string(), egui::FontId::proportional(12.5), t.text, f32::INFINITY); let clip = egui::Rect::from_min_max(egui::pos2(left, rect.top()), egui::pos2(right.max(left), rect.bottom())); - ui.painter().with_clip_rect(clip).galley(egui::pos2(left, rect.center().y - name.size().y / 2.0), name, t.text); - resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), title)); + painter.with_clip_rect(clip).galley(egui::pos2(left, rect.center().y - name.size().y / 2.0), name, t.text); + resp.widget_info(|| egui::WidgetInfo { + current_text_value: value.clone(), + ..egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), title) + }); resp.on_hover_cursor(egui::CursorIcon::PointingHand) } +/// A skill's progress ring at `center`: an outline, with the share `done` of `total` drawn over it +/// clockwise from the top. With no tutorials it stays empty. +fn ring(painter: &egui::Painter, t: &Tokens, center: egui::Pos2, done: usize, total: usize) { + painter.circle_stroke(center, MARK_RADIUS, Stroke::new(2.0, t.border)); + if done == 0 || total == 0 { + return; + } + let stroke = Stroke::new(2.0, t.accent); + if done >= total { + painter.circle_stroke(center, MARK_RADIUS, stroke); + return; + } + let sweep = std::f32::consts::TAU * done as f32 / total as f32; + // About one segment per 1/32 of a turn, and never fewer than two. + let segments = ((32.0 * done as f32 / total as f32).ceil() as usize).max(2); + let points = (0..=segments) + .map(|k| { + let angle = -std::f32::consts::FRAC_PI_2 + sweep * k as f32 / segments as f32; + center + MARK_RADIUS * vec2(angle.cos(), angle.sin()) + }) + .collect(); + painter.add(egui::Shape::line(points, stroke)); +} + +/// A tutorial's mark at `center`: an outline, filled with a check mark once it is finished. +fn check(painter: &egui::Painter, t: &Tokens, center: egui::Pos2, finished: bool) { + if !finished { + painter.circle_stroke(center, MARK_RADIUS, Stroke::new(1.0, t.border)); + return; + } + painter.circle_filled(center, MARK_RADIUS, t.accent); + let tick = vec![center + vec2(-3.5, 0.0), center + vec2(-1.0, 2.5), center + vec2(3.5, -2.5)]; + painter.add(egui::Shape::line(tick, Stroke::new(1.5, t.panel))); +} + /// The Learn panel's UI commands: `window.learn`, `learn.list`, `learn.skills`, `learn.show`, -/// `learn.locateTool`, `learn.openSample`, `learn.finish` and `learn.next`. +/// `learn.locateTool`, `learn.openSample`, `learn.markStep`, `learn.finish`, `learn.next` and +/// `learn.resetProgress`. pub(crate) fn command(app: &mut VectorcraftApp, id: &str, p: &Value) -> Option> { Some(match id { "window.learn" => toggle(app, p), - "learn.list" => Ok(list()), + "learn.list" => Ok(list(&app.ui.learn_progress)), "learn.skills" => skills_list(app), "learn.show" => open(app, p), "learn.locateTool" => locate::locate_tool(app, p), "learn.openSample" => open_sample(app, p), + "learn.markStep" => mark_step(app, p), "learn.finish" => finish(app, p), "learn.next" => next(app, p), + "learn.resetProgress" => { + app.ui.learn_progress = progress::Progress::default(); + Ok(list(&app.ui.learn_progress)) + } _ => return None, }) } @@ -287,11 +379,25 @@ fn toggle(app: &mut VectorcraftApp, p: &Value) -> Result { Ok(json!(visible(&app.ui))) } -/// `learn.list`: every skill with its tutorials and their step counts. -fn list() -> Value { +/// `learn.list`: every skill with its count of tutorials finished (`done`) of all (`total`), and its +/// tutorials with their step counts, whether each is finished, and the zero-based indexes of its +/// steps marked done (`completedSteps`). +fn list(progress: &progress::Progress) -> Value { let skills = catalog::SKILLS.iter().map(|s| { - let tutorials: Vec = s.tutorials.iter().map(|t| json!({"id": t.id, "title": t.title, "steps": t.steps.len()})).collect(); - json!({"id": s.id, "title": s.title, "tutorials": tutorials}) + let tutorials: Vec = s + .tutorials + .iter() + .map(|t| { + json!({ + "id": t.id, + "title": t.title, + "steps": t.steps.len(), + "finished": progress.is_finished(t.id), + "completedSteps": progress.completed_steps(t), + }) + }) + .collect(); + json!({"id": s.id, "title": s.title, "done": progress.done(s), "total": s.tutorials.len(), "tutorials": tutorials}) }); json!({ "skills": skills.collect::>() }) } @@ -301,7 +407,7 @@ fn list() -> Value { fn skills_list(app: &mut VectorcraftApp) -> Result { crate::panel_docking::reveal_panel(app, ID)?; app.ui.learn = View { tab: Tab::Skills, skill: None, tutorial: None }; - Ok(list()) + Ok(list(&app.ui.learn_progress)) } /// `learn.show {tutorial}`: show the panel on the Skills tab with that tutorial's steps → the @@ -344,19 +450,42 @@ fn open_sample(app: &mut VectorcraftApp, p: &Value) -> Result { Ok(json!({"tutorial": id, "index": opened["index"], "title": opened["title"]})) } -/// `learn.finish {tutorial}`: Finish tutorial. Mark a tutorial whose sample was opened finished → -/// `{tutorial, finished: true, next}`, where `next` is the id of the next tutorial in its skill, or -/// null after the skill's last one. Finishing it again keeps one entry. The Learn view stays as it is. +/// `learn.markStep {tutorial, step, complete?}`: a step's check box. Mark step `step` (zero-based) +/// of a tutorial whose sample was opened done (`complete` true or omitted) or not done (false) → +/// `{tutorial, step, complete}`. A finished tutorial keeps every step done, so marking one of its +/// steps is an error; so are a step the tutorial does not have and a `complete` that is not true or +/// false. An error changes nothing. +fn mark_step(app: &mut VectorcraftApp, p: &Value) -> Result { + let (_, tutorial) = tutorial_param(p)?; + let id = tutorial.id; + let last = tutorial.steps.len().saturating_sub(1); + let step = match p.get("step") { + None | Some(Value::Null) => return Err("missing `step` (see learn.show)".into()), + Some(v) => v.as_u64().and_then(|s| usize::try_from(s).ok()).filter(|s| *s < tutorial.steps.len()), + }; + let step = step.ok_or_else(|| format!("`step` must be a step number from 0 to {last}"))?; + let complete = crate::menus::opt_bool(p, "complete")?.unwrap_or(true); + if !app.ui.learn_practice.opened.contains(&id) { + return Err(format!("open the practice sample of `{id}` first (see learn.openSample)")); + } + if app.ui.learn_progress.is_finished(id) { + return Err(format!("`{id}` is finished (see learn.resetProgress)")); + } + app.ui.learn_progress.mark(id, step, complete); + Ok(json!({"tutorial": id, "step": step, "complete": complete})) +} + +/// `learn.finish {tutorial}`: Finish tutorial. Mark a tutorial whose sample was opened finished, +/// with all its steps done → `{tutorial, finished: true, next}`, where `next` is the id of the next +/// tutorial in its skill, or null after the skill's last one. Finishing it again keeps one entry, +/// also after a restart, when its sample has not been opened again. The Learn view stays as it is. fn finish(app: &mut VectorcraftApp, p: &Value) -> Result { let (_, tutorial) = tutorial_param(p)?; let id = tutorial.id; - let practice = &mut app.ui.learn_practice; - if !practice.opened.contains(&id) { + if !app.ui.learn_practice.opened.contains(&id) && !app.ui.learn_progress.is_finished(id) { return Err(format!("open the practice sample of `{id}` first (see learn.openSample)")); } - if !practice.finished.contains(&id) { - practice.finished.push(id); - } + app.ui.learn_progress.finish(id); Ok(json!({"tutorial": id, "finished": true, "next": catalog::next(id).map(|t| t.id)})) } @@ -366,7 +495,7 @@ fn finish(app: &mut VectorcraftApp, p: &Value) -> Result { fn next(app: &mut VectorcraftApp, p: &Value) -> Result { let (skill, tutorial) = tutorial_param(p)?; let id = tutorial.id; - if !app.ui.learn_practice.finished.contains(&id) { + if !app.ui.learn_progress.is_finished(id) { return Err(format!("finish `{id}` first (see learn.finish)")); } let after = catalog::next(id).ok_or_else(|| format!("`{id}` is the last tutorial in its skill"))?; diff --git a/crates/ui-egui/src/panels/learn/progress.rs b/crates/ui-egui/src/panels/learn/progress.rs new file mode 100644 index 0000000000..a425b0e58f --- /dev/null +++ b/crates/ui-egui/src/panels/learn/progress.rs @@ -0,0 +1,122 @@ +//! What a learner has done in the Learn panel: the steps marked done in each tutorial and the +//! tutorials finished. The UI preferences keep it (`UiState::learn_progress`), so it lasts from +//! one start to the next where the preferences are saved. Saved progress is read leniently: an +//! unknown tutorial id, a step the tutorial does not have, a repeated entry or a value of the wrong +//! kind is skipped, and the rest of the preferences read as usual. + +use std::collections::BTreeMap; + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use serde_json::Value; + +use super::catalog; + +/// The most entries read from one saved list or map; the rest are skipped. +const MAX_READ: usize = 1024; + +/// The tutorials finished and the steps marked done. +#[derive(Clone, Debug, Default, PartialEq, Eq)] +pub struct Progress { + /// The tutorials finished, in the order they were finished. Each id is listed once. + pub finished: Vec<&'static str>, + /// For each tutorial not finished, the zero-based indexes of the steps marked done, ascending. + /// A tutorial with no step marked has no entry. + pub steps: BTreeMap<&'static str, Vec>, +} + +impl Progress { + /// Nothing is finished and no step is marked. + pub fn is_empty(&self) -> bool { + self.finished.is_empty() && self.steps.is_empty() + } + + /// Whether the tutorial `id` is finished. + pub fn is_finished(&self, id: &str) -> bool { + self.finished.contains(&id) + } + + /// The zero-based indexes of `tutorial`'s steps marked done, ascending: every step of a + /// finished tutorial. + pub fn completed_steps(&self, tutorial: &catalog::Tutorial) -> Vec { + if self.is_finished(tutorial.id) { + return (0..tutorial.steps.len()).collect(); + } + self.steps.get(tutorial.id).cloned().unwrap_or_default() + } + + /// Whether step `step` of `tutorial` is marked done. + pub fn step_done(&self, tutorial: &catalog::Tutorial, step: usize) -> bool { + self.is_finished(tutorial.id) || self.steps.get(tutorial.id).is_some_and(|s| s.contains(&step)) + } + + /// Mark step `step` of the unfinished tutorial `id` done (`complete`) or not done. + pub fn mark(&mut self, id: &'static str, step: usize, complete: bool) { + let marks = self.steps.entry(id).or_default(); + match (marks.binary_search(&step), complete) { + (Err(at), true) => marks.insert(at, step), + (Ok(at), false) => { + marks.remove(at); + } + _ => {} + } + if marks.is_empty() { + self.steps.remove(id); + } + } + + /// Mark the tutorial `id` finished, with all its steps done. Finishing it again keeps one entry. + pub fn finish(&mut self, id: &'static str) { + if !self.is_finished(id) { + self.finished.push(id); + } + self.steps.remove(id); + } + + /// How many of `skill`'s tutorials are finished. + pub fn done(&self, skill: &catalog::Skill) -> usize { + skill.tutorials.iter().filter(|t| self.is_finished(t.id)).count() + } + + /// Progress read from a saved value, keeping only what the catalog knows (see the module). + fn from_value(saved: &Value) -> Self { + let mut progress = Progress::default(); + let known = |id: &Value| id.as_str().and_then(catalog::tutorial).map(|(_, t)| t); + if let Some(finished) = saved.get("finished").and_then(Value::as_array) { + for tutorial in finished.iter().take(MAX_READ).filter_map(known) { + progress.finish(tutorial.id); + } + } + if let Some(steps) = saved.get("steps").and_then(Value::as_object) { + for (id, marks) in steps.iter().take(MAX_READ) { + let Some((_, tutorial)) = catalog::tutorial(id) else { continue }; + if progress.is_finished(tutorial.id) { + continue; + } + let indexes = marks.as_array().into_iter().flatten().take(MAX_READ).filter_map(Value::as_u64); + for step in indexes.filter_map(|s| usize::try_from(s).ok()).filter(|s| *s < tutorial.steps.len()) { + progress.mark(tutorial.id, step, true); + } + } + } + progress + } +} + +/// The saved form: `{finished: [id], steps: {id: [index]}}`. +#[derive(Serialize)] +struct Saved<'a> { + finished: &'a [&'static str], + steps: &'a BTreeMap<&'static str, Vec>, +} + +impl Serialize for Progress { + fn serialize(&self, serializer: S) -> Result { + Saved { finished: &self.finished, steps: &self.steps }.serialize(serializer) + } +} + +impl<'de> Deserialize<'de> for Progress { + fn deserialize>(deserializer: D) -> Result { + Ok(Progress::from_value(&Value::deserialize(deserializer)?)) + } +} diff --git a/crates/ui-egui/src/panels/learn/tests.rs b/crates/ui-egui/src/panels/learn/tests.rs index 4bd00648d1..ea65a64fe9 100644 --- a/crates/ui-egui/src/panels/learn/tests.rs +++ b/crates/ui-egui/src/panels/learn/tests.rs @@ -1,7 +1,7 @@ use std::collections::HashSet; -use egui::accesskit::Node; -use serde_json::json; +use egui::accesskit::{Node, Role, Toggled}; +use serde_json::{Value, json}; use vectorcraft_engine::Session; use super::{ID, Practice, Tab, View, catalog, samples, show}; @@ -225,7 +225,8 @@ fn learn_show_opens_a_tutorial_and_learn_list_lists_them() { assert_eq!(skills.len(), catalog::SKILLS.len()); let count: usize = skills.iter().map(|s| s["tutorials"].as_array().map_or(0, Vec::len)).sum(); assert_eq!(count, catalog::SKILLS.iter().map(|s| s.tutorials.len()).sum::()); - assert_eq!(skills[2]["tutorials"][1], json!({"id": "gradient", "title": "Add a gradient", "steps": 3})); + assert_eq!(skills[2]["tutorials"][1], json!({"id": "gradient", "title": "Add a gradient", "steps": 3, "finished": false, "completedSteps": []})); + assert_eq!((skills[2]["done"].clone(), skills[2]["total"].clone()), (json!(0), json!(3))); } /// Every tutorial has one sample of its own, in the catalog's order, each one small and read @@ -279,7 +280,8 @@ fn view_more_opens_the_tutorial_s_sample_as_a_new_untitled_document() { assert_eq!(docs[0].doc.node_count(), work, "the open document stays as it was"); assert!(docs[1].path.is_none() && docs[1].title().starts_with("Untitled-"), "{}", docs[1].title()); let pen = docs[1].doc.node_count(); - assert_eq!(app.ui.learn_practice, Practice { opened: vec!["pen-paths"], finished: vec![] }); + assert_eq!(app.ui.learn_practice, Practice { opened: vec!["pen-paths"] }); + assert!(app.ui.learn_progress.is_empty(), "opening a sample marks nothing"); let r = app.run("learn.openSample", json!({"tutorial": "gradient"})).unwrap(); assert_eq!(r["tutorial"], "gradient"); @@ -306,7 +308,7 @@ fn finishing_a_tutorial_offers_next_up_in_its_skill() { let text = painted_text(&mut app, show); assert!(text.contains("Finish tutorial") && !text.contains("Next Up"), "{text}"); click(&mut app, &ctx, "Finish tutorial", show); - assert_eq!(app.ui.learn_practice.finished, ["pen-paths"]); + assert_eq!(app.ui.learn_progress.finished, ["pen-paths"]); let text = painted_text(&mut app, show); assert!(text.contains("Next Up") && text.contains("Draw smooth curves") && !text.contains("Finish tutorial"), "{text}"); let docs = app.session.documents().len(); @@ -350,7 +352,7 @@ fn the_practice_controls_work_from_the_keyboard() { assert_eq!(app.ui.learn_practice.opened, ["pen-paths"]); tab_to(&mut app, &ctx, "Finish tutorial", show); key(&mut app, &ctx, egui::Key::Enter, show); - assert_eq!(app.ui.learn_practice.finished, ["pen-paths"]); + assert_eq!(app.ui.learn_progress.finished, ["pen-paths"]); tab_to(&mut app, &ctx, "Next Up", show); key(&mut app, &ctx, egui::Key::Enter, show); assert_eq!(app.ui.learn, View { tab: Tab::Skills, skill: Some("draw"), tutorial: Some("smooth-curves") }); @@ -408,13 +410,14 @@ fn learn_finish_and_learn_next_follow_the_practice() { assert_eq!(app.run("learn.finish", json!({"tutorial": "gradient"})).unwrap_err(), open); assert_eq!(app.run("learn.next", json!({"tutorial": "gradient"})).unwrap_err(), "finish `gradient` first (see learn.finish)"); assert_eq!(app.ui.learn_practice, Practice::default()); + assert!(app.ui.learn_progress.is_empty()); app.run("learn.openSample", json!({"tutorial": "gradient"})).unwrap(); assert_eq!(app.run("learn.next", json!({"tutorial": "gradient"})).unwrap_err(), "finish `gradient` first (see learn.finish)"); for _ in 0..2 { let r = app.run("learn.finish", json!({"tutorial": "gradient"})).unwrap(); assert_eq!(r, json!({"tutorial": "gradient", "finished": true, "next": "copy-colors"})); } - assert_eq!(app.ui.learn_practice.finished, ["gradient"], "finishing again keeps one entry"); + assert_eq!(app.ui.learn_progress.finished, ["gradient"], "finishing again keeps one entry"); let r = app.run("learn.next", json!({"tutorial": "gradient"})).unwrap(); assert_eq!(r, json!({"skill": "color", "tutorial": "copy-colors", "title": "Copy colors from other art"})); assert!(shown(&app)); @@ -471,6 +474,7 @@ fn the_practice_commands_reject_a_missing_or_unknown_tutorial() { assert_eq!(app.run(cmd, params).unwrap_err(), error, "{cmd}"); assert_eq!(app.ui.learn, View::default()); assert_eq!(app.ui.learn_practice, Practice::default()); + assert!(app.ui.learn_progress.is_empty()); assert_eq!(app.session.documents().len(), 1); assert!(!shown(&app)); } @@ -581,3 +585,274 @@ fn learn_locate_tool_is_unavailable_while_the_toolbars_are_hidden() { assert_eq!(reply["location"], "unavailable", "{reply}"); assert!(app.ui.learn_locate.is_none() && !app.ui.toolbar && app.ui.tab_hid.is_some(), "Tab's state stays"); } + +/// The screen-reader name of step `i` of the Pen tutorial's check box. +fn pen_step(i: usize) -> String { + let (_, tutorial) = catalog::tutorial("pen-paths").unwrap(); + format!("{}. {}", i + 1, tutorial.steps[i].plain()) +} + +/// The check boxes of what `draw` draws, from the top, as (enabled, checked). +fn check_boxes(app: &mut VectorcraftApp, ctx: &egui::Context, draw: fn(&mut VectorcraftApp, &mut egui::Ui)) -> Vec<(bool, bool)> { + let nodes = frame(app, ctx, vec![], draw); + let mut boxes: Vec<&Node> = nodes.iter().filter(|n| n.role() == Role::CheckBox).collect(); + boxes.sort_by(|a, b| a.bounds().map_or(0.0, |r| r.y0).total_cmp(&b.bounds().map_or(0.0, |r| r.y0))); + boxes.iter().map(|n| (!n.is_disabled(), n.toggled() == Some(Toggled::True))).collect() +} + +/// Each step has a check box, off until the tutorial's sample is open. A click marks only its own +/// step and a second click clears it; marking every step does not finish the tutorial. A finished +/// tutorial shows every step done, and its check boxes and `learn.markStep` no longer change them. +#[test] +fn a_step_s_check_box_marks_only_that_step() { + let mut app = app(); + let ctx = context(); + assert_eq!(check_boxes(&mut app, &ctx, pen_paths), [(false, false); 3], "off before View more"); + click(&mut app, &ctx, &pen_step(1), pen_paths); + assert!(app.ui.learn_progress.is_empty(), "a check box that is off changes nothing"); + app.run("learn.openSample", json!({"tutorial": "pen-paths"})).unwrap(); + click(&mut app, &ctx, &pen_step(1), pen_paths); + assert_eq!(check_boxes(&mut app, &ctx, pen_paths), [(true, false), (true, true), (true, false)], "{}", app.ui.status); + let list = app.run("learn.list", json!({})).unwrap(); + assert_eq!(list["skills"][1]["tutorials"][0]["completedSteps"], json!([1])); + assert_eq!(list["skills"][1]["tutorials"][1]["completedSteps"], json!([]), "other tutorials stay as they are"); + click(&mut app, &ctx, &pen_step(1), pen_paths); + assert!(app.ui.learn_progress.is_empty(), "a second click clears the mark"); + for i in 0..3 { + click(&mut app, &ctx, &pen_step(i), pen_paths); + } + assert_eq!(check_boxes(&mut app, &ctx, pen_paths), [(true, true); 3]); + assert!(!app.ui.learn_progress.is_finished("pen-paths"), "marking every step does not finish the tutorial"); + assert!(painted_text(&mut app, pen_paths).contains("Finish tutorial")); + click(&mut app, &ctx, &pen_step(0), pen_paths); + click(&mut app, &ctx, "Finish tutorial", pen_paths); + assert_eq!(app.ui.learn_progress.finished, ["pen-paths"]); + assert!(app.ui.learn_progress.steps.is_empty(), "a finished tutorial keeps no marks of its own"); + assert_eq!(check_boxes(&mut app, &ctx, pen_paths), [(false, true); 3], "Finish marks every step"); + let before = app.ui.learn_progress.clone(); + click(&mut app, &ctx, &pen_step(2), pen_paths); + let error = app.run("learn.markStep", json!({"tutorial": "pen-paths", "step": 2, "complete": false})).unwrap_err(); + assert_eq!(error, "`pen-paths` is finished (see learn.resetProgress)"); + assert_eq!(app.ui.learn_progress, before); +} + +/// The check boxes are reached with Tab and changed with Space. +#[test] +fn a_step_s_check_box_works_from_the_keyboard() { + let mut app = app(); + let ctx = context(); + app.run("learn.openSample", json!({"tutorial": "pen-paths"})).unwrap(); + frame(&mut app, &ctx, vec![], pen_paths); + tab_to(&mut app, &ctx, &pen_step(2), pen_paths); + key(&mut app, &ctx, egui::Key::Space, pen_paths); + assert_eq!(app.ui.learn_progress.steps.get("pen-paths"), Some(&vec![2]), "{}", app.ui.status); +} + +/// Finishing tutorials fills only their own skill's ring and count, once each however often they +/// are finished; the skill's tutorial rows show which are finished; `learn.list` answers the same. +#[test] +fn finishing_tutorials_fills_their_skill_s_ring_and_count() { + let mut app = app(); + let ctx = context(); + for id in ["pen-paths", "smooth-curves"] { + app.run("learn.openSample", json!({"tutorial": id})).unwrap(); + for _ in 0..2 { + app.run("learn.finish", json!({"tutorial": id})).unwrap(); + } + } + let values = |app: &mut VectorcraftApp, view: View| { + app.ui.learn = view; + let nodes = frame(app, &ctx, vec![], show); + nodes + .iter() + .filter(|n| n.role() == Role::Button) + .map(|n| (n.label().unwrap_or_default().to_string(), n.value().map(str::to_string))) + .collect::>() + }; + let skills = View { tab: Tab::Skills, skill: None, tutorial: None }; + let rows = values(&mut app, skills.clone()); + for skill in catalog::SKILLS { + let count = if skill.id == "draw" { "2/3".to_string() } else { format!("0/{}", skill.tutorials.len()) }; + assert!(rows.contains(&(skill.title.to_string(), Some(count.clone()))), "{} {count} in {rows:?}", skill.id); + } + assert!(painted_text(&mut app, show).contains("2/3")); + let list = app.run("learn.list", json!({})).unwrap(); + let draw = &list["skills"][1]; + assert_eq!((draw["done"].clone(), draw["total"].clone()), (json!(2), json!(3))); + assert_eq!(draw["tutorials"][1]["finished"], json!(true)); + assert_eq!(draw["tutorials"][1]["completedSteps"], json!([0, 1, 2])); + assert_eq!(list["skills"][2]["done"], json!(0), "other skills stay at 0"); + + let rows = values(&mut app, View { tab: Tab::Skills, skill: Some("draw"), tutorial: None }); + assert!(rows.contains(&("Draw paths with the Pen".to_string(), Some("Finished".to_string()))), "{rows:?}"); + assert!(rows.contains(&("Draw smooth curves".to_string(), Some("Finished".to_string()))), "{rows:?}"); + assert!(rows.contains(&("Sketch with the Pencil".to_string(), None)), "{rows:?}"); + + app.run("learn.openSample", json!({"tutorial": "pencil-sketch"})).unwrap(); + app.run("learn.finish", json!({"tutorial": "pencil-sketch"})).unwrap(); + let rows = values(&mut app, skills); + assert!(rows.contains(&("Draw and build".to_string(), Some("3/3".to_string()))), "every tutorial finished: {rows:?}"); +} + +/// A skill row with no tutorials, which the catalog does not have today, shows an empty ring and +/// 0/0. +fn empty_skill(_: &mut VectorcraftApp, ui: &mut egui::Ui) { + super::row(ui, "Empty skill", super::Mark::Ring { done: 0, total: 0 }); +} + +#[test] +fn a_skill_with_no_tutorials_shows_0_of_0() { + let mut app = app(); + let text = painted_text(&mut app, empty_skill); + assert!(text.contains("Empty skill") && text.contains("0/0"), "{text}"); +} + +/// `learn.markStep` marks a step done by default and with `complete: true`, clears it with `false`, +/// and answers what it did; a bad param is an error and changes nothing. +#[test] +fn learn_mark_step_checks_its_params() { + let mut app = app(); + let open = "open the practice sample of `gradient` first (see learn.openSample)"; + assert_eq!(app.run("learn.markStep", json!({"tutorial": "gradient", "step": 0})).unwrap_err(), open); + assert!(app.ui.learn_progress.is_empty()); + app.run("learn.openSample", json!({"tutorial": "gradient"})).unwrap(); + assert_eq!( + app.run("learn.markStep", json!({"tutorial": "gradient", "step": 0})).unwrap(), + json!({"tutorial": "gradient", "step": 0, "complete": true}) + ); + let before = app.ui.learn_progress.clone(); + let missing = "missing `step` (see learn.show)"; + let range = "`step` must be a step number from 0 to 2"; + for (params, error) in [ + (json!({"tutorial": "gradient"}), missing), + (json!({"tutorial": "gradient", "step": null}), missing), + (json!({"tutorial": "gradient", "step": 3}), range), + (json!({"tutorial": "gradient", "step": -1}), range), + (json!({"tutorial": "gradient", "step": 1.5}), range), + (json!({"tutorial": "gradient", "step": "1"}), range), + (json!({"tutorial": "gradient", "step": u64::MAX}), range), + (json!({"tutorial": "gradient", "step": 1, "complete": "yes"}), "`complete` must be true or false"), + (json!({"tutorial": "nope", "step": 1}), "unknown tutorial `nope` (see learn.list)"), + (json!({"step": 1}), "missing `tutorial` (see learn.list)"), + ] { + assert_eq!(app.run("learn.markStep", params.clone()).unwrap_err(), error, "{params}"); + assert_eq!(app.ui.learn_progress, before, "{params}"); + } + let r = app.run("learn.markStep", json!({"tutorial": "gradient", "step": 2, "complete": null})).unwrap(); + assert_eq!(r, json!({"tutorial": "gradient", "step": 2, "complete": true})); + let r = app.run("learn.markStep", json!({"tutorial": "gradient", "step": 0, "complete": false})).unwrap(); + assert_eq!(r, json!({"tutorial": "gradient", "step": 0, "complete": false})); + let r = app.run("learn.markStep", json!({"tutorial": "gradient", "step": 0, "complete": false})).unwrap(); + assert_eq!(r["complete"], json!(false), "clearing a step that is not marked is no error"); + assert_eq!(app.ui.learn_progress.steps.get("gradient"), Some(&vec![2])); + assert!(app.ui.learn_progress.finished.is_empty()); +} + +/// `learn.resetProgress` and Reset progress clear every tutorial finished and every step marked; +/// documents, opened samples and the Learn view stay. Reset progress shows only when there is +/// progress. +#[test] +fn reset_progress_clears_only_the_progress() { + let mut app = app(); + let ctx = context(); + let skills = View { tab: Tab::Skills, skill: None, tutorial: None }; + app.ui.learn = skills.clone(); + assert!(!painted_text(&mut app, show).contains("Reset progress")); + app.run("learn.openSample", json!({"tutorial": "pen-paths"})).unwrap(); + app.run("learn.finish", json!({"tutorial": "pen-paths"})).unwrap(); + app.run("learn.openSample", json!({"tutorial": "gradient"})).unwrap(); + app.run("learn.markStep", json!({"tutorial": "gradient", "step": 1})).unwrap(); + let view = app.ui.learn.clone(); + let docs = app.session.documents().len(); + let reply = app.run("learn.resetProgress", json!({})).unwrap(); + assert!(app.ui.learn_progress.is_empty()); + assert_eq!(reply, app.run("learn.list", json!({})).unwrap()); + assert_eq!(reply["skills"][1]["done"], json!(0)); + assert_eq!((app.ui.learn.clone(), app.session.documents().len()), (view, docs)); + assert_eq!(app.ui.learn_practice.opened, ["pen-paths", "gradient"], "opened samples stay open for practice"); + + app.run("learn.finish", json!({"tutorial": "gradient"})).unwrap(); + app.ui.learn = skills.clone(); + assert!(painted_text(&mut app, show).contains("Reset progress")); + click(&mut app, &ctx, "Reset progress", show); + assert!(app.ui.learn_progress.is_empty(), "{}", app.ui.status); + assert_eq!(app.ui.learn, skills); + assert!(!painted_text(&mut app, show).contains("Reset progress")); +} + +/// The UI state after its preferences are saved and read again, as at the next start. +fn restarted(app: &VectorcraftApp) -> crate::state::UiState { + let bytes = serde_json::to_vec(&app.ui).unwrap(); + crate::state::UiState::read_preferences(&bytes).expect("the preferences read").ui.sanitized() +} + +/// The preferences keep the tutorials finished and the steps marked; the opened samples, the +/// Learn view and a tool's mark last only while the app runs, so a step can be marked again only +/// after View more. +#[test] +fn the_preferences_keep_the_progress() { + let mut app = app(); + app.run("learn.openSample", json!({"tutorial": "pen-paths"})).unwrap(); + app.run("learn.finish", json!({"tutorial": "pen-paths"})).unwrap(); + app.run("learn.openSample", json!({"tutorial": "gradient"})).unwrap(); + for step in [2, 0] { + app.run("learn.markStep", json!({"tutorial": "gradient", "step": step})).unwrap(); + } + let list = app.run("learn.list", json!({})).unwrap(); + let ui = restarted(&app); + assert_eq!(ui.learn_progress, app.ui.learn_progress); + assert_eq!(ui.learn_progress.steps.get("gradient"), Some(&vec![0, 2])); + assert_eq!((ui.learn_practice.clone(), ui.learn.clone(), ui.learn_locate.is_none()), (Practice::default(), View::default(), true)); + + let mut next = self::app(); + next.ui = ui; + assert_eq!(next.run("learn.list", json!({})).unwrap(), list); + assert_eq!(next.run("learn.next", json!({"tutorial": "pen-paths"})).unwrap()["tutorial"], "smooth-curves"); + let again = next.run("learn.finish", json!({"tutorial": "pen-paths"})).unwrap(); + assert_eq!(again, json!({"tutorial": "pen-paths", "finished": true, "next": "smooth-curves"}), "finishing again needs no sample"); + assert_eq!(next.ui.learn_progress.finished, ["pen-paths"]); + let open = "open the practice sample of `gradient` first (see learn.openSample)"; + assert_eq!(next.run("learn.markStep", json!({"tutorial": "gradient", "step": 1})).unwrap_err(), open); +} + +/// Saved preferences with `learn_progress` set to `progress` (left out for None), and +/// `control_bar` on, read as at a start. +fn read_progress(progress: Option) -> crate::state::UiState { + let mut saved = serde_json::to_value(crate::state::UiState::default()).unwrap(); + let fields = saved.as_object_mut().unwrap(); + fields.insert("control_bar".into(), json!(true)); + match progress { + Some(p) => fields.insert("learn_progress".into(), p), + None => fields.remove("learn_progress"), + }; + let ui = crate::state::UiState::read_preferences(&serde_json::to_vec(&saved).unwrap()).expect("the preferences read").ui; + assert!(ui.control_bar, "the other preferences read as usual"); + ui +} + +/// Preferences saved before the progress was kept read with none. Saved progress keeps only the +/// catalog's tutorials and steps, each once, and a value of the wrong kind, or a huge list, does not +/// stop the rest of the preferences from reading. +#[test] +fn saved_progress_is_read_leniently() { + assert!(read_progress(None).learn_progress.is_empty()); + for bad in [json!("garbage"), json!(3), json!(null), json!([1, 2]), json!({"finished": "pen-paths", "steps": [0]})] { + assert!(read_progress(Some(bad.clone())).learn_progress.is_empty(), "{bad}"); + } + let ui = read_progress(Some(json!({ + "finished": ["pen-paths", "nope", 3, "pen-paths", "gradient"], + "steps": { + "gradient": [0], + "smooth-curves": [2, 0, 2, 99, -1, "1", 1.5], + "nope": [0], + "copy-colors": "x", + "add-headline": [], + }, + }))); + assert_eq!(ui.learn_progress.finished, ["pen-paths", "gradient"]); + let steps: Vec<(&str, Vec)> = ui.learn_progress.steps.iter().map(|(id, s)| (*id, s.clone())).collect(); + assert_eq!(steps, [("smooth-curves", vec![0, 2])], "a finished tutorial keeps no marks"); + let ui = read_progress(Some(json!({"finished": vec!["pen-paths"; 100_000], "steps": {"smooth-curves": vec![1; 100_000]}}))); + assert_eq!(ui.learn_progress.finished, ["pen-paths"]); + assert_eq!(ui.learn_progress.steps.get("smooth-curves"), Some(&vec![1])); +} diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index a06dc2f1df..3a711815c1 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -424,10 +424,11 @@ pub struct UiState { /// is on screen. Not saved. #[serde(skip)] pub learn_locate: Option, - /// The tutorials whose practice samples were opened and the tutorials finished, kept while the - /// app runs. + /// The tutorials whose practice samples were opened, kept while the app runs. #[serde(skip)] pub learn_practice: crate::panels::learn::Practice, + /// The Learn panel's tutorials finished and steps marked done, saved with the preferences. + pub learn_progress: crate::panels::learn::progress::Progress, pub control_bar: bool, /// The Control bar is docked to the bottom of the window instead of the top /// (`window.control.dock`). @@ -1112,6 +1113,7 @@ impl Default for UiState { learn: Default::default(), learn_locate: None, learn_practice: Default::default(), + learn_progress: Default::default(), control_bar: false, control_bar_bottom: false, control_bar_floating: false, diff --git a/docs/mcp.md b/docs/mcp.md index ef3ff788a5..25e4a0aca6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -2849,14 +2849,18 @@ own layout rules. Window › Learn and the Explore tutorials button beside the search icon at the right end of the app bar show and hide the Learn panel. Its For you tab holds a Get started section with a Quick skill guide card; choosing the card opens -the Skills tab. The Skills tab lists VectorCraft's own skills, each with its number of tutorials and an empty progress -ring. Choosing a skill lists its tutorials, choosing a tutorial shows its numbered steps, and Back goes up one level. +the Skills tab. The Skills tab lists VectorCraft's own skills, each with a progress ring and the count of its tutorials +finished of all its tutorials. Choosing a skill lists its tutorials, choosing a tutorial shows its numbered steps, and +Back goes up one level. The tutorial text is English. `window.learn {show?}` shows the panel (`show: true`), hides it (`show: false`) or toggles it (`show` omitted or null), and answers whether it shows; Window › Learn and Explore tutorials run it. The panel counts as hidden while the dock is hidden or a full screen mode hides the panels. Showing it shows a hidden dock; in a full screen mode it makes Learn the front panel, which shows when the mode ends, and answers false. Any -other value of `show` is an error and changes nothing. `learn.list {}` → `{skills: [{id, title, tutorials: [{id, title, steps}]}]}`, in the order the Skills tab -lists them, where `steps` is the number of steps. `learn.skills {}` shows the panel on its Skills tab with the list of +other value of `show` is an error and changes nothing. `learn.list {}` → +`{skills: [{id, title, done, total, tutorials: [{id, title, steps, finished, completedSteps}]}]}`, in the order the +Skills tab lists them, where `done` is the number of the skill's tutorials finished, `total` the number of its +tutorials, `steps` the number of a tutorial's steps, `finished` whether it is finished, and `completedSteps` the +zero-based indexes of its steps marked done (every step of a finished tutorial). `learn.skills {}` shows the panel on its Skills tab with the list of skills, with no skill and no tutorial open, as the Quick skill guide card and Back to skills do, and answers what `learn.list` answers. `learn.show {tutorial}` shows the panel on its Skills tab with that tutorial's steps → `{skill, tutorial, title, steps: [text]}`. A missing, non-string or unknown `tutorial` is an error @@ -2866,24 +2870,41 @@ Under a tutorial's steps, View more opens the tutorial's practice sample, a smal art its steps work on, as a new untitled document that becomes the active one; Save asks where to save it. Once the sample is open, Finish tutorial marks the tutorial finished. A finished tutorial shows Next Up with the title of the next tutorial in the same skill, which Next Up shows without opening its sample. A skill's last tutorial, finished, -says so and shows Back to skills instead; Next Up never moves to another skill. Which tutorials are finished is kept -while the app runs, and the skill rings and counts do not show it yet. These are VectorCraft's own rules; the help -page also plays a short video, which VectorCraft does not have. `learn.openSample {tutorial}` runs View more → +says so and shows Back to skills instead; Next Up never moves to another skill. These are VectorCraft's own rules; the +help page also plays a short video, which VectorCraft does not have. `learn.openSample {tutorial}` runs View more → `{tutorial, index, title}` of the new document, and moves the Learn view to that tutorial; each call opens another copy and leaves the open documents as they are. `learn.finish {tutorial}` runs Finish tutorial → `{tutorial, finished: true, next}`, where `next` is the next tutorial's id in the skill, or null after the skill's -last one; the tutorial's sample must have been opened, and finishing it again keeps one entry. `learn.next {tutorial}` +last one; the tutorial's sample must have been opened, and finishing it again keeps one entry, also after a restart +without opening the sample again. `learn.next {tutorial}` runs Next Up on a finished tutorial and shows the panel on the next one → `{skill, tutorial, title}`; on a tutorial not finished, or a skill's last tutorial, it is an error. For all three, a missing, non-string or unknown `tutorial` is an error, and an error changes nothing. Behavior reference: [Quick skill guide](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html). +Each step has a check box before its number that shows whether it is done, and a skill's ring fills as its tutorials +are finished, as the help page describes; a finished tutorial has a check mark in its skill's list. A step is marked +done by its check box, which can be changed once the tutorial's sample is open and until the tutorial is finished; +marking every step does not finish the tutorial. Finish tutorial marks all its steps done, and a finished tutorial's +steps stay marked. Reset progress under the list of skills, shown while there is progress, clears every tutorial +finished and every step marked. The desktop app keeps the progress in its preferences, so it lasts to the next start; +when two windows change it, the one that saves last keeps its progress. The web build keeps it while the page is open. +Marking steps by hand, keeping the progress and Reset progress are VectorCraft's own rules. +`learn.markStep {tutorial, step, complete?}` runs a step's check box → `{tutorial, step, complete}`: `step` is the +zero-based step number, and `complete` marks the step done (`true`, omitted or null) or not done (`false`). A missing +`step` or one the tutorial does not have, a `complete` that is not true or false, a tutorial whose sample was not +opened, and a finished tutorial are errors. `learn.resetProgress {}` runs Reset progress and answers what `learn.list` +answers; open documents, opened samples and the Learn view stay as they are. For both, a missing, non-string or +unknown `tutorial` is an error, and an error changes nothing. + ```json {"name":"invoke_menu","arguments":{"command":"learn.show","params":{"tutorial":"pen-paths"}}} {"name":"invoke_menu","arguments":{"command":"learn.openSample","params":{"tutorial":"pen-paths"}}} +{"name":"invoke_menu","arguments":{"command":"learn.markStep","params":{"tutorial":"pen-paths","step":0}}} {"name":"invoke_menu","arguments":{"command":"learn.finish","params":{"tutorial":"pen-paths"}}} {"name":"invoke_menu","arguments":{"command":"learn.next","params":{"tutorial":"pen-paths"}}} {"name":"invoke_menu","arguments":{"command":"learn.skills","params":{}}} +{"name":"invoke_menu","arguments":{"command":"learn.resetProgress","params":{}}} ``` A step that names a tool shows the tool's name as a blue link. A click on it, or Enter or Space while it has the diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f3707717e6..48793e82c9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -902,9 +902,10 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Perspective Distort and Free Distort (`object.distort`) turn each warped object's bounding box as the warp turns the object at its own center, the objects inside groups, compound paths and clip groups and the art of linked opacity masks included, so the next Selection or Free Transform drag uses the tilted box; Object › Transform › Reset Bounding Box squares it again, and corners left where they are add no undo step (VectorCraft's own rule; `bboxrotate::distort_turns_an_upright_box_with_the_warp_at_its_center`, `distort_turns_each_member_and_linked_mask_by_its_own_warp`, `mirrored_and_collapsing_distorts_keep_valid_angles`, `distort_angles_undo_redo_and_reopen_together`, `xform::unchanged_distort_records_no_history`). - The Free Transform widget's Constrain works in Free Distort as well as in Free Transform ([the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/free-transform-tool.html)). With Constrain on, or Shift held, a corner dragged in Free Distort moves only along the line through the opposite corner, in the box's own proportions, and the other three corners stay in place; on a turned box the line runs through the box's own corners. The line is VectorCraft's own rule. Cmd/Ctrl+Alt+Shift on a corner still drags in Perspective Distort, where Constrain stays unavailable (tools `xform::free::tests::free_distort_corner_keeps_to_its_diagonal_with_shift_or_constrain`, `shift_pressed_during_a_free_distort_drag_constrains_it`, `a_turned_box_is_constrained_along_its_own_diagonal`, `along_diagonal_of_a_degenerate_box`; engine `xform::free_transform_constrained_distort_keeps_the_corner_on_its_diagonal`; ui-egui `free_transform::tests::the_widget_sets_the_mode_and_a_corner_drag_then_distorts`). - Native macOS menu bar, vector tool cursors, a ⌘K command palette, middle-button panning with any tool. Native menus explicitly end tracking on command selection, outside window presses and Escape; menu updates wait until tracking ends, and a dismissing press never starts a canvas gesture (M14.8). - - The Learn panel (Window › Learn, or Explore tutorials beside the search icon on the app bar) has a For you tab with a Get started section and a Quick skill guide card, and a Skills tab that lists VectorCraft's own skills with their tutorial counts and empty progress rings; a skill lists its tutorials, a tutorial shows its numbered steps, and Back goes up a level; `learn.list` and `learn.show {tutorial}` script it ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`). + - The Learn panel (Window › Learn, or Explore tutorials beside the search icon on the app bar) has a For you tab with a Get started section and a Quick skill guide card, and a Skills tab that lists VectorCraft's own skills with their progress rings and counts of tutorials finished; a skill lists its tutorials, a tutorial shows its numbered steps, and Back goes up a level; `learn.list` and `learn.show {tutorial}` script it ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`). - A tool's name in a Learn tutorial step is a blue link that shows where the tool is without choosing it (`learn.locateTool {tool}`): its toolbar button is marked, a collapsed group's flyout opens with the tool's row marked, a torn-off strip comes to the front, and a tool no shown toolbar holds is marked in the All Tools drawer. The mark, its 3 seconds and the hidden-toolbar cases are VectorCraft's own rules ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `panels::learn::tests`, the `a_learn_link_*` tests in `toolbar::tests`). - - Under a tutorial's steps, View more opens the tutorial's own practice sample as a new untitled document, and once the tutorial is finished, Next Up moves to the next tutorial in the same skill, as the help page describes ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html)). The samples are VectorCraft's own drawings. A Finish tutorial button that shows once the sample is open, the untitled copy, Back to skills in place of Next Up after a skill's last tutorial, and Next Up showing the next tutorial without opening its sample are VectorCraft's own rules. `learn.openSample`, `learn.finish`, `learn.next` and `learn.skills` (Back to skills) script them. Not done: the help page's short video, and progress kept between sessions and shown in the skill rings. Regression tests: `view_more_opens_the_tutorial_s_sample_as_a_new_untitled_document`, `finishing_a_tutorial_offers_next_up_in_its_skill`, `the_practice_controls_work_from_the_keyboard`, `the_last_tutorial_of_a_skill_offers_back_to_skills`, `learn_finish_and_learn_next_follow_the_practice`, `learn_skills_shows_the_list_of_skills`, `the_practice_commands_reject_a_missing_or_unknown_tutorial`, `every_tutorial_has_its_own_readable_sample` and `the_next_tutorial_is_the_next_one_in_the_same_skill` in `crates/ui-egui/src/panels/learn/tests.rs`. + - Under a tutorial's steps, View more opens the tutorial's own practice sample as a new untitled document, and once the tutorial is finished, Next Up moves to the next tutorial in the same skill, as the help page describes ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html)). The samples are VectorCraft's own drawings. A Finish tutorial button that shows once the sample is open, the untitled copy, Back to skills in place of Next Up after a skill's last tutorial, and Next Up showing the next tutorial without opening its sample are VectorCraft's own rules. `learn.openSample`, `learn.finish`, `learn.next` and `learn.skills` (Back to skills) script them. Not done: the help page's short video. Regression tests: `view_more_opens_the_tutorial_s_sample_as_a_new_untitled_document`, `finishing_a_tutorial_offers_next_up_in_its_skill`, `the_practice_controls_work_from_the_keyboard`, `the_last_tutorial_of_a_skill_offers_back_to_skills`, `learn_finish_and_learn_next_follow_the_practice`, `learn_skills_shows_the_list_of_skills`, `the_practice_commands_reject_a_missing_or_unknown_tutorial`, `every_tutorial_has_its_own_readable_sample` and `the_next_tutorial_is_the_next_one_in_the_same_skill` in `crates/ui-egui/src/panels/learn/tests.rs`. + - A Learn tutorial's steps are marked complete as the learner works, and a skill's progress ring fills as its tutorials are finished, as the help page describes ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html)). Each step has a check box that marks it done once the tutorial's sample is open (`learn.markStep`); Finish tutorial marks every step done; a skill's count shows its tutorials finished of all, and a finished tutorial has a check mark in its skill's list. Marking steps by hand, the count, keeping the progress in the preferences (the web build keeps it while the page is open) and Reset progress (`learn.resetProgress`) are VectorCraft's own rules; `learn.list` reports the progress. Regression tests: `a_step_s_check_box_marks_only_that_step`, `a_step_s_check_box_works_from_the_keyboard`, `finishing_tutorials_fills_their_skill_s_ring_and_count`, `a_skill_with_no_tutorials_shows_0_of_0`, `learn_mark_step_checks_its_params`, `reset_progress_clears_only_the_progress`, `the_preferences_keep_the_progress` and `saved_progress_is_read_leniently` in `crates/ui-egui/src/panels/learn/tests.rs`. - The errors of the blend spine commands (Move Spine Point, Reshape Spine Segment, Add Spine Point and Delete Spine Point) show in the status bar in the interface language: each has a row in every catalog that translates all status and error messages and in Bulgarian (`blend_spine_param_errors_are_translated`). - The errors of the 3D effects (Extrude & Bevel, Revolve, Inflate, Rotate and their Classic forms) show in the status bar in the interface language: the art a 3D effect cannot build a solid from, invalid light, graphics and surface settings, and the notes for an object that draws no 3D faces or more wireframe edges than the limit. Each has a row in every catalog that translates all status and error messages, and the effect's name and the values in the message are translated or kept as written (`three_d_refusals_are_translated_in_every_complete_catalog`, `three_d_refusals_translate_with_their_values`). - The errors of the parameter checks that many commands share show in the status bar in the interface language: a value that is not a number where a number goes (`object.move` with `"dx": "60 mm"`, and `object.rotate`, `object.setBounds` and the other commands that call `check_numbers`), a missing number or index, `ids` that are not a list of object ids, an object id that is not a non-negative integer or names no object, and a date that is not Unix seconds. Each has a row in every catalog that translates all status and error messages, and in Bulgarian, Danish, Indonesian and Dutch (`shared_param_check_errors_are_translated`). diff --git a/docs/ui-parity.md b/docs/ui-parity.md index 62a99726a2..4872135936 100644 --- a/docs/ui-parity.md +++ b/docs/ui-parity.md @@ -383,7 +383,7 @@ next unit in the order a right-click on a ruler lists them, from Feet back to Po |---|---|---| | Effect > Warp Options: style previews, orientation choices and percent controls | done | #1760; focused input, mixed-style and history checks passed; original captures reviewed. No geometry or optional Properties changes. | | Command search: Up and Down move through the results, Enter runs the highlighted one | done | #1798 (#1757) | -| Learn panel: Window › Learn and Explore tutorials on the app bar open it; For you holds a Quick skill guide card, Skills lists VectorCraft's own skills with tutorial counts and empty progress rings, a tutorial shows its numbered steps, Back goes up a level; a tool's name in a step is a link that marks the tool where the toolbars show it (its button, its group's flyout, a torn-off strip, a toolbar made with New Toolbar or the All Tools drawer) without choosing it; View more opens the tutorial's practice sample as a new untitled document, Finish tutorial then marks it finished, and Next Up shows the next tutorial in the same skill (no video) | done | [the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `learn.list`, `learn.skills`, `learn.show`, `learn.locateTool`, `learn.openSample`, `learn.finish`, `learn.next`; the mark's look and 3-second lifetime are VectorCraft's own rules; `panels::learn::tests`, `toolbar::tests` | +| Learn panel: Window › Learn and Explore tutorials on the app bar open it; For you holds a Quick skill guide card, Skills lists VectorCraft's own skills with progress rings that fill and counts of tutorials finished, a tutorial shows its numbered steps with a check box each that marks the step done once its sample is open, a finished tutorial has a check mark, Back goes up a level; a tool's name in a step is a link that marks the tool where the toolbars show it (its button, its group's flyout, a torn-off strip, a toolbar made with New Toolbar or the All Tools drawer) without choosing it; View more opens the tutorial's practice sample as a new untitled document, Finish tutorial then marks it finished with all its steps, and Next Up shows the next tutorial in the same skill; Reset progress clears the progress (no video) | done | [the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/learn-skills-quick-skill-guide.html); `learn.list`, `learn.skills`, `learn.show`, `learn.locateTool`, `learn.openSample`, `learn.markStep`, `learn.finish`, `learn.next`, `learn.resetProgress`; the mark's look and 3-second lifetime, marking steps by hand, keeping the progress in the preferences and Reset progress are VectorCraft's own rules; `panels::learn::tests`, `toolbar::tests` | | Pathfinder panel: a group selected alone counts its nested shapes, so an expanded stroked object keeps the Shape Modes enabled | done | #1642 (#1635) | | Selected Grid Repeat shows row, column and corner handles and spacing sliders; bounding-box handles take priority where they meet | done | #2691, `tools/src/repeat_grid.rs`; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html); drags preview and commit `object.repeat.options` as one undo step, Escape cancels; Radial Repeat has no handles yet | | Grid Repeat Options (Object › Repeat › Options…) has a Preview checkbox: the repeat on the canvas follows the fields while the dialog is open, Cancel puts the original back without a history step, OK keeps the previewed values as one undo step | done | #2651; [public behavior reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html) lists the Preview option for the grid options only, so Radial and Mirror Repeat Options have none; `dialogs/command.rs` tests | From 7b475b46b0b47663a9828365f1c16f6f06498dda Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 17:05:00 -0800 Subject: [PATCH 010/108] .ai import: Calligraphic paths with pen samples keep their drawn look MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A path's own lines can be followed by samples of the pen (`(…) Xt n XD`). The reader took them as the end of the object, so the style marker after them was not matched: the path came in as its drawn look plus a second, unpainted copy of the path, and no note said the look was kept. The samples now stay with the path. They aren't read, so a path that has them keeps its drawn look alone, with the note, when a setting of its Calligraphic brush varies with the pen (Pressure, Tilt, Bearing or Rotation, with a variation above 0). With any other style, an Art brush or a Calligraphic brush that doesn't follow the pen included, it takes the style as it would without them. A Calligraphic brush's filter with an entry the reader doesn't know, or with a variable width, keeps the drawn look too, as an Art brush's filter does. Docs: docs/file-format-parity.md, docs/gaps.md. --- crates/eps/src/import/ai/brush.rs | 3 +- crates/eps/src/import/ai/read.rs | 5 ++ crates/eps/src/import/ai/read/ops.rs | 37 ++++++++++++-- crates/eps/src/import/ai/read/types.rs | 3 +- crates/eps/src/import/ai/style.rs | 31 ++++++++++-- crates/eps/src/import/ai/tests.rs | 68 +++++++++++++++++++++++++- docs/file-format-parity.md | 2 +- docs/gaps.md | 5 ++ 8 files changed, 141 insertions(+), 13 deletions(-) diff --git a/crates/eps/src/import/ai/brush.rs b/crates/eps/src/import/ai/brush.rs index 5a5db47114..7b4023afdd 100644 --- a/crates/eps/src/import/ai/brush.rs +++ b/crates/eps/src/import/ai/brush.rs @@ -18,7 +18,8 @@ //! 1 pt draws it at its own size), the brush by name (`/GObjRef : (name) (plug-in) //! /PluginObject`), and the brush's settings for this path as entries: `Diameter`, `Roundness`, //! `Angle`, their `…Variation` either side and `…DependsOn` codes, and `AngleRelativeTo` (0 the -//! page). +//! page). Samples of the pen may follow a path's own lines on `%_` lines (`(hex) Xt n XD`). They +//! aren't read, so such a path keeps its drawn look when a setting varies with the pen. //! - A path with an Art brush is a stroke in its art style too: the filter //! `(Adobe ArtOnPath Brush Tool)`, its stroke's paint and weight (the weight scales the art across //! the path), the brush by name, and its settings for this path as entries: `Scaling`, diff --git a/crates/eps/src/import/ai/read.rs b/crates/eps/src/import/ai/read.rs index b77bc32199..d460e317f5 100644 --- a/crates/eps/src/import/ai/read.rs +++ b/crates/eps/src/import/ai/read.rs @@ -598,6 +598,10 @@ struct Reader<'a> { compound_groups: HashSet, /// Groups of a text object and its look (see [`Self::style_marker`]), which aren't a look. text_looks: HashSet, + /// Objects followed by samples of the pen (`(…) Xt n XD`), which aren't read: such an object + /// whose style has a Calligraphic brush that varies with the pen keeps its drawn look (see + /// [`Self::style_marker`]). + pen_samples: HashSet, /// The gradient mesh being read (`/Mesh X!` … `/End X!`), and whether it started on a `%_` line. mesh: Option<(super::mesh::MeshReader, bool)>, /// The art styles (`%AI9_BeginArtStyles`), by name. @@ -790,6 +794,7 @@ impl<'a> Reader<'a> { ruler_guides: HashMap::new(), compound_groups: HashSet::new(), text_looks: HashSet::new(), + pen_samples: HashSet::new(), group_ended: false, mesh_ended: false, layer_state: None, diff --git a/crates/eps/src/import/ai/read/ops.rs b/crates/eps/src/import/ai/read/ops.rs index 50a356e524..1bc5d036b5 100644 --- a/crates/eps/src/import/ai/read/ops.rs +++ b/crates/eps/src/import/ai/read/ops.rs @@ -89,6 +89,18 @@ impl<'a> Reader<'a> { } } + /// `(…) Xt n XD`: samples of the pen along the object before it. They aren't read, so the object + /// keeps its drawn look when its style has a Calligraphic brush with a setting that varies with + /// the pen ([`Self::style_marker`]). + fn pen_samples_op(&mut self) { + if !self.after_object || self.pen_samples.len() >= MAX_NODES { + return; + } + if let Some(n) = self.frames.last().and_then(|f| f.children.last()) { + self.pen_samples.insert(n.id); + } + } + /// `/identifier (string) XT` (version 7 specification §7): a tag on the object before it. The /// `AdobeURL` tag sets the object's URL, and every other tag is added to the object's data in /// order, up to [`MAX_TAGS`]. A tag with no object before it, with an empty identifier, or with @@ -418,6 +430,7 @@ impl<'a> Reader<'a> { self.end_envelope(); } } + "XD" => self.pen_samples_op(), _ if IGNORED.contains(&w) => {} // Before the art, the setup runs procedures of the printing format. _ if self.frames.is_empty() => {} @@ -559,9 +572,9 @@ impl<'a> Reader<'a> { return; } self.image_tail = false; - // An object's tags (`XT`, and a graph's `Go`) follow it one after another, and an image's - // follow the `XH` that ends its data. - if matches!(w, "Xy" | "Xd" | "XW" | "BB" | "LB" | "XT" | "XH" | "Go") { + // An object's tags (`XT`, and a graph's `Go`) and samples of the pen (`Xt`, `XD`) follow it + // one after another, and an image's tags follow the `XH` that ends its data. + if matches!(w, "Xy" | "Xd" | "XW" | "BB" | "LB" | "XT" | "XH" | "Go" | "Xt" | "XD") { return; } self.after_object = false; @@ -688,6 +701,8 @@ impl<'a> Reader<'a> { /// drawn look before it (all on `%_` lines inside another such object). Other markers end what /// follows an object. fn style_marker(&mut self, vals: &[V], hidden: bool) { + use crate::import::ai::brush::PathBrush; + use crate::import::ai::style::{ArtStyle, StyleItem}; let code = Self::nums(vals).last().copied().unwrap_or(0.0); let style = vals.iter().rev().find_map(|v| self.names.text(v)).unwrap_or_default(); let after = std::mem::take(&mut self.after_object); @@ -754,8 +769,20 @@ impl<'a> Reader<'a> { } else { look }; - // A style read here: the object, painted as it says. - let appearance = self.styles.get(&style).and_then(|st| { + // A style read here: the object, painted as it says. An object with samples of the pen + // keeps its drawn look when its style has a Calligraphic brush with a setting that varies + // with the pen: the samples aren't read, and the brush draws such a stroke at the pen's + // middle values. + let sampled = self.pen_samples.contains(&object.id); + let follows_pen = |st: &ArtStyle| { + st.items.iter().any(|i| match i { + StyleItem::Stroke { brush: Some((_, PathBrush::Calligraphic(c))), .. } => { + c.modes().iter().zip(c.variation).any(|(m, v)| m.follows_pen() && v != 0.0) + } + _ => false, + }) + }; + let appearance = self.styles.get(&style).filter(|st| !(sampled && follows_pen(st))).and_then(|st| { styled( object, look, diff --git a/crates/eps/src/import/ai/read/types.rs b/crates/eps/src/import/ai/read/types.rs index 83a838a6cb..b6e908c2e1 100644 --- a/crates/eps/src/import/ai/read/types.rs +++ b/crates/eps/src/import/ai/read/types.rs @@ -386,9 +386,8 @@ pub(super) const IGNORED: &[&str] = &[ // Path resolution (`Ar`, §12): how finely curves print. "Ar", "Xs", + // The samples of the pen that `XD` notes on the object before them (`Reader::pen_samples`). "Xt", - // Five indexed curves of samples along a brushed path (`(…) Xt n XD`), on its hidden source path. - "XD", "Xi", "XI", "LB2", diff --git a/crates/eps/src/import/ai/style.rs b/crates/eps/src/import/ai/style.rs index d27a297925..313132ed5a 100644 --- a/crates/eps/src/import/ai/style.rs +++ b/crates/eps/src/import/ai/style.rs @@ -1445,13 +1445,38 @@ fn offset_stroke(f: &Filter) -> Result, ()> { stroke_item(f, if inside { StrokeAlign::Inside } else { StrokeAlign::Outside }) } +/// The entries a Calligraphic brush's filter may hold, with the settings [`calligraphic_stroke`] +/// reads. Any other entry keeps the drawn look. +const CALLIGRAPHIC_ENTRIES: [&str; 14] = [ + "StrokeStyle", + "DisplayString", + "Brush", + "Diameter", + "DiameterVariation", + "DiameterDependsOn", + "Roundness", + "RoundnessVariation", + "RoundnessDependsOn", + "Angle", + "AngleVariation", + "AngleDependsOn", + "AngleRelativeTo", + "Adobe Effect Expand Before Version", // brand-ok: the entry's name in the files +]; + /// A Calligraphic brush's filter `f` as the stroke it paints: `None` when it isn't a stroke in a -/// colour, names no Calligraphic brush, or its settings aren't all there as numbers. An angle -/// relative to the path isn't read. +/// color, names no Calligraphic brush, holds an entry or a width that isn't read, or its settings +/// aren't all there as numbers. An angle relative to the path isn't read. fn calligraphic_stroke(f: &Filter) -> Option { let real = |key: &str| entry(f, key, Kind::Real).ok().flatten(); let code = |key: &str| entry(f, key, Kind::Int).ok().flatten(); - if !f.paints.0 || f.gradient || f.pattern.is_some() || f.repeated { + if !f.paints.0 + || f.gradient + || f.pattern.is_some() + || f.repeated + || !f.arrays.is_empty() + || !f.kinds.keys().all(|k| CALLIGRAPHIC_ENTRIES.contains(&k.as_str())) + { return None; } if entry(f, "AngleRelativeTo", Kind::Int).ok()?.unwrap_or(0.0) != 0.0 { diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index daf99047f3..1b9cc54ea5 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -10228,20 +10228,86 @@ fn a_path_with_a_calligraphic_brush_comes_in_brushed() { let pieces = vectorcraft_brush::stroke_pieces(&r.doc, &lib[0], &a[0].path_data().unwrap().to_bezpath(), st); let height = pieces.iter().filter_map(|n| n.geometric_bounds()).map(|b| b.height()).fold(0.0, f64::max); assert!(height > 40.0 && height < 46.0, "the line's rise and about half the nib's 3 pt: {height}"); + // A filter with the version entry an effect's filter may carry still comes in brushed. + let versioned = style.replace("(Brush) ,\n", "(Brush) ,\n15 /Int (Adobe Effect Expand Before Version) ,\n"); + let a = art(&read_ok(&format!("{def}{versioned}{}", layer(&brushed_path()))).doc); + assert!(matches!(a[0].kind, NodeKind::Path { .. }), "{a:#?}"); +} + +/// Samples of the pen along a path (`(…) Xt n XD`), as they follow its own lines. +const PEN_SAMPLES: &str = "%_(00FE64FE) Xt 0 XD\n%_(00006400) Xt 1 XD\n%_(00986498) Xt 2 XD\n%_(009E649E) Xt 3 XD\n%_(007F647F) Xt 4 XD\n"; + +/// A path with a Calligraphic brush that varies with the pen, followed by samples of the pen, comes +/// in as its drawn look alone, with the note that says so: the samples aren't read, and the brush +/// would draw it at the pen's middle values. Its own path doesn't come in beside the look. A brush +/// that doesn't follow the pen draws such a path the same without the samples, so it comes in +/// brushed. +#[test] +fn a_brushed_path_with_samples_of_the_pen_keeps_its_drawn_look() { + // GUARDS: the path came in beside its look, unpainted, and the note was missing. + let def = plugin_object(CALLIGRAPHIC, "Six D", SIX_D); + let style = brushed_style("Six D", 0.5, SIX_D_SETTINGS, [2, 5, 6], 0); + let path = brushed_path().replace("%_n\n", &format!("%_n\n{PEN_SAMPLES}")); + let r = read_ok(&format!("{def}{style}{}", layer(&path))); + let a = art(&r.doc); + assert_eq!(a.len(), 1, "{a:#?}"); + assert!(matches!(a[0].kind, NodeKind::Group { .. }), "the drawn look: {a:#?}"); + assert!(r.warnings.iter().any(|w| w.contains("drawn look")), "{:?}", r.warnings); + // The samples belong to the path before them: a path after them is read as it was. + let after = format!("{path}{RED}{}f\n", rect_path(0.0, 0.0, 10.0, 10.0)); + let a = art(&read_ok(&format!("{def}{style}{}", layer(&after))).doc); + assert_eq!(a.len(), 2, "{a:#?}"); + assert!(matches!(a[1].kind, NodeKind::Path { .. }) && a[1].appearance.fill().is_some(), "{a:#?}"); + // Samples with no object before them in the layer mark nothing: the path after them is read. + let first = format!("{PEN_SAMPLES}{}", brushed_path()); + let a = art(&read_ok(&format!("{def}{style}{}", layer(&first))).doc); + assert_eq!(a.len(), 1, "{a:#?}"); + assert!(matches!(a[0].kind, NodeKind::Path { .. }), "the path, brushed: {a:#?}"); + // A brush whose modes are Fixed and Random, one whose pen modes vary by 0, and an Art brush + // don't follow the pen: the path comes in brushed. + let fixed_def = plugin_object(CALLIGRAPHIC, "Six D", &SIX_D.replace(" 2 5 6 0", " 0 1 0 0")); + let fixed = brushed_style("Six D", 0.5, SIX_D_SETTINGS, [0, 1, 0], 0); + let even_def = plugin_object(CALLIGRAPHIC, "Six D", "1 6 6 40 40 30 30 2 5 6 0"); + let even = brushed_style("Six D", 0.5, [(6.0, 0.0), (40.0, 0.0), (30.0, 0.0)], [2, 5, 6], 0); + for (why, def, style) in [("Fixed and Random", fixed_def, fixed), ("no variation", even_def, even)] { + let r = read_ok(&format!("{def}{style}{}", layer(&path))); + let a = art(&r.doc); + assert_eq!(a.len(), 1, "{why}: {a:#?}"); + assert!(matches!(a[0].kind, NodeKind::Path { .. }), "{why}: the path, brushed: {a:#?}"); + assert!(!r.warnings.iter().any(|w| w.contains("drawn look")), "{why}: {:?}", r.warnings); + } + let ribbon = format!("{}{}", lopsided_art("Ribbon art"), plugin_object(ART_BRUSH, "Ribbon", RIBBON)); + let a = art(&read_ok(&format!("{ribbon}{}{}", art_style("Ribbon", 2.0, &STRETCHED, ""), layer(&path))).doc); + assert_eq!(a.len(), 1, "{a:#?}"); + assert_eq!(a[0].appearance.stroke().and_then(|s| s.brush.as_deref()), Some("Ribbon"), "{a:#?}"); + // A style with no brush doesn't draw the samples: the path takes it as it would without them. + let square = styled_square("Blue").replace("f\n1 (Blue) XW", &format!("f\n{PEN_SAMPLES}1 (Blue) XW")); + let r = read_ok(&format!("{}{}", styles_and_list(&[fill_style("Blue", "0 0 0 0 0 0 1 Xa\n")], &["Blue"]), layer(&square))); + let a = art(&r.doc); + assert_eq!(a.len(), 1, "{a:#?}"); + assert!(matches!(a[0].kind, NodeKind::Path { .. }), "the path with its style: {a:#?}"); + assert_eq!(a[0].extras().graphic_style, Some(1), "linked to its style"); } /// A brushed path keeps its drawn look when its stroke can't be read as the brush: the object's /// own settings differ from the brush's (Options of Selected Object), its angle follows the path, -/// or the file defines no brush of its name. +/// its filter holds an entry or a variable width that isn't read, or the file defines no brush of +/// its name. #[test] fn a_brushed_path_the_brush_cant_draw_keeps_its_drawn_look() { let def = plugin_object(CALLIGRAPHIC, "Six D", SIX_D); let mut own = SIX_D_SETTINGS; own[0] = (9.0, 2.0); + let plain = brushed_style("Six D", 1.0, SIX_D_SETTINGS, [2, 5, 6], 0); + let with = |more: &str| plain.replace("(Brush) ,\n", &format!("(Brush) ,\n{more}")); + let widths = "/Dictionary : /NotRecorded ,\n/Array :\n0 /Real ,\n1 /Real ,\n; (BSVariableWidthTValuesArray) ,\n\ + /Array :\n1 /Real ,\n0.1 /Real ,\n; (BSCenteredWidthsArray) ,\n; (kAIBeautifulStrokesParamsDictKey) ,\n"; let cases = [ ("its own settings", def.clone(), brushed_style("Six D", 1.0, own, [2, 5, 6], 0)), ("its own modes", def.clone(), brushed_style("Six D", 1.0, SIX_D_SETTINGS, [2, 5, 4], 0)), ("an angle on the path", def.clone(), brushed_style("Six D", 1.0, SIX_D_SETTINGS, [2, 5, 6], 1)), + ("an entry that isn't read", def.clone(), with("1 /Real (Unread) ,\n")), + ("a variable width", def.clone(), with(widths)), ("no such brush", def, brushed_style("Other", 1.0, SIX_D_SETTINGS, [2, 5, 6], 0)), ]; for (why, def, style) in cases { diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index d6816744fb..ca7c2a3e81 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -264,7 +264,7 @@ private editing data. VectorCraft: ### Illustrator's private editing data -The app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping (several clipping paths in a clipping group, a layer or an opacity mask's art clip to their intersection, and a compound path of clipping paths stays one clip; a filled clipping path keeps its fill, which paints under the art it clips, except the path of a mask that covers several layers, whose fill is read as a path of its own in the layer that holds the mask's path, and a compound clipping path whose subpaths paint differently, whose filled subpaths are read as a compound path of their own under the art it clips; clipping paths that would nest the art past the document's 32 levels stop the editing data from being read: #5789), object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint; a stroke of width 0, `0 w`, on a path, a gradient-filled path, legacy type or in an art style comes in as a 0.25 pt hairline, as from PDF: #1671), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), gradient and pattern names in the file up to their first newline (a name that another swatch, or a gradient or pattern defined earlier, already has is numbered "Sky 2"; a name without a newline is kept, and when another swatch has it, the pattern's swatch, or a named color sharing a gradient or pattern swatch's name, is numbered the same way), opacity, blend modes, isolation and knockout, embedded images where their matrix puts them, rotated ones too (#2269), with their alpha channel (CMYK images keep their ink amounts, as they do when a `.ai` opens from its PDF part, and an alpha channel that hides part of a CMYK image becomes a grayscale opacity mask), placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), with the folder the file keeps relative to the document's, where the link is looked for when its path is gone, placed PDF and `.ai` pages as placed documents of the [page and Crop to box](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-other-file-types/adobe-pdf-placement-options.html) their dictionary names (`AI11 PlacedPDFPageIndex`, `AI11 PlacedPDFCropTo`; a value VectorCraft doesn't read, or a binding to an image variable, leaves a linked image), guides, and every artboard where it is, with its center mark, cross hairs, video safe areas and video ruler pixel aspect ratio. VectorCraft reads `CropAreaActive`, an `/Int` in the dictionary that holds the artboard array, as the index of the active artboard in that array, and the file opens with that artboard active; without it, or when it names no artboard that opens, the first artboard is active. It also reads the Document Raster Effects Settings (resolution, color model, background, anti-alias, clipping mask, Add Around Object and Preserve Spot Colors), the author from the header's `%%For` (an EPS's own header when the editing data's has none), swatches for the header's `%%CMYKCustomColor` and `%%RGBCustomColor` colors that the document has none of, and `%%TemplateBox` in older files; a setting with a value of another type or out of range keeps its default. Objects on Path groups open live, with their path, their objects in order along it, Pivot and Rotate; one with a dragged spacing or other options opens as a plain group. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile on a Stroke Offset stroke or written as each side's widths) with Drop Shadow, Inner Glow, Outer Glow, Feather, Round Corners, Scribble, Offset Path, Outline Object, Outline Stroke, Convert to Shape, Tweak (only when it moves nothing), Pucker & Bloat at 0 or Bas Relief (read from its settings block: [raster effects reference](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/raster-effects-reference.html), [Photoshop File Formats Specification](https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/), [scripting the filter gallery](https://community.adobe.com/questions-712/scripting-support-for-the-filter-gallery-1064646)) comes in as itself with them and their saved settings. A path, compound path or group (not a clipping group) whose only effect is Transform (not with copies or Random) or a Free Distort whose corners make a parallelogram comes in as itself with it too, when neither it nor anything in it paints with a gradient or pattern and everything in it is a path, compound path or group with no opacity mask and no effects of its own; Transform that scales, rotates or reflects needs nothing in it to be stroked. Twist as the only effect is read the same way when nothing in the object is stroked: up to 180° either way (a limit VectorCraft sets) on a path or compound path whose segments are all straight, and up to 90° either way (a limit VectorCraft sets) on another path, compound path or group with no guide in it. One with more, other effects (Zig Zag, a Pucker & Bloat of another amount, a Free Distort with other corners), an effect setting that is not read (an unknown key, a missing or out-of-range value, a Scribble with a color of its own), a variable-width stroke with one centered width array, dashes aligned to corners, a brush other than a Calligraphic or Art one, a Calligraphic brush with settings of its own or an angle that follows the path, or an Art brush other than the ones described next comes in as its drawn look (a group named after it). Objects in a symbol defined before the file's art styles section, as newer files write it, take the same styles as the layers' objects. A path with a Calligraphic brush otherwise comes in as the path, the brush on its stroke at the stroke's weight, which scales the brush (#372), and so does a path with an Art brush, whose weight scales the art across the path, when all of these hold: the brush stretches its art along the path, unflipped, at 100% in Tints; the path's settings are the brush's own, with no entry that isn't read, no variable width and no effects; its stroke isn't a swatch; and the art is paths, compound paths and groups in solid fills, with no strokes, masks or effects, and has some length along the path. A stroke takes the brush the Brushes panel keeps under its name, and one whose name the panel doesn't keep comes in as its drawn look. Type with an Art brush keeps its drawn look under the type. A Calligraphic brush's Pressure, Tilt, Bearing and Rotation come in as those channels (a 6D Art Pen's brushes vary with the pressure, the bearing and the barrel's rotation); its Stylus Wheel varies at random. The file's Calligraphic, Scatter, Art and Bristle brushes replace the default ones in the Brushes panel, in the file's order, also when the file comes in as its PDF part (a brush library has no layers); pattern brushes and brushes it can't read are left out with a note. When the file opens from its layers, the spot colors in the art of each brush that comes in become swatches, and that art's colors count toward the document's color mode, as a pattern's do. The swatches take at most 20,000 color names in all across the brush art, and each brush-art section keeps at most 20,000 names. Each name keeps its first definition, with the color operators' names before the gradient stops' names. A spot color past those limits makes no swatch, and its color still counts toward the color mode. A spot color that the page's art, a pattern or a symbol also defines keeps the value defined there. Type keeps its art style as a live appearance whatever its stack (an Art brush aside), so it can be retyped: each fill and stroke of the style's stack (solid colours, gradients and pattern fills, placed as the drawn look places them) with its own opacity, blend mode and effects, the effects on the whole object, and where the characters paint among them; the effects read are Warp, Offset Path, Outline Object, Outline Stroke, Transform (with copies, Transform Objects, Transform Patterns and Scale Strokes & Effects; not with Random), Free Distort, Pucker & Bloat, Twist, Zig Zag, Tweak (only when it moves nothing, the file holding none of its random outline), Drop Shadow, Inner Glow, Outer Glow, Feather, Round Corners, Scribble, Gaussian Blur, Bas Relief (its detail, smoothness and light direction from its settings block, or the effect's defaults when the style holds no settings block; a settings block that isn't read keeps the drawn look) and Convert to Shape, and a style with others, or with an effect setting that isn't read, keeps the type's drawn look. Convert to Shape keeps its Rectangle, Rounded Rectangle or Ellipse, its Absolute or Relative size (a relative size in the file is added to each side) and its corner radius; a relative Ellipse, or a setting that isn't read, keeps the drawn look. The page's drawing of such a style isn't held to look like VectorCraft's where its drawn look lay. Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and its stroke, and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` or an Illustrator EPS from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type (its frame's matrix, which newer files leave out when it is neither turned nor scaled, read as none), area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing (a character attribute a run doesn't set comes from its character style, then the style that one is based on, then the document's defaults); area type keeps its frame's Area Type Options rows and columns, the gutter between rows and the gutter between columns, and its first baseline (Fixed, Cap Height, Leading or x Height) with its minimum; type on a path keeps its frame's Type on a Path effect, Align to Path and Flip (a frame whose options set key 6 to true keeps their defaults), and the first frame's Spacing is fitted from the file's layout, not read from the dialog's value; the distance from the path under Align to Path is measured for each character at its size and vertical scale (in vertical type, its horizontal scale), from the top of its font's em box (Ascender), half the height of the top of its font's H (Center) or the bottom of its font's bounding box (Descender); the fit under Gravity does not reproduce the file's layout, and its glyphs can lie up to 7.4 pt from the positions the file keeps; the page's drawing of it (often in pieces) is left out. Vertical type keeps its orientation, its columns from right to left, and a run set to Tate-chu-yoko keeps that setting. When it makes the type of every text object that shows, the page's type is only compared with it, each text object keeps its own group, frame and layer, and a line break inside a paragraph stays one. Where it can't make a text object's type (a frame of another kind), that text object takes the page's type where the text document puts its lines, or else what is left of the page's type in painting order (no group around it); the page's type where made type draws stays that type's, and hidden type is left out with a note. Text wrap is read too: an object whose dictionary has the wrap options (offset and Invert Wrap), or any graphic of a legacy wraparound group (`*w` … `*W`, before or after its type, with no offset), is a wrap object, and area type below it in its layer flows around it when the file opens, threaded type included (#2763). Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). A `.ai` whose PDF part draws nothing at all (an empty page, with or without those boxes) opens from its editing data alone where that reads too: there is no page art to check its layers against, and the empty page would lose all of it. Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). In a PDF saved with some of its artboards, the type on each page after the first goes to an artboard of that page's size after the previous page's artboard, and only to one that leaves an artboard for each later page; the first page's artboard also leaves one for each later page. When several artboards fit a later page, VectorCraft takes the one whose art draws most like the page, and compares at most 16 artboards for all the later pages together. Symbols are read into the Symbols panel, in the file's symbol list order, with their art, their registration point and the instances in their art, and their instances come in live with their matrix, name, hide, lock, opacity, blending mode, isolation, knockout and opacity mask; a symbol whose art isn't read whole (type, placed files, an image it leaves out or anything else it doesn't read) isn't kept. A file that comes in as its page or PDF part because its editing data has no layers (a symbol library), or because its layers can't be read or used (any of the cases below), gets the symbols its editing data defines before its first layer, in the symbol list's order, while its page art stays as the page draws it. Instances of symbols it can't read, instances with appearance changes of their own (a dynamic symbol's), pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. An unread object on a shown layer whose box can be found instead comes in as a group of the page's objects inside that box, named after it, with the rest of the layers and groups kept and a warning listing what came in as the page's art; the file still comes in as its page when live art or another unread object shares that page art, when the object spans two artboards or lies on an artboard that has no page, when no page art lies inside its box, when that page art is inside a page group with a clip, mask, transparency or appearance, when the object holds a frame of threaded type, when the page art uses a pattern, image or swatch that the page lacks or that differs from the editing data's, or when the page art doesn't carry its transparency (#4806). The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5% (away from type, when all the type is made from the text document), where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). A `.ai` is not compared with its page, and its PDF part is not imported, when its text document makes the type of every text object (at least one shows, and none is drawn by the appearance of the layer or group it is in), no object is unread, no placed file has a second placement, no live envelope keeps its drawn art, it declares no large canvas, and its artboards are its pages' trim boxes one for one, in points or in the first page's `UserUnit`: it opens from its layers, with the bleed of its pages' bleed boxes. When they differ because some objects draw differently (an object in another color, or one that only one of them draws), each top-level object of the layers that holds such a difference comes in as a group of the page's objects inside its box and the layers stay, with a warning that names the layer or sublayer of each such object as the Layers panel shows it (`` for one without a name) and how many came in from it; an export or Save As to the file's own path then needs `acknowledgeLoss: true`, and a wrap object replaced this way keeps its wrap options. The file still comes in as its page when only edges or type differ, when a difference lies outside every top-level object, when more than half of the top-level objects or more than 64 hold one, when such an object is or holds type or holds a wrap object inside a group, when the page's type of a text object that stays lies inside such an object's box, when the page's art can't replace such an object for one of the reasons above for an unread object, when matching the differences to the objects would take too much work, or when the result still differs from the page. `editingData: "always"` keeps the objects as read, and placed files at the other point their data gives are tried as well. An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on its own and marks only layers, clipping groups and groups with opacity, blending or a mask (those come back). Art outside the artboards isn't in that part at all (Illustrator's PDF part leaves it out), so it doesn't open; the import says so in a note (#472). Its pages still go where the editing data puts the artboards (a grid stays a grid), with the art on each, when it has as many artboards as pages, of the same sizes (#1068); the page of the artboard `CropAreaActive` names is then the active artboard. A `.ai` whose editing data has artboards but no layers also opens on that page under the same check, and its pages stay where they are. A `.ai` whose PDF part's pages are cropped to its art (each page the box of all the art, which is the editing data's bounding box) instead of its artboards opens from its layers, with its own artboards, where they draw as that page does. Its pages are laid out so that art one of them draws past its artboard (notes beside a design, which the part doesn't clip) doesn't lie over the page before it in the row, where it was taken for that page's art: the check against the editing data then found art its layers don't have there and opened the file as its PDF part, without the art outside the artboards. That part also has no paragraphs: area type is written line by line, and comes back as area type only where its font is installed and lays the lines out with the same breaks, else as a point type object per line (#508). Art off the page that a PDF does draw opens on the pasteboard. +The app's own editing copy of a file (an EPS after its `%%EOF`, a `.ai`'s `AIPrivateData` streams, a PDF's `AIPDFPrivateData` streams when it was saved with the editing data (#868), Zstandard or zlib, the EPS's in ASCII85) is not documented as a whole. VectorCraft reads its structure: layers and sublayers (names, order, visibility, lock, printing, preview, dimming, colour), groups as they were nested, compound paths (painted by their last path, or the last painted one, with the paths of groups inside them kept as their paths: #1410), clipping groups and layer clipping (several clipping paths in a clipping group, a layer or an opacity mask's art clip to their intersection, and a compound path of clipping paths stays one clip; a filled clipping path keeps its fill, which paints under the art it clips, except the path of a mask that covers several layers, whose fill is read as a path of its own in the layer that holds the mask's path, and a compound clipping path whose subpaths paint differently, whose filled subpaths are read as a compound path of their own under the art it clips; clipping paths that would nest the art past the document's 32 levels stop the editing data from being read: #5789), object names, hidden and locked objects, fills and strokes (grey, CMYK, RGB, named and spot colours, spot colours defined in Lab with their Lab values (#1032), global process colours as global swatches at their tint; a stroke of width 0, `0 w`, on a path, a gradient-filled path, legacy type or in an art style comes in as a 0.25 pt hairline, as from PDF: #1671), linear and radial gradients, pattern fills with their patterns as pattern swatches (#1025), gradient and pattern names in the file up to their first newline (a name that another swatch, or a gradient or pattern defined earlier, already has is numbered "Sky 2"; a name without a newline is kept, and when another swatch has it, the pattern's swatch, or a named color sharing a gradient or pattern swatch's name, is numbered the same way), opacity, blend modes, isolation and knockout, embedded images where their matrix puts them, rotated ones too (#2269), with their alpha channel (CMYK images keep their ink amounts, as they do when a `.ai` opens from its PDF part, and an alpha channel that hides part of a CMYK image becomes a grayscale opacity mask), placed (linked) files as linked images in their place, each showing the low-resolution preview the file keeps of it until its file is found or relinked in the Links panel (#1264), with the folder the file keeps relative to the document's, where the link is looked for when its path is gone, placed PDF and `.ai` pages as placed documents of the [page and Crop to box](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-other-file-types/adobe-pdf-placement-options.html) their dictionary names (`AI11 PlacedPDFPageIndex`, `AI11 PlacedPDFCropTo`; a value VectorCraft doesn't read, or a binding to an image variable, leaves a linked image), guides, and every artboard where it is, with its center mark, cross hairs, video safe areas and video ruler pixel aspect ratio. VectorCraft reads `CropAreaActive`, an `/Int` in the dictionary that holds the artboard array, as the index of the active artboard in that array, and the file opens with that artboard active; without it, or when it names no artboard that opens, the first artboard is active. It also reads the Document Raster Effects Settings (resolution, color model, background, anti-alias, clipping mask, Add Around Object and Preserve Spot Colors), the author from the header's `%%For` (an EPS's own header when the editing data's has none), swatches for the header's `%%CMYKCustomColor` and `%%RGBCustomColor` colors that the document has none of, and `%%TemplateBox` in older files; a setting with a value of another type or out of range keeps its default. Objects on Path groups open live, with their path, their objects in order along it, Pivot and Rotate; one with a dragged spacing or other options opens as a plain group. A gradient with stops in the middle runs its whole ramp across its shape, and a gradient object does not pass its fill to the next path (#1390). An object whose art style is one fill and one stroke at most (solid colours, its own gradient, a variable-width profile on a Stroke Offset stroke or written as each side's widths) with Drop Shadow, Inner Glow, Outer Glow, Feather, Round Corners, Scribble, Offset Path, Outline Object, Outline Stroke, Convert to Shape, Tweak (only when it moves nothing), Pucker & Bloat at 0 or Bas Relief (read from its settings block: [raster effects reference](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/apply-filter-effects/raster-effects-reference.html), [Photoshop File Formats Specification](https://www.adobe.com/devnet-apps/photoshop/fileformatashtml/), [scripting the filter gallery](https://community.adobe.com/questions-712/scripting-support-for-the-filter-gallery-1064646)) comes in as itself with them and their saved settings. A path, compound path or group (not a clipping group) whose only effect is Transform (not with copies or Random) or a Free Distort whose corners make a parallelogram comes in as itself with it too, when neither it nor anything in it paints with a gradient or pattern and everything in it is a path, compound path or group with no opacity mask and no effects of its own; Transform that scales, rotates or reflects needs nothing in it to be stroked. Twist as the only effect is read the same way when nothing in the object is stroked: up to 180° either way (a limit VectorCraft sets) on a path or compound path whose segments are all straight, and up to 90° either way (a limit VectorCraft sets) on another path, compound path or group with no guide in it. One with more, other effects (Zig Zag, a Pucker & Bloat of another amount, a Free Distort with other corners), an effect setting that is not read (an unknown key, a missing or out-of-range value, a Scribble with a color of its own), a variable-width stroke with one centered width array, dashes aligned to corners, a brush other than a Calligraphic or Art one, a Calligraphic brush with settings of its own, an entry that isn't read, a variable width or an angle that follows the path, a path followed by samples of the pen (`(…) Xt n XD`) whose Calligraphic brush varies with the pen, or an Art brush other than the ones described next comes in as its drawn look (a group named after it). Objects in a symbol defined before the file's art styles section, as newer files write it, take the same styles as the layers' objects. A path with a Calligraphic brush otherwise comes in as the path, the brush on its stroke at the stroke's weight, which scales the brush (#372), and so does a path with an Art brush, whose weight scales the art across the path, when all of these hold: the brush stretches its art along the path, unflipped, at 100% in Tints; the path's settings are the brush's own, with no entry that isn't read, no variable width and no effects; its stroke isn't a swatch; and the art is paths, compound paths and groups in solid fills, with no strokes, masks or effects, and has some length along the path. A stroke takes the brush the Brushes panel keeps under its name, and one whose name the panel doesn't keep comes in as its drawn look. Type with an Art brush keeps its drawn look under the type. A Calligraphic brush's Pressure, Tilt, Bearing and Rotation come in as those channels (a 6D Art Pen's brushes vary with the pressure, the bearing and the barrel's rotation); its Stylus Wheel varies at random. The file's Calligraphic, Scatter, Art and Bristle brushes replace the default ones in the Brushes panel, in the file's order, also when the file comes in as its PDF part (a brush library has no layers); pattern brushes and brushes it can't read are left out with a note. When the file opens from its layers, the spot colors in the art of each brush that comes in become swatches, and that art's colors count toward the document's color mode, as a pattern's do. The swatches take at most 20,000 color names in all across the brush art, and each brush-art section keeps at most 20,000 names. Each name keeps its first definition, with the color operators' names before the gradient stops' names. A spot color past those limits makes no swatch, and its color still counts toward the color mode. A spot color that the page's art, a pattern or a symbol also defines keeps the value defined there. Type keeps its art style as a live appearance whatever its stack (an Art brush aside), so it can be retyped: each fill and stroke of the style's stack (solid colours, gradients and pattern fills, placed as the drawn look places them) with its own opacity, blend mode and effects, the effects on the whole object, and where the characters paint among them; the effects read are Warp, Offset Path, Outline Object, Outline Stroke, Transform (with copies, Transform Objects, Transform Patterns and Scale Strokes & Effects; not with Random), Free Distort, Pucker & Bloat, Twist, Zig Zag, Tweak (only when it moves nothing, the file holding none of its random outline), Drop Shadow, Inner Glow, Outer Glow, Feather, Round Corners, Scribble, Gaussian Blur, Bas Relief (its detail, smoothness and light direction from its settings block, or the effect's defaults when the style holds no settings block; a settings block that isn't read keeps the drawn look) and Convert to Shape, and a style with others, or with an effect setting that isn't read, keeps the type's drawn look. Convert to Shape keeps its Rectangle, Rounded Rectangle or Ellipse, its Absolute or Relative size (a relative size in the file is added to each side) and its corner radius; a relative Ellipse, or a setting that isn't read, keeps the drawn look. The page's drawing of such a style isn't held to look like VectorCraft's where its drawn look lay. Gradients take their matrix (`Xm`, radials and skewed ones too), focal point and the order of stops sharing a ramp point; gradient meshes, a clipping path's own fill and its stroke, and the artboards' names are read too. `editingData: "always"` (`convert --editing-data`) opens a `.ai` or an Illustrator EPS from its editing data even where it draws differently from its page, which can be older, with a note. Type is made from the file's text document, whole and editable, shown or not: point type (its frame's matrix, which newer files leave out when it is neither turned nor scaled, read as none), area type (a story in several frames as threaded type) and type on a path, with its characters, fonts, size, leading, tracking, scaling, baseline shift, fill and stroke (grey, RGB or CMYK), alignment, indents and paragraph spacing (a character attribute a run doesn't set comes from its character style, then the style that one is based on, then the document's defaults); area type keeps its frame's Area Type Options rows and columns, the gutter between rows and the gutter between columns, and its first baseline (Fixed, Cap Height, Leading or x Height) with its minimum; type on a path keeps its frame's Type on a Path effect, Align to Path and Flip (a frame whose options set key 6 to true keeps their defaults), and the first frame's Spacing is fitted from the file's layout, not read from the dialog's value; the distance from the path under Align to Path is measured for each character at its size and vertical scale (in vertical type, its horizontal scale), from the top of its font's em box (Ascender), half the height of the top of its font's H (Center) or the bottom of its font's bounding box (Descender); the fit under Gravity does not reproduce the file's layout, and its glyphs can lie up to 7.4 pt from the positions the file keeps; the page's drawing of it (often in pieces) is left out. Vertical type keeps its orientation, its columns from right to left, and a run set to Tate-chu-yoko keeps that setting. When it makes the type of every text object that shows, the page's type is only compared with it, each text object keeps its own group, frame and layer, and a line break inside a paragraph stays one. Where it can't make a text object's type (a frame of another kind), that text object takes the page's type where the text document puts its lines, or else what is left of the page's type in painting order (no group around it); the page's type where made type draws stays that type's, and hidden type is left out with a note. Text wrap is read too: an object whose dictionary has the wrap options (offset and Invert Wrap), or any graphic of a legacy wraparound group (`*w` … `*W`, before or after its type, with no offset), is a wrap object, and area type below it in its layer flows around it when the file opens, threaded type included (#2763). Kerning, underline and the other character and paragraph options aren't read yet. A `.ai` saved without PDF compatibility (a placeholder page) opens from its editing data alone, its point type, area type and type on a path made from the text document. A `.ai` whose PDF part shows only text isn't taken for that placeholder when its page states an art, trim or bleed box: it opens from its editing data alone where that reads, else from its PDF part (#1387). A `.ai` whose PDF part draws nothing at all (an empty page, with or without those boxes) opens from its editing data alone where that reads too: there is no page art to check its layers against, and the empty page would lose all of it. Text objects with an appearance keep their own text and frame, type of hidden layers stays hidden, and type on later artboards lands on its text objects (#1391); area type whose frame is too short for a line of the fallback font shows its first line (the frame is made taller, with a warning in the open result) (#1392). In a PDF saved with some of its artboards, the type on each page after the first goes to an artboard of that page's size after the previous page's artboard, and only to one that leaves an artboard for each later page; the first page's artboard also leaves one for each later page. When several artboards fit a later page, VectorCraft takes the one whose art draws most like the page, and compares at most 16 artboards for all the later pages together. Symbols are read into the Symbols panel, in the file's symbol list order, with their art, their registration point and the instances in their art, and their instances come in live with their matrix, name, hide, lock, opacity, blending mode, isolation, knockout and opacity mask; a symbol whose art isn't read whole (type, placed files, an image it leaves out or anything else it doesn't read) isn't kept. A file that comes in as its page or PDF part because its editing data has no layers (a symbol library), or because its layers can't be read or used (any of the cases below), gets the symbols its editing data defines before its first layer, in the symbol list's order, while its page art stays as the page draws it. Instances of symbols it can't read, instances with appearance changes of their own (a dynamic symbol's), pattern fills whose pattern it can't read, placed files the data keeps no preview of and anything else it doesn't read make the file come in as its page (on a layer that doesn't show, they are left out of that layer), with a warning saying what. An unread object on a shown layer whose box can be found instead comes in as a group of the page's objects inside that box, named after it, with the rest of the layers and groups kept and a warning listing what came in as the page's art; the file still comes in as its page when live art or another unread object shares that page art, when the object spans two artboards or lies on an artboard that has no page, when no page art lies inside its box, when that page art is inside a page group with a clip, mask, transparency or appearance, when the object holds a frame of threaded type, when the page art uses a pattern, image or swatch that the page lacks or that differs from the editing data's, or when the page art doesn't carry its transparency (#4806). The layers' art is also compared with the page (by lightness, so colours written as their CMYK equivalents compare alike, and by whether a pixel is inked at all); the page is used when they differ by more than 5% (away from type, when all the type is made from the text document), where one draws an object the other doesn't (away from type, whose lines may be laid out afresh), and when an EPS whose page is its art's box has art printed outside it (#735). A `.ai` is not compared with its page, and its PDF part is not imported, when its text document makes the type of every text object (at least one shows, and none is drawn by the appearance of the layer or group it is in), no object is unread, no placed file has a second placement, no live envelope keeps its drawn art, it declares no large canvas, and its artboards are its pages' trim boxes one for one, in points or in the first page's `UserUnit`: it opens from its layers, with the bleed of its pages' bleed boxes. When they differ because some objects draw differently (an object in another color, or one that only one of them draws), each top-level object of the layers that holds such a difference comes in as a group of the page's objects inside its box and the layers stay, with a warning that names the layer or sublayer of each such object as the Layers panel shows it (`` for one without a name) and how many came in from it; an export or Save As to the file's own path then needs `acknowledgeLoss: true`, and a wrap object replaced this way keeps its wrap options. The file still comes in as its page when only edges or type differ, when a difference lies outside every top-level object, when more than half of the top-level objects or more than 64 hold one, when such an object is or holds type or holds a wrap object inside a group, when the page's type of a text object that stays lies inside such an object's box, when the page's art can't replace such an object for one of the reasons above for an unread object, when matching the differences to the objects would take too much work, or when the result still differs from the page. `editingData: "always"` keeps the objects as read, and placed files at the other point their data gives are tried as well. An EPS whose page is its art's box keeps that page when it comes in through its layers, not the editing data's artboard, and a text object counts as drawn by the page by its colours, not only its lightness, so a red stroke stacked over a dark red one stays (#1102). `textAs: "outlines"` opens a `.ai` whose type shows from its PDF part, which has the outlines; `editingData: false` opens any of them as its page or PDF part only, for print pipelines (#735). A file whose import left something out (hidden text, art or layers) is never written over by an export or Save As to its own path unless `acknowledgeLoss: true` (`convert --replace-lossy`), so the original keeps what the document lacks. Where a `.ai` can't be read that way (or its layers are turned off in the import options), we read its PDF-compatible part, so Illustrator-only live objects arrive as appearance, and plain groups arrive ungrouped: that part draws each object on its own and marks only layers, clipping groups and groups with opacity, blending or a mask (those come back). Art outside the artboards isn't in that part at all (Illustrator's PDF part leaves it out), so it doesn't open; the import says so in a note (#472). Its pages still go where the editing data puts the artboards (a grid stays a grid), with the art on each, when it has as many artboards as pages, of the same sizes (#1068); the page of the artboard `CropAreaActive` names is then the active artboard. A `.ai` whose editing data has artboards but no layers also opens on that page under the same check, and its pages stay where they are. A `.ai` whose PDF part's pages are cropped to its art (each page the box of all the art, which is the editing data's bounding box) instead of its artboards opens from its layers, with its own artboards, where they draw as that page does. Its pages are laid out so that art one of them draws past its artboard (notes beside a design, which the part doesn't clip) doesn't lie over the page before it in the row, where it was taken for that page's art: the check against the editing data then found art its layers don't have there and opened the file as its PDF part, without the art outside the artboards. That part also has no paragraphs: area type is written line by line, and comes back as area type only where its font is installed and lays the lines out with the same breaks, else as a point type object per line (#508). Art off the page that a PDF does draw opens on the pasteboard. A run of type in the editing data whose baseline direction is 1 opens with Standard Vertical Roman Alignment (https://helpx.adobe.com/illustrator/using/formatting-asian-characters.html) on, which is VectorCraft's own mapping: its half-width characters stand upright in vertical type, and horizontal type keeps the mark with no change to its layout. A run whose baseline direction is 2 or 3 (Tate-chu-yoko), or that names none in the run, its character style or the document's defaults, opens with it off. The scripting reference lists 1, 2 and 3 as the Standard, vertical rotated and Tate-chu-yoko baseline directions (https://web.archive.org/web/20170621180804/https://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2015_3/Illustrator%20VBScript%20Reference.pdf, page 256). A Scatter brush in the editing data whose last 15 numbers start with 1 comes into the Brushes panel in Tints. Each brush art section is read without its frame: an unnamed, unpainted rectangle with no settings of its own at the art's bounds (within 1/1000 pt), closed, or open with its first corner again at the end. A wider frame stays in the art, and an art group with a state or look of its own (hidden, locked, isolated, knockout, an opacity, a blend mode, a name, a mask, a note or an appearance) stays a group. diff --git a/docs/gaps.md b/docs/gaps.md index 201823b983..a3f2482950 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -217,6 +217,11 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi stroke. Other Art brushes (None or another colorization, another width, Proportional, between guides, flipped, art with strokes, gradients or patterns) and type with an Art brush keep the drawn look. +- **Done (2026-11-14):** Calligraphic paths whose brush filter holds an entry that isn't read or a variable width + keep their drawn look. So do paths followed by samples of the pen (`(…) Xt n XD`) whose Calligraphic brush varies + with the pen; such a path no longer also comes in beside its look, unpainted. Synthetic importer regressions; + scores unchanged. + - **Done (2026-11-12):** Explicitly requested editing data retains a single artboard larger than a capped 14,400 pt PDF page (#6865); the default import and other size mismatches remain unchanged. Synthetic importer regression; scores unchanged. - **Missing:** faithful layer and group structure from the editing data in real files (#951: 109 layers instead of 14), open speed on large files (#758), live effects, Scatter, Pattern and Bristle brushes on paths, the Art From 1f6332c0a4cda24ae9887ec3e3a2b79bba21d83e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:17:21 -0800 Subject: [PATCH 011/108] Live Paint: Expand keeps the faces and edges that draw Expand kept a face only when its topmost fill had paint, and an edge only when its topmost stroke had paint and a weight. A face or edge drawn by a lower row under an unpainted top row was removed, and one whose only painted row was hidden was kept as a visible path. Expand now keeps a face or edge when it is shown, its opacity is above 0, and any fill or stroke row is shown, has paint and an opacity above 0 (a stroke also a weight above 0), with all of its rows. The rows are checked with the new Appearance::has_drawn_fill and has_drawn_stroke. Merge carried a face's topmost fill paint by the same topmost-row test. It now carries every row of each face that draws by this rule, and of each edge, pins their unplaced gradients to the old outline as repaint_from does, and leaves the strokes' pen pressure, tilt, bearing and rotation behind, since the rebuilt parts are other paths. Docs: livePaint.expand params text, docs/mcp.md, and a line in docs/target-app-parity.md, which also drops a repeated Live Paint Selection marquee line. --- crates/doc/src/appearance.rs | 10 ++ crates/doc/src/appearance/tests.rs | 22 +++ crates/engine/src/cmd/buildcmds.rs | 2 +- crates/engine/src/cmd/buildcmds/live_paint.rs | 45 +++-- crates/engine/src/tests/build.rs | 158 ++++++++++++++++++ docs/mcp.md | 6 + docs/target-app-parity.md | 2 +- 7 files changed, 229 insertions(+), 16 deletions(-) diff --git a/crates/doc/src/appearance.rs b/crates/doc/src/appearance.rs index ba0f5fc013..3bfba32f6a 100644 --- a/crates/doc/src/appearance.rs +++ b/crates/doc/src/appearance.rs @@ -271,6 +271,16 @@ impl Appearance { _ => None, }) } + /// Does any fill draw: one that is shown, has paint and has an opacity above 0, wherever it + /// sits in the stack? + pub fn has_drawn_fill(&self) -> bool { + self.items.iter().any(|i| matches!(i, AppearanceItem::Fill(f) if f.visible && !f.paint.is_none() && f.opacity > 0.0)) + } + /// Does any stroke draw: one that is shown, has paint, a weight above 0 and an opacity above + /// 0, wherever it sits in the stack? + pub fn has_drawn_stroke(&self) -> bool { + self.painted_strokes().any(|s| s.width > 0.0 && s.opacity > 0.0) + } /// Largest distance the painted area can extend beyond any geometry (see /// [`StrokeLayer::reach`]); paths measure their own with [`Self::stroked_bounds`]. pub fn outset(&self) -> f64 { diff --git a/crates/doc/src/appearance/tests.rs b/crates/doc/src/appearance/tests.rs index 22e5659051..cb5f8fed66 100644 --- a/crates/doc/src/appearance/tests.rs +++ b/crates/doc/src/appearance/tests.rs @@ -79,6 +79,28 @@ fn basic_means_one_plain_fill_and_stroke() { assert!(!e.is_basic(), "an effect"); } +#[test] +fn drawn_fills_and_strokes_count_every_row() { + let fill = |p: Paint| AppearanceItem::Fill(FillLayer::new(p)); + let stroke = |p: Paint, w: f64| AppearanceItem::Stroke(StrokeLayer::new(p, w)); + let black = || Paint::solid(Color::BLACK); + assert!(!Appearance::default().has_drawn_fill() && !Appearance::default().has_drawn_stroke()); + // A painted lower row draws under an unpainted top row. + let a = Appearance { items: vec![fill(black()), stroke(black(), 2.0), fill(Paint::None), stroke(Paint::None, 1.0)], ..Appearance::default() }; + assert!(a.has_drawn_fill() && a.has_drawn_stroke()); + // A hidden painted row, a zero opacity or a zero weight draws nothing. + let mut b = Appearance { items: vec![fill(black()), stroke(black(), 2.0)], ..Appearance::default() }; + b.fill_mut().unwrap().visible = false; + b.stroke_mut().unwrap().visible = false; + assert!(!b.has_drawn_fill() && !b.has_drawn_stroke()); + let mut c = Appearance::default_art(); + c.fill_mut().unwrap().opacity = 0.0; + c.stroke_mut().unwrap().opacity = 0.0; + assert!(!c.has_drawn_fill() && !c.has_drawn_stroke()); + let d = Appearance::basic(Paint::None, black(), 0.0); + assert!(!d.has_drawn_fill() && !d.has_drawn_stroke()); +} + #[test] fn set_creates_missing() { let mut a = Appearance::default(); diff --git a/crates/engine/src/cmd/buildcmds.rs b/crates/engine/src/cmd/buildcmds.rs index 3fc5953619..06ec06e348 100644 --- a/crates/engine/src/cmd/buildcmds.rs +++ b/crates/engine/src/cmd/buildcmds.rs @@ -99,7 +99,7 @@ pub fn specs() -> Vec { "Expand", ["Object", "Live Paint"], None, - "{id?, ids?: [id…] (instead of id)} turn Live Paint groups into plain groups of their painted faces and edges → {ids}", + "{id?, ids?: [id…] (instead of id)} turn Live Paint groups into plain groups of the faces and edges that draw, with all their fill and stroke rows: a shown face or edge with an opacity above 0 and a shown fill or stroke row that has paint and an opacity above 0 (a stroke also a weight above 0), whichever row is on top → {ids}", has_selection_or_ids, lp_expand ), diff --git a/crates/engine/src/cmd/buildcmds/live_paint.rs b/crates/engine/src/cmd/buildcmds/live_paint.rs index fb9e6c32ac..04c6a3fb1b 100644 --- a/crates/engine/src/cmd/buildcmds/live_paint.rs +++ b/crates/engine/src/cmd/buildcmds/live_paint.rs @@ -1,7 +1,7 @@ use super::{ - Appearance, Arc, Beside, Document, EDGE_NAME, EngineError, FACE_NAME, GapOptions, GapSize, LIVE_PAINT_NAME, Node, NodeId, Paint, PathData, Point, - Rect, Result, SOURCES_NAME, Selection, Session, SubPath, Value, b, bad, build_children, edge_near, face_at, finite, ids_json, is_live_paint, - json, number_or, object_param, paint_from, po, point_param, repaint_from, replace_roots, root_ids, source_nodes, source_shapes, switch_or, + Appearance, Arc, Beside, Document, EDGE_NAME, EngineError, FACE_NAME, GapOptions, GapSize, LIVE_PAINT_NAME, Node, NodeId, PathData, Point, Rect, + Result, SOURCES_NAME, Selection, Session, SubPath, Value, b, bad, build_children, edge_near, face_at, finite, ids_json, is_live_paint, json, + number_or, object_param, paint_from, po, point_param, repaint_from, replace_roots, root_ids, source_nodes, source_shapes, switch_or, }; /// `options` as stored on a Live Paint group: none for the defaults. @@ -84,6 +84,19 @@ pub(super) fn lp_make(s: &mut Session, p: &Value) -> Result { Ok(json!({ "id": id.0, "faces": faces, "edges": edges })) } +/// The appearance of face or edge `n` for the part Merge makes again in its place, another path: +/// gradients fitted to `n`'s outline keep that fit, and the strokes' pen pressure, tilt, bearing +/// and rotation stay behind. +fn carried_appearance(n: &Node) -> Appearance { + let mut app = (*n.appearance).clone().without_pressure(); + if app.has_unplaced_gradient() + && let Some(bounds) = n.geometric_bounds() + { + app.pin_gradients(bounds); + } + app +} + /// Add the other `roots` (back → front) to the first Live Paint group among them, which keeps its /// id, the paint of its faces and edges, and its own properties apart from the Gap Options, which /// are merged; returns (group, faces, edges). @@ -95,18 +108,16 @@ fn merge_live(d: &mut Document, sel: &mut Selection, roots: &[NodeId]) -> Result .ok_or_else(|| EngineError::Other("Live Paint Merge: select a Live Paint group and the paths to add".into()))?; check_live_paint_takes(d, roots)?; let old = d.node(target).cloned().ok_or(EngineError::NoNode(target))?; - // Paint to carry over: (point inside face, fill) and (point on edge, stroke). - let keep_faces: Vec<(Point, Paint)> = b::faces(&old) - .iter() - .filter(|f| !f.appearance.fill_paint().is_none()) - .filter_map(|f| Some((po::interior_point(f.path_data()?)?, f.appearance.fill_paint()))) - .collect(); + // Paint to carry over: (point inside face, appearance) for faces that draw, and (point on + // edge, appearance) for every edge. + let keep_faces: Vec<(Point, Appearance)> = + b::faces(&old).iter().filter(|f| draws(f)).filter_map(|f| Some((po::interior_point(f.path_data()?)?, carried_appearance(f)))).collect(); let keep_edges: Vec<(Point, Appearance)> = b::edges(&old) .iter() .filter_map(|e| { let pd = e.path_data()?; let sp = pd.subpaths.first().filter(|sp| sp.segment_count() > 0)?; - Some((kurbo::ParamCurve::eval(&sp.segment(0), 0.5), (*e.appearance).clone())) + Some((kurbo::ParamCurve::eval(&sp.segment(0), 0.5), carried_appearance(e))) }) .collect(); let mut sources = source_nodes(&old); @@ -126,12 +137,12 @@ fn merge_live(d: &mut Document, sel: &mut Selection, roots: &[NodeId]) -> Result *ch = children; } g.extras_mut().live_paint_gaps = stored_gap_options(options); - for (pt, paint) in keep_faces { + for (pt, app) in keep_faces { if let Some(fid) = face_at(&g, pt).map(|f| f.id) && let Some(ch) = g.children_mut() && let Some(f) = ch.iter_mut().find(|c| c.id == fid) { - Arc::make_mut(f).appearance.set_fill(paint); + Arc::make_mut(f).appearance = app.into(); } } for (pt, app) in keep_edges { @@ -191,6 +202,13 @@ pub(super) fn lp_release(s: &mut Session, p: &Value) -> Result { Ok(json!({ "ids": ids_json(&ids) })) } +/// Does face or edge `n` draw on the canvas: it is shown, its opacity is above 0, and a fill or +/// stroke row of its appearance draws (see [`Appearance::has_drawn_fill`] and +/// [`Appearance::has_drawn_stroke`])? +fn draws(n: &Node) -> bool { + n.visible && n.opacity > 0.0 && (n.appearance.has_drawn_fill() || n.appearance.has_drawn_stroke()) +} + pub(super) fn lp_expand(s: &mut Session, p: &Value) -> Result { let targets = live_targets(s, p)?; s.edit("Expand Live Paint", |d, sel| { @@ -205,8 +223,7 @@ pub(super) fn lp_expand(s: &mut Session, p: &Value) -> Result { if let Some(ch) = n.children_mut() { ch.retain(|c| match c.name.as_deref() { Some(SOURCES_NAME) => false, - Some(FACE_NAME) => !c.appearance.fill_paint().is_none(), - Some(EDGE_NAME) => !c.appearance.stroke_paint().is_none() && c.appearance.stroke_width() > 0.0, + Some(FACE_NAME | EDGE_NAME) => draws(c), _ => true, }); } diff --git a/crates/engine/src/tests/build.rs b/crates/engine/src/tests/build.rs index 1c3ad5d8b4..0e6bf5ad8d 100644 --- a/crates/engine/src/tests/build.rs +++ b/crates/engine/src/tests/build.rs @@ -2947,6 +2947,164 @@ fn live_paint_release_and_expand() { assert!((area(&s, a) - 10000.0).abs() < 1.0); } +/// Set the appearance rows of the face of Live Paint group `g` at `face` (or the edge nearest +/// `edge`) to `items`, and give it `opacity`; returns that child's id. +fn set_live_part(s: &mut Session, g: NodeId, face: Option<(f64, f64)>, edge: Option<(f64, f64)>, items: Vec, opacity: f32) -> NodeId { + use vectorcraft_tools::builder::{edge_near, face_at}; + let n = node(s, g); + let part = match (face, edge) { + (Some((x, y)), _) => face_at(&n, Point::new(x, y)), + (_, Some((x, y))) => edge_near(&n, Point::new(x, y), 0.5), + _ => None, + }; + let id = part.unwrap().id; + s.edit("t", |d, _| { + let c = d.node_mut(id).unwrap(); + c.appearance.items = items; + c.opacity = opacity; + Ok(()) + }) + .unwrap(); + id +} + +/// Expand keeps a face or edge when a fill or stroke row draws it, whatever row is on top: a +/// painted lower row under an unpainted top row is kept, and a part whose only painted row is +/// hidden, transparent or 0 pt wide, or whose own opacity is 0, is dropped. +#[test] +fn live_paint_expand_keeps_the_faces_and_edges_that_draw() { + use vectorcraft_doc::{FillLayer, StrokeLayer}; + let fill = |p: Paint| AppearanceItem::Fill(FillLayer::new(p)); + let stroke = |p: Paint, w: f64| AppearanceItem::Stroke(StrokeLayer::new(p, w)); + let red = || Paint::solid(Color::rgb(1.0, 0.0, 0.0)); + let hidden = |mut i: AppearanceItem| { + match &mut i { + AppearanceItem::Fill(f) => f.visible = false, + AppearanceItem::Stroke(st) => st.visible = false, + } + i + }; + let clear = |mut i: AppearanceItem| { + match &mut i { + AppearanceItem::Fill(f) => f.opacity = 0.0, + AppearanceItem::Stroke(st) => st.opacity = 0.0, + } + i + }; + let mut s = session(); + let g = live(&mut s); + let lower_fill = set_live_part(&mut s, g, Some((25.0, 50.0)), None, vec![fill(red()), fill(Paint::None)], 1.0); + let hidden_fill = set_live_part(&mut s, g, Some((125.0, 50.0)), None, vec![hidden(fill(red()))], 1.0); + let clear_fill = set_live_part(&mut s, g, Some((75.0, 50.0)), None, vec![clear(fill(red()))], 1.0); + let lower_stroke = set_live_part(&mut s, g, None, Some((0.0, 50.0)), vec![stroke(red(), 2.0), stroke(Paint::None, 1.0)], 1.0); + let hidden_stroke = set_live_part(&mut s, g, None, Some((150.0, 50.0)), vec![hidden(stroke(red(), 2.0))], 1.0); + let thin_stroke = set_live_part(&mut s, g, None, Some((100.0, 50.0)), vec![stroke(red(), 0.0)], 1.0); + let clear_stroke = set_live_part(&mut s, g, None, Some((50.0, 50.0)), vec![clear(stroke(red(), 2.0))], 1.0); + let clear_edge = set_live_part(&mut s, g, None, Some((75.0, 0.0)), vec![stroke(red(), 2.0)], 0.0); + let parts = [lower_fill, hidden_fill, clear_fill, lower_stroke, hidden_stroke, thin_stroke, clear_stroke, clear_edge]; + assert_eq!(parts.iter().collect::>().len(), parts.len()); + let before = node(&s, g); + s.execute("livePaint.expand", &json!({})).unwrap(); + let n = node(&s, g); + let kept: Vec = n.children().unwrap().iter().map(|c| c.id).collect(); + let has = |id: NodeId| kept.contains(&id); + assert!(has(lower_fill) && has(lower_stroke), "a painted lower row draws: {kept:?}"); + for id in [hidden_fill, clear_fill, hidden_stroke, thin_stroke, clear_stroke, clear_edge] { + assert!(!has(id), "{id:?} draws nothing: {kept:?}"); + } + // The kept parts keep every row. + let rows = |n: &Node, id: NodeId| n.children().unwrap().iter().find(|c| c.id == id).unwrap().appearance.items.clone(); + assert_eq!(rows(&n, lower_fill), rows(&before, lower_fill)); + assert_eq!(rows(&n, lower_stroke), rows(&before, lower_stroke)); +} + +/// Merge carries a face's whole appearance when one of its rows draws, and carries nothing from a +/// face that draws nothing. +#[test] +fn live_paint_merge_carries_the_faces_that_draw() { + use vectorcraft_doc::FillLayer; + use vectorcraft_tools::builder::face_at; + let fill = |p: Paint| AppearanceItem::Fill(FillLayer::new(p)); + let green = || Paint::solid(Color::rgb(0.0, 1.0, 0.0)); + let mut s = session(); + let g = live(&mut s); + let rows = vec![fill(green()), fill(Paint::None)]; + set_live_part(&mut s, g, Some((25.0, 50.0)), None, rows.clone(), 1.0); + let mut only_hidden = fill(green()); + if let AppearanceItem::Fill(f) = &mut only_hidden { + f.visible = false; + } + set_live_part(&mut s, g, Some((125.0, 50.0)), None, vec![only_hidden], 1.0); + let c = rect(&mut s, 120.0, 120.0, 100.0, 20.0); + s.execute("livePaint.merge", &json!({"ids": [g.0, c.0]})).unwrap(); + let n = node(&s, g); + assert_eq!(face_at(&n, Point::new(25.0, 50.0)).unwrap().appearance.items, rows, "the drawn lower fill is carried"); + let b = face_at(&n, Point::new(125.0, 50.0)).unwrap(); + assert_eq!(b.appearance.fill_paint(), Paint::solid(Color::rgb(0.0, 0.0, 1.0)), "the face takes its source's fill again"); + assert!(b.appearance.has_drawn_fill()); +} + +/// Merge rebuilds the faces and edges as other paths, so the appearance it carries to them leaves +/// the strokes' pen pressure behind and keeps the rest. +#[test] +fn live_paint_merge_leaves_pen_pressure_behind() { + use vectorcraft_doc::{FillLayer, PressureProfile, StrokeLayer}; + use vectorcraft_tools::builder::{edge_near, face_at}; + let pressed = || { + let mut st = StrokeLayer::new(Paint::solid(Color::BLACK), 3.0); + st.pressure = PressureProfile::from_samples([(0.0, 0.2), (0.5, 1.0), (1.0, 0.2)]); + assert!(st.pressure.is_some()); + st + }; + let green = AppearanceItem::Fill(FillLayer::new(Paint::solid(Color::rgb(0.0, 1.0, 0.0)))); + let mut s = session(); + let g = live(&mut s); + set_live_part(&mut s, g, Some((75.0, 50.0)), None, vec![green.clone(), AppearanceItem::Stroke(pressed())], 1.0); + set_live_part(&mut s, g, None, Some((0.0, 50.0)), vec![AppearanceItem::Stroke(pressed())], 1.0); + let c = rect(&mut s, 120.0, 120.0, 100.0, 20.0); + s.execute("livePaint.merge", &json!({"ids": [g.0, c.0]})).unwrap(); + let n = node(&s, g); + let mut plain = pressed(); + plain.pressure = None; + let face = &face_at(&n, Point::new(75.0, 50.0)).unwrap().appearance.items; + assert_eq!(face, &vec![green, AppearanceItem::Stroke(plain.clone())]); + assert_eq!(edge_near(&n, Point::new(0.0, 50.0), 0.5).unwrap().appearance.items, vec![AppearanceItem::Stroke(plain)]); +} + +/// The gradients Merge carries to the rebuilt faces and edges keep their fit on the old outline, +/// lower rows included. +#[test] +fn live_paint_merge_keeps_the_fit_of_carried_gradients() { + use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop}; + use vectorcraft_doc::{FillLayer, StrokeLayer}; + use vectorcraft_tools::builder::{edge_near, face_at}; + let stops = vec![GradientStop::new(0.0, Color::BLACK), GradientStop::new(1.0, Color::WHITE)]; + let unplaced = GradientPaint::new(Gradient::new(GradientKind::Linear, stops)); + let gradient = || Paint::Gradient(Box::new(unplaced.clone())); + let mut s = session(); + let g = live(&mut s); + let rows = vec![AppearanceItem::Fill(FillLayer::new(gradient())), AppearanceItem::Fill(FillLayer::new(Paint::None))]; + let face = set_live_part(&mut s, g, Some((25.0, 50.0)), None, rows, 1.0); + let edge = set_live_part(&mut s, g, None, Some((0.0, 50.0)), vec![AppearanceItem::Stroke(StrokeLayer::new(gradient(), 2.0))], 1.0); + let before = node(&s, g); + let old = |id: NodeId| before.children().unwrap().iter().find(|c| c.id == id).unwrap().clone(); + let (old_face, old_edge) = (old(face), old(edge)); + let c = rect(&mut s, 120.0, 120.0, 100.0, 20.0); + s.execute("livePaint.merge", &json!({"ids": [g.0, c.0]})).unwrap(); + let n = node(&s, g); + let geom = |items: &[AppearanceItem]| match items[0].paint() { + Paint::Gradient(gp) => gp.geom, + p => panic!("a gradient, not {p:?}"), + }; + let face_bounds = old_face.geometric_bounds().unwrap(); + let new_face = face_at(&n, Point::new(25.0, 50.0)).unwrap(); + assert_eq!(geom(&new_face.appearance.items), Some(unplaced.resolve(face_bounds)), "the lower-row fill keeps its fit"); + let AppearanceItem::Stroke(st) = &old_edge.appearance.items[0] else { panic!("a stroke") }; + let edge_box = st.paint_bounds(old_edge.geometric_bounds().unwrap()); + let new_edge = edge_near(&n, Point::new(0.0, 50.0), 0.5).unwrap(); + assert_eq!(geom(&new_edge.appearance.items), Some(unplaced.resolve(edge_box)), "the stroke keeps its fit"); +} + fn live_group_only(s: &mut Session) -> NodeId { let r = s.execute("livePaint.make", &json!({})).unwrap(); NodeId(r["id"].as_u64().unwrap()) diff --git a/docs/mcp.md b/docs/mcp.md index 84c75a81d0..beecd227f5 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3486,6 +3486,12 @@ already walks Image Trace. Short agent entry points: `livePaint.info {group}`, `livePaint.release`, `livePaint.expand`, and `livePaint.gapOptions {ids?, detect?, size?, color?, closeGaps?}` (Object › Live Paint › Gap Options). Make gives each covered face the fill of its front-most covering source, including compound paths with shared curved boundaries. Expand keeps those face fills. + `livePaint.expand` keeps each face and edge that draws, with all its fill and stroke rows: it is shown, its opacity + is above 0, and a fill or stroke row is shown, has paint and an opacity above 0 (a stroke also a weight above 0), + whichever row is on top. A painted lower row under an unpainted top row keeps the part; a part whose only painted + row is hidden is removed. `livePaint.merge` copies the fill and stroke rows of each face that draws by this rule, and + of each edge, to the rebuilt parts, with their gradients kept at their fit on the old outline and without the + strokes' pen pressure, tilt, bearing and rotation. With `detect: true`, paint stops at the gaps that run from a loose end of a path to the nearest path, up to `size` wide (`small` 3 pt, `medium` 6 pt, `large` 12 pt, or a number of points up to 72); `closeGaps: true` adds an unpainted path across each of them. `color` (the Gap Preview diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..3ab2127e30 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1447,6 +1447,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Double-clicking the Live Paint Bucket opens Live Paint Bucket Options ([Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html)): Paint Fills (on) and Paint Strokes (off) set whether a click paints faces, edges or both, Highlight turns the outline of the face or edge under the pointer on or off, and Color and Width set it (red and 4 px by default). Faces are outlined at the Width and edges at half of it, as the page says faces are highlighted with a thick line and edges with a thin line. With both on, a click paints the edge within 4 px of the pointer, else the face, and Shift switches to Paint Fills only; with one on, Shift switches to the other. The options last across tool switches and are saved with the preferences (`tool.setOption {tool: "livePaintBucket"}`). Evidence: `builder::tests::{bucket_options_choose_what_a_click_paints, bucket_options_set_the_highlight, bucket_highlights_an_edge_thinner_than_a_face}`, `dialogs::live_paint_bucket::tests::double_clicking_the_tool_opens_its_options_and_ok_sets_them`. Live Paint Bucket Options has Cursor Swatch Preview, as the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html) lists: with the Bucket selected, the active fill or stroke shows above the pointer between the color swatches before and after it in the Swatches panel, and the Left and Right arrow keys pick the swatch before or after it, as the page describes. The selected art keeps its paint. As VectorCraft's own rules, the option is on at first, the arrows step the stroke when the Stroke proxy is in front, they wrap around at the ends and still step with the preview off, a color that is no swatch shows alone until Right picks the first swatch or Left the last, and the arrows do nothing during a fill drag or with no color swatch. Evidence: `tests::build::{live_paint_bucket_arrow_keys_step_the_active_paint_through_the_swatches, live_paint_bucket_arrow_keys_handle_unmatched_paint_few_swatches_and_drags, live_paint_bucket_arrow_keys_pass_swatches_of_the_same_color_for_fill_and_stroke, swatch_arrow_keys_leave_modified_arrows_to_the_shortcuts}`. Live Paint Make preserves the front-most covering source's fill when compound paths share a curved boundary, and Expand keeps the face fills. Regression evidence: `planar::tests::coincident_curves_keep_their_source_faces` checks source order, winding, fill rules and nearby boundaries; `tests::build::live_paint_make_and_expand_keep_abutting_compound_colors` checks native compound paths, Make, Expand and Undo/Redo. This preserves VectorCraft's source-fill rule without changing arrangement precision. + Object › Live Paint › Expand keeps the faces and edges that draw on the canvas, with all their fill and stroke rows, so the expanded paths look as the painted group did ([Create Live Paint groups](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/create-live-paint-groups.html)). As VectorCraft's own rule, a face or edge draws when it is shown, its opacity is above 0, and any of its fill or stroke rows is shown, has paint and an opacity above 0 (a stroke also needs a weight above 0), whichever row is on top: a painted lower row under an unpainted top row is kept, and a part whose only painted row is hidden is removed. Merge copies the fill and stroke rows of each face that draws by this rule, and of each edge, to the rebuilt parts, with their gradients kept at their fit on the old outline and without the strokes' pen pressure, tilt, bearing and rotation. Evidence: `tests::build::{live_paint_expand_keeps_the_faces_and_edges_that_draw, live_paint_merge_carries_the_faces_that_draw, live_paint_merge_leaves_pen_pressure_behind, live_paint_merge_keeps_the_fit_of_carried_gradients}`. Live Paint Gap Options (Object › Live Paint › Gap Options…, `livePaint.gapOptions`): with Gap Detection on, paint stops at the gaps that run from a loose end of a path to the nearest path, up to Small (3 pt), Medium (6 pt), Large (12 pt) or a custom size; Close Gaps With Paths adds an unpainted path across each gap; Preview applies the options live and draws the gaps in the Gap Preview Color. The options are saved, copied and undone with the group, and Merge keeps the bottom group's options when its Gap Detection is on, or else turns Gap Detection on with Small when another merged group has it on. When Gap Detection is off in every merged group, it stays off. View › Show Live Paint Gaps (`view.livePaintGaps`) draws the gaps of the selected Live Paint groups up to their Paint Stops At size, each in its group's Gap Preview Color, until Hide Live Paint Gaps or Hide Edges hides them ([Live Paint gaps](https://web.archive.org/web/20260105111201/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/find-and-close-gaps-in-live-paint-groups.html)). Double-clicking the Live Paint Selection tool opens its Tool Options ([Live Paint Selection tool options](https://web.archive.org/web/20250904012025/https://helpx.adobe.com/illustrator/using/selecting-objects.html)): with Select Fills off, a click selects an edge instead of a face; with Select Strokes off, Alt-click selects a face instead of an edge; Color and Width set the color and width of the highlight on the face or edge under the pointer (red and 4 px by default). The options last across tool switches and are saved with the preferences (`tool.setOption {tool: "livePaintSelection"}`). @@ -1455,7 +1456,6 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur As VectorCraft's own rule, `tool.setOption` for the Live Paint Bucket and the Live Paint Selection tool, chosen or not, checks every value before it sets any: a switch that is not `true` or `false`, a `color` that is not an RGB color or a layer color's name, or that has an alpha part, a `width` that is not a number and an option the tool does not have give an error naming the option, and nothing is set or saved. A `width` outside 1 to 20 px is still set to the nearest end of that range. Saved settings that hold an invalid value still load, and the tool keeps its default for that option. Evidence: `tests::build::{live_paint_tool_options_refuse_invalid_values_and_change_nothing, live_paint_tool_options_take_rgb_colors_and_clamp_the_width, live_paint_tools_load_saved_settings_with_invalid_values}`. As VectorCraft's own rule, `tool.setOption` for the Shape Builder, chosen or not, checks every value the same way: a switch that is not `true` or `false`, a `pickColorFrom` or `selection` that is not one of its names, a `gapLength` that is not a number, a `highlightColor` that is not an RGB color or a layer color's name, or that has an alpha part, and an option the tool does not have give an error naming the option, and nothing is set or saved. A `gapLength` outside 0 to 72 pt is still set to the nearest end of that range. Evidence: `tests::build::{shape_builder_tool_options_refuse_invalid_values_and_change_nothing, shape_builder_tool_options_take_valid_values_and_clamp_the_gap}`. A drag of 3 screen pixels or more with the Live Paint Selection tool draws a marquee and selects the faces and edges it touches, partly enclosed ones included, and a Shift-drag adds them to the selection or removes them from it ([Modify Live Paint groups](https://web.archive.org/web/20261006115247/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)). A click and a marquee change the selection on release, and Escape before the release leaves the selection as it was. Locked Live Paint groups, those on a locked layer or artboard, and in isolation mode those outside the isolated art are not highlighted or selected. - A drag with the Live Paint Selection tool draws a marquee and selects the faces and edges it touches, partly enclosed ones included, and a Shift-drag adds them to the selection or removes them from it ([Modify Live Paint groups](https://web.archive.org/web/20261006115247/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/modify-live-paint-groups.html)). A click and a marquee change the selection on release, and Escape before the release leaves the selection as it was. Locked Live Paint groups, those on a locked layer or artboard, and in isolation mode those outside the isolated art are not highlighted or selected. When the object the Blend tool picked first is deleted or undone away before the second click, the next click on an object picks that object first instead of doing nothing. Regression tests: `blend_tool_picks_again_when_its_first_pick_is_gone` in `meshblend.rs` and `the_blend_tool_picks_again_when_its_first_pick_is_deleted` in `tests/blendopts.rs`. Window › Blend opens the Blend panel: Make, the selected blend's Spacing and Orientation (with no blend selected, the options new blends start with), Reverse Front to Back, Reverse Spine, Replace Spine, Expand and Release, each running its Object › Blend command. Make is dimmed until two or more objects are selected. Spacing and Orientation are dimmed until a blend or two or more objects are selected, and the other buttons are dimmed until a blend is selected. The Blend panel's Create Spine menu (Auto, Always, Never; `object.blend.createSpine`) sets whether new blends get a spine, from the Blend tool, Make and `object.blend.make` alike ([Blend panel overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blend-panel-overview.html)). Auto and Always give every new blend a straight spine, as before; Never makes blends without one, which keep their steps on the straight lines between the keys, have Type and Ramp dimmed, refuse Reverse Spine and spine edits, release without a spine path, and get a spine from Replace Spine. The setting is kept with the preferences and leaves blends already made as they are; Auto as the starting value and keeping the setting across sessions are VectorCraft's own rules. Builds on #5177 by adambelis. Evidence: `tests::blendopts::{create_spine_sets_whether_new_blends_get_a_spine, a_blend_without_a_spine_has_none_to_edit_reverse_ease_or_release, whether_a_blend_has_a_spine_is_saved_and_old_blends_have_one}` and `panels::tests_blend::create_spine_sets_what_new_blends_get_whatever_is_selected`. From 8239ec619ad90951c5cb0c3cb8ff7da6933444a4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:17:30 -0800 Subject: [PATCH 012/108] i18n: French has a row for every message no catalog translated The untranslated report listed 165 status and error messages that no complete-message catalog translated: messages of the SVG filter and 3D effects, the image encoders, color profiles, composite fonts, swatch exchange files and color books. fr.tsv now has an @msg row for each, with placeholders, parameter names and literal values as the English writes them, and a no-break space before : ; ? ! as the catalog's header asks. --- crates/ui-egui/src/i18n/fr.tsv | 167 +++++++++++++++++++++++++++++++++ 1 file changed, 167 insertions(+) diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 057dce6872..6c48bb2687 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7487,3 +7487,170 @@ breakText Glyphs Glyphes Grommets Œillets Grommet Inset Distance des œillets au bord Diameter Diamètre + +# Messages of the effects, 3D, image export, color profiles, composite fonts, swatch exchange files and color books. +@msg 3D effects require finite coordinates within 100 million points Les effets 3D exigent des coordonnées finies comprises dans 100 millions de points +@msg 3D effects require one to ten lights Les effets 3D exigent d’une à dix lumières +@msg <{_1}> isn't an element of an SVG filter <{_1}> n’est pas un élément de filtre SVG +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel Profondeur BMP {_1} : 1, 4, 8, 16, 24 ou 32 bits par pixel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer Échec de l’encodage BMP : {width} × {height} pixels ne conviennent ni au format ni au tampon de pixels +@msg GIF encoding failed: the palette image is malformed Échec de l’encodage GIF : l’image à palette est mal formée +@msg GIF encoding failed: {e} Échec de l’encodage GIF : {e} +@msg JPEG colour profile: {e} Profil colorimétrique JPEG : {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size Échec de l’encodage JPEG : le tampon de pixels ne correspond pas à la taille de l’image +@msg JPEG encoding failed: {e} Échec de l’encodage JPEG : {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size Échec de l’encodage PNG : le tampon de pixels ne correspond pas à la taille de l’image +@msg PNG encoding failed: the palette image is malformed Échec de l’encodage PNG : l’image à palette est mal formée +@msg PNG encoding failed: {e} Échec de l’encodage PNG : {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size Échec de l’encodage PNG : {width} × {height} pixels n’est pas une taille d’image valide +@msg PSD colour profile: {e} Profil colorimétrique PSD : {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size Échec de l’encodage PSD : le tampon de pixels ne correspond pas à la taille de l’image +@msg Revolve profile contains invalid coordinates Le profil de révolution contient des coordonnées non valides +@msg Revolve profile is too complex Le profil de révolution est trop complexe +@msg Revolve projection is not finite La projection de la révolution n’est pas finie +@msg Revolve requires finite profile coordinates within 100 million points La révolution exige des coordonnées de profil finies comprises dans 100 millions de points +@msg Revolve surface is too complex; reduce Segments or simplify the profile La surface de révolution est trop complexe ; réduisez Segments ou simplifiez le profil +@msg Revolve surface is too complex; simplify the profile La surface de révolution est trop complexe ; simplifiez le profil +@msg Revolve visibility cannot split the projected boundary La visibilité de la révolution ne peut pas diviser le contour projeté +@msg Revolve visibility creates too many fragments La visibilité de la révolution crée trop de fragments +@msg Revolve visibility creates too many vector anchors La visibilité de la révolution crée trop de points d’ancrage vectoriels +@msg Revolve visibility exceeds its geometry work limit La visibilité de la révolution dépasse sa limite de calcul géométrique +@msg Revolve visibility exceeds its spatial index limit La visibilité de la révolution dépasse sa limite d’index spatial +@msg Revolve visibility has too many boundary crossings La visibilité de la révolution compte trop de croisements de contour +@msg Revolve visibility has too many input anchors La visibilité de la révolution compte trop de points d’ancrage en entrée +@msg Revolve visibility requires convex cap sectors La visibilité de la révolution exige des secteurs de fermeture convexes +@msg Revolve visibility requires finite projected faces La visibilité de la révolution exige des faces projetées finies +@msg SVG options: {e} Options SVG : {e} +@msg Save for Web settings: {e} Réglages d’Enregistrer pour le web : {e} +@msg TIFF colour profile: {e} Profil colorimétrique TIFF : {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size Échec de l’encodage TIFF : le tampon de pixels ne correspond pas à la taille de l’image +@msg TIFF encoding failed: {e} Échec de l’encodage TIFF : {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Profondeur Targa {_1} : 16, 24 ou 32 bits par pixel +@msg Targa encoding failed: the pixel buffer doesn't match the image size Échec de l’encodage Targa : le tampon de pixels ne correspond pas à la taille de l’image +@msg The 3D projection is not finite La projection 3D n’est pas finie +@msg The 3D shadow is too complex; turn Shadows off or simplify the art L’ombre 3D est trop complexe ; désactivez Ombres ou simplifiez l’illustration +@msg The shape contains invalid coordinates La forme contient des coordonnées non valides +@msg Too many Revolve faces for visibility evaluation Trop de faces de révolution pour évaluer la visibilité +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft lit au plus {ASE_MAX_ENTRIES} couleurs et groupes d’un fichier d’échange de nuances, et cette bibliothèque en contient {entries} +@msg WebP encoding failed: {e} Échec de l’encodage WebP : {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}` : {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` vaut smallThumb, mediumThumb, largeThumb, smallList ou largeList +@msg `{_1}` can't name a composite font `{_1}` ne peut pas nommer une police composite +@msg `{_1}` is the name of an installed font `{_1}` est le nom d’une police installée +@msg `{_1}`: {_2} is set in `{font}`, a composite font `{_1}` : {_2} est composé en `{font}`, une police composite +@msg `{name}`: give the kanji part `{name}` : indiquez la partie kanji +@msg `{name}`: parts must be an object `{name}` : parts doit être un objet +@msg `{name}`: unknown class `{k}`; the classes are kanji, kana, punctuation, symbols, roman and numerals `{name}` : classe inconnue `{k}` ; les classes sont kanji, kana, punctuation, symbols, roman et numerals +@msg `{name}`: unknown key `{k}` in {_1} `{name}` : clé inconnue `{k}` dans {_1} +@msg `{name}`: {_1} must be an object `{name}` : {_1} doit être un objet +@msg `{raw}` can't name a composite font (1 to {COMPOSITE_NAME_MAX} characters, no control characters) `{raw}` ne peut pas nommer une police composite (de 1 à {COMPOSITE_NAME_MAX} caractères, sans caractères de contrôle) +@msg a document keeps at most {COMPOSITE_FONTS_MAX} composite fonts un document conserve au plus {COMPOSITE_FONTS_MAX} polices composites +@msg a line can't run from a point to itself une ligne ne peut pas relier un point à lui-même +@msg a line needs at least two points une ligne nécessite au moins deux points +@msg a linked JavaScript file is outside the read roots un fichier JavaScript lié se trouve hors des dossiers racines de lecture +@msg a number cannot be read un nombre ne peut pas être lu +@msg a swatch exchange block is too long un bloc du fichier d’échange de nuances est trop long +@msg a swatch exchange name is too long un nom du fichier d’échange de nuances est trop long +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels une image de {sw} × {sh} ne peut pas être redimensionnée à {width} × {height} pixels +@msg a {width} × {height} image is too large une image de {width} × {height} est trop grande +@msg a {width} × {height} image: {e} une image de {width} × {height} : {e} +@msg an SVG filter has at most {MAX_PRIMITIVES} primitives un filtre SVG comporte au plus {MAX_PRIMITIVES} primitives +@msg an SVG filter has no event attributes such as {_1} un filtre SVG ne comporte aucun attribut d’événement tel que {_1} +@msg an SVG filter is at most {_1} KB un filtre SVG fait au plus {_1} Ko +@msg an SVG filter's elements nest at most {MAX_DEPTH} deep les éléments d’un filtre SVG s’imbriquent sur au plus {MAX_DEPTH} niveaux +@msg an SVG filter's id is at most {MAX_NAME} characters l’id d’un filtre SVG compte au plus {MAX_NAME} caractères +@msg an SVG filter's images are PNG, JPEG, GIF or WebP data: URLs les images d’un filtre SVG sont des URL data: PNG, JPEG, GIF ou WebP +@msg an SVG filter's images have at most {MAX_IMAGE_PIXELS} pixels in all les images d’un filtre SVG comptent au plus {MAX_IMAGE_PIXELS} pixels au total +@msg an image could not be written: {e} une image n’a pas pu être écrite : {e} +@msg an image that couldn't be read was left out une image illisible a été omise +@msg can't open “{name}”: {e} impossible d’ouvrir « {name} » : {e} +@msg cannot align zip entries to {align} bytes impossible d’aligner les entrées zip sur {align} octets +@msg cannot open the automation {kind} root `{_1}`: {e} impossible d’ouvrir le dossier racine d’automatisation ({kind}) `{_1}` : {e} +@msg cannot read profile: {0} impossible de lire le profil : {0} +@msg color book version {version} isn't supported (only 1) la version {version} du carnet de couleurs n’est pas prise en charge (seulement 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) les carnets de couleurs dans l’espace colorimétrique {other} ne sont pas pris en charge (seulement RVB, CMJN et Lab) +@msg dataBase64 is not base64 dataBase64 n’est pas en base64 +@msg each font must be {name, parts} chaque police doit être {name, parts} +@msg each font needs a name chaque police nécessite un nom +@msg feTurbulence's numOctaves is at most {MAX_OCTAVES} le numOctaves de feTurbulence vaut au plus {MAX_OCTAVES} +@msg file name too long to zip: {_1} nom de fichier trop long pour le zip : {_1} +@msg file name too long to zip: {name} nom de fichier trop long pour le zip : {name} +@msg fonts must be a list of composite fonts fonts doit être une liste de polices composites +@msg freeform line {i}: {e} ligne libre {i} : {e} +@msg freeform point {i}: {e} point libre {i} : {e} +@msg give `{key}` or `{other}`, not both indiquez `{key}` ou `{other}`, pas les deux +@msg give fonts: [{name, parts}…] indiquez fonts: [{name, parts}…] +@msg give one of path, data or dataBase64 indiquez path, data ou dataBase64 +@msg grayscale profiles can't be working spaces yet les profils en niveaux de gris ne peuvent pas encore servir d’espaces de travail +@msg input contains NaN or infinite coordinates l’entrée contient des coordonnées NaN ou infinies +@msg input path could not be closed le tracé d’entrée n’a pas pu être fermé +@msg invalid ICC profile: {0} profil ICC non valide : {0} +@msg invalid scale {scale} échelle non valide {scale} +@msg its localized names take more than {_1} KB ses noms localisés occupent plus de {_1} Ko +@msg its objects are nested too deep ({e}) ses objets sont trop profondément imbriqués ({e}) +@msg its tag table lists the `{_1}` tag more than once sa table de balises répertorie la balise `{_1}` plus d’une fois +@msg names must be a list of names names doit être une liste de noms +@msg names must be strings names doit contenir des chaînes +@msg no composite font aucune police composite +@msg no composite font named `{n}` aucune police composite nommée `{n}` +@msg no composite fonts to export aucune police composite à exporter +@msg not a composite fonts file: no compositeFonts list ce n’est pas un fichier de polices composites : aucune liste compositeFonts +@msg not a composite fonts file: {e} ce n’est pas un fichier de polices composites : {e} +@msg not a graphic style library: {e} ce n’est pas une bibliothèque de styles graphiques : {e} +@msg not a swatch library (.vcswatches or .gpl) ce n’est pas une bibliothèque de nuances (.vcswatches ou .gpl) +@msg not a swatch library (format `{_1}`) ce n’est pas une bibliothèque de nuances (format `{_1}`) +@msg not a swatch library: {e} ce n’est pas une bibliothèque de nuances : {e} +@msg not an action set file ({e}) ce n’est pas un fichier de jeu de scripts ({e}) +@msg path is empty le chemin est vide +@msg profile colour space {other} is not RGB, CMYK or Gray l’espace colorimétrique {other} du profil n’est pas RVB, CMJN ou Niveaux de gris +@msg regular expression too large expression régulière trop volumineuse +@msg script file is not UTF-8 text: {value} le fichier de script n’est pas du texte UTF-8 : {value} +@msg stop {i}: {e} étape de dégradé {i} : {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) la version {major}.{minor} du fichier d’échange de nuances n’est pas prise en charge (seulement 1.x) +@msg the element needs an id, the filter's name l’élément nécessite un id, le nom du filtre +@msg the SVG filter can't be drawn: check its primitives and their inputs le filtre SVG ne peut pas être dessiné : vérifiez ses primitives et leurs entrées +@msg the SVG filter has no primitives le filtre SVG ne comporte aucune primitive +@msg the SVG filter is too large once its attributes are written out le filtre SVG est trop volumineux une fois ses attributs écrits en entier +@msg the SVG filter isn't valid XML: {e} le filtre SVG n’est pas du XML valide : {e} +@msg the art of a graph design in a graph series is drawn again from the design: edit the design to change it l’illustration d’une conception de graphe dans une série de graphe est redessinée à partir de la conception : modifiez la conception pour la changer +@msg the color book holds more than {ASE_MAX_ENTRIES} colors le carnet de couleurs contient plus de {ASE_MAX_ENTRIES} couleurs +@msg the color book is cut short le carnet de couleurs est tronqué +@msg the color book's names take more than {_1} MB les noms du carnet de couleurs occupent plus de {_1} Mo +@msg the file holds more than {COMPOSITE_FONTS_MAX} composite fonts le fichier contient plus de {COMPOSITE_FONTS_MAX} polices composites +@msg the file holds no composite fonts le fichier ne contient aucune police composite +@msg the file holds two composite fonts named `{_1}` le fichier contient deux polices composites nommées `{_1}` +@msg the file is larger than 4 MB le fichier dépasse 4 Mo +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution l’image mesurerait {w} × {h} pixels ; les exports en pixels sont limités à {MAX_RASTER_SIDE} pixels par côté et à {_1} mégapixels : réduisez l’échelle ou la résolution +@msg the optimised image can't be read back: {e} l’image optimisée ne peut pas être relue : {e} +@msg the pixel buffer doesn't match the image size le tampon de pixels ne correspond pas à la taille de l’image +@msg the preview: {e} l’aperçu : {e} +@msg the request may not read the New Document profiles folder la requête n’est pas autorisée à lire le dossier des profils de nouveau document +@msg the shapes are too degenerate to combine les formes sont trop dégénérées pour être combinées +@msg the shapes cross themselves and each other too often to combine les formes se croisent elles-mêmes et entre elles trop souvent pour être combinées +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups le fichier d’échange de nuances contient plus de {ASE_MAX_ENTRIES} couleurs et groupes +@msg the swatch exchange file is cut short le fichier d’échange de nuances est tronqué +@msg the {_1} plate can't be read: {e} la plaque {_1} ne peut pas être lue : {e} +@msg too many classes trop de classes +@msg too many groups trop de groupes +@msg too many layers for PSD (at most 32767) trop de calques pour le PSD (32767 au plus) +@msg too many swatch exchange blocks trop de blocs dans le fichier d’échange de nuances +@msg two composite fonts are named `{_1}` deux polices composites sont nommées `{_1}` +@msg unknown colour profile: {0} profil colorimétrique inconnu : {0} +@msg unknown key `{k}`; a font takes name and parts clé inconnue `{k}` ; une police accepte name et parts +@msg {_1} clashes with a built-in profile name {_1} entre en conflit avec le nom d’un profil intégré +@msg {_1}: no usable transform to/from sRGB {_1} : aucune transformation utilisable vers ou depuis sRGB +@msg {k}: baseline must be {_1} to {_2}% {k} : baseline doit être compris entre {_1} et {_2} % +@msg {k}: give a font {k} : indiquez une police +@msg {k}: only kana can be scaled at the center {k} : seuls les kana peuvent être mis à l’échelle au centre +@msg {k}: only kana, roman and numerals can be scaled {k} : seuls kana, roman et numerals peuvent être mis à l’échelle +@msg {k}: scale must be {_1} to {_2}% {k} : scale doit être compris entre {_1} et {_2} % +@msg {k}: size must be {_1} to {_2}% {k} : size doit être compris entre {_1} et {_2} % +@msg {name} is not a CMYK profile {name} n’est pas un profil CMJN +@msg {name} is not an RGB profile {name} n’est pas un profil RVB +@msg {path}: could not be read {path} : lecture impossible +@msg {what} is at most {max} {what} vaut au plus {max} +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pixels, c’est trop grand pour le JPEG (65535 pixels par côté au plus) : réduisez la résolution +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pixels, c’est trop grand pour le Targa (65535 pixels par côté au plus) : réduisez la résolution +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixels, c’est trop grand pour le PSD ({MAX_SIDE} pixels par côté au plus) : réduisez la résolution +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixels, c’est trop grand pour le GIF (65535 pixels par côté au plus) : réduisez la résolution From 94db0b1ebd4737d1744060e0dd127b6af9c46174 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:20:35 -0800 Subject: [PATCH 013/108] .ai export: a masked image copy whose mask is left out keeps all of its pixels A copy of an image written whole already was cut to the painted bounds of its opacity mask even when the mask was then left out, nested too deep or past the object limit, so the file read back with a cropped image and no mask. The copy is now cut to its mask only when the mask is written, and otherwise written whole. The progress-doc line now gives the measured total for the warped test image's pieces: about 7 times the image's samples, not twice. --- crates/eps/src/ai_editing/tests.rs | 66 ++++++++++++++++++++++ crates/eps/src/ai_editing/writer.rs | 33 ++++++++--- crates/eps/src/ai_editing/writer/images.rs | 35 ++++++++++-- docs/target-app-parity.md | 2 +- 4 files changed, 123 insertions(+), 13 deletions(-) diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 04ec867063..a120ac0c82 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -7649,6 +7649,72 @@ fn a_masked_image_keeps_the_pixels_its_mask_effects_show() { assert!(sizes[1] >= 35 * 35 * 3, "{sizes:?}"); } +/// The speckled image with an opacity mask that clips it to six small white squares in its corner. +fn photo_masked_to_its_corner(doc: &mut Document) -> Node { + let mut masked = speckled_photo(doc); + let squares = (0..6).map(|i| square(doc, Rect::new(20.0 + f64::from(i) * 5.0, 10.0, 23.0 + f64::from(i) * 5.0, 20.0), Color::WHITE)).collect(); + let art = group(doc, squares, false); + masked.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(art), clip: true, invert: false, disabled: false, linked: true })); + masked +} + +/// A copy of an image written whole already whose opacity mask is left out for the object limit is +/// written whole: without the mask, it shows all of its pixels. +#[test] +fn a_masked_copy_whose_mask_is_left_out_keeps_all_of_its_pixels() { + // GUARDS: the copy was cut to its mask, and the mask then left out, so it read back cropped. + let doc = photo_doc(|d| { + let photo = speckled_photo(d); + let masked = photo_masked_to_its_corner(d); + group(d, vec![photo, masked], false) + }); + let (mut left_out, mut kept) = (0, 0); + for (max, mask, _, shown) in samples_within_each_limit(&doc) { + if shown.len() < 2 { + continue; + } + if mask { + assert!(shown[1] < SPECKLED_WHOLE, "room for {max}: {shown:?}"); + kept += 1; + } else { + assert_eq!(shown, [SPECKLED_WHOLE, SPECKLED_WHOLE], "room for {max}"); + left_out += 1; + } + } + assert!(left_out > 0 && kept > 0, "{left_out} limits left the mask out, {kept} kept it"); +} + +/// A copy of an image written whole already whose opacity mask is nested too deep to be written is +/// written whole. +#[test] +fn a_masked_copy_nested_too_deep_for_its_mask_keeps_all_of_its_pixels() { + // GUARDS: the copy was cut to its mask, and the mask then left out for its depth. + let mut doc = Document::new(200.0, 100.0); + let layer = doc.layers[0].id; + let photo = speckled_photo(&mut doc); + doc.insert(Some(layer), usize::MAX, photo).unwrap(); + // Isolated instances are written as their art, each a level deeper: the masked copy is at the limit. + let art = photo_masked_to_its_corner(&mut doc); + doc.symbols.push(Symbol { dynamic: false, name: "S0".into(), art: Arc::new(art) }); + for i in 1..writer::MAX_NEST { + let mut inner = instance(&mut doc, &format!("S{}", i - 1), Affine::IDENTITY); + inner.isolate = true; + doc.symbols.push(Symbol { dynamic: false, name: format!("S{i}"), art: Arc::new(inner) }); + } + let mut outer = instance(&mut doc, &format!("S{}", writer::MAX_NEST - 1), Affine::IDENTITY); + outer.isolate = true; + doc.insert(Some(layer), usize::MAX, outer).unwrap(); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(out.warnings.iter().any(|w| w == writer::DEEP_MASKS), "{:?}", out.warnings); + // The symbols' definitions hold copies too: each copy written with its mask is the part the + // mask shows, and each copy whose mask is left out is whole. + let sizes = sample_sizes(&doc); + let whole = sizes.iter().filter(|s| **s == SPECKLED_WHOLE).count(); + let masks = String::from_utf8_lossy(&out.program).matches("(AI9_Mask)").count(); + assert_eq!(sizes.len() - whole, masks, "{sizes:?}"); + assert!(whole >= 2, "the first copy and a copy whose mask is left out: {sizes:?}"); +} + /// A linked image, an image with an opacity mask, and an image with a Warp and another effect are /// written as their drawn art, with no art style. #[test] diff --git a/crates/eps/src/ai_editing/writer.rs b/crates/eps/src/ai_editing/writer.rs index 570c65daa2..0373624b64 100644 --- a/crates/eps/src/ai_editing/writer.rs +++ b/crates/eps/src/ai_editing/writer.rs @@ -282,6 +282,8 @@ pub(super) struct Writer<'a> { /// The outlines of the clipping groups the art being written is in, in the document (empty in /// a definition, an opacity mask's art and a brush's art, which are written apart from them). shown: Vec, + /// The copy of an image that the last [`Self::image`] wrote as a window, when it did. + windowed: Option, } impl<'a> Writer<'a> { @@ -350,6 +352,7 @@ impl<'a> Writer<'a> { last_samples: None, whole_images: HashMap::new(), shown: vec![], + windowed: None, } } @@ -657,6 +660,8 @@ impl<'a> Writer<'a> { xy.knockout = Knockout::Off; } let start = self.body.len(); + // An image's copy written as the part that its opacity mask, among other regions, shows. + let mut mask_window = None; match &n.kind { NodeKind::Layer { .. } => {} NodeKind::Group { children, clip: true } => self.clip_group(children, xy), @@ -690,14 +695,16 @@ impl<'a> Writer<'a> { .extras() .mask .as_ref() - .filter(|m| m.clip && !m.invert && !m.disabled) + .filter(|m| m.clip && !m.invert && !m.disabled && self.nest < MAX_NEST) .and_then(|m| vectorcraft_render::painted_bounds(self.doc, &m.art)); if let Some(b) = masked { self.shown.push(b.to_path(0.1)); } + self.windowed = None; self.image(&self.doc.shown_image(n, im), xy); if masked.is_some() { self.shown.pop(); + mask_window = self.windowed.take(); } } NodeKind::SymbolInstance { symbol, xf } if self.live_instance_in_room(n, symbol, *xf) => self.symbol_instance(symbol, *xf, xy), @@ -763,10 +770,14 @@ impl<'a> Writer<'a> { // A group's dictionary goes between its end and its state block. let block = (self.block_end == self.body.len() && self.block_start >= start).then(|| self.body.split_off(self.block_start)); self.block_end = usize::MAX; - self.dictionary(n); + let mask_written = self.dictionary(n); if let Some(b) = block { self.body.push_str(&b); } + // Without its opacity mask, the image shows whole. + if let Some(w) = mask_window.filter(|_| !mask_written) { + self.write_whole(w); + } } // An envelope's plugin `XP` follows its distorted art, after the art's state block. if deform { @@ -796,24 +807,27 @@ impl<'a> Writer<'a> { /// `n`'s `/ArtDictionary`, after it, when it has a name (`AI10_ArtUID`, see [`Self::take_id`]), /// is bound to variables ([`Self::bound_variables`]; without a name, it gets an XML id and an /// empty `AIArtName`), has an opacity mask (`AI9_Mask`, see [`Self::mask`]), or is a symbol's - /// art (its symbol's entries first, see [`Self::define_symbol`]). - fn dictionary(&mut self, n: &Node) { + /// art (its symbol's entries first, see [`Self::define_symbol`]). False when `n` has an opacity + /// mask that is left out: nested too deep, or its art doesn't fit. + fn dictionary(&mut self, n: &Node) -> bool { let name = n.name.as_deref().filter(|s| !s.is_empty()); let placed = std::mem::take(&mut self.placed); let typed = std::mem::take(&mut self.typed); let bound = self.bound_variables(n, placed, typed); let mut mask = n.extras().mask.as_deref(); + let mut mask_written = true; // Masks nested too deep are left out (an empty mask would hide the object). if mask.is_some() && self.nest >= MAX_NEST { self.warn(DEEP_MASKS); mask = None; + mask_written = false; } let entries = match &self.root_entries { Some((id, _)) if *id == n.id => self.root_entries.take().map(|(_, e)| e), _ => None, }; if name.is_none() && mask.is_none() && bound.is_empty() && entries.is_none() { - return; + return mask_written; } let start = self.body.len(); let has_id = name.is_some() || !bound.is_empty(); @@ -836,12 +850,15 @@ impl<'a> Writer<'a> { // A mask whose art doesn't fit is left out, and with nothing else in it the dictionary too. if let Some(m) = mask && !self.mask(m) - && !has_id - && !has_entries { - return self.body.truncate(start); + if !has_id && !has_entries { + self.body.truncate(start); + return false; + } + mask_written = false; } self.body.push_str("%_;\n%_\n"); + mask_written } /// An `/ArtDictionary` whose `AI10_ArtUID` is `name` as an XML id. diff --git a/crates/eps/src/ai_editing/writer/images.rs b/crates/eps/src/ai_editing/writer/images.rs index d69b1d7e09..0ebfee5228 100644 --- a/crates/eps/src/ai_editing/writer/images.rs +++ b/crates/eps/src/ai_editing/writer/images.rs @@ -30,6 +30,18 @@ pub(super) const SAMPLES_LINE: &str = "XI\u{1}"; /// An image's pixels as the data holds them, and whether it had 16 bits a channel ([`Samples::of`]). pub(super) type Read = Arc<(Samples, bool)>; +/// A copy of an image written as the part of it that its regions show ([`Writer::image`]). +pub(super) struct Windowed { + /// Where its raster is in the body. + at: std::ops::Range, + /// The index of its samples in [`Writer::payloads`]. + payload: usize, + /// The image's pixels. + samples: Read, + /// What places the image's whole pixel grid in the document. + xf: Affine, +} + /// An image's pixels as the data holds them. pub(super) struct Samples { /// `/DeviceGray`, `/DeviceRGB` or `/DeviceCMYK`. @@ -166,11 +178,14 @@ impl Writer<'_> { ai_ops::image_window(&clips, im.xf * fit, (samples.width, samples.height)) }) .flatten(); - match window { - Some(window) => { - self.raster(&samples.window(window), im.xf * fit * Affine::translate((f64::from(window[0]), f64::from(window[1])))) + match (window, &read) { + (Some(window), Some(read)) => { + let at = self.body.len(); + self.raster(&samples.window(window), im.xf * fit * Affine::translate((f64::from(window[0]), f64::from(window[1])))); + self.windowed = + Some(Windowed { at: at..self.body.len(), payload: self.payloads.len() - 1, samples: read.clone(), xf: im.xf * fit }); } - None => { + _ => { if let Some(d) = data { // `raster` adds the samples as the next payload. A copy written whole on // `%_` lines after an earlier whole copy keeps the earlier one's entry. @@ -290,6 +305,18 @@ impl Writer<'_> { read } + /// The copy `w`, written as a window, written whole in its place, with fresh samples; its + /// window's samples are emptied. + pub(super) fn write_whole(&mut self, w: Windowed) { + let tail = self.body.split_off(w.at.end); + self.body.truncate(w.at.start); + if let Some(p) = self.payloads.get_mut(w.payload) { + *p = Vec::new(); + } + self.raster(&w.samples.0, w.xf); + self.body.push_str(&tail); + } + /// Keep `bytes` to go in the program where the mark this returns is. fn payload(&mut self, bytes: Vec) -> String { self.payloads.push(bytes); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index d2b693c1ec..2e1acd44bd 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -617,7 +617,7 @@ since 2026-10-01. - **Warp effects bend images:** a Warp effect on an image, or on a group that holds one, bends the image's pixels with its frame, as the Warp effect is documented to distort bitmap images in [Reshaping with effects](https://helpx.adobe.com/illustrator/using/reshaping-objects-effects.html): after the last effect, the image is cut into 10 × 10 cells of two triangles, each a clipped piece under its own affine map. Effects after the Warp reshape only the frame, a second Warp bends the same pieces, and warps saved without a version bend the pixels with their earlier map, as they bend the frame. A placed gradient on a group that holds the image follows the group's bounds as the pieces draw them. SVG writes the image once for the pieces; PDF, EPS, `.ai` and PNG write the bent pieces. The images stay unbent when their pieces would make the art pass 2 million objects, and so does an image whose frame keeps its shape past the anchor budget. A grayscale image's fill color now colorizes the pieces of a warp or an envelope, and an image under any geometry effect keeps that color and its smoothing setting. Existing documents with a Warp effect on an image, or on a group that holds one, draw differently: before, the image showed unbent, cut by the bent frame. So do existing documents with a colorized image under an envelope or a geometry effect, or an image drawn without smoothing under a geometry effect: before, those lost the color or the setting. The cell count and the limits are VectorCraft's own (effects `tests::warped_images_stay_within_the_object_budget`, `tests::warped_images_keep_document_keys_and_hidden_images_apart`, `tests::an_image_whose_frame_passes_the_budget_stays_whole`, `tests::effects_after_a_warp_reshape_an_images_frame_and_not_its_pieces`, `tests::an_images_pixels_take_the_map_their_warps_version_names`, `tests::an_image_under_a_geometry_effect_keeps_its_color_and_smoothing`, `tests::a_nested_groups_gradient_follows_its_warped_image`; engine `warp_images::an_images_pixels_bend_with_effect_warp`, `a_warped_image_keeps_its_bend_in_svg`, `a_warped_image_keeps_its_bend_in_pdf`, `a_warped_image_keeps_its_bend_in_ai`, `a_warped_image_keeps_its_bend_in_eps`, `a_warped_image_keeps_its_bend_in_png`, `svg_writes_an_image_clipped_twice_in_a_users_group_twice`, `expand_appearance_of_a_warped_image_draws_as_the_canvas_did`, `a_colorized_image_keeps_its_color_when_warped`, `a_warp_on_a_group_bends_the_image_in_it`, `envelope_distort::a_colorized_image_keeps_its_color_in_an_envelope`). Scores and hours unchanged. - **`.ai` files keep an image's Warp live:** an embedded image whose appearance is one Warp effect, with no opacity mask, is saved to the `.ai` editing data with an art style of that Warp: its bent pieces are its drawn look, and the image itself follows on `%_` lines, as for other styled objects. Opening an `.ai` file reads such an image as the image with its Warp live, its pixels, placement, name and opacity kept, when the live warp draws as the file's drawn look and the import has a comparison left; otherwise the drawn look stays, with the drawn-look note. The Warp effect applies to bitmap images ([the help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html)), and native files keep live effects ([the help page](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/supported-file-formats-in-illustrator.html)). A linked image with a Warp is saved as its drawn art, as before, and its live Warp is not saved. Images with an opacity mask, and images with a Warp and another effect or with another geometry effect, are saved and opened as their drawn art. Existing `.ai` files with an embedded image on `%_` lines open differently: before, that image also came in beside its drawn look. Which images keep the Warp and the comparison are VectorCraft's own rules (eps `ai_editing::tests::an_image_with_a_warp_reads_back_with_its_warp_live`, `an_image_whose_warp_draws_otherwise_than_its_look_keeps_its_look`, `an_image_on_hidden_lines_does_not_come_in_beside_its_look`, `other_warped_images_are_written_as_their_drawn_art`, `import::ai::read::ops::tests::an_image_takes_a_style_of_one_warp_alone`). Scores and hours unchanged. - **EPS writes a repeated image's samples once:** an image drawn more than once in an EPS file (the pieces of an envelope or a Warp effect, copies of one image, or one image in a symbol's instances) has its compressed samples written once in the setup, and each placement reads them from there: a reusable stream rewound for each placement at Language Level 3 ([PostScript Language Reference, 3rd ed., §3.13](https://www.adobe.com/jp/print/postscript/pdfs/PLRM.pdf)), and an array of strings of at most 49,152 bytes fed to the image by a procedure at Level 2. An image drawn once is written where it is drawn, as before. The 256 MB limit on the page counts the samples once, so an envelope of a large photo no longer loses pieces to it. A colorized image is reused per ink (eps `tests::an_image_placed_twice_writes_its_samples_once_at_both_levels`, `tests::an_envelopes_image_pieces_draw_one_copy_of_its_samples`, `tests::each_ink_of_a_colorized_image_placed_twice_is_written_once`, `tests::samples_longer_than_a_string_are_reused_at_both_levels`, `tests::the_page_limit_counts_a_repeated_images_samples_once`). Scores and hours unchanged. -- **`.ai` files write a warped image's pieces as the parts they show:** in the `.ai` editing data and in legacy `.ai` files, an embedded image cut to a clipping path (in the editing data, also an image under an opacity mask that clips) is written with all of its pixels the first time, and every later copy of the same pixels is written as the rectangle of them that the path or mask shows, 2 pixels more on each side, placed where it lies in the image. The pieces of a Warp effect, an envelope or their expanded art, 200 copies of the image for 10 × 10 cells before, now add about twice the image's pixels. Each image's pixels are read once for the pieces that follow one another. An image cut to a rectangle of half its pixels or more, and the first copy written, keep all of their pixels. The `XI` operator's arguments give an image's location and size ([AI file-format specification, §8.1](https://web.archive.org/web/20050126105313/https://partners.adobe.com/public/developer/en/illustrator/sdk/AI7FileFormat.pdf)); the 2-pixel margin and the half-the-pixels limit are VectorCraft's own rules (eps `ai_editing::tests::the_pieces_of_a_warped_image_are_written_as_the_parts_they_show`, `masked_pieces_of_a_warped_image_are_written_as_the_parts_they_show`, `an_image_with_a_live_warp_writes_its_pixels_whole_once`, `a_clipped_image_written_first_keeps_all_of_its_pixels`, `legacy_ai::tests::the_pieces_of_a_warped_image_are_written_as_the_parts_they_show`). Scores and hours unchanged. +- **`.ai` files write a warped image's pieces as the parts they show:** in the `.ai` editing data and in legacy `.ai` files, an embedded image cut to a clipping path (in the editing data, also an image under an opacity mask that clips) is written with all of its pixels the first time, and every later copy of the same pixels is written as the rectangle of them that the path or mask shows, 2 pixels more on each side, placed where it lies in the image. The pieces of a Warp effect, an envelope or their expanded art, 200 copies of the image for 10 × 10 cells before, now hold about 7 times the image's pixels in all for a 64 × 64 image. A copy whose opacity mask is left out, nested too deep or past the object limit, keeps all of its pixels. Each image's pixels are read once for the pieces that follow one another. An image cut to a rectangle of half its pixels or more, and the first copy written, keep all of their pixels. The `XI` operator's arguments give an image's location and size ([AI file-format specification, §8.1](https://web.archive.org/web/20050126105313/https://partners.adobe.com/public/developer/en/illustrator/sdk/AI7FileFormat.pdf)); the 2-pixel margin and the half-the-pixels limit are VectorCraft's own rules (eps `ai_editing::tests::the_pieces_of_a_warped_image_are_written_as_the_parts_they_show`, `masked_pieces_of_a_warped_image_are_written_as_the_parts_they_show`, `an_image_with_a_live_warp_writes_its_pixels_whole_once`, `a_clipped_image_written_first_keeps_all_of_its_pixels`, `a_masked_copy_whose_mask_is_left_out_keeps_all_of_its_pixels`, `a_masked_copy_nested_too_deep_for_its_mask_keeps_all_of_its_pixels`, `legacy_ai::tests::the_pieces_of_a_warped_image_are_written_as_the_parts_they_show`). Scores and hours unchanged. - **PDF writes a warped image once:** with downsampling on, the pieces of an image bent by a Warp effect are resampled for the widest and the highest size any piece places the image at, so every piece paints one image XObject (a colorized image: one colorized image and its soft mask), instead of one image for each size a piece is placed at. Another placement of the same image is still resampled for its own size. Without downsampling, a colorized image and a CMYK image with a grayscale image mask on its grid are decoded and encoded once for all the sizes they are placed at (pdf `tests::compression::a_warped_image_is_written_once_for_all_its_pieces`, `tests::colorize::a_colorized_warped_image_is_written_once_for_all_its_pieces`, `export::images::tests::colorized_and_grid_masked_images_are_made_once_for_every_size_without_downsampling`). Scores and hours unchanged. - **Distort Appearance with Transform effect options:** with Envelope Options › Distort Appearance on, a path whose Transform effect has Scale Strokes & Effects or Transform Patterns on, or copies it with a gradient, is bent as the same per-copy art it draws and expands as outside the envelope: each copy's own stroke weight, dashes, pattern placement and gradient (effects `bake::tests`). Scores and hours unchanged. - **Fitted gradients turn with the Transform effect:** a gradient fitted to the object (not placed with the Gradient tool) turns, reflects and stretches with the object when its Transform effect rotates, reflects or scales it unevenly, as Object › Transform already does: the gradient is fixed to its fit on the geometry the effect takes, then follows the effect and the effects after it as a placed gradient does. Under moves and even scales it draws as a refit does, and a Transform effect that scales the object to nothing across leaves it fitted, with Scale Strokes & Effects or Transform Patterns on too, and on each copy. This holds on the canvas and in Object › Expand of the fill, for an object's own effects, a fill's or stroke's own, and a group's, where the gradients fitted to its paths, to its own fill, to the groups inside it and to its images' and symbol instances' own fills each fix to their own object's fit. Existing documents with such a Transform effect on fitted-gradient art draw differently: before, the gradient refit to the turned outline. The Gradient tool still shows a fitted gradient's vector at its unturned fit. How gradients follow the effect is VectorCraft's own rule; what the effect does to the object is described in [Distort and transform effects](https://helpx.adobe.com/illustrator/desktop/manage-objects/reshape-transform-objects/distort-and-transform-effects-in-illustrator.html) (effects `bake::tests::a_fitted_gradient_turns_reflects_and_stretches_with_a_transform_effect`, `bake::tests::a_transform_effect_that_scales_to_nothing_leaves_a_fitted_gradient_fitted`, `group::tests::a_groups_transform_turns_the_gradients_fitted_to_its_members_and_its_own_fill`; render `objectfx::a_fitted_gradient_turns_and_reflects_with_its_transform_on_the_canvas`; engine `objexpand::a_fitted_gradient_turned_by_a_transform_expands_as_the_canvas_draws_it`). Scores and hours unchanged. From c0b9eed99f70e783a83361326e90d82c4bf97336 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:24:07 -0800 Subject: [PATCH 014/108] Links: a web open with missing and modified links shows both lines On the web, a document that opened with linked files it can't read and linked files that changed on disk showed only the line about the changed files when Update Links doesn't ask. The status bar now shows the line about the unreadable files and lists the line about the changed files as the first note in its hover, ahead of the open's notes. With Ask When Modified the update question opens and the line about the unreadable files stays, as before. --- crates/ui-egui/src/dialogs/missing_links.rs | 70 +++++++++++++++++---- docs/target-app-parity.md | 1 + 2 files changed, 60 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/dialogs/missing_links.rs b/crates/ui-egui/src/dialogs/missing_links.rs index 70c2370f1b..6de49453b3 100644 --- a/crates/ui-egui/src/dialogs/missing_links.rs +++ b/crates/ui-egui/src/dialogs/missing_links.rs @@ -43,26 +43,27 @@ fn ids(rows: &[Value]) -> Vec { /// then about its modified ones, then about the fonts it opened without /// ([`super::missing_fonts`]). The web reads no linked files, so missing ones just show their /// previews there. The status bar shows what it says about the linked files followed by the open's -/// `notes` ([`crate::io::show_opened`]). +/// `notes` ([`crate::io::show_opened`]). On the web, with both missing and modified files and +/// Update Links not asking, the line about the missing files comes first and the line about the +/// modified ones is the first of the notes. pub fn after_open(app: &mut VectorcraftApp, r: &Value, notes: Vec) { after_open_for(app, r, notes, cfg!(target_arch = "wasm32")); } -fn after_open_for(app: &mut VectorcraftApp, r: &Value, notes: Vec, web: bool) { +fn after_open_for(app: &mut VectorcraftApp, r: &Value, mut notes: Vec, web: bool) { // The fonts' dialog waits for these questions (one dialog at a time). super::missing_fonts::after_open(app, r); let rows = |k: &str| r[k].as_array().cloned().unwrap_or_default(); let (missing, modified) = (rows("missingLinks"), ids(&rows("modifiedLinks"))); let notice = if missing.is_empty() || web { - let unreadable = (!missing.is_empty()).then(|| { - crate::i18n::msg_n( - missing.len() as u64, - "{n} linked file can't be read here: its preview shows", - "{n} linked files can't be read here: their previews show", - &[], - ) - }); - ask_update(app, modified).or(unreadable) + let unreadable = (!missing.is_empty()).then(|| unreadable_status(missing.len())); + match (ask_update(app, modified), unreadable) { + (Some(changed), Some(unreadable)) => { + notes.insert(0, changed); + Some(unreadable) + } + (changed, unreadable) => changed.or(unreadable), + } } else { open(app, missing, modified, ¬es); None @@ -71,6 +72,16 @@ fn after_open_for(app: &mut VectorcraftApp, r: &Value, notes: Vec, web: super::settle(app); } +/// The status bar's line for `n` linked files the web can't read. +fn unreadable_status(n: usize) -> String { + crate::i18n::msg_n( + n as u64, + "{n} linked file can't be read here: its preview shows", + "{n} linked files can't be read here: their previews show", + &[], + ) +} + fn open(app: &mut VectorcraftApp, missing: Vec, modified: Vec, notes: &[String]) { let fields = json!({ "missing": missing, "modified": modified, "notes": notes, "applyToAll": false, "path": "" }); app.ui.dialog = Some(Dialog::new(KIND, fields)); @@ -346,6 +357,43 @@ mod tests { assert_eq!((app.ui.status.as_str(), &app.ui.status_notes), (notice, &None)); } + /// On the web, an open with linked files it can't read and modified ones, with Update Links + /// not asking: the status bar shows the line about the unreadable files and counts the line + /// about the modified ones as the first note, ahead of the open's notes, and keeps them all + /// for its hover. With Ask When Modified the update question opens and the line about the + /// unreadable files stays. + #[test] + fn a_web_open_with_unreadable_and_modified_links_keeps_both_lines() { + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.run("file.new", json!({"width": 400, "height": 300})).unwrap(); + app.session.prefs.update_links = "manually".into(); + let missing = json!([{ "name": "a.png", "path": "/gone/a.png", "ids": [1] }, { "name": "b.png", "path": "/gone/b.png", "ids": [2] }]); + let r = json!({ "missingLinks": missing, "modifiedLinks": [{ "ids": [3] }] }); + let unreadable = "2 linked files can't be read here: their previews show"; + let changed = changed_on_disk_status(1); + + let notes = vec!["a note".to_string(), "another note".to_string()]; + after_open_for(&mut app, &r, notes.clone(), true); + let kept = [vec![changed.clone()], notes].concat(); + assert_eq!(app.ui.status, crate::io::opened_after_notice(unreadable, 3, &changed)); + assert_eq!(app.ui.status_notes, Some((app.ui.status.clone(), kept))); + assert!(app.ui.dialog.is_none()); + + after_open_for(&mut app, &r, vec![], true); + assert_eq!(app.ui.status, crate::io::opened_after_notice(unreadable, 1, &changed)); + assert_eq!(app.ui.status_notes, Some((app.ui.status.clone(), vec![changed.clone()]))); + + // One kind of line alone shows as before. + after_open_for(&mut app, &json!({ "modifiedLinks": [{ "ids": [3] }] }), vec![], true); + assert_eq!((app.ui.status.clone(), &app.ui.status_notes), (changed, &None)); + + app.session.prefs.update_links = "askWhenModified".into(); + after_open_for(&mut app, &r, vec![], true); + let d = app.ui.dialog.as_ref().expect("asks"); + assert_eq!((d.kind.as_str(), d.str("__command")), (super::super::confirm::KIND, "links.update".to_string())); + assert_eq!((app.ui.status.as_str(), &app.ui.status_notes), (unreadable, &None)); + } + /// The line about modified linked files that follows the Linked File Not Found dialog keeps the /// notes of that open, also when another message was shown meanwhile. An open without notes /// shows the line alone, even while the status bar shows an earlier open's notes, and a later diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..63cabcab30 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1771,6 +1771,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - On Windows, a link on a drive mapped to a network share other than the document's (`Y:\…`) is missing, with the reason that the path is on another computer, as a link stored with that share's own path is; links on this computer's drives and on the document's share are followed. - In the Links panel, Shift-click selects a range of links and Ctrl/Cmd-click adds or removes one. - When a document opens with notes and with linked files that changed on disk (Update Links: Manually) or, on the web, can't be read, the status bar shows the line about the linked files, then counts the notes and names the first, and hovering it lists the notes. The same holds when the line about modified files follows the Linked File Not Found dialog, and File › New from Template… shows the notes of the file it opens as File › Open does (`an_open_with_modified_links_keeps_link_notice_and_import_notes_reachable`, `new_from_template_preserves_open_warnings`, `an_open_with_unreadable_links_keeps_import_notes_reachable`, `modified_links_after_the_missing_ones_keep_the_open_notes`, `combined_open_and_link_status_lists_notes_on_hover_and_for_accessibility`). + - On the web, when a document opens with linked files that can't be read and linked files that changed on disk (Update Links: Manually), the status bar shows the line about the unreadable files, and the line about the changed files is the first of the notes its hover lists, ahead of the open's notes. With Ask When Modified the update question opens and the line about the unreadable files stays (`a_web_open_with_unreadable_and_modified_links_keeps_both_lines`). - Linked images and placed documents kept only in symbols, graph designs, patterns or opacity masks are listed in the Links panel after the layers' own, one row per stored object, with their status in its Missing and Modified filters, in Check Links, in the missing and modified files reported when a document opens, in the link watch and in Find in Folder; Relink, Update, Embed, Placement Options and Link Info act on them, and Go To says they have no place on the canvas. Opening a document gives such an object whose id is 0 or repeats another object's a new id. - Linked files another app changes while their document is open follow Preferences › File Handling › Update Links, as they do when it opens: Automatically reads them again (an Update Links undo step), Ask When Modified offers to, Manually leaves them modified in the Links panel. The desktop app compares the active document’s linked files by size and modification time every two seconds and when its window comes back to the front, on a worker thread; a file still being written is tried again (`links.updateChanged`). - A look at the linked files whose worker thread ends without a result, such as after a panic, no longer stops later looks: the app clears it, stops asking for a frame every 100 ms, and the next look starts on schedule (`crates/engine/src/tests/linkwatch.rs`, `crates/ui-egui/src/tests/place.rs`). From b006f4a35ff985b05c3ad74b62135c535e792c33 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:35:11 -0800 Subject: [PATCH 015/108] i18n: French translates the DWG and damaged binary DXF messages --- crates/ui-egui/src/i18n/fr.tsv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 6c48bb2687..bc641414a0 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7653,4 +7653,6 @@ breakText Glyphs Glyphes @msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pixels, c’est trop grand pour le JPEG (65535 pixels par côté au plus) : réduisez la résolution @msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pixels, c’est trop grand pour le Targa (65535 pixels par côté au plus) : réduisez la résolution @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixels, c’est trop grand pour le PSD ({MAX_SIDE} pixels par côté au plus) : réduisez la résolution +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that c’est un dessin DWG, qui ne peut pas être lu : enregistrez-le depuis l’application de CAO au format DXF et ouvrez ce fichier +@msg this binary DXF file is damaged or cut short ce fichier DXF binaire est endommagé ou tronqué @msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixels, c’est trop grand pour le GIF (65535 pixels par côté au plus) : réduisez la résolution From 9ab8b6ce16af81954f7e79e91bf6c8066f146af5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:12:45 -0800 Subject: [PATCH 016/108] i18n: German translates the messages no catalog had a row for The untranslated report listed 167 status and error messages with no row in any complete-message catalog, and 11 more that other catalogs translate but German did not, so with the interface in German these messages showed in English. - de.tsv gains 116 `@msg` rows for the listed messages: image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, 3D and Revolve limits, and script, zip and file errors. They sit in one commented block after the existing message rows. - de.tsv gains 10 `@msg` rows for the Banner Hems and Grommets errors and the failed recovery save. - The 51 listed messages that open #7211 and #7378 translate (composite fonts and SVG filters), and the justification order error that open #7116 translates, are left out, so no row is added twice. - Placeholders, parameter names, command ids and literal values stay as the English writes them. The translations use the catalog's existing terms and typography. - docs/localization-parity.md and docs/target-app-parity.md give the German counts: 3,563 `@msg` and 48 `@msgplural` rows, 52 messages still listed. --- crates/ui-egui/src/i18n/de.tsv | 128 +++++++++++++++++++++++++++++++++ docs/localization-parity.md | 2 +- docs/target-app-parity.md | 2 +- 3 files changed, 130 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 951f6f9c37..172657bff7 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -8887,6 +8887,134 @@ breakText Glyphs Glyphen @msg the paths are too many or too tangled to find where they cross die Pfade sind zu zahlreich oder zu verschlungen, um ihre Kreuzungen zu finden @msg the rectangle or line reaches too many paths to check das Rechteck oder die Linie erreicht zu viele Pfade, um sie zu prüfen @msg {name} must be a number {name} muss eine Zahl sein +# Messages no catalog translated yet: image export and color profiles, color books and swatch exchange files, 3D and Revolve, and script and file errors. +@msg 3D effects require finite coordinates within 100 million points 3D-Effekte erfordern endliche Koordinaten innerhalb von 100 Millionen Punkt +@msg 3D effects require one to ten lights 3D-Effekte erfordern ein bis zehn Lichter +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP-Farbtiefe {_1}: 1, 4, 8, 16, 24 oder 32 Bit pro Pixel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP-Kodierung fehlgeschlagen: {width} × {height} Pixel passen nicht zum Format oder zum Pixelpuffer +@msg GIF encoding failed: the palette image is malformed GIF-Kodierung fehlgeschlagen: Das Palettenbild ist fehlerhaft +@msg GIF encoding failed: {e} GIF-Kodierung fehlgeschlagen: {e} +@msg JPEG colour profile: {e} JPEG-Farbprofil: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG-Kodierung fehlgeschlagen: Der Pixelpuffer passt nicht zur Bildgröße +@msg JPEG encoding failed: {e} JPEG-Kodierung fehlgeschlagen: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG-Kodierung fehlgeschlagen: Der Pixelpuffer passt nicht zur Bildgröße +@msg PNG encoding failed: the palette image is malformed PNG-Kodierung fehlgeschlagen: Das Palettenbild ist fehlerhaft +@msg PNG encoding failed: {e} PNG-Kodierung fehlgeschlagen: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG-Kodierung fehlgeschlagen: {width} × {height} Pixel sind keine gültige Bildgröße +@msg PSD colour profile: {e} PSD-Farbprofil: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD-Kodierung fehlgeschlagen: Der Pixelpuffer passt nicht zur Bildgröße +@msg Revolve profile contains invalid coordinates Kreiseln: Das Profil enthält ungültige Koordinaten +@msg Revolve profile is too complex Kreiseln: Das Profil ist zu komplex +@msg Revolve projection is not finite Kreiseln: Die Projektion ist nicht endlich +@msg Revolve requires finite profile coordinates within 100 million points Kreiseln erfordert endliche Profilkoordinaten innerhalb von 100 Millionen Punkt +@msg Revolve surface is too complex; reduce Segments or simplify the profile Kreiseln: Die Oberfläche ist zu komplex; verringern Sie „Segmente“ oder vereinfachen Sie das Profil +@msg Revolve surface is too complex; simplify the profile Kreiseln: Die Oberfläche ist zu komplex; vereinfachen Sie das Profil +@msg Revolve visibility cannot split the projected boundary Kreiseln: Die Sichtbarkeitsberechnung kann die projizierte Begrenzung nicht teilen +@msg Revolve visibility creates too many fragments Kreiseln: Die Sichtbarkeitsberechnung erzeugt zu viele Fragmente +@msg Revolve visibility creates too many vector anchors Kreiseln: Die Sichtbarkeitsberechnung erzeugt zu viele Vektor-Ankerpunkte +@msg Revolve visibility exceeds its geometry work limit Kreiseln: Die Sichtbarkeitsberechnung überschreitet ihre Grenze für den Geometrieaufwand +@msg Revolve visibility exceeds its spatial index limit Kreiseln: Die Sichtbarkeitsberechnung überschreitet ihre Grenze für den räumlichen Index +@msg Revolve visibility has too many boundary crossings Kreiseln: Die Sichtbarkeitsberechnung hat zu viele Kreuzungen der Begrenzung +@msg Revolve visibility has too many input anchors Kreiseln: Die Sichtbarkeitsberechnung hat zu viele Eingabe-Ankerpunkte +@msg Revolve visibility requires convex cap sectors Kreiseln: Die Sichtbarkeitsberechnung erfordert konvexe Sektoren der Deckflächen +@msg Revolve visibility requires finite projected faces Kreiseln: Die Sichtbarkeitsberechnung erfordert endliche projizierte Flächen +@msg SVG options: {e} SVG-Optionen: {e} +@msg Save for Web settings: {e} Einstellungen für „Für Web speichern“: {e} +@msg TIFF colour profile: {e} TIFF-Farbprofil: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF-Kodierung fehlgeschlagen: Der Pixelpuffer passt nicht zur Bildgröße +@msg TIFF encoding failed: {e} TIFF-Kodierung fehlgeschlagen: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa-Farbtiefe {_1}: 16, 24 oder 32 Bit pro Pixel +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa-Kodierung fehlgeschlagen: Der Pixelpuffer passt nicht zur Bildgröße +@msg The 3D projection is not finite Die 3D-Projektion ist nicht endlich +@msg The 3D shadow is too complex; turn Shadows off or simplify the art Der 3D-Schatten ist zu komplex; schalten Sie „Schatten“ aus oder vereinfachen Sie die Grafik +@msg The shape contains invalid coordinates Die Form enthält ungültige Koordinaten +@msg Too many Revolve faces for visibility evaluation Zu viele Kreiseln-Flächen für die Sichtbarkeitsberechnung +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft liest höchstens {ASE_MAX_ENTRIES} Farben und Gruppen aus einer Farbfeld-Austauschdatei, und diese Bibliothek hat {entries} +@msg WebP encoding failed: {e} WebP-Kodierung fehlgeschlagen: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` ist smallThumb, mediumThumb, largeThumb, smallList oder largeList +@msg a line can't run from a point to itself eine Linie kann nicht von einem Punkt zu sich selbst verlaufen +@msg a line needs at least two points eine Linie braucht mindestens zwei Punkte +@msg a linked JavaScript file is outside the read roots eine verknüpfte JavaScript-Datei liegt außerhalb der Lesestammordner +@msg a number cannot be read eine Zahl kann nicht gelesen werden +@msg a swatch exchange block is too long ein Block der Farbfeld-Austauschdatei ist zu lang +@msg a swatch exchange name is too long ein Name in der Farbfeld-Austauschdatei ist zu lang +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels ein Bild mit {sw} × {sh} Pixeln kann nicht auf {width} × {height} Pixel skaliert werden +@msg a {width} × {height} image is too large ein Bild mit {width} × {height} Pixeln ist zu groß +@msg a {width} × {height} image: {e} ein Bild mit {width} × {height} Pixeln: {e} +@msg an image could not be written: {e} ein Bild konnte nicht geschrieben werden: {e} +@msg an image that couldn't be read was left out ein Bild, das nicht gelesen werden konnte, wurde ausgelassen +@msg can't open “{name}”: {e} „{name}“ kann nicht geöffnet werden: {e} +@msg cannot align zip entries to {align} bytes die ZIP-Einträge können nicht auf {align} Byte ausgerichtet werden +@msg cannot open the automation {kind} root `{_1}`: {e} der Automatisierungs-Stammordner ({kind}) `{_1}` kann nicht geöffnet werden: {e} +@msg cannot read profile: {0} das Profil kann nicht gelesen werden: {0} +@msg color book version {version} isn't supported (only 1) die Farbbuchversion {version} wird nicht unterstützt (nur 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) Farbbücher im Farbraum {other} werden nicht unterstützt (nur RGB, CMYK und Lab) +@msg file name too long to zip: {_1} der Dateiname ist zu lang für ein ZIP-Archiv: {_1} +@msg file name too long to zip: {name} der Dateiname ist zu lang für ein ZIP-Archiv: {name} +@msg freeform line {i}: {e} Freiformlinie {i}: {e} +@msg freeform point {i}: {e} Freiformpunkt {i}: {e} +@msg give `{key}` or `{other}`, not both geben Sie `{key}` oder `{other}` an, nicht beides +@msg grayscale profiles can't be working spaces yet Graustufenprofile können noch keine Arbeitsfarbräume sein +@msg input contains NaN or infinite coordinates die Eingabe enthält NaN oder unendliche Koordinaten +@msg input path could not be closed der Eingabepfad konnte nicht geschlossen werden +@msg invalid ICC profile: {0} ungültiges ICC-Profil: {0} +@msg invalid scale {scale} ungültige Skalierung {scale} +@msg its localized names take more than {_1} KB seine lokalisierten Namen belegen mehr als {_1} KB +@msg its objects are nested too deep ({e}) seine Objekte sind zu tief verschachtelt ({e}) +@msg its tag table lists the `{_1}` tag more than once seine Tag-Tabelle führt das Tag `{_1}` mehr als einmal auf +@msg not a graphic style library: {e} keine Grafikstil-Bibliothek: {e} +@msg not a swatch library (.vcswatches or .gpl) keine Farbfeldbibliothek (.vcswatches oder .gpl) +@msg not a swatch library (format `{_1}`) keine Farbfeldbibliothek (Format `{_1}`) +@msg not a swatch library: {e} keine Farbfeldbibliothek: {e} +@msg not an action set file ({e}) keine Aktionssatzdatei ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray der Farbraum {other} des Profils ist nicht RGB, CMYK oder Graustufen +@msg regular expression too large regulärer Ausdruck zu groß +@msg script file is not UTF-8 text: {value} die Skriptdatei ist kein UTF-8-Text: {value} +@msg stop {i}: {e} Farbstopp {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) die Version {major}.{minor} der Farbfeld-Austauschdatei wird nicht unterstützt (nur 1.x) +@msg the art of a graph design in a graph series is drawn again from the design: edit the design to change it die Grafik eines Diagrammdesigns in einer Diagrammreihe wird aus dem Design neu gezeichnet: Bearbeiten Sie das Design, um sie zu ändern +@msg the color book holds more than {ASE_MAX_ENTRIES} colors das Farbbuch enthält mehr als {ASE_MAX_ENTRIES} Farben +@msg the color book is cut short das Farbbuch ist unvollständig +@msg the color book's names take more than {_1} MB die Namen des Farbbuchs belegen mehr als {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution das Bild hätte {w} × {h} Pixel; Rasterexporte sind auf {MAX_RASTER_SIDE} Pixel pro Seite und {_1} Megapixel begrenzt: Verringern Sie die Skalierung oder die Auflösung +@msg the optimised image can't be read back: {e} das optimierte Bild kann nicht zurückgelesen werden: {e} +@msg the pixel buffer doesn't match the image size der Pixelpuffer passt nicht zur Bildgröße +@msg the preview: {e} die Vorschau: {e} +@msg the request may not read the New Document profiles folder die Anfrage darf den Ordner der Profile für neue Dokumente nicht lesen +@msg the shapes are too degenerate to combine die Formen sind zu entartet, um sie zu kombinieren +@msg the shapes cross themselves and each other too often to combine die Formen überschneiden sich selbst und einander zu oft, um sie zu kombinieren +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups die Farbfeld-Austauschdatei enthält mehr als {ASE_MAX_ENTRIES} Farben und Gruppen +@msg the swatch exchange file is cut short die Farbfeld-Austauschdatei ist unvollständig +@msg the {_1} plate can't be read: {e} der Farbauszug {_1} kann nicht gelesen werden: {e} +@msg this binary DXF file is damaged or cut short diese binäre DXF-Datei ist beschädigt oder unvollständig +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that dies ist eine DWG-Zeichnung, die nicht gelesen werden kann: Speichern Sie sie in der CAD-App als DXF und öffnen Sie diese Datei +@msg too many classes zu viele Zeichenklassen +@msg too many groups zu viele Gruppen +@msg too many layers for PSD (at most 32767) zu viele Ebenen für PSD (höchstens 32767) +@msg too many swatch exchange blocks zu viele Blöcke in der Farbfeld-Austauschdatei +@msg unknown colour profile: {0} unbekanntes Farbprofil: {0} +@msg {_1} clashes with a built-in profile name {_1} kollidiert mit dem Namen eines integrierten Profils +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} Pixel ist zu groß für GIF (höchstens 65535 Pixel pro Seite): Verringern Sie die Auflösung +@msg {_1}: no usable transform to/from sRGB {_1}: keine verwendbare Transformation von/nach sRGB +@msg {name} is not a CMYK profile {name} ist kein CMYK-Profil +@msg {name} is not an RGB profile {name} ist kein RGB-Profil +@msg {path}: could not be read {path}: konnte nicht gelesen werden +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} Pixel ist zu groß für JPEG (höchstens 65535 Pixel pro Seite): Verringern Sie die Auflösung +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} Pixel ist zu groß für Targa (höchstens 65535 Pixel pro Seite): Verringern Sie die Auflösung +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} Pixel ist zu groß für PSD (höchstens {MAX_SIDE} Pixel pro Seite): Verringern Sie die Auflösung +# Messages other catalogs translate and German did not: Banner Hems and Grommets and recovery data. +@msg `{key}` must be from 0.01 to 1000 pt `{key}` muss zwischen 0,01 und 1000 pt liegen +@msg select the banner, or mark every artboard wählen Sie das Banner aus oder markieren Sie alle Zeichenflächen +@msg the banner has no width or height das Banner hat keine Breite oder Höhe +@msg the grommet inset is too large for the banner der Randabstand der Ösen ist zu groß für das Banner +@msg the hem is too deep for the banner der Saum ist zu tief für das Banner +@msg the spacing makes more than {MAX_GROMMETS} grommets der Abstand ergibt mehr als {MAX_GROMMETS} Ösen +@msg there is no banner to mark es gibt kein Banner zum Markieren +@msg turn on at least one side aktivieren Sie mindestens eine Seite +@msg with no hem and no grommets there is nothing to mark ohne Saum und ohne Ösen gibt es nichts zu markieren +@msg {saving} failed: {e} {saving} fehlgeschlagen: {e} Banner Hems and Grommets… Bannersäume und Ösen… Banner Hems and Grommets Bannersäume und Ösen Hem Saum diff --git a/docs/localization-parity.md b/docs/localization-parity.md index 6cbad8f5e3..da94e3c977 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -35,7 +35,7 @@ Chinese by `imachus`). Only Georgian is recorded as reviewed by a native speaker | Portuguese | `pt-br` | 9,260 rows, 3,445 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 39 missing messages for it; one/other plurals | all | Latin | contributor is a Brazilian Portuguese speaker; further native review welcome | full | — (review) | | Indonesian | `id` | 5,279 rows, 750 of them `@msg` (counted 2026-10-21): menus and `tl!` literals complete when counted; its messages are partial; one plural form | dialogs and tooltips all; 750 message rows (French has 796) | Latin | no | full | — (review) | | Japanese | `ja` | 4,004 / 4,020 (99.6%) | all | CJK UI font as above; Japanese IME; vertical type partial; Japanese crop marks and composition settings | no | full | — (review) | -| German | `de` | 3,952 / 4,020 (98%; menus, literals and messages complete when counted) | all (3,433 `@msg` and 48 `@msgplural` rows, counted 2026-11-13: the untranslated report lists 48 missing messages for it) | Latin | contributor-written, not reviewed | full | — (review) | +| German | `de` | 3,952 / 4,020 (98%; menus, literals and messages complete when counted) | all (3,563 `@msg` and 48 `@msgplural` rows, counted 2026-11-13: the untranslated report lists 52 missing messages for it, which open #7116, #7211 and #7378 translate) | Latin | contributor-written, not reviewed | full | — (review) | | Korean | `ko` | 4,870 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form | all | Hangul from an installed system font on the desktop (Apple SD Gothic Neo, Malgun Gothic, Noto Sans CJK KR…); the web build has no Korean UI font yet (craft-fonts); IME path exists | no (AI-drafted) | full | — (review; web font) | | Vietnamese | `vi` | 4,886 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form; 4,046 plain + 18 `@plural` + 28 contextual + 794 `@msg` | all | Latin with Vietnamese diacritics (stacked marks attach in precomposed, decomposed and keyboard forms, #4491; glyph tests pass) | contributor is a Vietnamese speaker; AI-assisted draft, further native review welcome | full | — (review) | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..d618eb0867 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -902,7 +902,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The Simplified Chinese catalog (`crates/ui-egui/src/i18n/zh-hans.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,439 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins. The report lists 40 Simplified Chinese messages: the composite font, justification order and Blob Brush connect end errors that open #7211, #7116 and #7330 translate, and two messages that no catalog has a row for yet. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. - Edit › Undo and Edit › Redo, in the in-window and native menus, name the step in the interface language as the History panel lists it (`panels::history::step_name`), so when the catalog has no plain row for a step named after an effect, such as Feather, the menu shows the translation of the effect's menu row without its ellipsis (`undo_and_redo_name_the_step_as_the_history_panel_does`). - The History panel translates the undo step names the engine, the tools and the shell write as literals: the untranslated report (`untranslated_report`) lists any a complete catalog lacks, and a step whose catalog row exists only with an ellipsis (such as an effect's menu name) shows that row without the ellipsis. - - The German catalog (`crates/ui-egui/src/i18n/de.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,433 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins. The report lists 48 German messages; 38 of them are the composite font, select-a-path and justification order errors that open #7211, #7214 and #7116 translate. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. + - The German catalog (`crates/ui-egui/src/i18n/de.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,563 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins, including the image export, color profile, color book, swatch exchange file, DXF import and Revolve errors that no other catalog translates yet. The report lists 52 German messages: the composite font and SVG filter errors that open #7211 and #7378 translate, and the justification order error that open #7116 translates. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. - The History panel menu has Step Backward and Step Forward, which run Edit › Undo and Edit › Redo and are disabled when there is no step to undo or redo, and Set History Limit…, which opens Preferences at Performance, where History States is set. - The History panel menu's Clear History (`edit.clearHistory`) removes every step to undo and to redo and leaves the document as it is; it is not an undo step itself, and it is disabled when there is no step to clear. - The New Document from State button at the bottom of the History panel (`edit.newDocumentFromState`) makes a new document, which becomes active, from the state the panel has selected ([public source](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/undo-edits-and-manage-design-history.html)). VectorCraft's own rules: the new document takes the next Untitled-N name, is marked unsaved, has nothing selected and has no steps to undo or redo, and the source document and its steps stay as they are. From 2d862c1c678bbf17e617df14f78163ecddad1e70 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:43:10 -0800 Subject: [PATCH 017/108] i18n: French leaves the SVG filter and composite font messages to their own pull requests Open pull requests #7211 and #7378 add French rows for these 51 messages. Keeping them here too would make bundled_catalogs_are_consistent fail on a duplicate row once both merge. --- crates/ui-egui/src/i18n/fr.tsv | 53 +--------------------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index bc641414a0..e069cd3212 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7488,10 +7488,9 @@ breakText Glyphs Glyphes Grommet Inset Distance des œillets au bord Diameter Diamètre -# Messages of the effects, 3D, image export, color profiles, composite fonts, swatch exchange files and color books. +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. @msg 3D effects require finite coordinates within 100 million points Les effets 3D exigent des coordonnées finies comprises dans 100 millions de points @msg 3D effects require one to ten lights Les effets 3D exigent d’une à dix lumières -@msg <{_1}> isn't an element of an SVG filter <{_1}> n’est pas un élément de filtre SVG @msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel Profondeur BMP {_1} : 1, 4, 8, 16, 24 ou 32 bits par pixel @msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer Échec de l’encodage BMP : {width} × {height} pixels ne conviennent ni au format ni au tampon de pixels @msg GIF encoding failed: the palette image is malformed Échec de l’encodage GIF : l’image à palette est mal formée @@ -7536,16 +7535,6 @@ breakText Glyphs Glyphes @msg [{j}] `{_1}`: {why} [{j}] `{_1}` : {why} @msg `answers[{i}]` {e} `answers[{i}]` {e} @msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` vaut smallThumb, mediumThumb, largeThumb, smallList ou largeList -@msg `{_1}` can't name a composite font `{_1}` ne peut pas nommer une police composite -@msg `{_1}` is the name of an installed font `{_1}` est le nom d’une police installée -@msg `{_1}`: {_2} is set in `{font}`, a composite font `{_1}` : {_2} est composé en `{font}`, une police composite -@msg `{name}`: give the kanji part `{name}` : indiquez la partie kanji -@msg `{name}`: parts must be an object `{name}` : parts doit être un objet -@msg `{name}`: unknown class `{k}`; the classes are kanji, kana, punctuation, symbols, roman and numerals `{name}` : classe inconnue `{k}` ; les classes sont kanji, kana, punctuation, symbols, roman et numerals -@msg `{name}`: unknown key `{k}` in {_1} `{name}` : clé inconnue `{k}` dans {_1} -@msg `{name}`: {_1} must be an object `{name}` : {_1} doit être un objet -@msg `{raw}` can't name a composite font (1 to {COMPOSITE_NAME_MAX} characters, no control characters) `{raw}` ne peut pas nommer une police composite (de 1 à {COMPOSITE_NAME_MAX} caractères, sans caractères de contrôle) -@msg a document keeps at most {COMPOSITE_FONTS_MAX} composite fonts un document conserve au plus {COMPOSITE_FONTS_MAX} polices composites @msg a line can't run from a point to itself une ligne ne peut pas relier un point à lui-même @msg a line needs at least two points une ligne nécessite au moins deux points @msg a linked JavaScript file is outside the read roots un fichier JavaScript lié se trouve hors des dossiers racines de lecture @@ -7555,13 +7544,6 @@ breakText Glyphs Glyphes @msg a {sw} × {sh} image can't be resized to {width} × {height} pixels une image de {sw} × {sh} ne peut pas être redimensionnée à {width} × {height} pixels @msg a {width} × {height} image is too large une image de {width} × {height} est trop grande @msg a {width} × {height} image: {e} une image de {width} × {height} : {e} -@msg an SVG filter has at most {MAX_PRIMITIVES} primitives un filtre SVG comporte au plus {MAX_PRIMITIVES} primitives -@msg an SVG filter has no event attributes such as {_1} un filtre SVG ne comporte aucun attribut d’événement tel que {_1} -@msg an SVG filter is at most {_1} KB un filtre SVG fait au plus {_1} Ko -@msg an SVG filter's elements nest at most {MAX_DEPTH} deep les éléments d’un filtre SVG s’imbriquent sur au plus {MAX_DEPTH} niveaux -@msg an SVG filter's id is at most {MAX_NAME} characters l’id d’un filtre SVG compte au plus {MAX_NAME} caractères -@msg an SVG filter's images are PNG, JPEG, GIF or WebP data: URLs les images d’un filtre SVG sont des URL data: PNG, JPEG, GIF ou WebP -@msg an SVG filter's images have at most {MAX_IMAGE_PIXELS} pixels in all les images d’un filtre SVG comptent au plus {MAX_IMAGE_PIXELS} pixels au total @msg an image could not be written: {e} une image n’a pas pu être écrite : {e} @msg an image that couldn't be read was left out une image illisible a été omise @msg can't open “{name}”: {e} impossible d’ouvrir « {name} » : {e} @@ -7570,18 +7552,11 @@ breakText Glyphs Glyphes @msg cannot read profile: {0} impossible de lire le profil : {0} @msg color book version {version} isn't supported (only 1) la version {version} du carnet de couleurs n’est pas prise en charge (seulement 1) @msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) les carnets de couleurs dans l’espace colorimétrique {other} ne sont pas pris en charge (seulement RVB, CMJN et Lab) -@msg dataBase64 is not base64 dataBase64 n’est pas en base64 -@msg each font must be {name, parts} chaque police doit être {name, parts} -@msg each font needs a name chaque police nécessite un nom -@msg feTurbulence's numOctaves is at most {MAX_OCTAVES} le numOctaves de feTurbulence vaut au plus {MAX_OCTAVES} @msg file name too long to zip: {_1} nom de fichier trop long pour le zip : {_1} @msg file name too long to zip: {name} nom de fichier trop long pour le zip : {name} -@msg fonts must be a list of composite fonts fonts doit être une liste de polices composites @msg freeform line {i}: {e} ligne libre {i} : {e} @msg freeform point {i}: {e} point libre {i} : {e} @msg give `{key}` or `{other}`, not both indiquez `{key}` ou `{other}`, pas les deux -@msg give fonts: [{name, parts}…] indiquez fonts: [{name, parts}…] -@msg give one of path, data or dataBase64 indiquez path, data ou dataBase64 @msg grayscale profiles can't be working spaces yet les profils en niveaux de gris ne peuvent pas encore servir d’espaces de travail @msg input contains NaN or infinite coordinates l’entrée contient des coordonnées NaN ou infinies @msg input path could not be closed le tracé d’entrée n’a pas pu être fermé @@ -7590,37 +7565,20 @@ breakText Glyphs Glyphes @msg its localized names take more than {_1} KB ses noms localisés occupent plus de {_1} Ko @msg its objects are nested too deep ({e}) ses objets sont trop profondément imbriqués ({e}) @msg its tag table lists the `{_1}` tag more than once sa table de balises répertorie la balise `{_1}` plus d’une fois -@msg names must be a list of names names doit être une liste de noms -@msg names must be strings names doit contenir des chaînes -@msg no composite font aucune police composite -@msg no composite font named `{n}` aucune police composite nommée `{n}` -@msg no composite fonts to export aucune police composite à exporter -@msg not a composite fonts file: no compositeFonts list ce n’est pas un fichier de polices composites : aucune liste compositeFonts -@msg not a composite fonts file: {e} ce n’est pas un fichier de polices composites : {e} @msg not a graphic style library: {e} ce n’est pas une bibliothèque de styles graphiques : {e} @msg not a swatch library (.vcswatches or .gpl) ce n’est pas une bibliothèque de nuances (.vcswatches ou .gpl) @msg not a swatch library (format `{_1}`) ce n’est pas une bibliothèque de nuances (format `{_1}`) @msg not a swatch library: {e} ce n’est pas une bibliothèque de nuances : {e} @msg not an action set file ({e}) ce n’est pas un fichier de jeu de scripts ({e}) -@msg path is empty le chemin est vide @msg profile colour space {other} is not RGB, CMYK or Gray l’espace colorimétrique {other} du profil n’est pas RVB, CMJN ou Niveaux de gris @msg regular expression too large expression régulière trop volumineuse @msg script file is not UTF-8 text: {value} le fichier de script n’est pas du texte UTF-8 : {value} @msg stop {i}: {e} étape de dégradé {i} : {e} @msg swatch exchange version {major}.{minor} isn't supported (only 1.x) la version {major}.{minor} du fichier d’échange de nuances n’est pas prise en charge (seulement 1.x) -@msg the element needs an id, the filter's name l’élément nécessite un id, le nom du filtre -@msg the SVG filter can't be drawn: check its primitives and their inputs le filtre SVG ne peut pas être dessiné : vérifiez ses primitives et leurs entrées -@msg the SVG filter has no primitives le filtre SVG ne comporte aucune primitive -@msg the SVG filter is too large once its attributes are written out le filtre SVG est trop volumineux une fois ses attributs écrits en entier -@msg the SVG filter isn't valid XML: {e} le filtre SVG n’est pas du XML valide : {e} @msg the art of a graph design in a graph series is drawn again from the design: edit the design to change it l’illustration d’une conception de graphe dans une série de graphe est redessinée à partir de la conception : modifiez la conception pour la changer @msg the color book holds more than {ASE_MAX_ENTRIES} colors le carnet de couleurs contient plus de {ASE_MAX_ENTRIES} couleurs @msg the color book is cut short le carnet de couleurs est tronqué @msg the color book's names take more than {_1} MB les noms du carnet de couleurs occupent plus de {_1} Mo -@msg the file holds more than {COMPOSITE_FONTS_MAX} composite fonts le fichier contient plus de {COMPOSITE_FONTS_MAX} polices composites -@msg the file holds no composite fonts le fichier ne contient aucune police composite -@msg the file holds two composite fonts named `{_1}` le fichier contient deux polices composites nommées `{_1}` -@msg the file is larger than 4 MB le fichier dépasse 4 Mo @msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution l’image mesurerait {w} × {h} pixels ; les exports en pixels sont limités à {MAX_RASTER_SIDE} pixels par côté et à {_1} mégapixels : réduisez l’échelle ou la résolution @msg the optimised image can't be read back: {e} l’image optimisée ne peut pas être relue : {e} @msg the pixel buffer doesn't match the image size le tampon de pixels ne correspond pas à la taille de l’image @@ -7635,21 +7593,12 @@ breakText Glyphs Glyphes @msg too many groups trop de groupes @msg too many layers for PSD (at most 32767) trop de calques pour le PSD (32767 au plus) @msg too many swatch exchange blocks trop de blocs dans le fichier d’échange de nuances -@msg two composite fonts are named `{_1}` deux polices composites sont nommées `{_1}` @msg unknown colour profile: {0} profil colorimétrique inconnu : {0} -@msg unknown key `{k}`; a font takes name and parts clé inconnue `{k}` ; une police accepte name et parts @msg {_1} clashes with a built-in profile name {_1} entre en conflit avec le nom d’un profil intégré @msg {_1}: no usable transform to/from sRGB {_1} : aucune transformation utilisable vers ou depuis sRGB -@msg {k}: baseline must be {_1} to {_2}% {k} : baseline doit être compris entre {_1} et {_2} % -@msg {k}: give a font {k} : indiquez une police -@msg {k}: only kana can be scaled at the center {k} : seuls les kana peuvent être mis à l’échelle au centre -@msg {k}: only kana, roman and numerals can be scaled {k} : seuls kana, roman et numerals peuvent être mis à l’échelle -@msg {k}: scale must be {_1} to {_2}% {k} : scale doit être compris entre {_1} et {_2} % -@msg {k}: size must be {_1} to {_2}% {k} : size doit être compris entre {_1} et {_2} % @msg {name} is not a CMYK profile {name} n’est pas un profil CMJN @msg {name} is not an RGB profile {name} n’est pas un profil RVB @msg {path}: could not be read {path} : lecture impossible -@msg {what} is at most {max} {what} vaut au plus {max} @msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pixels, c’est trop grand pour le JPEG (65535 pixels par côté au plus) : réduisez la résolution @msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pixels, c’est trop grand pour le Targa (65535 pixels par côté au plus) : réduisez la résolution @msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixels, c’est trop grand pour le PSD ({MAX_SIDE} pixels par côté au plus) : réduisez la résolution From f643cddec4c1ffaad52b89e79240a7f2f0f489ad Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:25:20 -0800 Subject: [PATCH 018/108] Dimension tool: a reflected aligned dimension has its line on the reflected side An unlinked aligned dimension that was reflected on its own kept its offset, which is measured along the left normal of a to b. A reflection turns that normal to the other side, so a line 30 pt above two level points stayed 30 pt above them after a flip top to bottom instead of going below them. The offset now changes sign when the transform reverses orientation, as a reflection or a scale by a negative factor does. Other transforms leave it as before, and linked, horizontal and vertical dimensions keep their own rules. Docs: docs/dimensions.md. --- crates/doc/src/dimension.rs | 4 +++ crates/engine/tests/it/dimensions.rs | 50 ++++++++++++++++++++++++++++ docs/dimensions.md | 3 +- 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/crates/doc/src/dimension.rs b/crates/doc/src/dimension.rs index 89df899743..e803d867fc 100644 --- a/crates/doc/src/dimension.rs +++ b/crates/doc/src/dimension.rs @@ -815,6 +815,10 @@ impl Dimension { if self.line_between_points() && !old.line_between_points() { self.keep_gap(&old); } + } else if self.mode == DimensionMode::Linear && xf.determinant() < 0.0 && (self.b - self.a).hypot() > 1e-9 { + // A reflection turns the left normal of a → b to the other side, so an aligned + // dimension's line stays on the reflected side of its points. + self.offset = -self.offset; } if self.mode == DimensionMode::Linear { self.length = self.measured(); diff --git a/crates/engine/tests/it/dimensions.rs b/crates/engine/tests/it/dimensions.rs index 56ee67be17..240a7fe280 100644 --- a/crates/engine/tests/it/dimensions.rs +++ b/crates/engine/tests/it/dimensions.rs @@ -419,6 +419,56 @@ fn a_reflected_horizontal_dimension_keeps_its_line_on_the_reflected_side() { assert_eq!(text(&s, id), "100.00 pt"); } +/// An unlinked aligned dimension reflected on its own has its line on the reflected side of its +/// points: a line 30 pt above a level pair is 30 pt below it after a flip top to bottom, and a +/// half turn moves it below them as well, by turning it. +#[test] +fn a_reflected_aligned_dimension_keeps_its_line_on_the_reflected_side() { + let mut s = session(); + let id = run(&mut s, "dimension.create", json!({"a":[100,200],"b":[200,200],"offset":-30}))["id"].as_u64().unwrap(); + assert_eq!(path_ends(&s, id)[2], vec![(100.0, 170.0), (200.0, 170.0)]); + run(&mut s, "select.set", json!({"ids":[id]})); + run(&mut s, "object.reflect", json!({"axis":"horizontal","origin":[0,200]})); + assert_eq!(path_ends(&s, id)[2], vec![(100.0, 230.0), (200.0, 230.0)]); + assert_eq!(text(&s, id), "100.00 pt"); + // Reflected left to right, the points swap ends and the line stays below them. + run(&mut s, "object.reflect", json!({"axis":"vertical","origin":[150,0]})); + assert_eq!(path_ends(&s, id)[2], vec![(200.0, 230.0), (100.0, 230.0)]); + run(&mut s, "edit.undo", json!({})); + run(&mut s, "edit.undo", json!({})); + assert_eq!(path_ends(&s, id)[2], vec![(100.0, 170.0), (200.0, 170.0)]); + // A half turn about the points' midpoint puts the line below them by turning it. + run(&mut s, "object.rotate", json!({"angle":180,"origin":[150,200]})); + let ends = path_ends(&s, id)[2].iter().map(|(x, y)| (x.round(), y.round())).collect::>(); + assert_eq!(ends, vec![(200.0, 230.0), (100.0, 230.0)]); +} + +/// An unlinked aligned dimension of a diagonal pair reflected about a mirror line through its +/// points has its line on the other side of them, and a scale by a negative factor reverses the +/// side as a reflection does, while a scale by positive factors keeps it. +#[test] +fn an_aligned_dimension_reflected_about_an_angle_or_scaled_by_a_negative_factor_changes_sides() { + let mut s = session(); + let id = run(&mut s, "dimension.create", json!({"a":[100,200],"b":[200,100],"offset":-30}))["id"].as_u64().unwrap(); + let k = 30.0 / 2f64.sqrt(); + let near = |got: &[(f64, f64)], want: [(f64, f64); 2]| got.iter().zip(want).all(|(g, w)| (g.0 - w.0).abs() < 1e-6 && (g.1 - w.1).abs() < 1e-6); + let ends = path_ends(&s, id)[2].clone(); + assert!(near(&ends, [(100.0 - k, 200.0 - k), (200.0 - k, 100.0 - k)]), "{ends:?}"); + run(&mut s, "select.set", json!({"ids":[id]})); + // The mirror line at 45 degrees through (150, 150) holds both points. + run(&mut s, "object.reflect", json!({"axis":45,"origin":[150,150]})); + let ends = path_ends(&s, id)[2].clone(); + assert!(near(&ends, [(100.0 + k, 200.0 + k), (200.0 + k, 100.0 + k)]), "{ends:?}"); + run(&mut s, "edit.undo", json!({})); + let level = run(&mut s, "dimension.create", json!({"a":[100,200],"b":[200,200],"offset":-30}))["id"].as_u64().unwrap(); + run(&mut s, "select.set", json!({"ids":[level]})); + run(&mut s, "object.scale", json!({"sx":-200,"sy":100,"origin":[150,0]})); + assert_eq!(path_ends(&s, level)[2], vec![(250.0, 170.0), (50.0, 170.0)]); + run(&mut s, "edit.undo", json!({})); + run(&mut s, "object.scale", json!({"sx":200,"sy":200,"origin":[150,200]})); + assert_eq!(path_ends(&s, level)[2], vec![(50.0, 170.0), (250.0, 170.0)]); +} + /// The line of a linked horizontal dimension below both points stays below them when the art /// turns a half turn; a line between the points keeps its distance from the first point. #[test] diff --git a/docs/dimensions.md b/docs/dimensions.md index 9cba8a66dc..377ab9d698 100644 --- a/docs/dimensions.md +++ b/docs/dimensions.md @@ -66,7 +66,8 @@ Measurements follow the art they measure through moves, scaling and anchor and h undo and redo included. When the art is reflected, the line of a linked linear dimension goes to the reflected side, as far past the outermost point as before. This does not happen for art whose anchors and handles all lie on one line, such as a straight line, which a half turn puts in the -same place as a reflection. Deleting the art, changing its number of anchors or whether it is +same place as a reflection. An unlinked aligned dimension that is reflected, or scaled by a +negative factor, has its line on the reflected side of its points. Deleting the art, changing its number of anchors or whether it is closed, turning an angle's arm into a curve, or making a measured circle or arc no longer circular leaves its dimensions where they were, no longer linked, in the same undo step, rather than attaching them to a different edge. Undo links them again. A linked dimension moved on its own From 7c40cd2df2984c91da6e052daa3a162ff6d07dae Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:56:38 -0800 Subject: [PATCH 019/108] Plug-ins: unlinking a gradient stop's spot swatch also clears its plates A filter or importer that changes a gradient paint unlinks each stop from its swatch and resets its tint, but left the stop's process plates. The PDF and EPS writers read plates only with a spot swatch, so the stop kept a plates array with no ink, saved with the document and compared in later edits. Unlinking now clears the plates too, in fills and strokes; a paint returned unchanged keeps its link, tint and plates. The plate clamping test now checks the decoded output, before admission. --- crates/plugins/src/objects.rs | 6 +-- crates/plugins/src/objects/tests.rs | 68 ++++++++++++++++++++++++++--- docs/plugins.md | 4 +- docs/target-app-parity.md | 1 + 4 files changed, 67 insertions(+), 12 deletions(-) diff --git a/crates/plugins/src/objects.rs b/crates/plugins/src/objects.rs index 3e844415a7..192ed24a96 100644 --- a/crates/plugins/src/objects.rs +++ b/crates/plugins/src/objects.rs @@ -951,7 +951,8 @@ fn paints(ap: &Appearance, fill: bool) -> Vec<&Paint> { } /// `p` without swatch links: a plug-in's colours are its own, so only paints it returned -/// unchanged keep theirs. +/// unchanged keep theirs. A gradient stop also loses its process plates, which print only with +/// a spot swatch. fn unlinked(mut p: Paint) -> Paint { match &mut p { Paint::Solid { swatch, tint, .. } => { @@ -961,8 +962,7 @@ fn unlinked(mut p: Paint) -> Paint { Paint::Gradient(g) => { g.swatch = None; for s in &mut g.gradient.stops { - s.swatch = None; - s.tint = 1.0; + s.set_color(s.color, None); } } Paint::None | Paint::Pattern { .. } => {} diff --git a/crates/plugins/src/objects/tests.rs b/crates/plugins/src/objects/tests.rs index 3483971355..5fb48cf396 100644 --- a/crates/plugins/src/objects/tests.rs +++ b/crates/plugins/src/objects/tests.rs @@ -109,27 +109,81 @@ fn only_a_radial_keeps_a_focal_point_through_a_plug_in() { } } -/// A gradient stop's process plates handed back out of range are clamped to 0..1, each in its +/// A gradient stop's process plates handed back out of range are read clamped to 0..1, each in its /// place, in a fill and in a stroke (a JSON number too large for `f32` is infinite); plates in range /// and a stop without plates are kept. #[test] fn gradient_stop_plates_are_clamped_through_a_plug_in() { use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop}; - let (mut d, ids, _) = doc(); + let (_, ids, _) = doc(); let stops = vec![GradientStop::new(0.0, Color::WHITE), GradientStop::new(0.5, Color::gray(0.5)), GradientStop::new(1.0, Color::BLACK)]; let mut p = serde_json::to_value(Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(GradientKind::Linear, stops))))).unwrap(); - p["gradient"]["stops"][0]["plates"] = json!([-0.5, 1.5, -1e300, 1e300]); - p["gradient"]["stops"][1]["plates"] = json!([0.25, 2.0, 0.75, -3.0]); + for (i, plates) in [(0, json!([-0.5, 1.5, -1e300, 1e300])), (1, json!([0.25, 2.0, 0.75, -3.0]))] { + p["gradient"]["stops"][i]["plates"] = plates; + p["gradient"]["stops"][i]["swatch"] = json!("Spot"); + } let out = json!({"objects": [{"id": ids[0].0, "fills": [p.clone()], "strokes": [{"paint": p}]}]}); - apply_output(&mut d, &ids, decode_json(out).unwrap(), None, &keep).unwrap(); - let ap = &d.node(ids[0]).unwrap().appearance; - for (what, paint) in [("fill", ap.fill_paint()), ("stroke", ap.stroke_paint())] { + let out = decode_json(out).unwrap(); + let fill = &out[0].fills.as_ref().unwrap()[0]; + let stroke = &out[0].strokes.as_ref().unwrap()[0].paint; + for (what, paint) in [("fill", fill), ("stroke", stroke)] { let Paint::Gradient(g) = paint else { panic!("a gradient {what}") }; let plates: Vec<_> = g.gradient.stops.iter().map(|s| s.plates).collect(); assert_eq!(plates, [Some([0.0, 1.0, 0.0, 1.0]), Some([0.25, 1.0, 0.75, 0.0]), None], "{what}"); } } +/// A gradient linked to a gradient swatch, whose first stop is linked to a spot swatch at a tint +/// with process plates. +fn spot_gradient(color: Color) -> Paint { + use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop}; + let mut spot = GradientStop::new(0.0, color); + spot.midpoint = 0.3; + spot.opacity = 0.75; + spot.set_color(color, Some(("Spot".into(), 0.4))); + spot.plates = Some([0.1, 0.2, 0.3, 0.4]); + let mut g = GradientPaint::new(Gradient::new(GradientKind::Linear, vec![spot, GradientStop::new(1.0, Color::BLACK)])); + g.swatch = Some("Blend".into()); + Paint::Gradient(Box::new(g)) +} + +/// A changed gradient handed back loses each stop's spot link, tint and process plates, in a fill +/// and in a stroke, and keeps the stop's color, offset, opacity and midpoint; a new stop handed back +/// with plates and no link has none. +#[test] +fn changed_gradient_fill_and_stroke_drop_spot_plates() { + let (mut d, ids, _) = doc(); + let a = ids[0]; + let was = Color::cmyk(0.0, 0.5, 1.0, 0.0); + d.node_mut(a).unwrap().appearance.set_fill(spot_gradient(was)); + d.node_mut(a).unwrap().appearance.set_stroke(spot_gradient(was)); + let now = Color::cmyk(0.0, 0.25, 0.5, 0.0); + let mut p = serde_json::to_value(spot_gradient(now)).unwrap(); + p["gradient"]["stops"][1]["plates"] = json!([0.5, 0.5, 0.5, 0.5]); + let out = json!({"objects": [{"id": a.0, "fills": [p.clone()], "strokes": [{"paint": p}]}]}); + apply_output(&mut d, &[a], decode_json(out).unwrap(), None, &keep).unwrap(); + let ap = &d.node(a).unwrap().appearance; + for (what, paint) in [("fill", ap.fill_paint()), ("stroke", ap.stroke_paint())] { + let Paint::Gradient(g) = paint else { panic!("a gradient {what}") }; + assert_eq!(g.swatch, None, "{what}"); + let stops: Vec<_> = g.gradient.stops.iter().map(|s| (s.offset, s.color, s.opacity, s.midpoint, s.swatch.clone(), s.tint, s.plates)).collect(); + assert_eq!(stops, [(0.0, now, 0.75, 0.3, None, 1.0, None), (1.0, Color::BLACK, 1.0, 0.5, None, 1.0, None)], "{what}"); + } +} + +/// A gradient handed back as it was keeps its stops' spot links, tints and process plates. +#[test] +fn unchanged_gradient_paint_keeps_spot_plates() { + let (mut d, ids, _) = doc(); + let a = ids[0]; + d.node_mut(a).unwrap().appearance.set_fill(spot_gradient(Color::cmyk(0.0, 0.5, 1.0, 0.0))); + d.node_mut(a).unwrap().appearance.set_stroke(spot_gradient(Color::cmyk(0.0, 0.5, 1.0, 0.0))); + let input: Value = serde_json::from_slice(&encode_input(&d, &[a])).unwrap(); + let before = d.clone(); + apply_output(&mut d, &[a], decode(&serde_json::to_vec(&input).unwrap()).unwrap(), None, &keep).unwrap(); + assert_eq!(d, before); +} + /// A plate that is not a number is 0; infinities go to the nearest end of 0..1. #[test] fn plates_that_are_not_finite_are_in_range() { diff --git a/docs/plugins.md b/docs/plugins.md index 5f1479748e..fac6460249 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -617,7 +617,7 @@ An **importer** gets the bytes of the file being opened, as they are (not JSON), `paint`, `width` in points, `join` (`"miter"`, `"round"` or `"bevel"`), `cap` (`"butt"`, `"round"` or `"square"`) and `miterLimit`. Paints use the native file format's form: `{"type": "solid", "color", "swatch"?, "tint"?}`, `{"type": "gradient", "gradient": {"kind": "Linear"|"Radial"|"Freeform", "stops": [{offset, color, opacity, - midpoint}], "dither"?, "method"?: "Perceptual"|"HueClockwise"|"HueCounterclockwise"}, "geom"?, "angle", "freeform"?}`, `{"type": "pattern", "pattern", + midpoint, swatch?, tint?, plates?}], "dither"?, "method"?: "Perceptual"|"HueClockwise"|"HueCounterclockwise"}, "geom"?, "angle", "freeform"?}`, `{"type": "pattern", "pattern", "xf"?}`. Colours are `{"model": "rgb", r, g, b}`, `{"model": "cmyk", c, m, y, k}`, `{"model": "gray", k}` (ink: 0 white, 1 black) or `{"model": "lab", l, a, b}`; components 0–1 except Lab's. - `effects` (filters): the object's own effects in order, as its effect records: `id` (as `effect.list` lists it, or @@ -742,7 +742,7 @@ most 100,000 objects and 4,000,000 anchors, 256 fills, strokes or gradient stops clamped into range, stroke weights to 0–1,000 pt and miter limits to 1–500; a pattern must exist in the document. A gradient stop's four process `plates` are clamped to 0–1 as well: a value that is not a number becomes 0, and an infinite one becomes 0 or 1 by its sign. A paint returned unchanged keeps its swatch link; any other paint is -unlinked. One refused effect record refuses the whole output. +unlinked, and each of its gradient stops then has no swatch, a tint of 1 and no `plates`. One refused effect record refuses the whole output. A filter's output may also hold `documentData`: any JSON of at most 1 MiB, which replaces what the plug-in keeps with the document (`null` removes it), in the same undo step as its objects. Settings that belong to the whole document diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..39c1eb14cf 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1929,6 +1929,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Live-effect plug-ins before a fill's or stroke's own 3D effect:** a live effect listed before a fill's or stroke's own Extrude & Bevel, Inflate or Rotate effect is given `_context.item` for that fill or stroke (`{"fill": i}` or `{"stroke": i}`), not `"object"`, in the drawn art, in the 3D meshes and in Expand as Wireframes; a deferred stage there is listed at that fill's or stroke's place. Regressions: `crates/effects/src/tests/solidcontext.rs`. Scores and hours unchanged. - **Filter plug-ins set effects and stroke styles (G17):** a filter is given each object's effect records and its strokes' `join`, `cap` and `miterLimit`, and may return them; the records are admitted as `effect.apply` admits them (a known effect or installed live-effect plug-in, parameters it takes, one 3D effect that fits, no texture read from a file), and one refused refuses the output. Regressions: `crates/engine/src/tests/plugins.rs`, `crates/plugins/src/objects/tests.rs`. Scores and hours unchanged. - **Gradient stop plates from filter plug-ins are clamped (G17):** the four process `plates` of a gradient stop in a filter's or importer's output are clamped to 0–1, as its other colors are; a value that is not a number becomes 0, and an infinite one becomes 0 or 1 by its sign. Painted live effects still refuse such a stop. Regressions: `crates/plugins/src/objects/tests.rs`. Scores and hours unchanged. +- **Changed plug-in gradients lose spot plates (G17):** a gradient that a filter or importer changes loses each stop's swatch link, tint and process `plates` together, in fills and strokes, and keeps the stop's color, offset, opacity and midpoint; a gradient returned unchanged keeps all three. Regressions: `crates/plugins/src/objects/tests.rs` (`changed_gradient_fill_and_stroke_drop_spot_plates`, `unchanged_gradient_paint_keeps_spot_plates`). Scores and hours unchanged. - **Plug-in data kept with the document (G17):** a filter writes JSON of at most 1 MiB with `documentData` (one undo step with its objects; `null` removes it) and reads it back in `_context.documentData`, which no other filter is given. It is the document's foreign data (`unknown.pluginData`, by plug-in id), as the perspective grid is, so the native file keeps it with no section of its own; an exporter is given the whole document, so it can read every plug-in's. Regressions: `crates/engine/src/tests/plugins.rs`, `crates/engine/tests/plugin_export.rs` (the exporter), `crates/doc/src/plugin_data.rs`, `crates/plugins/src/objects/tests.rs`. Scores and hours unchanged. - **Heavy filter plug-ins (G17):** a filter's manifest may ask for `"budget": "heavy"`: 1 G instructions (20 times a light run's) and 300 s a run, for routing, packing or simulation. Install Plug-in… and File › Open ask the user first, `plugin.install` needs `allowHeavy: true` (`plugin.inspect` tells beforehand), the Additional Plug-ins Folder skips such filters, and the plug-in store keeps the answer. Its dialog has no Preview; the app runs it on a thread of its own with a progress window (Cancel, Continue in Background) and applies the result as `plugin.run` with the same parameters, one undo step, unless the document or the plug-in changed meanwhile. Regressions: `crates/plugins/tests/abi.rs`, `crates/plugins/src/manifest.rs`, `crates/engine/src/tests/plugins.rs`, `crates/ui-egui/src/tests/plugin_runs.rs`. Scores and hours unchanged. - **Safe Mode for plug-ins (G17):** `vectorcraft --safe-mode` and `vectorcraft-cli --safe-mode ` start without plug-ins. When a launch stopped while a plug-in was loading or drawing its first live effect, the next launch names that plug-in, without saying it caused the stop, and offers Disable and Continue, Start Normally or Start in Safe Mode. Help › Safe Mode lists the disabled plug-ins with Enable on Re-launch, which takes effect at the next launch, and the app bar and the window title show Safe Mode. The help page (https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf, pages 65 to 69) describes the same choice between diagnosing and starting normally, a Safe Mode with the problem item off and the rest of the app working, and turning the item back on at the next launch. In Safe Mode no plug-in loads or runs, and a live-effect plug-in draws its object's geometry unchanged while the object keeps the effect, which the Appearance panel marks "(Safe Mode)" with the plug-in's id in its tooltip and `effect.list` marks `skipped`; Expand Appearance refuses such an object. The web build keeps no plug-ins between page loads and has no marker. Each desktop launch with preferences keeps a marker in the `Launch` folder next to them; `vectorcraft-cli` and a desktop launch without preferences keep none, so a stop there leads to no choice at the next launch. Disabled plug-ins are listed in `Plug-ins/disabled.json`. `plugin.safeMode` reports Safe Mode and the disabled plug-ins, and `plugin.setEnabled` changes the list. Regressions: `crates/plugins/src/safe_mode.rs`, `crates/plugins/tests/safe_mode.rs`, `crates/engine/tests/plugin_safe_mode.rs`, `crates/ui-egui/tests/safe_mode.rs`. Scores and hours unchanged. From be8fafde788f15c6b0a2cdacb5031e0519ff07f1 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:51:23 -0800 Subject: [PATCH 020/108] Type: justification spaces a right-to-left warichu block, and the caret keeps to its block line A justified line opened no gap before a right-to-left warichu block: the glyph drawn first after the text before it is not the block's first glyph, and it was taken as continuing the block. The block now starts at the first of its glyphs the line draws, and blocks the bidi order interleaves keep their starts. The caret next to a character of a block spanned the whole line. It now spans the band of the character's block line, as the selection does. --- crates/text/src/layout/flow.rs | 88 +++++++++++++++++++----- crates/text/src/layout/wrapping_tests.rs | 11 +-- crates/text/src/lib.rs | 37 +++++++--- crates/text/src/tests/warichu.rs | 45 ++++++++++++ 4 files changed, 150 insertions(+), 31 deletions(-) diff --git a/crates/text/src/layout/flow.rs b/crates/text/src/layout/flow.rs index 1ee9a3fe50..e7753c8c04 100644 --- a/crates/text/src/layout/flow.rs +++ b/crates/text/src/layout/flow.rs @@ -544,6 +544,9 @@ struct LineJustification { fit: LineFit, start_x: f64, after: Vec>, + /// The warichu glyphs drawn inside a block already started, by offset from the line's first + /// glyph ([`blocks_begun`]). + begun: Vec, kashidas: Vec<(usize, f64)>, /// Right-aligned area type: the line's last tab, which takes the text after it to the right /// edge (the text before it sits at its stops, from the left edge). @@ -805,14 +808,14 @@ fn visible_after(index: usize, glyph: usize, after: &[Option], sg: &[SGly next } -// The glyph after which a gap between drawn glyphs opens, and the visible glyph that follows it: -// not a held glyph, and never a zero-width format control on either side. -fn gap_pair<'a>(glyph: usize, held: &[usize], after: &[Option], index: usize, sg: &'a [SGlyph]) -> Option<(&'a SGlyph, &'a SGlyph)> { +// The glyph after which a gap between drawn glyphs opens, and the visible glyph that follows it +// with its index: not a held glyph, and never a zero-width format control on either side. +fn gap_pair<'a>(glyph: usize, held: &[usize], after: &[Option], index: usize, sg: &'a [SGlyph]) -> Option<(&'a SGlyph, &'a SGlyph, usize)> { if held.contains(&glyph) { return None; } let a = sg.get(glyph).filter(|a| !is_format_control(a.ch))?; - visible_after(index, glyph, after, sg).and_then(|next| sg.get(next)).map(|b| (a, b)) + visible_after(index, glyph, after, sg).and_then(|next| sg.get(next).map(|b| (a, b, next))) } // Are `a` and `b` glyphs of the same warichu block? Right to left, the bidi order can draw a @@ -821,18 +824,61 @@ fn same_warichu_block(a: &SGlyph, b: &SGlyph) -> bool { a.wari.zip(b.wari).is_some_and(|(first, second)| first.start == second.start) } +// Is glyph `next` drawn inside a block the line has already started: a tate-chu-yoko glyph after +// its block's first, or a warichu glyph drawn after another glyph of its block (`begun`, by offset +// from the line's first glyph, from [`blocks_begun`])? A warichu block starts at the first of its +// glyphs drawn on the line, which right to left is not the block's first glyph. +fn continues_drawn_block(next: usize, index: usize, begun: &[bool], sg: &[SGlyph]) -> bool { + let Some(b) = sg.get(next) else { return false }; + match (b.wari, next.checked_sub(index).and_then(|k| begun.get(k))) { + (Some(_), Some(&begun)) => begun, + _ => b.continues_block(), + } +} + +// The warichu glyphs of `line` drawn after another glyph of their block, by offset from the line's +// first glyph. A block the bidi order interleaves with another keeps its start. +fn blocks_begun(line: &LineGeometry, sg: &[SGlyph]) -> Vec { + let len = line.body.saturating_sub(line.index); + // Each glyph's block, as the offset of the block's first glyph: a block's glyphs are neighbors + // in `sg`, and a block stays on one line. + let mut first: Vec = Vec::with_capacity(len); + for k in 0..len { + let pair = k.checked_sub(1).and_then(|p| sg.get(line.index + p)).zip(sg.get(line.index + k)); + let block = match first.last() { + Some(&f) if pair.is_some_and(|(a, b)| same_warichu_block(a, b)) => f, + _ => k, + }; + first.push(block); + } + let mut started = vec![false; len]; + let mut begun = vec![false; len]; + for &j in &line.drawn { + let Some(k) = j.checked_sub(line.index).filter(|_| sg.get(j).is_some_and(|g| g.wari.is_some())) else { continue }; + let Some(&f) = first.get(k) else { continue }; + if let (Some(seen), Some(slot)) = (started.get(f).copied(), begun.get_mut(k)) { + *slot = seen; + } + if let Some(seen) = started.get_mut(f) { + *seen = true; + } + } + begun +} + // Japanese (and Chinese) lines are justified between their characters (JLREQ 3.8): the // gaps next to a CJK character, not inside a Latin word, a tate-chu-yoko or warichu block or a -// shaped cluster. -pub(super) fn is_cjk_gap(glyph: usize, held: &[usize], after: &[Option], index: usize, sg: &[SGlyph]) -> bool { - gap_pair(glyph, held, after, index, sg).is_some_and(|(a, b)| { +// shaped cluster. `begun` holds the warichu glyphs drawn inside a block already started +// ([`blocks_begun`]). +pub(super) fn is_cjk_gap(glyph: usize, held: &[usize], (after, begun): (&[Option], &[bool]), index: usize, sg: &[SGlyph]) -> bool { + gap_pair(glyph, held, after, index, sg).is_some_and(|(a, b, next)| { a.byte != b.byte && !a.is_space() && !b.is_space() - && !b.continues_block() && !same_warichu_block(a, b) && a.ch != '\t' && (is_cjk(a.ch) || is_cjk(b.ch)) + && !continues_drawn_block(next, index, begun, sg) }) && !in_pair(glyph, index, after, sg) } @@ -861,13 +907,20 @@ fn in_pair(glyph: usize, index: usize, after: &[Option], sg: &[SGlyph]) - // its drawn glyphs: not after a held glyph, nor inside a tate-chu-yoko block (one cell) or a // warichu block (set as one piece), a shaped cluster, whose glyphs (a letter and its combining marks, a conjunct and its matra) stay // together, or an inseparable pair. On a line that ends in a drawn hyphen, the gap before the -// hyphen counts too: it follows the line's last visible glyph. -pub(super) fn is_letter_gap(glyph: usize, held: &[usize], after: &[Option], index: usize, sg: &[SGlyph], hyphen: bool) -> bool { +// hyphen counts too: it follows the line's last visible glyph. `begun` is as for [`is_cjk_gap`]. +pub(super) fn is_letter_gap( + glyph: usize, + held: &[usize], + (after, begun): (&[Option], &[bool]), + index: usize, + sg: &[SGlyph], + hyphen: bool, +) -> bool { if held.contains(&glyph) || sg.get(glyph).is_none_or(|a| is_format_control(a.ch)) || in_pair(glyph, index, after, sg) { return false; } match gap_pair(glyph, held, after, index, sg) { - Some((a, b)) => a.byte != b.byte && !b.continues_block() && !same_warichu_block(a, b), + Some((a, b, next)) => a.byte != b.byte && !same_warichu_block(a, b) && !continues_drawn_block(next, index, begun, sg), None => hyphen, } } @@ -974,7 +1027,8 @@ fn justify_flow_line(cx: &Ctx<'_>, paragraph: &ParagraphData<'_, '_>, line: &Lin *slot = Some(b); } } - let cjk_gaps = (line.index..line.body).filter(|&j| free(j) && is_cjk_gap(j, held, &after, line.index, sg)).count(); + let begun = blocks_begun(line, sg); + let cjk_gaps = (line.index..line.body).filter(|&j| free(j) && is_cjk_gap(j, held, (&after, &begun), line.index, sg)).count(); // Single Word Justification: a justified line holding one word (no word space) is // spread between its letters (Full Justify) or aligned. A tab separates two words. let single_word = justify && fixed.is_empty() && spaces == 0 && cjk_gaps == 0; @@ -1013,7 +1067,7 @@ fn justify_flow_line(cx: &Ctx<'_>, paragraph: &ParagraphData<'_, '_>, line: &Lin let pushed_in = line.position.pushed_in && paragraph.regions.is_some() && cjk_gaps > 0 && width > room + EPS; if pushed_in { let ems: f64 = (line.index..line.body) - .filter(|&j| free(j) && is_cjk_gap(j, held, &after, line.index, sg) && may_squeeze(&sg[j])) + .filter(|&j| free(j) && is_cjk_gap(j, held, (&after, &begun), line.index, sg) && may_squeeze(&sg[j])) .map(|j| squeeze_em(&sg[j], cx.vertical)) .sum(); if ems > EPS { @@ -1044,7 +1098,7 @@ fn justify_flow_line(cx: &Ctx<'_>, paragraph: &ParagraphData<'_, '_>, line: &Lin let used: f64 = flex.iter().map(|f| fit.letter(f) + fit.glyph(f)).sum(); let rest = room - width - used; let hyphen = line.hyphen.is_some(); - let gaps = (line.index..line.body).filter(|&j| free(j) && is_letter_gap(j, held, &after, line.index, sg, hyphen)).count(); + let gaps = (line.index..line.body).filter(|&j| free(j) && is_letter_gap(j, held, (&after, &begun), line.index, sg, hyphen)).count(); if gaps > 0 && rest > EPS { per_gap = rest / gaps as f64; } @@ -1076,7 +1130,7 @@ fn justify_flow_line(cx: &Ctx<'_>, paragraph: &ParagraphData<'_, '_>, line: &Lin _ => line.ax1 + line.opt_r - width, } }; - LineJustification { per_space, per_gap, per_cjk, squeeze, fit, start_x, after, kashidas, last_tab, trailing, fixed } + LineJustification { per_space, per_gap, per_cjk, squeeze, fit, start_x, after, begun, kashidas, last_tab, trailing, fixed } } /// The advance and leader of tab `glyph_index` of `line`, drawn at `order_index` of @@ -1203,10 +1257,10 @@ fn emit_flow_line(cx: &mut Ctx<'_>, pen: &mut Pen<'_>, paragraph: &ParagraphData advance += justification.fit.letter(&flex) + justification.fit.glyph(&flex); scale = justification.fit.glyph_scale(&flex); if justification.per_cjk != 0.0 || justification.squeeze != 0.0 { - if is_cjk_gap(glyph_index, &line.held, &justification.after, index, sg) { + if is_cjk_gap(glyph_index, &line.held, (&justification.after, &justification.begun), index, sg) { advance += justification.per_cjk + squeeze_after(glyph, justification.squeeze, cx.vertical); } - } else if is_letter_gap(glyph_index, &line.held, &justification.after, index, sg, line.hyphen.is_some()) { + } else if is_letter_gap(glyph_index, &line.held, (&justification.after, &justification.begun), index, sg, line.hyphen.is_some()) { advance += justification.per_gap; } } diff --git a/crates/text/src/layout/wrapping_tests.rs b/crates/text/src/layout/wrapping_tests.rs index eae22bab8a..3a83a5673b 100644 --- a/crates/text/src/layout/wrapping_tests.rs +++ b/crates/text/src/layout/wrapping_tests.rs @@ -1173,11 +1173,14 @@ fn justification_adds_no_gap_inside_a_warichu_block_drawn_right_to_left() { let mut glyphs = synthetic_glyphs(&[(0, 2, 10.0, first), (2, 2, 0.0, second)]); block(&mut glyphs[0], 0, 0.0); block(&mut glyphs[1], 0, 10.0); - assert!(!flow::is_letter_gap(1, &[], &after, 0, &glyphs, false), "{first}{second}"); - assert!(!flow::is_cjk_gap(1, &[], &after, 0, &glyphs), "{first}{second}"); + // Glyph 0 is drawn after glyph 1 of its block. + let begun = [true, false]; + assert!(!flow::is_letter_gap(1, &[], (&after, &begun), 0, &glyphs, false), "{first}{second}"); + assert!(!flow::is_cjk_gap(1, &[], (&after, &begun), 0, &glyphs), "{first}{second}"); // The same two glyphs as the first glyphs of two blocks. block(&mut glyphs[1], 2, 0.0); - assert!(flow::is_letter_gap(1, &[], &after, 0, &glyphs, false), "{first}{second}"); - assert_eq!(flow::is_cjk_gap(1, &[], &after, 0, &glyphs), first == '漢', "{first}{second}"); + let begun = [false, false]; + assert!(flow::is_letter_gap(1, &[], (&after, &begun), 0, &glyphs, false), "{first}{second}"); + assert_eq!(flow::is_cjk_gap(1, &[], (&after, &begun), 0, &glyphs), first == '漢', "{first}{second}"); } } diff --git a/crates/text/src/lib.rs b/crates/text/src/lib.rs index 2ff6b9ad5b..3065b9a153 100644 --- a/crates/text/src/lib.rs +++ b/crates/text/src/lib.rs @@ -556,25 +556,32 @@ fn cluster_extent(layout: &TextLayout, glyphs: &[PositionedGlyph], i: usize) -> /// Caret for byte offset `byte`, as a (top, bottom) segment in text space. In horizontal type, a /// cluster drawn with several glyphs is measured whole ([`cluster_extent`]). Inside a ligature the -/// caret stands at its caret stops ([`PositionedGlyph::carets`]). +/// caret stands at its caret stops ([`PositionedGlyph::carets`]). Next to a character of a warichu +/// block the caret spans the band of its block line, as its highlight does. pub fn caret_position(layout: &TextLayout, byte: usize) -> (Point, Point) { let Some(line) = layout.lines.get(layout.line_of(byte)) else { return (Point::ZERO, Point::ZERO); }; let glyphs = &layout.glyphs[line.glyph_start..line.glyph_end]; - let (pos, angle) = if let Some(i) = glyphs.iter().position(|g| g.byte <= byte && g.byte + g.len > byte) { + let (pos, angle, glyph) = if let Some(i) = glyphs.iter().position(|g| g.byte <= byte && g.byte + g.len > byte) { let g = &glyphs[i]; let (origin, advance) = match cluster_extent(layout, glyphs, i) { Some((left, right)) => (Point::new(left, g.origin.y), right - left), None => (g.origin, g.advance), }; let off = g.caret_offset(byte, advance); - (origin + dir(g.angle) * if g.rtl { advance - off } else { off }, g.angle) + (origin + dir(g.angle) * if g.rtl { advance - off } else { off }, g.angle, Some(g)) } else if let Some(g) = glyphs.iter().max_by_key(|g| g.byte + g.len) { - (g.origin + dir(g.angle) * if g.rtl { 0.0 } else { g.advance }, g.angle) + (g.origin + dir(g.angle) * if g.rtl { 0.0 } else { g.advance }, g.angle, Some(g)) } else { - (layout.physical_point(Point::new(line.x0, line.baseline)), if layout.vertical { std::f64::consts::FRAC_PI_2 } else { 0.0 }) + (layout.physical_point(Point::new(line.x0, line.baseline)), if layout.vertical { std::f64::consts::FRAC_PI_2 } else { 0.0 }, None) }; + if let Some((_, top, bottom)) = + glyph.filter(|g| g.warichu.is_some() && !layout.on_path).and_then(|g| block_band(&warichu_rows(layout, line), line, g)) + { + let x = layout.logical_point(pos).x; + return (layout.physical_point(Point::new(x, top)), layout.physical_point(Point::new(x, bottom))); + } // Up vector in y-down space, rotated with the baseline. let d = dir(angle); let up = Vec2::new(d.y, -d.x); @@ -786,6 +793,20 @@ fn warichu_rows(layout: &TextLayout, l: &LineInfo) -> Vec<(usize, f64, f64)> { rows } +/// The band across line `l` (text space, from the top) of the block line that warichu glyph `g` is +/// on, with that block line's index in its block: out to halfway to the block lines next to it, +/// and to the line's top or bottom past the block's outer lines. `rows` are the line's +/// [`warichu_rows`]. None for a glyph of no block. +fn block_band(rows: &[(usize, f64, f64)], l: &LineInfo, g: &PositionedGlyph) -> Option<(usize, f64, f64)> { + let block = g.warichu?; + let lines = rows.get(rows.partition_point(|r| r.0 < block)..rows.partition_point(|r| r.0 <= block)).unwrap_or_default(); + let row = lines.partition_point(|r| r.1 < g.warichu_line - 1e-9); + let own = lines.get(row).filter(|r| (r.1 - g.warichu_line).abs() < 1e-9)?; + let top = row.checked_sub(1).and_then(|k| lines.get(k)).map_or(l.baseline - l.ascent, |above| (above.2 + own.2) * 0.5); + let bottom = lines.get(row + 1).map_or(l.baseline + l.descent, |below| (below.2 + own.2) * 0.5); + Some((row, top, bottom)) +} + /// A glyph of a warichu block line, for [`selection_quads`]: its block and block line, its extent /// along the line and its band across it (text space), and whether the selection covers it. struct BlockPiece { @@ -829,11 +850,7 @@ pub fn selection_quads(layout: &TextLayout, a: usize, b: usize) -> Vec<[Point; 4 let mut pieces: Vec = Vec::new(); for (i, g) in layout.glyphs.iter().enumerate().take(l.glyph_end).skip(l.glyph_start) { let Some(block) = g.warichu else { continue }; - let lines = rows.get(rows.partition_point(|r| r.0 < block)..rows.partition_point(|r| r.0 <= block)).unwrap_or_default(); - let row = lines.partition_point(|r| r.1 < g.warichu_line - 1e-9); - let Some(own) = lines.get(row).filter(|r| (r.1 - g.warichu_line).abs() < 1e-9) else { continue }; - let top = row.checked_sub(1).and_then(|k| lines.get(k)).map_or(l.baseline - l.ascent, |above| (above.2 + own.2) * 0.5); - let bottom = lines.get(row + 1).map_or(l.baseline + l.descent, |below| (below.2 + own.2) * 0.5); + let Some((row, top, bottom)) = block_band(&rows, l, g) else { continue }; let x = layout.logical_point(g.origin).x; let selected = selected(i, g); let (f0, f1) = if selected { covered(g) } else { (0.0, g.advance) }; diff --git a/crates/text/src/tests/warichu.rs b/crates/text/src/tests/warichu.rs index d68cb8fccc..6aee052cbd 100644 --- a/crates/text/src/tests/warichu.rs +++ b/crates/text/src/tests/warichu.rs @@ -433,6 +433,51 @@ fn blocks_the_bidi_order_interleaves_keep_their_places() { assert!(c.x < bet.x && bet.x < z.x, "{c:?} {bet:?} {z:?}"); } +/// A justified line spreads its letters with the same gap before a right-to-left block as before a +/// left-to-right one: the block starts at the first of its glyphs the line draws. +#[test] +fn justification_opens_the_same_gap_before_a_right_to_left_block() { + for inside in ["cd", "אב"] { + let at = |justify: Justify| { + let mut t = area("", style(20.0), Rect::new(0.0, 0.0, 200.0, 400.0), justify); + t.runs = vec![TextRun::new("ab", style(20.0)), TextRun::new(inside, marked(20.0)), TextRun::new("z", style(20.0))]; + let l = layout(db(), &t); + let x = |byte: usize| l.glyphs.iter().filter(|g| g.byte == byte).map(|g| g.origin.x).fold(f64::INFINITY, f64::min); + let block = l.glyphs.iter().filter(|g| g.warichu.is_some()).map(|g| g.origin.x).fold(f64::INFINITY, f64::min); + (x(0), x(1), block, x(2 + inside.len())) + }; + let (a, b, block, z) = at(Justify::Left); + let (a2, b2, block2, z2) = at(Justify::JustifyAll); + let gap = (b2 - a2) - (b - a); + assert!(gap > 1.0, "{inside}: the line is spread: {gap}"); + assert!(((block2 - b2) - (block - b) - gap).abs() < 1e-6, "{inside}: the gap before the block: {} {gap}", (block2 - b2) - (block - b)); + assert!(((z2 - block2) - (z - block) - gap).abs() < 1e-6, "{inside}: the gap after the block: {} {gap}", (z2 - block2) - (z - block)); + } +} + +/// The caret next to a character of a block spans the band of the character's block line, not +/// the whole line. +#[test] +fn the_caret_in_a_block_spans_its_block_line() { + let l = layout(db(), &with_block("cdef", marked(20.0))); + let (c, e) = (&l.glyphs[2], &l.glyphs[4]); + let middle = (c.origin.y + e.origin.y) * 0.5; + let line = &l.lines[0]; + // "c" and "d", on the upper line. + for byte in [2, 3] { + let (top, bottom) = caret_position(&l, byte); + assert!((top.y - (line.baseline - line.ascent)).abs() < 1e-6 && (bottom.y - middle).abs() < 1e-6, "{byte}: {top:?} {bottom:?} {middle}"); + } + // "e" and "f", on the lower line. + for byte in [4, 5] { + let (top, bottom) = caret_position(&l, byte); + assert!((top.y - middle).abs() < 1e-6 && (bottom.y - (line.baseline + line.descent)).abs() < 1e-6, "{byte}: {top:?} {bottom:?} {middle}"); + } + // Outside the block the caret spans the line. + let (top, bottom) = caret_position(&l, 0); + assert!((top.y - (line.baseline - line.ascent)).abs() < 1e-6 && (bottom.y - (line.baseline + line.descent)).abs() < 1e-6); +} + /// A click on a block's lower line goes to that line's characters, not to the character of the /// upper line at the same place along the block. #[test] From 85e0d59bfa88b145f38658037e96d2a4884e4f9a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 18:53:52 -0800 Subject: [PATCH 021/108] Brushes: Scale Proportionately art grows with the stroke weight An Art brush set to Scale Proportionately drew its art at the same size on every stroke weight: the art was scaled across only by how much the path stretched it along and by the brush's Width. Stretch to Fit Stroke Length and Stretch Between Guides already multiply by the stroke weight. Proportional art now does too, so a 3 pt stroke draws it three times as wide as a 1 pt stroke, still as long as the path. The same applies to each run with Overlap on and to a Width that follows the pen. Existing Scale Proportionately art brush strokes at weights other than 1 pt draw scaled by the stroke weight. Strokes at 1 pt draw as before. --- crates/brush/src/lib.rs | 3 ++- crates/brush/src/tests.rs | 44 +++++++++++++++++++++++++++++++++++++++ crates/brush/src/warp.rs | 21 +++++-------------- docs/target-app-parity.md | 1 + 4 files changed, 52 insertions(+), 17 deletions(-) diff --git a/crates/brush/src/lib.rs b/crates/brush/src/lib.rs index 080462d0b6..851afc9e7a 100644 --- a/crates/brush/src/lib.rs +++ b/crates/brush/src/lib.rs @@ -351,7 +351,8 @@ pub enum Direction { #[derive(Clone, Copy, Debug, Default, PartialEq, Serialize, Deserialize)] #[serde(rename_all = "camelCase", tag = "mode")] pub enum ArtScale { - /// Keep the art's proportions (length follows the path; width scales with it). + /// Keep the art's proportions (length follows the path; width scales with it, times the + /// stroke weight and the brush width). Proportional, /// Stretch the art to the path length. #[default] diff --git a/crates/brush/src/tests.rs b/crates/brush/src/tests.rs index 2d62a1a993..ecaba1266a 100644 --- a/crates/brush/src/tests.rs +++ b/crates/brush/src/tests.rs @@ -141,6 +141,50 @@ fn art_brush_proportional_keeps_aspect() { assert!(near(bounds(&out).height(), 8.0, 1e-6)); } +/// Scale Proportionately art is scaled across by the stroke weight and the Width, as Stretch art +/// is, on top of the scale the path length gives it. +#[test] +fn art_brush_proportional_grows_with_weight() { + let brush = |width: f64, overlap: bool| { + let mut b = art_brush(rect_art(100.0, 4.0), ArtScale::Proportional); + if let BrushKind::Art(a) = &mut b.kind { + (a.width, a.overlap) = (width, overlap); + } + b + }; + let draw = |b: &Brush, bp: &BezPath, st: &StrokeLayer| stroke_pieces(&Document::new(1.0, 1.0), b, bp, st); + // 3 pt stroke → 3× wider than at 1 pt (8 pt); the length still follows the path. + let b = bounds(&draw(&brush(100.0, false), &line(0.0, 0.0, 200.0, 0.0), &stroke(3.0))); + assert!(near(b.height(), 24.0, 1e-6) && near(b.x0, 0.0, 1e-6) && near(b.x1, 200.0, 1e-6), "{b:?}"); + // The Width (50 %) applies on top of the stroke weight. + let b = bounds(&draw(&brush(50.0, false), &line(0.0, 0.0, 200.0, 0.0), &stroke(3.0))); + assert!(near(b.height(), 12.0, 1e-6), "{b:?}"); + // A path twice as long at twice the weight (as Scale Strokes & Effects at 200 % leaves it): + // 2× from the length and 2× from the weight. + let b = bounds(&draw(&brush(100.0, false), &line(0.0, 0.0, 400.0, 0.0), &stroke(2.0))); + assert!(near(b.height(), 32.0, 1e-6), "{b:?}"); + // With Overlap, each run between corners is scaled by its own length and by the weight: the + // 100 pt run 4 pt × 3 across, the 50 pt run 2 pt × 3. + let mut bent = BezPath::new(); + bent.move_to((0.0, 0.0)); + bent.line_to((100.0, 0.0)); + bent.line_to((100.0, 50.0)); + let out = draw(&brush(100.0, true), &bent, &stroke(3.0)); + assert_eq!(out.len(), 2); + let (r0, r1) = (out[0].geometric_bounds().unwrap(), out[1].geometric_bounds().unwrap()); + assert!(near(r0.height(), 12.0, 1e-6) && near(r1.width(), 6.0, 1e-6), "{r0:?} {r1:?}"); + // A width that follows the pen: 50 % at the lightest pressure, 300 % at the heaviest, times + // the 2 pt weight (4 pt art on a 100 pt path: 4 pt across at 100 %, 1 pt either side). + let mut pen = brush(50.0, false); + if let BrushKind::Art(a) = &mut pen.kind { + (a.width_mode, a.width_max) = (Some(Variation::Pressure), Some(300.0)); + } + let ramp = StrokeLayer { width: 2.0, ..pressed(vec![(0.0, 0.0), (1.0, 1.0)]) }; + let out = draw(&pen, &line(0.0, 0.0, 100.0, 0.0), &ramp); + assert!(near(half_width(&out, 0.0, 1.0), 2.0, 0.1), "{}", half_width(&out, 0.0, 1.0)); + assert!(near(half_width(&out, 99.0, 100.0), 12.0, 0.2), "{}", half_width(&out, 99.0, 100.0)); +} + #[test] fn art_brush_between_guides_keeps_ends() { // Head (last 20 % of a 100 pt art) keeps its 20 pt length on a 300 pt path. diff --git a/crates/brush/src/warp.rs b/crates/brush/src/warp.rs index c72e1c33f8..edf0ac0567 100644 --- a/crates/brush/src/warp.rs +++ b/crates/brush/src/warp.rs @@ -465,17 +465,8 @@ fn art_runs(t: &Track) -> Vec<(f64, f64)> { bounds.windows(2).map(|w| (w[0], w[1])).collect() } -/// The art on [s0, s1] of `t`, `cross` across where `widen` (0..=1, by arc length) is 1, and -/// `width` the width (%) there. -fn art_on_run( - t: &Track, - (s0, s1): (f64, f64), - a: &ArtBrush, - (art, b): (&Node, Rect), - cross: f64, - width: f64, - widen: &dyn Fn(f64) -> f64, -) -> Option { +/// The art on [s0, s1] of `t`, `cross` across where `widen` (0..=1, by arc length) is 1. +fn art_on_run(t: &Track, (s0, s1): (f64, f64), a: &ArtBrush, (art, b): (&Node, Rect), cross: f64, widen: &dyn Fn(f64) -> f64) -> Option { let l = s1 - s0; if l <= 1e-9 { return None; @@ -483,10 +474,8 @@ fn art_on_run( let w = b.width(); let (along, cross) = match a.scale { ArtScale::Stretch => (AlongMap::linear(w, s0, s1), cross), - ArtScale::Proportional => { - let k = l / w; - (AlongMap::linear(w, s0, s1), k * width / 100.0) - } + // Scaled across as much as along, times the stroke weight and the width, as the other modes are. + ArtScale::Proportional => (AlongMap::linear(w, s0, s1), l / w * cross), ArtScale::BetweenGuides { start, end } => { let (g0, g1) = (start.clamp(0.0, 1.0) * w, end.clamp(0.0, 1.0) * w); let (g0, g1) = (g0.min(g1), g0.max(g1)); @@ -528,7 +517,7 @@ pub(crate) fn art(a: &ArtBrush, bp: &BezPath, weight: f64, stroke: &StrokeLayer) }; let runs = if a.overlap { art_runs(&t) } else { vec![(0.0, l)] }; for run in runs { - if let Some(n) = art_on_run(&t, run, a, (&art, b), cross, width, &widen) { + if let Some(n) = art_on_run(&t, run, a, (&art, b), cross, &widen) { out.push(n); } } diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..5f8e6e7ab0 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1519,6 +1519,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Strokes:** one stroke-geometry module shared by the canvas, SVG, PDF and Outline Stroke; dotted lines (zero-length dashes draw dots or squares); arrowheads with hollow outlines, tip-on-end or extend-past-end alignment and one opacity for line and head. SVG and PDF export arrowheads, width profiles, brushes and aligned strokes exactly as the canvas draws them; Outline Stroke and the live Outline Stroke effect outline every stroke item as drawn (dashes, heads, profiles, alignment); dashes can be fitted to corners and path ends; width profiles carry through dashes, and their corners take the join. The Stroke panel edits type's character strokes, follows the stroke units (its weight presets are round values in that unit: `0.25 mm`, `0.0625 in`, `1 px`, #426; fields show four decimals in mm, cm and inches, three in points), shows mixed values blank and opens from the Control bar. A width profile library, thirty-one more arrowheads (among them Line Arrow: two arms of the head's weight (stroke weight × arrowhead scale, at least 0.25 pt: the line's weight at 100 % for lines of 0.25 pt or more) at right angles, cut square, #5421), and Width Point Edit with multi-select and discontinuous points. Visual bounds and clicks cover the whole painted stroke. Scale Strokes & Effects, Scale Corners and Use Preview Bounds work everywhere, and new art inherits stroke options, a graphic style or the whole last appearance. A width profile's sides run as a smooth C1 curve between the width points (a monotone cubic Hermite, Fritsch–Carlson, with the one-sided three-point PCHIP slope at the profile's ends and flat either side of a step), sampled adaptively along the path (two samples per profile segment, refined where the width bends, and leaning on dense path flattening) so straight runs draw it too; added samples offset along the source curve's exact tangent, not the flattened chord, so high zoom follows the true width; the sampled edges are fitted with G1 cubics within a tenth of the flattening tolerance (0.001 pt at the default 0.01 pt) rather than one cubic per flatten step, so exports stay close to a uniform stroke's path data; a point reshapes the curve as far as its neighbours' neighbours (their slopes depend on it), and coincident points still step. - **Brushes (part of #852):** double-clicking a brush in the Brushes panel (or the panel menu's Brush Options…) opens Calligraphic Brush Options (Name; Angle, Roundness and Size, each Fixed, Random, Pressure, Tilt, Bearing or Rotation with its Variation; live previews of the nib and of a light–heavy–light stroke) or Bristle Brush Options (Shape and the bristle sliders); OK edits the brush and every stroke painted with it. The Paintbrush records the pen pressure along each stroke (kept with the path, saved, and joined when a stroke continues a path); a Calligraphic value on Pressure goes from value − variation at the lightest pressure to value + variation at the heaviest, on the canvas and in SVG, PDF and the other exports. Brushes saved before keep their look. Scatter Brush Options (Size, Spacing, Scatter and Rotation, each Fixed, Random between two values, Pressure from the first at the lightest pressure to the second at the heaviest, Tilt, Bearing or Rotation; Rotation relative to Page or Path), Art Brush Options (Width, Scale Proportionately, Stretch to Fit Stroke Length or Stretch Between Guides with the guides' start and end, the four Directions, Flip Along and Across, Overlap) and Pattern Brush Options (Scale, Spacing, the five tiles shown, Flip Along and Across, Stretch to fit, Add space to fit or Approximate path) each have Colorization (None, Tints, Tints and Shades, Hue Shift with its Key Color picked from the art's colours) and a live stroke preview; values from files and commands are clamped to their ranges. Art Brush Options › Overlap places art on each run between sharp corners so folds do not overlap (`ArtBrush.overlap`; `art_brush_overlap_splits_at_corners`). Still to come: Stylus Wheel, pen pressure on macOS where the windowing layer reports none, and tilt, bearing and rotation for Pattern and Bristle brushes and on native Wayland and the web. Under Tints and Tints and Shades, art in black ink alone goes by its ink amount, and a process or gray stroke color's tints and shades stay in that color's model; these are VectorCraft's own rules. + Scale Proportionately art is scaled across by the stroke weight and the Width, as Stretch to Fit Stroke Length and Stretch Between Guides art is, on top of the scale the path length gives it, so a 3 pt stroke draws the art three times as wide as a 1 pt stroke. The [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page says Scale Proportionately keeps the art's proportions and does not say how the stroke weight applies; that rule is VectorCraft's own. Evidence: `tests::art_brush_proportional_grows_with_weight` (vectorcraft-brush). Type in a scatter brush's art takes the brush's colorization as its paths do: Tints, Tints and Shades and Hue Shift recolor the characters' solid fills and strokes in each copy the brush draws, and Brush Options' Key Color list, whose first color is Hue Shift's default key, counts the characters' fills and their strokes wider than 0. The Brushes page says that a scatter, art or pattern brush takes its colors from the current stroke color and the brush's colorization method () and does not mention type there; recoloring the characters' paints like the art's fills and strokes is VectorCraft's own rule. The Symbol Stainer mixes the characters' strokes of type toward the stain as it mixes their fills. Evidence: `tests::scatter_colorization_recolors_type`, `tests::art_colors_list_the_most_used_first`, `tests::stain_mixes_type_strokes_too` (vectorcraft-brush). - **Pen tilt, bearing and rotation (part of #764):** Calligraphic and Scatter Brush Options offer Tilt, Bearing and Rotation beside Fixed, Random and Pressure. The Paintbrush records along each stroke how far the pen leans, which way, and how far its barrel is turned (kept with the path, saved, and joined when a stroke continues a path). A Calligraphic value on Tilt goes from value − variation with the pen lying flat to value + variation upright; on Bearing or Rotation it adds variation × the angle over 180°, so Angle on Bearing with a Variation of 180° turns the nib with the way the pen leans. A Scatter value goes from its first value to its second over the same ranges. A stroke without that input draws the brush's own value. On Linux under X11 and XWayland the app reads the tilt and an Art Pen's barrel rotation from XInput2, on macOS it reads them from AppKit's tablet events, and `path.freehand` points and `pointer_gesture` events carry them on every platform. The [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page defines the three options and does not say which way each one runs; that mapping is VectorCraft's own rule. Evidence: `tests::tilt_maps_to_roundness_along_the_stroke`, `tests::bearing_and_rotation_turn_the_nib`, `tests::scatter_values_follow_tilt_and_bearing` (vectorcraft-brush), `tests_brushsym::paintbrush_records_the_pens_tilt_on_the_stroke` (vectorcraft-engine), `tablet::tests::a_pens_tilt_and_rotation_go_into_the_feed` and `mac_tablet::tests::a_pens_tilt_and_rotation_go_into_the_feed` (vectorcraft). Art Brush Options' Width (1% to 1000%) and Pattern Brush Options' Scale (1% to 10000%) each have a slider beside the field, over the same range in whole percents; screen readers name the slider as its row and read the field's value. From ec31808bf234319ae03d1be767e09241591c9808 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:42:13 -0800 Subject: [PATCH 022/108] i18n: Spanish translates 114 messages that no catalog had a row for The untranslated report lists 167 status and error messages that none of the 23 complete-message catalogs translates. Spanish now has an @msg row for 114 of them: the errors of the image encoders, color profiles, swatch exchange files and color books, 3D and Revolve, path operations, DXF import, the script engine and the parameter checks. Open #7211 and #7378 add Spanish rows for 51 of the others, and 2 stay in English. The rows keep their placeholders, backticked names, accepted values (smallThumb, RGB, CMYK, Lab, Gray) and limits as the English writes them. A test checks the Spanish shown for messages of each group. --- crates/ui-egui/src/i18n/es.tsv | 116 +++++++++++++++++++++++++++++++ crates/ui-egui/src/i18n/tests.rs | 38 ++++++++++ docs/target-app-parity.md | 1 + 3 files changed, 155 insertions(+) diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index d1c6aa53af..8f165e4576 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -7323,6 +7323,122 @@ breakText Glyphs Glifos @msg only an exporter or an importer declares `extensions` solo un plugin de exportación o de importación declara `extensions` @msg an importer always gets an import's budget: leave `budget` out un plugin de importación siempre recibe el presupuesto de una importación: omita `budget` +# Messages of the image encoders, color profiles, swatch exchange files and color books, 3D and Revolve, path operations, DXF import, the script engine and parameter checks. +@msg 3D effects require finite coordinates within 100 million points Los efectos 3D requieren coordenadas finitas dentro de 100 millones de puntos +@msg 3D effects require one to ten lights Los efectos 3D requieren de una a diez luces +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel Profundidad de BMP {_1}: 1, 4, 8, 16, 24 o 32 bits por píxel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer Error al codificar BMP: {width} × {height} píxeles no caben en el formato o no coinciden con el búfer de píxeles +@msg GIF encoding failed: the palette image is malformed Error al codificar GIF: la imagen con paleta está mal formada +@msg GIF encoding failed: {e} Error al codificar GIF: {e} +@msg JPEG colour profile: {e} Perfil de color de JPEG: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size Error al codificar JPEG: el búfer de píxeles no coincide con el tamaño de la imagen +@msg JPEG encoding failed: {e} Error al codificar JPEG: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size Error al codificar PNG: el búfer de píxeles no coincide con el tamaño de la imagen +@msg PNG encoding failed: the palette image is malformed Error al codificar PNG: la imagen con paleta está mal formada +@msg PNG encoding failed: {e} Error al codificar PNG: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size Error al codificar PNG: {width} × {height} píxeles no es un tamaño de imagen válido +@msg PSD colour profile: {e} Perfil de color de PSD: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size Error al codificar PSD: el búfer de píxeles no coincide con el tamaño de la imagen +@msg Revolve profile contains invalid coordinates El perfil de Revolución contiene coordenadas no válidas +@msg Revolve profile is too complex El perfil de Revolución es demasiado complejo +@msg Revolve projection is not finite La proyección de Revolución no es finita +@msg Revolve requires finite profile coordinates within 100 million points Revolución requiere coordenadas de perfil finitas dentro de 100 millones de puntos +@msg Revolve surface is too complex; reduce Segments or simplify the profile La superficie de Revolución es demasiado compleja; reduce Segmentos o simplifica el perfil +@msg Revolve surface is too complex; simplify the profile La superficie de Revolución es demasiado compleja; simplifica el perfil +@msg Revolve visibility cannot split the projected boundary La visibilidad de Revolución no puede dividir el contorno proyectado +@msg Revolve visibility creates too many fragments La visibilidad de Revolución crea demasiados fragmentos +@msg Revolve visibility creates too many vector anchors La visibilidad de Revolución crea demasiados puntos de ancla vectoriales +@msg Revolve visibility exceeds its geometry work limit La visibilidad de Revolución supera su límite de trabajo geométrico +@msg Revolve visibility exceeds its spatial index limit La visibilidad de Revolución supera su límite de índice espacial +@msg Revolve visibility has too many boundary crossings La visibilidad de Revolución tiene demasiados cruces de contorno +@msg Revolve visibility has too many input anchors La visibilidad de Revolución tiene demasiados puntos de ancla de entrada +@msg Revolve visibility requires convex cap sectors La visibilidad de Revolución requiere sectores de tapa convexos +@msg Revolve visibility requires finite projected faces La visibilidad de Revolución requiere caras proyectadas finitas +@msg SVG options: {e} Opciones de SVG: {e} +@msg Save for Web settings: {e} Ajustes de Guardar para web: {e} +@msg TIFF colour profile: {e} Perfil de color de TIFF: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size Error al codificar TIFF: el búfer de píxeles no coincide con el tamaño de la imagen +@msg TIFF encoding failed: {e} Error al codificar TIFF: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Profundidad de Targa {_1}: 16, 24 o 32 bits por píxel +@msg Targa encoding failed: the pixel buffer doesn't match the image size Error al codificar Targa: el búfer de píxeles no coincide con el tamaño de la imagen +@msg The 3D projection is not finite La proyección 3D no es finita +@msg The 3D shadow is too complex; turn Shadows off or simplify the art La sombra 3D es demasiado compleja; desactiva Sombras o simplifica la ilustración +@msg The shape contains invalid coordinates La forma contiene coordenadas no válidas +@msg Too many Revolve faces for visibility evaluation Demasiadas caras de Revolución para evaluar la visibilidad +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft lee como máximo {ASE_MAX_ENTRIES} colores y grupos de un archivo de intercambio de muestras, y esta biblioteca tiene {entries} +@msg WebP encoding failed: {e} Error al codificar WebP: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` es smallThumb, mediumThumb, largeThumb, smallList o largeList +@msg a line can't run from a point to itself una línea no puede ir de un punto a sí mismo +@msg a line needs at least two points una línea necesita al menos dos puntos +@msg a number cannot be read no se puede leer un número +@msg a swatch exchange block is too long un bloque de intercambio de muestras es demasiado largo +@msg a swatch exchange name is too long un nombre de intercambio de muestras es demasiado largo +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels una imagen de {sw} × {sh} no se puede cambiar de tamaño a {width} × {height} píxeles +@msg a {width} × {height} image is too large una imagen de {width} × {height} es demasiado grande +@msg a {width} × {height} image: {e} una imagen de {width} × {height}: {e} +@msg an image could not be written: {e} no se pudo escribir una imagen: {e} +@msg an image that couldn't be read was left out se omitió una imagen que no se pudo leer +@msg can't open “{name}”: {e} no se puede abrir «{name}»: {e} +@msg cannot align zip entries to {align} bytes no se pueden alinear las entradas zip a {align} bytes +@msg cannot open the automation {kind} root `{_1}`: {e} no se puede abrir la carpeta raíz de automatización ({kind}) `{_1}`: {e} +@msg cannot read profile: {0} no se puede leer el perfil: {0} +@msg color book version {version} isn't supported (only 1) no se admite la versión {version} del libro de colores (solo 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) no se admiten libros de colores en el espacio de color {other} (solo RGB, CMYK y Lab) +@msg file name too long to zip: {_1} nombre de archivo demasiado largo para comprimirlo en zip: {_1} +@msg file name too long to zip: {name} nombre de archivo demasiado largo para comprimirlo en zip: {name} +@msg freeform line {i}: {e} línea de forma libre {i}: {e} +@msg freeform point {i}: {e} punto de forma libre {i}: {e} +@msg give `{key}` or `{other}`, not both indica `{key}` o `{other}`, no ambos +@msg grayscale profiles can't be working spaces yet los perfiles de escala de grises todavía no pueden ser espacios de trabajo +@msg input contains NaN or infinite coordinates la entrada contiene coordenadas NaN o infinitas +@msg input path could not be closed no se pudo cerrar el trazado de entrada +@msg invalid ICC profile: {0} perfil ICC no válido: {0} +@msg invalid scale {scale} escala no válida {scale} +@msg its localized names take more than {_1} KB sus nombres localizados ocupan más de {_1} KB +@msg its objects are nested too deep ({e}) sus objetos están anidados a demasiada profundidad ({e}) +@msg its tag table lists the `{_1}` tag more than once su tabla de etiquetas incluye la etiqueta `{_1}` más de una vez +@msg not a graphic style library: {e} no es una biblioteca de estilos gráficos: {e} +@msg not a swatch library (.vcswatches or .gpl) no es una biblioteca de muestras (.vcswatches o .gpl) +@msg not a swatch library (format `{_1}`) no es una biblioteca de muestras (formato `{_1}`) +@msg not a swatch library: {e} no es una biblioteca de muestras: {e} +@msg not an action set file ({e}) no es un archivo de conjunto de acciones ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray el espacio de color {other} del perfil no es RGB, CMYK ni Gray +@msg regular expression too large expresión regular demasiado grande +@msg script file is not UTF-8 text: {value} el archivo de script no es texto UTF-8: {value} +@msg stop {i}: {e} parada {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) no se admite la versión {major}.{minor} de intercambio de muestras (solo 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors el libro de colores contiene más de {ASE_MAX_ENTRIES} colores +@msg the color book is cut short el libro de colores está truncado +@msg the color book's names take more than {_1} MB los nombres del libro de colores ocupan más de {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution la imagen mediría {w} × {h} píxeles; las exportaciones de mapa de bits se limitan a {MAX_RASTER_SIDE} píxeles por lado y {_1} megapíxeles: baja la escala o la resolución +@msg the optimised image can't be read back: {e} la imagen optimizada no se puede volver a leer: {e} +@msg the pixel buffer doesn't match the image size el búfer de píxeles no coincide con el tamaño de la imagen +@msg the preview: {e} la previsualización: {e} +@msg the request may not read the New Document profiles folder la solicitud no puede leer la carpeta de perfiles de Nuevo documento +@msg the shapes are too degenerate to combine las formas están demasiado degeneradas para combinarlas +@msg the shapes cross themselves and each other too often to combine las formas se cruzan consigo mismas y entre sí demasiadas veces para combinarlas +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups el archivo de intercambio de muestras contiene más de {ASE_MAX_ENTRIES} colores y grupos +@msg the swatch exchange file is cut short el archivo de intercambio de muestras está truncado +@msg the {_1} plate can't be read: {e} no se puede leer la plancha {_1}: {e} +@msg this binary DXF file is damaged or cut short este archivo DXF binario está dañado o truncado +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that este es un dibujo DWG, que no se puede leer: guárdalo desde la aplicación de CAD como DXF y abre ese archivo +@msg too many classes demasiadas clases +@msg too many groups demasiados grupos +@msg too many layers for PSD (at most 32767) demasiadas capas para PSD (como máximo 32767) +@msg too many swatch exchange blocks demasiados bloques de intercambio de muestras +@msg unknown colour profile: {0} perfil de color desconocido: {0} +@msg {_1} clashes with a built-in profile name {_1} coincide con el nombre de un perfil integrado +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} píxeles es demasiado grande para GIF (como máximo 65535 píxeles por lado): baja la resolución +@msg {_1}: no usable transform to/from sRGB {_1}: no hay ninguna transformación utilizable a sRGB ni desde sRGB +@msg {name} is not a CMYK profile {name} no es un perfil CMYK +@msg {name} is not an RGB profile {name} no es un perfil RGB +@msg {path}: could not be read {path}: no se pudo leer +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} píxeles es demasiado grande para JPEG (como máximo 65535 píxeles por lado): baja la resolución +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} píxeles es demasiado grande para Targa (como máximo 65535 píxeles por lado): baja la resolución +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} píxeles es demasiado grande para PSD (como máximo {MAX_SIDE} píxeles por lado): baja la resolución + # Copy Troubleshooting Info Copy Troubleshooting Info Copiar información de solución de problemas @msg Copied the troubleshooting info Se copió la información de solución de problemas diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 705fc68db2..d4fb18cfcb 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -2029,6 +2029,44 @@ fn recolor_notes_on_objects_left_unchanged_translate_with_their_counts() { } } +/// Spanish shows the image encoders', color profiles', swatch exchange files', Revolve's, DXF +/// import's, the script engine's and the parameter checks' errors in Spanish, with their values, +/// backticked names and accepted values kept as the English writes them. +#[test] +fn spanish_translates_encoder_profile_swatch_revolve_and_parameter_errors() { + let es = Lang::from_code("es").expect("registered"); + for (english, spanish) in [ + ("PNG encoding failed: 0 × 0 pixels is not a valid image size", "Error al codificar PNG: 0 × 0 píxeles no es un tamaño de imagen válido"), + ( + "70000 × 10 pixels is too large for GIF (at most 65535 pixels a side): lower the resolution", + "70000 × 10 píxeles es demasiado grande para GIF (como máximo 65535 píxeles por lado): baja la resolución", + ), + ("profile colour space XYZ is not RGB, CMYK or Gray", "el espacio de color XYZ del perfil no es RGB, CMYK ni Gray"), + ( + "color books in color space HSB aren't supported (only RGB, CMYK and Lab)", + "no se admiten libros de colores en el espacio de color HSB (solo RGB, CMYK y Lab)", + ), + ( + "the swatch exchange file holds more than 65536 colors and groups", + "el archivo de intercambio de muestras contiene más de 65536 colores y grupos", + ), + ( + "Revolve surface is too complex; reduce Segments or simplify the profile", + "La superficie de Revolución es demasiado compleja; reduce Segmentos o simplifica el perfil", + ), + ("regular expression too large", "expresión regular demasiado grande"), + ("this binary DXF file is damaged or cut short", "este archivo DXF binario está dañado o truncado"), + ( + "`view` is smallThumb, mediumThumb, largeThumb, smallList or largeList", + "`view` es smallThumb, mediumThumb, largeThumb, smallList o largeList", + ), + ("give `fill` or `stroke`, not both", "indica `fill` o `stroke`, no ambos"), + ("stop 2: oops", "parada 2: oops"), + ] { + assert_eq!(message(es, english), spanish); + } +} + #[test] fn package_status_message_templates_parse() { let c = Catalog::parse(concat!( diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..66e5d63211 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -922,6 +922,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The errors of the parameter checks that many commands share show in the status bar in the interface language: a value that is not a number where a number goes (`object.move` with `"dx": "60 mm"`, and `object.rotate`, `object.setBounds` and the other commands that call `check_numbers`), a missing number or index, `ids` that are not a list of object ids, an object id that is not a non-negative integer or names no object, and a date that is not Unix seconds. Each has a row in every catalog that translates all status and error messages, and in Bulgarian, Danish, Indonesian and Dutch (`shared_param_check_errors_are_translated`). - A parameter schema's errors show in the status bar with what the value must be in the interface language, for every type a schema has (a number with each kind of range and with a unit, an integer and its range, true or false, a string, a list of names, an object id, a list of object ids, a color, a point, an object and a list), in every catalog that translates all status and error messages; the path, the refused value, the bounds, the unit and the names stay as the English gives them. The error for a value that is not one of its names is also translated in Bulgarian, Bosnian, Danish, Indonesian and Dutch (`parameter_schema_expected_phrases_are_translated`, `bracketed_message_parts_translate_only_as_exact_messages`). - The untranslated report lists the status and error messages of the effects, swatch libraries, raster sizes and encoders, 3D solids and path operations that a catalog lacks, the messages that a `.map_err` closure or a named error handler returns, and the phrases a parameter schema's error builds for what a value must be (`untranslated_report_checks_every_message_crate_and_schema_phrase`, `message_scan_reads_map_err_closures`, `message_scan_reads_named_map_err_handlers`). + - Spanish messages (2026-11-13): the Spanish catalog (`crates/ui-egui/src/i18n/es.tsv`) has an `@msg` row for 114 of the 167 status and error messages that the untranslated report (`untranslated_report`) lists as missing in all 23 complete-message languages: the errors of the image encoders, color profiles, swatch exchange files and color books, 3D and Revolve, path operations, DXF import, the script engine and the parameter checks. Open #7211 and #7378 translate 51 of the others (the composite font and SVG filter errors), and 2 stay in English. The rows keep the placeholders, backticked names, accepted values and limits of their English (`spanish_translates_encoder_profile_swatch_revolve_and_parameter_errors`); native review remains; scores and estimates unchanged. - Export commands run through MCP, the control channel or the CLI refuse a key that no format takes, and warn about a key that only another format takes (`{"format": "pdf", "quality": 80}` writes the PDF with the warning "`quality` was not used: PDF files don't read it"; `an_option_only_another_format_reads_gets_a_note`, `control_export_notes_an_option_the_format_does_not_read`, `convert_warns_about_an_unused_option_only_when_one_was_given`), and a command that writes one format (`document.exportPdf`, `document.exportEps`, `document.exportDxf`) or takes one format's options (`document.pdfSettings`, `pdf.preset.save`) refuses a key that format doesn't take. An unknown key inside `marks`, `bleed`, `compression`, `output`, `advanced`, `security` or `flattener` is refused by its path. - Save commands run through MCP, the control channel or the CLI (`document.save`, `file.saveAs`, `file.saveCopy`, `file.saveAsTemplate`, `app.save`) refuse a key that no save format takes, beside the path or in `options`. Export for Screens refuses a key it doesn't take, and a key that no format takes in a format row or in a format's settings, by its path (`formats[1].marks.useDocumentBleed`); Export Assets (`assets.export`, `assets.settings.set`) checks the rows and settings it is given the same way. - Commands that read their `ids` (or `slices`) list themselves refuse a list with an entry that is not a non-negative integer, and a value that is not a list, and change nothing; they no longer drop the entry and act on the rest (Copy Appearance From, the Edit Colors commands and Overprint Black, Find and Replace, `layer.highlight`, `layer.move`, `library.add`, the Links panel commands, `object.transform`, Make Pattern, the Repeat commands, the slice commands, Join, Average and Join, `plugin.run`, `symbol.edit`, Make Opacity Mask; `tests::ids_without_selection::an_ids_entry_that_is_not_an_id_is_refused_and_changes_nothing`). The error for an entry of an object id list names the key, the entry and its value ("`ids` entry 1 is true, not a non-negative integer object id"), with a row in every catalog that has the other object id errors. From f0175cbdcb8df4fa350cef271214b4e35f00156b Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 20:09:54 -0800 Subject: [PATCH 023/108] i18n: French leaves the read-root and graph design messages to their own pull request --- crates/ui-egui/src/i18n/fr.tsv | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index e069cd3212..f7c2c1f71c 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7537,7 +7537,6 @@ breakText Glyphs Glyphes @msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` vaut smallThumb, mediumThumb, largeThumb, smallList ou largeList @msg a line can't run from a point to itself une ligne ne peut pas relier un point à lui-même @msg a line needs at least two points une ligne nécessite au moins deux points -@msg a linked JavaScript file is outside the read roots un fichier JavaScript lié se trouve hors des dossiers racines de lecture @msg a number cannot be read un nombre ne peut pas être lu @msg a swatch exchange block is too long un bloc du fichier d’échange de nuances est trop long @msg a swatch exchange name is too long un nom du fichier d’échange de nuances est trop long @@ -7575,7 +7574,6 @@ breakText Glyphs Glyphes @msg script file is not UTF-8 text: {value} le fichier de script n’est pas du texte UTF-8 : {value} @msg stop {i}: {e} étape de dégradé {i} : {e} @msg swatch exchange version {major}.{minor} isn't supported (only 1.x) la version {major}.{minor} du fichier d’échange de nuances n’est pas prise en charge (seulement 1.x) -@msg the art of a graph design in a graph series is drawn again from the design: edit the design to change it l’illustration d’une conception de graphe dans une série de graphe est redessinée à partir de la conception : modifiez la conception pour la changer @msg the color book holds more than {ASE_MAX_ENTRIES} colors le carnet de couleurs contient plus de {ASE_MAX_ENTRIES} couleurs @msg the color book is cut short le carnet de couleurs est tronqué @msg the color book's names take more than {_1} MB les noms du carnet de couleurs occupent plus de {_1} Mo From 00de304ab05a9f430592b677c43c1121a3f5eaa9 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 20:12:05 -0800 Subject: [PATCH 024/108] Live Shapes: saved object.setLiveShape steps with a negative radius or out-of-range sides replay again Since #7294, object.setLiveShape refuses a negative `radius` and a `sides` that is not a whole number from 3 to 1000. Session::replay applied the same checks, so a journal entry or action step recorded before that change with such a value stopped with a parameter error. On replay, a negative radius now counts as 0, which is how it drew before. A whole side count below 3 or above 1000 is brought into that range, and a fractional or negative one is ignored. Direct calls still refuse these values. --- crates/engine/src/cmd/object/shape.rs | 17 +++++++++++++++-- crates/engine/src/tests/livecorners.rs | 24 ++++++++++++++++++++++++ docs/mcp.md | 4 +++- docs/target-app-parity.md | 2 +- 4 files changed, 43 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/object/shape.rs b/crates/engine/src/cmd/object/shape.rs index e3909c5935..b30959de99 100644 --- a/crates/engine/src/cmd/object/shape.rs +++ b/crates/engine/src/cmd/object/shape.rs @@ -149,9 +149,22 @@ pub(super) fn set_live_shape(s: &mut Session, p: &Value) -> Result { }; let angle = |k: &str| Ok::<_, EngineError>(number(k, |_| true, "an angle in degrees")?.map(|a| a.rem_euclid(360.0))); let length = |k: &str| number(k, |x| x > 0.0 && x <= crate::MAX_COORD, "a length in points above 0"); - let radius = number("radius", |r| r >= 0.0, "a radius of 0 or more")?; + // Saved steps ([`Session::replay`]) can hold values a direct call refuses, recorded before these + // checks: a negative radius is 0, a whole side count of 0 or more is brought into 3 to 1000, and + // a fractional or negative one is ignored. A whole number written as 5.0 counts as 5, as in a + // direct call. + let replaying = s.replaying(); + let radius = if replaying { + number("radius", |_| true, "a number")?.map(|r| r.max(0.0)) + } else { + number("radius", |r| r >= 0.0, "a radius of 0 or more")? + }; // A polygon's side count: a whole number from 3 to 1000. - let sides = number("sides", |n| n.fract() == 0.0 && (3.0..=1000.0).contains(&n), "a whole number from 3 to 1000")?.map(|n| n as u64); + let sides = if replaying { + number("sides", |_| true, "a number")?.filter(|n| n.fract() == 0.0 && *n >= 0.0).map(|n| n.min(1000.0) as u64) + } else { + number("sides", |n| n.fract() == 0.0 && (3.0..=1000.0).contains(&n), "a whole number from 3 to 1000")?.map(|n| n as u64) + }; // An ellipse's pie (Ellipse Properties: Pie Start and End Angle, degrees; Invert Pie swaps them). let (pie_start, pie_end) = (angle("pieStart")?, angle("pieEnd")?); let invert = p.get("invertPie").and_then(Value::as_bool) == Some(true); diff --git a/crates/engine/src/tests/livecorners.rs b/crates/engine/src/tests/livecorners.rs index 190cd0d354..b9e3793913 100644 --- a/crates/engine/src/tests/livecorners.rs +++ b/crates/engine/src/tests/livecorners.rs @@ -126,6 +126,30 @@ fn bad_sides_radii_and_keys_are_errors() { assert_eq!(corners(&s, id).0, [0.0; 4]); } +/// Saved steps play as they did before `sides` and `radius` were checked: a negative radius +/// removes the rounding, a whole side count outside 3 to 1000 is brought into that range, and a +/// fractional or negative side count is ignored. +#[test] +fn saved_steps_with_out_of_range_sides_or_radius_still_play() { + let (mut s, id) = session(); + let poly = NodeId(s.execute("shape.polygon", &json!({"cx": 200, "cy": 200, "radius": 80, "sides": 6})).unwrap()["id"].as_u64().unwrap()); + let replay = |s: &mut Session, p: Value| s.replay("object.setLiveShape", &p).unwrap_or_else(|e| panic!("{p}: {e}")); + run(&mut s, json!({"id": id.0, "radius": 6})); + replay(&mut s, json!({"id": id.0, "radius": -4})); + assert_eq!(corners(&s, id).0, [0.0; 4]); + let sides = |s: &Session| match node_path(s, poly).1 { + Some(LiveShape::Polygon { sides, .. }) => sides, + other => panic!("{other:?}"), + }; + for (n, want) in [(json!(2), 3), (json!(1001), 1000), (json!(2.5), 1000), (json!(-1), 1000), (json!(5.0), 5)] { + replay(&mut s, json!({"ids": [poly.0], "sides": n})); + assert_eq!(sides(&s), want, "{n}"); + } + // A direct call still refuses them. + assert!(s.execute("object.setLiveShape", &json!({"id": id.0, "radius": -4})).is_err()); + assert!(s.execute("object.setLiveShape", &json!({"ids": [poly.0], "sides": 2})).is_err()); +} + #[test] fn direct_selected_corners_round_alone_and_stay_selected() { let (mut s, id) = session(); diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..87c4260377 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5546,7 +5546,9 @@ one undo step. `object.setLiveShape` returns a parameter error, and leaves the document and its undo history as they were, for a key it does not take, at the top level (`` unknown parameter `path` ``) or in one of `items` (`` unknown parameter `items[0].corner`; did you mean `items[0].corners`? ``), for a `sides` that is not a whole number -from 3 to 1000, such as 2.5, 2 or 1001, and for a negative `radius`. A `radius` of 0 removes the rounding. +from 3 to 1000, such as 2.5, 2 or 1001, and for a negative `radius`. A `radius` of 0 removes the rounding. Saved +steps (a journal or an action) replay these values without an error: a negative `radius` counts as 0, a whole `sides` +below 3 or above 1000 counts as 3 or 1000, and a fractional or negative `sides` is ignored. ```json {"name":"run_command","arguments":{"command":"object.setLiveShape","params":{"sides":8,"polygonAngle":22.5,"sideLength":40}}} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..ea3a8977ad 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1587,7 +1587,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Create Object Mosaic (its columns and rows), Transform Each (its reference point and Random seed) and Rearrange All Artboards (its columns) refuse a fraction, a negative number or a string, such as 2.5, -1 or "4"; 4.0 counts as 4. Move, Rotate, Scale, Reflect, Shear, Transform Again, Nudge and the Transform panel's values (their copy, Scale Strokes & Effects, Scale Corners, Transform Patterns, Transform Objects and area type options), Align, Distribute and Distribute Spacing (Transform Patterns), Object Properties (visible, locked, Isolate Blending and Opacity & Mask Define Knockout Shape) and Live Shape Properties (Invert Pie, Make Sides Equal and relative rounding) refuse a value other than true, false or null, such as "false", and leave the document as it was. Object Properties (its opacity), Live Shape Properties (corner radius and polygon sides), the Transform panel's reference point and Align, Distribute and Distribute Spacing to an artboard (the artboard's number) refuse a value other than a number or null, such as "50", and leave the document as it was. - Live Shape Properties refuses a key it does not take, at the top level or in one of its items, a polygon side count that is not a whole number from 3 to 1000 and a negative corner radius, and leaves the document as it was; the Transform panel's Sides field takes 3 to 1000. + Live Shape Properties refuses a key it does not take, at the top level or in one of its items, a polygon side count that is not a whole number from 3 to 1000 and a negative corner radius, and leaves the document as it was; the Transform panel's Sides field takes 3 to 1000. Saved steps with such a side count or radius still replay, as they did before the check. Transform Each (its scales, moves and rotation), Rasterize (its resolution), Create Object Mosaic (its new width and height and its spacing), Create Trim Marks (its offset, length, bleed and weight) and Rearrange All Artboards (its spacing) refuse a value other than a number or null, such as "50", and change nothing. Crop Image refuses a rectangle that is not four numbers, such as "0, 0, 20, 20". Transform Each (Reflect X, Reflect Y, Random, Copy, Scale Strokes & Effects, Scale Corners, Transform Objects and Transform Patterns), Create Object Mosaic (gray tiles and deleting the image), Crop Image (its trim), Create Trim Marks (all artboards) and Rearrange All Artboards (by column, Move Artwork with Artboard and Transform Patterns) refuse a value other than true, false or null, such as "false", and change nothing. Create Trim Marks refuses a style that is not text, such as 5. New Artboard refuses a position or size other than a number or null, such as "10", and New Artboard and Artboard Options refuse a name other than text or null, such as 5; each leaves the artboards and the undo history as they were. From d06870e41413258c734a2a63a24df37698af484e Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 20:12:19 -0800 Subject: [PATCH 025/108] Docs: DXF export of a non-circular ellipse is listed as a native ELLIPSE The DXF SPLINE line in docs/target-app-parity.md said a non-circular ellipse keeps the existing fallback. crates/cad/src/scene.rs writes a closed four-cubic ellipse, or a circle scaled out of proportion, as a native ELLIPSE in R13 and later, unless its minor-to-major ratio is below 1e-6, and only R12 keeps the fallback. The line now says so. --- 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 296bd84b2b..d3dc0b86c8 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1725,7 +1725,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - EPS and PostScript import keeps a CMYK image's ink amounts, as PDF import does: the samples of `image` and `colorimage` in a CMYK color space, and of a CMYK JPEG read through `DCTDecode`, come in as a CMYK TIFF, read through the image's Decode array, and the pixels a `MaskColor` or `ImageType 3` mask hides become a grayscale opacity mask (`crates/eps/src/import/tests_images.rs`). Such images came in as RGB PNGs. - EPS and PostScript import reads image data through `CCITTFaxDecode`: Group 4 (ITU-T T.6) and Group 3 one-dimensional and mixed (ITU-T T.4) data, with the filter's `K`, `Columns`, `Rows`, `EndOfBlock`, `EndOfLine`, `EncodedByteAlign` and `BlackIs1` parameters, decodes to 1-bit rows for `image` and `imagemask`. Damaged data keeps the rows decoded before it (damage in the first row is a PostScript `ioerror`), and parameters out of range or past the 256 MiB limit on decoded data are refused (`crates/eps/src/import/tests_images.rs`). Reading such a file stopped at an error naming the filter, and the file opened from a fallback, such as its preview or the art drawn before the image, or did not open. - EPS and PostScript `.ai` import undoes the TIFF predictor (`/Predictor 2`) of `FlateDecode` and `LZWDecode` data at 1, 2, 4 and 16 bits a component as well as 8: each component adds the same component of the pixel to its left within its bit width, 16-bit components add as big-endian numbers, and each row starts again (ISO 32000-1 §7.4.4.4; `crates/eps/src/import/tests_images.rs`, `crates/engine/src/cmd/fileio/tests_epsimport.rs`). At those depths the image drew the stored differences instead of its samples. - - DXF control-point SPLINE import honors its closed flag (#1299 follow-up after #1320 fixed export), including rational curves; open curves whose endpoints meet stay open. Own-fixture regressions cover controls/knots, fit-point fallback and all export versions (`crates/cad/src/import/tests.rs`, `crates/cad/src/tests.rs`); native save/read checked. Circular cubic paths export as native CIRCLE/ARC where stroke semantics permit; R12 weighted strokes remain POLYLINE, and a non-circular ellipse keeps the existing fallback (`crates/cad/src/tests.rs`); an open path of one straight segment exports as a LINE (R12 to R14 strokes with a weight stay polylines, which carry the width) and reads back as the same segment (`crates/cad/src/tests.rs`, `crates/cad/src/import/tests.rs`); DXF Options' Preset menu and `document.exportDxf`'s `dxfPreset: "cnc"` set the CNC / CAM options (version 2000, 1 mm = 1 unit, 256 colors, Maximize Editability with Alter Paths off, Outline Text, placed images and fill hatches left out), and the menu shows Custom once a field changes (`the_cnc_preset_writes_version_2000_in_millimeters_with_type_as_paths_and_strokes_as_lines`, `the_cnc_preset_sets_the_options_that_are_not_given`, `the_cnc_cam_preset_sets_the_fields_and_a_change_shows_custom`); VCarve QA remains pending. + - DXF control-point SPLINE import honors its closed flag (#1299 follow-up after #1320 fixed export), including rational curves; open curves whose endpoints meet stay open. Own-fixture regressions cover controls/knots, fit-point fallback and all export versions (`crates/cad/src/import/tests.rs`, `crates/cad/src/tests.rs`); native save/read checked. Circular cubic paths export as native CIRCLE/ARC where stroke semantics permit; R12 weighted strokes remain POLYLINE; a closed four-cubic ellipse, or a circle scaled out of proportion, exports as a native ELLIPSE in R13 and later (an ellipse whose minor-to-major ratio is below 1e-6 is still written as a polyline or spline), and R12 keeps the existing fallback (`crates/cad/src/tests.rs`); an open path of one straight segment exports as a LINE (R12 to R14 strokes with a weight stay polylines, which carry the width) and reads back as the same segment (`crates/cad/src/tests.rs`, `crates/cad/src/import/tests.rs`); DXF Options' Preset menu and `document.exportDxf`'s `dxfPreset: "cnc"` set the CNC / CAM options (version 2000, 1 mm = 1 unit, 256 colors, Maximize Editability with Alter Paths off, Outline Text, placed images and fill hatches left out), and the menu shows Custom once a field changes (`the_cnc_preset_writes_version_2000_in_millimeters_with_type_as_paths_and_strokes_as_lines`, `the_cnc_preset_sets_the_options_that_are_not_given`, `the_cnc_cam_preset_sets_the_fields_and_a_change_shows_custom`); VCarve QA remains pending. - DXF export's Include Placed Images and Include Fill Hatches (`includeImages`, `includeHatches`; VectorCraft's own options, on by default and off in CNC / CAM) leave out placed images with their linked files, without decoding them, and the solid hatch after each filled area's outlines, each on its own, with one note in `warnings` when something was left out; R12 keeps its own notes. An open path's fill outline is closed, as the fill is, in every version (`an_open_path_s_fill_outline_keeps_its_closing_edge`, `fills_without_hatches_keep_their_outlines`, `images_can_be_left_out_with_their_files`, `images_and_hatches_are_left_out_independently_and_the_cnc_preset_leaves_out_both`, `placed_images_and_fill_hatches_can_be_left_out`, `include_placed_images_and_fill_hatches_follow_the_preset_and_a_change_shows_custom`). - DXF export writes a path of straight segments and circular arcs (a slot, a D shape, a rounded rectangle, a pie) as one polyline whose vertices carry a bulge (group 42) for each arc: an LWPOLYLINE in R14 and later, a POLYLINE with VERTEX entities in R12 and R13, closed when the path is closed, and it reads back as the same outline (#1299, `crates/cad/src/tests.rs`). Such a path was written as one SPLINE (a flattened polyline in R12); a path with any other curve still is. A shallow curve becomes an ARC or a bulge only when it lies on the circle within 5e-4 of its own extent as well as of the radius, and the drawing extents (`$EXTMIN`, `$EXTMAX`) reach the furthest points of every ARC and bulge. - Affinity documents in (AF.1–AF.4): `.af` (Affinity 3) and `.afdesign`/`.afphoto`/`.afpub` (Affinity 1 and 2, container versions 8–12) open and place as editable art: layers and sublayers, groups (pass-through or isolated), artboards (with their names and backgrounds) and Publisher pages side by side, curves with live corners, parametric shapes (rectangles with corner radii, ellipses, polygons, stars, pies, triangles, trapezoids), compound shapes, solid/linear/elliptical gradient fills and strokes (weight, dashes, alignment, scale-with-object), clipping by nesting, vector and pixel masks, artistic and frame text with fonts, sizes, tracking, leading and alignment, placed images (their original JPEG/PNG) and pixel layers (8/16-bit RGB, CMYK), opacity, visibility, locking and blend modes, at the document's resolution in points. Effects, adjustments, brushes and pressure profiles, transparency gradients, master pages, symbol instances (imported as their cached picture), special shapes (cloud, heart, cog…, imported as ellipses) and Affinity-only blend modes are named in the import warning. A file whose native data can't be read opens as its embedded preview with the reason, and that preview can't be placed. Save never writes back over the Affinity file and there is no Affinity export. AF.5 (from DesignCraft's import, storytold/designcraft#291) adds master pages (on a locked layer behind the pages that show them), tables (area type per cell and a line per edge), each paragraph's alignment, indents, spacing and leading, horizontal text scale, outlined text, frame text sized by its text scale, drop shadows and outer glows as live effects (inner shadows as inner glows), outline effects as strokes, colour and gradient overlays baked into the paint, embedded Affinity documents as editable content (their artboards don't become artboards), pixel layers over 64 MP at a reduced resolution and HEIC photos from their stored pixels; automatic leading (size plus the font's line gap) fitted on thumbnails; underlines and strikethrough; strokes whose style is None (every shape stores one) left out, which also brings 6 public files closer to their thumbnails; line breaks inside a paragraph; table cell text centred as Affinity centres it, also where it is taller than its cell; CMYK pixel layers converted through the document's embedded CMYK profile (relative colorimetric with black-point compensation, as each layer's colour settings name), or kept as CMYK images when there is none; outline effects on stroked shapes around their stroke; artistic text whose paragraphs align differently aligned within its longest line, a frame's first baseline at cap height, and frames whose last lines' descenders hang out made tall enough to show them (all measured on a local document's own PDF export: baselines match to 0.1 pt); a local 56-artboard document's mean thumbnail difference went from 16.2 to 11.4, and its pages' mean difference from the owner's PDF export from 12.9 to 9.3. AF.4 adds Affinity 3 artboard recognition and actual-outline clipping, source-backed JPEG/PNG raster tiles, Unicode text-run recovery, stored fallback/exact installed fonts, OpenType feature flags and compound-geometry limits. 51 public CC0/MIT/Apache-2.0 files (33 current `.af`), pinned and sha256-verified (`cargo xtask corpus --affinity`), test native retention and every-board native/SVG/PDF/PSD output for current files; selected files compare their saved thumbnails. No Affinity reopen or independent paired PSD oracle was available; [source audit and complex-font gaps](affinity-validation.md); [scope, provenance and limits](../crates/affinity/README.md). From 9b2e21f6ca9b8603b14c7f97725d24b16a54980d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 20:14:37 -0800 Subject: [PATCH 026/108] Live Paint: Merge keeps the visibility, opacity and blending of the parts it carries Merge copied a face's or edge's appearance to the part it rebuilds in its place, but not its visibility, opacity or blending mode. A half-transparent face drawn by its stroke became opaque, and a hidden edge was shown again. --- crates/engine/src/cmd/buildcmds/live_paint.rs | 56 ++++++++++++------- crates/engine/src/tests/build.rs | 28 ++++++++++ docs/mcp.md | 6 +- docs/target-app-parity.md | 2 +- 4 files changed, 68 insertions(+), 24 deletions(-) diff --git a/crates/engine/src/cmd/buildcmds/live_paint.rs b/crates/engine/src/cmd/buildcmds/live_paint.rs index 04c6a3fb1b..9c3c750996 100644 --- a/crates/engine/src/cmd/buildcmds/live_paint.rs +++ b/crates/engine/src/cmd/buildcmds/live_paint.rs @@ -84,17 +84,33 @@ pub(super) fn lp_make(s: &mut Session, p: &Value) -> Result { Ok(json!({ "id": id.0, "faces": faces, "edges": edges })) } -/// The appearance of face or edge `n` for the part Merge makes again in its place, another path: -/// gradients fitted to `n`'s outline keep that fit, and the strokes' pen pressure, tilt, bearing -/// and rotation stay behind. -fn carried_appearance(n: &Node) -> Appearance { - let mut app = (*n.appearance).clone().without_pressure(); - if app.has_unplaced_gradient() - && let Some(bounds) = n.geometric_bounds() - { - app.pin_gradients(bounds); +/// What Merge carries from a face or edge to the part it makes again in its place, another path: +/// the appearance, visibility, opacity and blending mode. Gradients fitted to the old outline keep +/// that fit, and the strokes' pen pressure, tilt, bearing and rotation stay behind. +struct Carried { + appearance: Appearance, + visible: bool, + opacity: f32, + blend: vectorcraft_color::BlendMode, +} + +impl Carried { + fn of(n: &Node) -> Self { + let mut appearance = (*n.appearance).clone().without_pressure(); + if appearance.has_unplaced_gradient() + && let Some(bounds) = n.geometric_bounds() + { + appearance.pin_gradients(bounds); + } + Self { appearance, visible: n.visible, opacity: n.opacity, blend: n.blend } + } + + fn onto(self, n: &mut Node) { + n.appearance = self.appearance.into(); + n.visible = self.visible; + n.opacity = self.opacity; + n.blend = self.blend; } - app } /// Add the other `roots` (back → front) to the first Live Paint group among them, which keeps its @@ -108,16 +124,16 @@ fn merge_live(d: &mut Document, sel: &mut Selection, roots: &[NodeId]) -> Result .ok_or_else(|| EngineError::Other("Live Paint Merge: select a Live Paint group and the paths to add".into()))?; check_live_paint_takes(d, roots)?; let old = d.node(target).cloned().ok_or(EngineError::NoNode(target))?; - // Paint to carry over: (point inside face, appearance) for faces that draw, and (point on - // edge, appearance) for every edge. - let keep_faces: Vec<(Point, Appearance)> = - b::faces(&old).iter().filter(|f| draws(f)).filter_map(|f| Some((po::interior_point(f.path_data()?)?, carried_appearance(f)))).collect(); - let keep_edges: Vec<(Point, Appearance)> = b::edges(&old) + // Paint to carry over: (point inside face, paint) for faces that draw, and (point on edge, + // paint) for every edge. + let keep_faces: Vec<(Point, Carried)> = + b::faces(&old).iter().filter(|f| draws(f)).filter_map(|f| Some((po::interior_point(f.path_data()?)?, Carried::of(f)))).collect(); + let keep_edges: Vec<(Point, Carried)> = b::edges(&old) .iter() .filter_map(|e| { let pd = e.path_data()?; let sp = pd.subpaths.first().filter(|sp| sp.segment_count() > 0)?; - Some((kurbo::ParamCurve::eval(&sp.segment(0), 0.5), carried_appearance(e))) + Some((kurbo::ParamCurve::eval(&sp.segment(0), 0.5), Carried::of(e))) }) .collect(); let mut sources = source_nodes(&old); @@ -137,20 +153,20 @@ fn merge_live(d: &mut Document, sel: &mut Selection, roots: &[NodeId]) -> Result *ch = children; } g.extras_mut().live_paint_gaps = stored_gap_options(options); - for (pt, app) in keep_faces { + for (pt, carried) in keep_faces { if let Some(fid) = face_at(&g, pt).map(|f| f.id) && let Some(ch) = g.children_mut() && let Some(f) = ch.iter_mut().find(|c| c.id == fid) { - Arc::make_mut(f).appearance = app.into(); + carried.onto(Arc::make_mut(f)); } } - for (pt, app) in keep_edges { + for (pt, carried) in keep_edges { if let Some(eid) = edge_near(&g, pt, 0.5).map(|e| e.id) && let Some(ch) = g.children_mut() && let Some(e) = ch.iter_mut().find(|c| c.id == eid) { - Arc::make_mut(e).appearance = app.into(); + carried.onto(Arc::make_mut(e)); } } let mut merged = Beside::replacing(d, roots); diff --git a/crates/engine/src/tests/build.rs b/crates/engine/src/tests/build.rs index 0e6bf5ad8d..19ac53494c 100644 --- a/crates/engine/src/tests/build.rs +++ b/crates/engine/src/tests/build.rs @@ -3105,6 +3105,34 @@ fn live_paint_merge_keeps_the_fit_of_carried_gradients() { assert_eq!(geom(&new_edge.appearance.items), Some(unplaced.resolve(edge_box)), "the stroke keeps its fit"); } +/// Merge carries a face's or edge's visibility, opacity and blending mode to the rebuilt part with +/// its appearance: a half-transparent face drawn by a stroke alone stays half transparent, and a +/// hidden edge stays hidden. +#[test] +fn live_paint_merge_keeps_the_visibility_opacity_and_blending_of_carried_parts() { + use vectorcraft_color::BlendMode; + use vectorcraft_doc::StrokeLayer; + use vectorcraft_tools::builder::{edge_near, face_at}; + let stroke = || AppearanceItem::Stroke(StrokeLayer::new(Paint::solid(Color::BLACK), 2.0)); + let mut s = session(); + let g = live(&mut s); + let face = set_live_part(&mut s, g, Some((25.0, 50.0)), None, vec![stroke()], 0.5); + let edge = set_live_part(&mut s, g, None, Some((0.0, 50.0)), vec![stroke()], 1.0); + s.edit("t", |d, _| { + d.node_mut(face).unwrap().blend = BlendMode::Multiply; + d.node_mut(edge).unwrap().visible = false; + Ok(()) + }) + .unwrap(); + let c = rect(&mut s, 120.0, 120.0, 100.0, 20.0); + s.execute("livePaint.merge", &json!({"ids": [g.0, c.0]})).unwrap(); + let n = node(&s, g); + let f = face_at(&n, Point::new(25.0, 50.0)).unwrap(); + assert_eq!((f.appearance.items.clone(), f.opacity, f.blend, f.visible), (vec![stroke()], 0.5, BlendMode::Multiply, true)); + let e = edge_near(&n, Point::new(0.0, 50.0), 0.5).unwrap(); + assert_eq!((e.appearance.items.clone(), e.visible), (vec![stroke()], false), "the hidden edge stays hidden"); +} + fn live_group_only(s: &mut Session) -> NodeId { let r = s.execute("livePaint.make", &json!({})).unwrap(); NodeId(r["id"].as_u64().unwrap()) diff --git a/docs/mcp.md b/docs/mcp.md index 6f7406f4a1..8f0849f912 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3489,9 +3489,9 @@ already walks Image Trace. Short agent entry points: `livePaint.expand` keeps each face and edge that draws, with all its fill and stroke rows: it is shown, its opacity is above 0, and a fill or stroke row is shown, has paint and an opacity above 0 (a stroke also a weight above 0), whichever row is on top. A painted lower row under an unpainted top row keeps the part; a part whose only painted - row is hidden is removed. `livePaint.merge` copies the fill and stroke rows of each face that draws by this rule, and - of each edge, to the rebuilt parts, with their gradients kept at their fit on the old outline and without the - strokes' pen pressure, tilt, bearing and rotation. + row is hidden is removed. `livePaint.merge` copies the fill and stroke rows, visibility, opacity and blending mode of + each face that draws by this rule, and of each edge, to the rebuilt parts, with their gradients kept at their fit on + the old outline and without the strokes' pen pressure, tilt, bearing and rotation. With `detect: true`, paint stops at the gaps that run from a loose end of a path to the nearest path, up to `size` wide (`small` 3 pt, `medium` 6 pt, `large` 12 pt, or a number of points up to 72); `closeGaps: true` adds an unpainted path across each of them. `color` (the Gap Preview diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 3ab2127e30..1c9dda5a5d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1447,7 +1447,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Double-clicking the Live Paint Bucket opens Live Paint Bucket Options ([Paint with the Live Paint Bucket tool](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html)): Paint Fills (on) and Paint Strokes (off) set whether a click paints faces, edges or both, Highlight turns the outline of the face or edge under the pointer on or off, and Color and Width set it (red and 4 px by default). Faces are outlined at the Width and edges at half of it, as the page says faces are highlighted with a thick line and edges with a thin line. With both on, a click paints the edge within 4 px of the pointer, else the face, and Shift switches to Paint Fills only; with one on, Shift switches to the other. The options last across tool switches and are saved with the preferences (`tool.setOption {tool: "livePaintBucket"}`). Evidence: `builder::tests::{bucket_options_choose_what_a_click_paints, bucket_options_set_the_highlight, bucket_highlights_an_edge_thinner_than_a_face}`, `dialogs::live_paint_bucket::tests::double_clicking_the_tool_opens_its_options_and_ok_sets_them`. Live Paint Bucket Options has Cursor Swatch Preview, as the [help page](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/paint-with-the-live-paint-bucket-tool.html) lists: with the Bucket selected, the active fill or stroke shows above the pointer between the color swatches before and after it in the Swatches panel, and the Left and Right arrow keys pick the swatch before or after it, as the page describes. The selected art keeps its paint. As VectorCraft's own rules, the option is on at first, the arrows step the stroke when the Stroke proxy is in front, they wrap around at the ends and still step with the preview off, a color that is no swatch shows alone until Right picks the first swatch or Left the last, and the arrows do nothing during a fill drag or with no color swatch. Evidence: `tests::build::{live_paint_bucket_arrow_keys_step_the_active_paint_through_the_swatches, live_paint_bucket_arrow_keys_handle_unmatched_paint_few_swatches_and_drags, live_paint_bucket_arrow_keys_pass_swatches_of_the_same_color_for_fill_and_stroke, swatch_arrow_keys_leave_modified_arrows_to_the_shortcuts}`. Live Paint Make preserves the front-most covering source's fill when compound paths share a curved boundary, and Expand keeps the face fills. Regression evidence: `planar::tests::coincident_curves_keep_their_source_faces` checks source order, winding, fill rules and nearby boundaries; `tests::build::live_paint_make_and_expand_keep_abutting_compound_colors` checks native compound paths, Make, Expand and Undo/Redo. This preserves VectorCraft's source-fill rule without changing arrangement precision. - Object › Live Paint › Expand keeps the faces and edges that draw on the canvas, with all their fill and stroke rows, so the expanded paths look as the painted group did ([Create Live Paint groups](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/create-live-paint-groups.html)). As VectorCraft's own rule, a face or edge draws when it is shown, its opacity is above 0, and any of its fill or stroke rows is shown, has paint and an opacity above 0 (a stroke also needs a weight above 0), whichever row is on top: a painted lower row under an unpainted top row is kept, and a part whose only painted row is hidden is removed. Merge copies the fill and stroke rows of each face that draws by this rule, and of each edge, to the rebuilt parts, with their gradients kept at their fit on the old outline and without the strokes' pen pressure, tilt, bearing and rotation. Evidence: `tests::build::{live_paint_expand_keeps_the_faces_and_edges_that_draw, live_paint_merge_carries_the_faces_that_draw, live_paint_merge_leaves_pen_pressure_behind, live_paint_merge_keeps_the_fit_of_carried_gradients}`. + Object › Live Paint › Expand keeps the faces and edges that draw on the canvas, with all their fill and stroke rows, so the expanded paths look as the painted group did ([Create Live Paint groups](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/create-live-paint-groups.html)). As VectorCraft's own rule, a face or edge draws when it is shown, its opacity is above 0, and any of its fill or stroke rows is shown, has paint and an opacity above 0 (a stroke also needs a weight above 0), whichever row is on top: a painted lower row under an unpainted top row is kept, and a part whose only painted row is hidden is removed. Merge copies the fill and stroke rows, visibility, opacity and blending mode of each face that draws by this rule, and of each edge, to the rebuilt parts, with their gradients kept at their fit on the old outline and without the strokes' pen pressure, tilt, bearing and rotation. Evidence: `tests::build::{live_paint_expand_keeps_the_faces_and_edges_that_draw, live_paint_merge_carries_the_faces_that_draw, live_paint_merge_leaves_pen_pressure_behind, live_paint_merge_keeps_the_fit_of_carried_gradients, live_paint_merge_keeps_the_visibility_opacity_and_blending_of_carried_parts}`. Live Paint Gap Options (Object › Live Paint › Gap Options…, `livePaint.gapOptions`): with Gap Detection on, paint stops at the gaps that run from a loose end of a path to the nearest path, up to Small (3 pt), Medium (6 pt), Large (12 pt) or a custom size; Close Gaps With Paths adds an unpainted path across each gap; Preview applies the options live and draws the gaps in the Gap Preview Color. The options are saved, copied and undone with the group, and Merge keeps the bottom group's options when its Gap Detection is on, or else turns Gap Detection on with Small when another merged group has it on. When Gap Detection is off in every merged group, it stays off. View › Show Live Paint Gaps (`view.livePaintGaps`) draws the gaps of the selected Live Paint groups up to their Paint Stops At size, each in its group's Gap Preview Color, until Hide Live Paint Gaps or Hide Edges hides them ([Live Paint gaps](https://web.archive.org/web/20260105111201/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/find-and-close-gaps-in-live-paint-groups.html)). Double-clicking the Live Paint Selection tool opens its Tool Options ([Live Paint Selection tool options](https://web.archive.org/web/20250904012025/https://helpx.adobe.com/illustrator/using/selecting-objects.html)): with Select Fills off, a click selects an edge instead of a face; with Select Strokes off, Alt-click selects a face instead of an edge; Color and Width set the color and width of the highlight on the face or edge under the pointer (red and 4 px by default). The options last across tool switches and are saved with the preferences (`tool.setOption {tool: "livePaintSelection"}`). From 155c2f722b6174dd735b4f4440678a8d4e223eaf Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 20:18:35 -0800 Subject: [PATCH 027/108] Place: Placement Options clip a DCS image inside its file's clipping path When links.update or links.relink re-read a DCS file and Placement Options also clipped the image (Fill with Clip, or an aspect change that overflows), the placement rectangle replaced the file's clipping path, so plate art outside that path showed and printed. The file's clip group now stays around the image and the placement's clip goes in a clip group around it. The clip group holding just the file's group takes that clip, as one holding just an image does today, else a new one does, so later updates reuse the same two groups. A file that loses its clipping path leaves its group as a plain group inside the placement's clip. The same applies in symbols, graph designs, patterns and opacity masks. --- crates/engine/src/cmd/links.rs | 131 ++++++++++++++++++++++++++------- crates/engine/src/tests/dcs.rs | 112 ++++++++++++++++++++++++++++ docs/mcp.md | 2 +- 3 files changed, 217 insertions(+), 28 deletions(-) diff --git a/crates/engine/src/cmd/links.rs b/crates/engine/src/cmd/links.rs index 3e1bc8b2ef..d37abc85c7 100644 --- a/crates/engine/src/cmd/links.rs +++ b/crates/engine/src/cmd/links.rs @@ -667,6 +667,16 @@ enum ClipTo { File(PathData), /// It goes into a new clip group of this path, inside the clip group that holds it. Nest(PathData), + /// Placement Options clip it to `placement` while its DCS file draws it through `file`: it is + /// clipped to `file` as [`ClipTo::File`] clips it, and the clip group holding it is clipped to + /// `placement` as [`ClipTo::Path`] clips an object. With no `file` (the new file lacks the + /// clipping path of the clip group holding it), that group stays as [`ClipTo::Off`] leaves it, + /// clipped to `placement`. + Both { file: Option, placement: PathData }, + /// Placement Options clip it to `placement` while its DCS file draws it through `file`, and the + /// clip group holding just it is not its old file's: that clip group's clipping path becomes + /// `placement`, and it goes into a new clip group of `file` inside it. + BothInside { file: PathData, placement: PathData }, /// The clipping path of the clip group holding just it goes (a DCS file's clipping path that /// its new file lacks): the group stays as a plain group of it, with its id, name, visibility /// and transparency. @@ -702,10 +712,10 @@ fn same_path(a: &PathData, b: &PathData) -> bool { } /// The clip an image placed with `old_xf` takes when it shows `img`, read from a file, placed with -/// `new_xf`: Placement Options' clip `clip` when they clip it, else the clipping path a DCS file -/// draws `img` through. When neither clips it, a clip group holding just it whose clipping path -/// `held` is its old DCS file's (`old_clip`, in the old pixels, under the nonzero rule its clip -/// groups get) goes. +/// `new_xf`: Placement Options' clip `clip` when they clip it, and the clipping path a DCS file +/// draws `img` through, the file's clip group inside the placement's. When neither clips it, a clip +/// group holding just it whose clipping path `held` is its old DCS file's (`old_clip`, in the old +/// pixels, under the nonzero rule its clip groups get) goes. fn clip_to( old_xf: Affine, old_clip: Option<&PathData>, @@ -714,16 +724,22 @@ fn clip_to( new_xf: Affine, held: Option<(&PathData, FillRule)>, ) -> ClipTo { - if let Some(clip) = clip { - return ClipTo::Path(clip_shape(clip)); - } // Whether the clip group holding just the image is the old DCS file's: a clipping path whose // fill rule was changed in the document is not. let file_held = match (old_clip, held) { (Some(old), Some((held, rule))) => rule == FillRule::NonZero && same_path(&old.transformed(old_xf), held), _ => false, }; - match img.clip.as_ref().map(|path| path.transformed(new_xf)) { + let file = img.clip.as_ref().map(|path| path.transformed(new_xf)); + if let Some(clip) = clip { + let placement = clip_shape(clip); + return match file { + Some(file) if held.is_some() && !file_held => ClipTo::BothInside { file, placement }, + file if file.is_some() || file_held => ClipTo::Both { file, placement }, + _ => ClipTo::Path(placement), + }; + } + match file { // A clipping mask made in the document stays, with the file's clip group inside it. Some(path) if held.is_some() && !file_held => ClipTo::Nest(path), Some(path) => ClipTo::File(path), @@ -752,7 +768,8 @@ impl Nested<'_> { let first = d.peek_next_id(); self.next = first; for l in d.layers.iter_mut() { - self.update(l, false); + // Nothing is picked in the layers themselves, so no layer is clipped. + let _ = self.update(l, false); } for root in d.symbols.iter_mut().map(|s| &mut s.art).chain(d.graph_designs.iter_mut().map(|g| &mut g.art)) { self.root(root); @@ -769,20 +786,30 @@ impl Nested<'_> { /// mask art). fn root(&mut self, n: &mut Arc) { if !(self.pick)(n) { - return self.update(n, true); + if let Some(placement) = self.update(n, true) { + *n = Arc::new(self.clip_group(Arc::clone(n), placement)); + } + return; } let (new, clip) = (self.make)(n, None); let mut new = Arc::new(new); - self.update(&mut new, true); + let _ = self.update(&mut new, true); *n = match clip { ClipTo::Path(path) | ClipTo::File(path) | ClipTo::Nest(path) => Arc::new(self.clip_group(new, path)), + ClipTo::Both { file, placement } => self.clip_both(new, file, placement), + ClipTo::BothInside { file, placement } => self.clip_both(new, Some(file), placement), ClipTo::Keep | ClipTo::Off => new, }; } /// `n` (outside the layer tree when `nested`) with the picked objects under it remade; it stays - /// the same node when none is there, and only the nodes on the way to one are copied. - fn update(&mut self, n: &mut Arc, nested: bool) { + /// the same node when none is there, and only the nodes on the way to one are copied. The + /// result is Placement Options' clip that `n` itself, now the clip group of a DCS file's + /// clipping path holding a picked object (or the plain group [`ClipTo::Off`] leaves), takes: + /// the clipping path of the clip group holding just `n` becomes it, else `n` goes into a new + /// clip group of it. + #[must_use] + fn update(&mut self, n: &mut Arc, nested: bool) -> Option { let mask = n.extras().mask.as_ref().and_then(|m| { let mut art = Arc::clone(&m.art); self.root(&mut art); @@ -794,6 +821,8 @@ impl Nested<'_> { // The clipping path and object of a plain group holding just the object, which becomes a // clip group again. let mut reclipped = None; + // Placement Options' clip for `n` itself. + let mut around = None; if let Some(children) = n.children() { // A clip group holding just the object: its clipping path changes. let clip_path = match (&n.kind, &children[..]) { @@ -804,9 +833,11 @@ impl Nested<'_> { for (i, c) in children.iter().enumerate() { if !(nested && (self.pick)(c)) { let mut new = Arc::clone(c); - self.update(&mut new, nested); - if !Arc::ptr_eq(&new, c) { - slots.push((i, new)); + match (self.update(&mut new, nested), clip_path) { + (None, _) if Arc::ptr_eq(&new, c) => {} + (None, _) => slots.push((i, new)), + (Some(placement), Some(path)) if i == 1 => slots.extend([(0, with_clip(path, placement)), (1, new)]), + (Some(placement), _) => slots.push((i, Arc::new(self.clip_group(new, placement)))), } continue; } @@ -816,16 +847,10 @@ impl Nested<'_> { }); let (new, clip) = (self.make)(c, held); let mut new = Arc::new(new); - self.update(&mut new, true); + let _ = self.update(&mut new, true); match (clip, clip_path) { (ClipTo::Keep, _) => slots.push((i, new)), - (ClipTo::Path(clip) | ClipTo::File(clip), Some(path)) if i == 1 => { - let mut path = Node::clone(path); - if let NodeKind::Path { path: p, .. } = &mut path.kind { - *p = clip; - } - slots.extend([(0, Arc::new(path)), (1, new)]); - } + (ClipTo::Path(clip) | ClipTo::File(clip), Some(path)) if i == 1 => slots.extend([(0, with_clip(path, clip)), (1, new)]), (ClipTo::File(clip), None) if plain => reclipped = Some((clip, new)), (ClipTo::Path(clip) | ClipTo::File(clip) | ClipTo::Nest(clip), _) => { let group = self.clip_group(new, clip); @@ -833,11 +858,30 @@ impl Nested<'_> { } (ClipTo::Off, Some(_)) if i == 1 => declipped = Some(new), (ClipTo::Off, _) => slots.push((i, new)), + // The file's clip group stays `n`, and the placement's clip goes around it. + (ClipTo::Both { file: Some(file), placement }, Some(path)) if i == 1 => { + slots.extend([(0, with_clip(path, file)), (1, new)]); + around = Some(placement); + } + (ClipTo::Both { file: Some(file), placement }, None) if plain => { + reclipped = Some((file, new)); + around = Some(placement); + } + (ClipTo::Both { file: None, placement }, Some(_)) if i == 1 => { + declipped = Some(new); + around = Some(placement); + } + (ClipTo::BothInside { file, placement }, Some(path)) if i == 1 => { + let group = self.clip_group(new, file); + slots.extend([(0, with_clip(path, placement)), (1, Arc::new(group))]); + } + (ClipTo::Both { file, placement }, _) => slots.push((i, self.clip_both(new, file, placement))), + (ClipTo::BothInside { file, placement }, _) => slots.push((i, self.clip_both(new, Some(file), placement))), } } } if mask.is_none() && slots.is_empty() && declipped.is_none() && reclipped.is_none() { - return; + return None; } let reclipped = reclipped.map(|(clip, object)| (Arc::new(self.clipping_path(clip)), object)); let n = Arc::make_mut(n); @@ -849,14 +893,14 @@ impl Nested<'_> { if let NodeKind::Group { children, clip } = &mut n.kind { (*children, *clip) = (vec![path, object], true); } - return; + return around; } // A clip group that stays as a plain group of just the object. if let Some(object) = declipped { if let NodeKind::Group { children, clip } = &mut n.kind { (*children, *clip) = (vec![object], false); } - return; + return around; } if let Some(children) = n.children_mut() { for (i, c) in slots { @@ -865,6 +909,17 @@ impl Nested<'_> { } } } + around + } + + /// A clip group of `placement` holding `object`, inside a clip group of `file` when there is a + /// `file` ([`ClipTo::Both`] for an object no clip group holds yet). + fn clip_both(&mut self, object: Arc, file: Option, placement: PathData) -> Arc { + let object = match file { + Some(file) => Arc::new(self.clip_group(object, file)), + None => object, + }; + Arc::new(self.clip_group(object, placement)) } /// A clip group of `object` clipped to `clip`, as [`clip_image_to`] makes one in the layers. @@ -1035,6 +1090,15 @@ fn clip_file_to(d: &mut Document, id: NodeId, path: PathData) -> Result<()> { Ok(()) } +/// Clipping path `path` (a node) with its path changed to `clip`. +fn with_clip(path: &Node, clip: PathData) -> Arc { + let mut path = Node::clone(path); + if let NodeKind::Path { path: p, .. } = &mut path.kind { + *p = clip; + } + Arc::new(path) +} + /// A clipping path `id` of `path`, unpainted. fn clipping_path(id: NodeId, path: PathData) -> Node { let none = vectorcraft_color::Paint::None; @@ -1130,6 +1194,19 @@ fn install(d: &mut Document, ids: &[NodeId], (link, img): FileRead, force: Optio ClipTo::File(path) => clip_file_to(d, id, path), ClipTo::Nest(path) => new_clip_group(d, id, path), ClipTo::Off => unclip(d, id), + ClipTo::Both { file, placement } => { + match file { + Some(file) => clip_file_to(d, id, file)?, + None => unclip(d, id)?, + } + // The file's clip group (or the plain group left of it) takes the placement's clip. + let group = d.parent_of(id).ok_or(EngineError::NoNode(id))?; + clip_image_to(d, group, placement) + } + ClipTo::BothInside { file, placement } => { + clip_image_to(d, id, placement)?; + new_clip_group(d, id, file) + } }) } diff --git a/crates/engine/src/tests/dcs.rs b/crates/engine/src/tests/dcs.rs index b780f14c09..43bdf180a7 100644 --- a/crates/engine/src/tests/dcs.rs +++ b/crates/engine/src/tests/dcs.rs @@ -490,6 +490,118 @@ fn a_clipping_mask_of_ones_own_stays_when_the_link_is_updated() { assert_eq!(mask_width(&s), Some(4.0), "the mask's path is kept"); } +/// [`two_plates`] on a 20 × 20 pt page, its composite drawn through the left half of it (same +/// length, so the plates stay where the header says). +fn two_plates_square() -> Vec { + let text = String::from_utf8(two_plates()).unwrap(); + let text = text.replace("0 0 20 10", "0 0 20 20").replace("20 10 scale", "20 20 scale"); + text.replacen("10 10 lineto 0 10 lineto", "10 20 lineto 0 20 lineto", 1).into_bytes() +} + +/// The bounds (width, height) of the clipping path of clip group `g`. +fn clip_size(doc: &Document, g: NodeId) -> (f64, f64) { + let NodeKind::Group { children, clip: true } = &doc.node(g).unwrap().kind else { panic!("a clip group: {:?}", doc.node(g).unwrap().kind) }; + let b = children[0].geometric_bounds().expect("a clipping path"); + (b.width(), b.height()) +} + +#[test] +fn placement_options_clip_a_dcs_image_inside_its_files_clipping_path() { + let dir = temp_dir("placement-clip"); + let path = write(&dir, "pic.eps", &two_plates()); + let square = write(&dir, "square.eps", &two_plates_square()); + let mut s = session(); + let r = s.execute("file.place", &json!({ "path": path, "at": [100, 100] })).unwrap(); + let id = image_of(&s, &r["ids"][0]).id; + s.execute("links.placementOptions", &json!({"ids": [id.0], "preserve": "fill", "clip": true})).unwrap(); + let depth = |doc: &Document| std::iter::successors(Some(id), |n| doc.parent_of(*n)).count(); + let mut first = None; + // The square file fills the 20 × 10 pt placement and is cut to it; the file's own clipping + // path, the left half of its page, still clips the image inside that, on every relink. + for _ in 0..2 { + s.execute("links.relink", &json!({ "ids": [id.0], "path": square })).unwrap(); + let doc = &s.doc().unwrap().doc; + let file = doc.parent_of(id).expect("the file's clip group"); + let (w, h) = clip_size(doc, file); + assert!((w - 10.0).abs() < 1e-6 && (h - 20.0).abs() < 1e-6, "the file's clipping path: {w} × {h}"); + let placement = doc.parent_of(file).expect("the placement's clip group"); + let (w, h) = clip_size(doc, placement); + assert!((w - 20.0).abs() < 1e-6 && (h - 10.0).abs() < 1e-6, "the placement's clip: {w} × {h}"); + assert_eq!(*first.get_or_insert(depth(doc)), depth(doc), "no group is added on a later relink"); + } + // An update of the file keeps both. + s.execute("links.update", &json!({ "ids": [id.0] })).unwrap(); + let doc = &s.doc().unwrap().doc; + assert_eq!(first, Some(depth(doc))); + let file = doc.parent_of(id).unwrap(); + assert!((clip_size(doc, file).0 - 10.0).abs() < 1e-6, "the file's clipping path"); + assert!((clip_size(doc, doc.parent_of(file).unwrap()).1 - 10.0).abs() < 1e-6, "the placement's clip"); + // The file loses its clipping path and gains it again: the same two groups, no more. + let unclipped = String::from_utf8(two_plates_square()).unwrap().replacen("closepath clip newpath", "closepath newpath ", 1); + for _ in 0..2 { + std::fs::write(&square, unclipped.as_bytes()).unwrap(); + s.execute("links.update", &json!({ "ids": [id.0] })).unwrap(); + let doc = &s.doc().unwrap().doc; + assert_eq!(first, Some(depth(doc)), "the file's group stays, without its clip"); + let plain = doc.parent_of(id).unwrap(); + assert!(!matches!(doc.node(plain).unwrap().kind, NodeKind::Group { clip: true, .. }), "the file's group is not clipped"); + assert!((clip_size(doc, doc.parent_of(plain).unwrap()).1 - 10.0).abs() < 1e-6, "the placement's clip stays"); + std::fs::write(&square, two_plates_square()).unwrap(); + s.execute("links.update", &json!({ "ids": [id.0] })).unwrap(); + let doc = &s.doc().unwrap().doc; + assert_eq!(first, Some(depth(doc)), "the file's clip group again, at the same depth"); + let file = doc.parent_of(id).unwrap(); + assert!((clip_size(doc, file).0 - 10.0).abs() < 1e-6, "the file's clipping path again"); + assert!((clip_size(doc, doc.parent_of(file).unwrap()).1 - 10.0).abs() < 1e-6, "the placement's clip"); + } +} + +#[test] +fn placement_options_clip_a_dcs_image_in_a_symbol_inside_its_files_clipping_path() { + let dir = temp_dir("placement-clip-symbol"); + let path = write(&dir, "pic.eps", &two_plates()); + let square = write(&dir, "square.eps", &two_plates_square()); + let mut s = session(); + let r = s.execute("file.place", &json!({ "path": path, "at": [100, 100] })).unwrap(); + s.execute("symbol.new", &json!({ "name": "Pic", "ids": [r["ids"][0]] })).unwrap(); + let list = s.execute("links.list", &json!({})).unwrap(); + let row = list["links"].as_array().unwrap().iter().find(|r| r["owner"]["kind"] == "symbol").cloned().expect("the symbol's image"); + let id = row["id"].as_u64().unwrap(); + s.execute("links.placementOptions", &json!({"ids": [id], "preserve": "fill", "clip": true})).unwrap(); + // The clip groups around the symbol's image, innermost first. + let clips = |s: &Session| { + fn find(n: &Node, id: u64, around: &mut Vec<(f64, f64)>) -> bool { + if n.id.0 == id { + return true; + } + let Some(children) = n.children() else { return false }; + if !children.iter().any(|c| find(c, id, around)) { + return false; + } + if let NodeKind::Group { clip: true, .. } = n.kind + && let Some(b) = children[0].geometric_bounds() + { + around.push((b.width(), b.height())); + } + true + } + let mut around = vec![]; + let doc = &s.doc().unwrap().doc; + assert!(find(&doc.symbols.iter().find(|w| w.name == "Pic").expect("the symbol").art, id, &mut around)); + around + }; + for _ in 0..2 { + s.execute("links.relink", &json!({ "ids": [id], "path": square })).unwrap(); + let around = clips(&s); + assert_eq!(around.len(), 2, "the file's clip group inside the placement's: {around:?}"); + // In the symbol's own units: the file's path as wide as the placement is tall, half as + // wide as it is tall, and the placement twice as wide as it is tall. + let ((fw, fh), (pw, ph)) = (around[0], around[1]); + assert!((fh - 2.0 * fw).abs() < 1e-6 && (fw - ph).abs() < 1e-6, "the file's clipping path: {around:?}"); + assert!((pw - 2.0 * ph).abs() < 1e-6, "the placement's clip: {around:?}"); + } +} + #[test] fn a_dcs_file_takes_the_place_parameters_an_eps_file_takes() { let dir = temp_dir("params"); diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..520341267d 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6512,7 +6512,7 @@ file's composite is drawn through clips the image (a clipping group, its path un clipping path kept as the same area), and `file.place` answers the image's id as `image`, since the Links commands take the image and not the group. `links.update` and `links.relink` clip the image by the file's clipping path again (a plain group holding just the image becomes its clipping group, a new clipping group holds it when no group does, and it goes inside a clipping mask made in the -document, whose path is kept), unless Placement Options clip the image, the same way for the images in symbols, graph designs, patterns and opacity masks; when the new file has no +document, whose path is kept), the same way for the images in symbols, graph designs, patterns and opacity masks. When Placement Options also clip the image, the file's clipping group goes inside a clipping group of the placement's clip (the clipping group holding just the file's one, or a clipping group holding just the image that is not the file's, takes that clip, else a new one does), and a later update or relink changes the same two groups; when the new file has no clipping path, a clipping group holding just the image whose path is the old file's clipping path loses that path and stays as a plain group of the image, with its id, name, visibility and transparency (one whose path was given the even-odd fill rule stays as it is). The link shows as modified when a plate file of its own changes From 1fbbb0a4e7b602368b96dd2fc5724511d08d74f5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 19:07:09 -0800 Subject: [PATCH 028/108] SVG export: shadows in a masked group show in readers that bound it by its shapes Some SVG readers draw a masked group only inside the bounding box of its shapes. A drop shadow, glow, blur or feather inside the group paints past those shapes, so these readers left it out, while others drew it. A masked group now starts with a rectangle over the mask's region, unpainted (fill="none") and hidden (visibility="hidden"), when what it holds has a visible raster effect: on a member at any depth, on a fill or stroke, in a symbol's art, or in the art a blend or other live object is written as. The rectangle widens the group's bounding box without drawing anything, and import leaves it out. The masked groups of a knockout group get the same rectangle when an element inside them has such an effect. Other masked art, brushed strokes included, is written as before, and so is an object whose own effects are written outside its mask. Tests: a_masked_group_spans_its_region_when_its_art_paints_past_its_shapes and a_knockout_group_spans_its_masks_when_an_element_paints_past_its_shapes in crates/svg/tests/it/blend_export.rs. --- crates/svg/src/export/nodes.rs | 67 ++++++++++- crates/svg/tests/it/blend_export.rs | 168 ++++++++++++++++++++++++++++ docs/file-format-parity.md | 2 +- 3 files changed, 235 insertions(+), 2 deletions(-) diff --git a/crates/svg/src/export/nodes.rs b/crates/svg/src/export/nodes.rs index a4cdf26271..cfc2cc2ecb 100644 --- a/crates/svg/src/export/nodes.rs +++ b/crates/svg/src/export/nodes.rs @@ -419,11 +419,66 @@ impl Writer<'_> { self.def(1, ""); self.line(&format!("")); self.depth += 1; + self.spanning_rect(&bare, ®ion); self.node_body(&bare); self.depth -= 1; self.line(""); } + /// Some readers draw a masked group only inside the bounding box of its shapes, which leaves + /// out a drop shadow, blur, glow or feather that paints past them. When `n`, written inside a + /// ``, holds one ([`Self::holds_raster`]), a hidden, unpainted rectangle over the + /// mask's `region` makes that box cover what it paints. + fn spanning_rect(&mut self, n: &Node, region: &str) { + if self.holds_raster(n) { + self.line(&format!("")); + } + } + + /// Do `n`, its fills and strokes, its members at any depth, its symbols' art or the art its + /// live objects are written as have a visible raster effect (shadow, glow, blur, feather)? + /// Objects that aren't written (hidden ones, unless the options keep them) are skipped. The + /// walk keeps its own stack, and looks at each symbol's art once. + fn holds_raster(&self, n: &Node) -> bool { + let mut stack: Vec> = vec![]; + let mut symbols = std::collections::HashSet::new(); + // Whether `n` itself has one; else its members, symbol art or expanded art go on the stack. + let mut visit = |n: &Node, stack: &mut Vec>| { + if !(n.visible || self.opts.hidden_layers) { + return false; + } + if has_raster(&n.appearance.effects) || n.appearance.items.iter().any(|i| has_raster(i.effects())) { + return true; + } + // A live object is written as its expanded art ([`Self::node_body`]), which holds no + // live objects. + if vectorcraft_doc::live::is_live(n) { + let g = vectorcraft_effects::expand_live_deep(Some(self.doc), n); + if !vectorcraft_doc::live::is_live(&g) { + stack.push(std::sync::Arc::new(g)); + return false; + } + } + if let NodeKind::SymbolInstance { symbol, .. } = &n.kind + && symbols.insert(symbol.clone()) + && let Some(s) = self.doc.symbols.iter().find(|s| s.name == *symbol) + { + stack.push(s.art.clone()); + } + stack.extend(n.children().into_iter().flatten().cloned()); + false + }; + if visit(n, &mut stack) { + return true; + } + while let Some(c) = stack.pop() { + if visit(&c, &mut stack) { + return true; + } + } + false + } + /// What `write` writes to the body, taken out of it (written at `depth`, for ``). fn detached(&mut self, depth: usize, write: impl FnOnce(&mut Self)) -> String { let (body, saved) = (std::mem::take(&mut self.body), self.depth); @@ -618,11 +673,21 @@ impl Writer<'_> { // Each mask covers what the group's elements paint. let all: Vec<&Node> = elements.iter().map(|c| &***c).collect(); let region = self.region_attrs(&all); - for (c, (before, _)) in rest.iter().zip(&written).rev() { + // The mask group of element i + 1 holds elements 0…i: it starts with a spanning rectangle + // when one of those paints past its shapes (`Self::spanning_rect`), as `past[i]` records. + let mut past = Vec::with_capacity(elements.len()); + for c in &elements { + let any = past.last().copied().unwrap_or(false) || self.holds_raster(c); + past.push(any); + } + for (i, (c, (before, _))) in rest.iter().zip(&written).enumerate().rev() { self.symbol_nodes = *before; let mid = self.knockout_mask(c, ®ion); self.line(&format!("")); self.depth += 1; + if past.get(i).copied().unwrap_or(false) { + self.line(&format!("")); + } } self.symbol_nodes = after; self.body.push_str(&first); diff --git a/crates/svg/tests/it/blend_export.rs b/crates/svg/tests/it/blend_export.rs index 3804d30ed2..fc0d86077d 100644 --- a/crates/svg/tests/it/blend_export.rs +++ b/crates/svg/tests/it/blend_export.rs @@ -202,6 +202,174 @@ fn a_mask_region_keeps_the_shadows_of_the_masked_art() { } } +fn drop_shadow() -> vectorcraft_doc::Effect { + vectorcraft_doc::Effect { + id: "stylize.dropShadow".into(), + params: serde_json::json!({"x": 15, "y": 15, "blur": 0, "opacity": 100}), + visible: true, + } +} + +/// Whether every `` in `svg` starts with a hidden, unpainted rectangle over its mask's region, +/// and whether any does. +fn spanning_rects(svg: &str) -> (bool, bool) { + let xml = roxmltree::Document::parse_with_options(svg, roxmltree::ParsingOptions { allow_dtd: true, ..Default::default() }).unwrap(); + let spans: Vec = xml + .descendants() + .filter(|n| n.has_tag_name("g") && n.has_attribute("mask")) + .map(|group| { + let id = group.attribute("mask").unwrap().trim_start_matches("url(#").trim_end_matches(')'); + let mask = xml.descendants().find(|n| n.has_tag_name("mask") && n.attribute("id") == Some(id)).unwrap(); + let first = group.children().find(|n| n.is_element()).unwrap(); + first.has_tag_name("rect") + && first.attribute("fill") == Some("none") + && first.attribute("visibility") == Some("hidden") + && ["x", "y", "width", "height"].iter().all(|a| first.attribute(*a).is_some() && first.attribute(*a) == mask.attribute(*a)) + }) + .collect(); + assert!(!spans.is_empty(), "no masked group in {svg}"); + (spans.iter().all(|s| *s), spans.iter().any(|s| *s)) +} + +/// The number of paths `svg` imports as. +fn imported_paths(svg: &str) -> usize { + let (back, warnings) = vectorcraft_svg::import_with_report(svg).unwrap(); + assert!(warnings.is_empty(), "{warnings:?}"); + let mut paths = 0; + back.walk(|n| paths += usize::from(n.path_data().is_some())); + paths +} + +/// A masked group whose content holds a raster effect (a drop shadow, blur, glow or feather, which +/// paint past the shapes) starts with a hidden, unpainted rectangle over the mask's region, so that +/// a reader that draws a masked group only inside the box of its shapes still draws it. Art without +/// one gets none, brushed strokes (written as shapes) included, nor does an object whose own shadow +/// is drawn outside the mask. Import leaves the rectangle out. +#[test] +fn a_masked_group_spans_its_region_when_its_art_paints_past_its_shapes() { + // How the red square sits under the mask. + #[derive(Debug, Clone, Copy)] + enum Case { + Alone, + InGroup, + InNestedGroup, + FillEffect, + HiddenInGroup, + Brushed, + InSymbol, + InBlend, + } + use Case::*; + for (case, shadowed, want) in [ + (InGroup, true, true), + (InGroup, false, false), + (Alone, true, false), + (Alone, false, false), + (InNestedGroup, true, true), + (FillEffect, true, true), + (FillEffect, false, false), + (HiddenInGroup, true, false), + (Brushed, false, false), + (Brushed, true, true), + (InSymbol, true, true), + (InSymbol, false, false), + (InBlend, true, true), + (InBlend, false, false), + ] { + let mut d = Document::new(100.0, 60.0); + let mut red = rect(&mut d, Rect::new(10.0, 10.0, 30.0, 30.0), [255, 0, 0]); + if matches!(case, Brushed) { + let mut stroke = vectorcraft_doc::StrokeLayer::new(Paint::solid(Color::rgb8(0, 0, 200)), 8.0); + stroke.brush = Some("Bristle Round".into()); + red.appearance.items.push(vectorcraft_doc::AppearanceItem::Stroke(stroke)); + } + if shadowed { + match case { + FillEffect => red.appearance.items[0].effects_mut().push(drop_shadow()), + _ => red.appearance.effects.push(drop_shadow()), + } + } + let group = |d: &mut Document, n: Node| Node::group(d.alloc_id(), vec![n.into()]); + let mut masked = match case { + Alone | FillEffect => red, + InGroup | Brushed => group(&mut d, red), + InNestedGroup => { + let inner = group(&mut d, red); + group(&mut d, inner) + } + HiddenInGroup => { + red.visible = false; + group(&mut d, red) + } + InSymbol => { + d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Square".into(), art: std::sync::Arc::new(red) }); + let instance = Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: "Square".into(), xf: vectorcraft_geom::Affine::IDENTITY }); + group(&mut d, instance) + } + InBlend => { + let mut blue = rect(&mut d, Rect::new(60.0, 10.0, 80.0, 30.0), [0, 0, 255]); + blue.appearance.effects = red.appearance.effects.clone(); + let blend = Node::new(d.alloc_id(), NodeKind::Blend { children: vec![red.into(), blue.into()], spec: Default::default() }); + group(&mut d, blend) + } + }; + let art = rect(&mut d, Rect::new(10.0, 10.0, 20.0, 30.0), [255, 255, 255]); + masked.extras_mut().mask = Some(Box::new(OpacityMask::new(art, false))); + add(&mut d, masked); + let svg = export(&d, &ExportOptions::default()); + assert_eq!(spanning_rects(&svg).0, want, "{case:?}, shadowed {shadowed}:\n{svg}"); + if matches!(case, Alone | InGroup | InNestedGroup | FillEffect) { + // The red square alone: no rectangle of the region's size comes back. + assert_eq!(imported_paths(&svg), 1, "{case:?}, shadowed {shadowed}:\n{svg}"); + } + } + // Type can't be measured, so its mask's region covers any artwork: a group of type gets the + // rectangle only when it holds a raster effect, on the type or on a path beside it. + for (shadowed, path_shadowed) in [(false, false), (true, false), (false, true)] { + let mut d = Document::new(80.0, 40.0); + let style = CharStyle { size: 24.0, fill: Paint::solid(Color::BLACK), ..CharStyle::default() }; + let mut t = Node::new(d.alloc_id(), NodeKind::Text(Box::new(TextObject::point(Point::new(5.0, 30.0), "Wide", style)))); + if shadowed { + t.appearance.effects.push(drop_shadow()); + } + let mut red = rect(&mut d, Rect::new(50.0, 5.0, 60.0, 15.0), [255, 0, 0]); + if path_shadowed { + red.appearance.effects.push(drop_shadow()); + } + let mut group = Node::group(d.alloc_id(), vec![t.into(), red.into()]); + let art = rect(&mut d, Rect::new(0.0, 0.0, 40.0, 40.0), [255, 255, 255]); + group.extras_mut().mask = Some(Box::new(OpacityMask::new(art, false))); + add(&mut d, group); + let svg = export(&d, &ExportOptions::default()); + let want = shadowed || path_shadowed; + assert_eq!(svg.contains("visibility=\"hidden\""), want, "type {shadowed}, path {path_shadowed}:\n{svg}"); + } +} + +/// In a knockout group, each element is drawn inside the masks of the elements above it. When an +/// element inside a mask's group has a drop shadow, that group starts with the same hidden, +/// unpainted rectangle over the region, and import leaves it out. +#[test] +fn a_knockout_group_spans_its_masks_when_an_element_paints_past_its_shapes() { + for shadowed in [false, true] { + let mut d = Document::new(60.0, 60.0); + let mut below = rect(&mut d, Rect::new(5.0, 5.0, 25.0, 25.0), [200, 0, 0]); + if shadowed { + below.appearance.effects.push(drop_shadow()); + } + let mut middle = rect(&mut d, Rect::new(15.0, 15.0, 35.0, 35.0), [0, 200, 0]); + middle.opacity = 0.5; + let mut top = rect(&mut d, Rect::new(20.0, 5.0, 30.0, 40.0), [0, 0, 200]); + top.opacity = 0.5; + let mut group = Node::group(d.alloc_id(), vec![below.into(), middle.into(), top.into()]); + group.knockout = vectorcraft_doc::Knockout::On; + add(&mut d, group); + let svg = export(&d, &ExportOptions::default()); + assert_eq!(spanning_rects(&svg), (shadowed, shadowed), "shadowed {shadowed}:\n{svg}"); + assert_eq!(imported_paths(&svg), 3, "shadowed {shadowed}:\n{svg}"); + } +} + /// Type is measured by its layout or its path, and a reader sets live type in its own font, so a /// mask or knockout over type keeps the region that covers any artwork. #[test] diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 92fd10cbb3..9edc7012ed 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -284,7 +284,7 @@ Names in the editing data that aren't UTF-8 (layers, objects, artboards, colors, | EPS | open, place, save | yes (own PostScript L3 interpreter, Illustrator EPS editing data structure) | yes (L2/L3, TIFF previews) | CIDFonts the file doesn't carry not drawn, but for those over a predefined CMap (`UniJIS-UCS2-H`, `90ms-RKSJ-H`, `GBK-EUC-H`, `KSCms-UHC-H`, `ETen-B5-H`), set as type in the font of the CIDFont's name, vertical over a `-V` CMap; a name that ends in the row-and-cell CMap `H` or `V` splits off the CMap only when the file defines the CIDFont of that name, or the name has a hyphen and an installed face that covers Japanese has it; name-keyed fonts in a FontSet set as type by name; #505; images encoded with `CCITTFaxDecode` (ITU-T T.4 Group 3 and T.6 Group 4, with `K`, `Columns`, `Rows`, `EndOfBlock`, `EndOfLine`, `EncodedByteAlign` and `BlackIs1`) draw, and damaged data keeps the rows decoded before its first damaged row; Type 42 (TrueType) fonts set type at its size (#1553); an embedded Type 1 font's encrypted part is read for its glyphs, which space its type, outline it and draw glyphs without a character, in plain and composite fonts; a Type 42 font that carries its TrueType font gives each code its character by its glyph name or, for names that say nothing (`/g12`), by the glyph's entry in the font's own character map, spaces its type by its own widths and draws glyphs that stand for no character from its outlines; the show operators' spacing along the baseline (`ashow`, `widthshow`, `xshow`, `yshow`, `xyshow`, and the moves of `kshow`'s procedure, run between each two characters) is kept on live type as tracking, so type in a font that isn't installed keeps the file's line lengths (spacing that moves characters off the baseline, as `yshow`, `xyshow` or a `kshow` procedure can, places each character as its own text object); composite (Type 0) fonts with the 8/8 mapping, as PDF-to-PostScript converters write two-byte fonts, draw a Type 42 descendant's glyphs from the TrueType outlines it carries and an embedded Type 1 descendant's from its charstrings, and set other descendants' characters as type at the composite font's size (other mappings are still set as type in the font of their name); CID-keyed fonts (`composefont`, `FMapType` 9 over a CMap built with the CIDInit operators or `Identity-H`/`Identity-V`; `bfchar` and `bfrange` mappings give a base-font descendant its codes or glyph names) draw the glyphs of the Type 0 CIDFonts (Type 1 charstrings in their `StartData` binary data or `GlyphDirectory`) and Type 2 CIDFonts (TrueType glyphs through `CIDMap`) they carry, and the CID-keyed fonts of a FontSet's Compact Font Format data (Type 2 charstrings); a clip only counts as covering the page when its shape does (#1542); an EPS another app copied pastes as editable vector art (`clipboard.importEps`, #1499); a stitched shading keeps its hard colour changes on import (#1654); sampled functions (type 0) interpolate between their samples, multilinearly or by cubics with `Order 3`, and a sampled axial or radial gradient has a stop at each sample; a gradient the page paints as a row of abutting one-colour strips (as Level 2 writers draw smooth shades) imports as one linear gradient, without the seams the strips leave when each is drawn alone; CMYK images, CMYK JPEGs included, keep their ink amounts on import, as from PDF, and the pixels a `MaskColor` or `ImageType 3` mask hides become a grayscale opacity mask; ruzstd 0.9.1 for compressed editing data (#1807, RUSTSEC-2026-0344) | | PostScript `.ps` | open, place | yes (the EPS reader reads its first page; `.epsf` files open and place as EPS) | via Print to PostScript | `tests_epsimport.rs` | | DCS 1.0 / 2.0 | place linked | place linked only (one image of the plates; spot plates as spot swatches; the composite's clipping path; each plate on its own ink in Separations Preview and print separations) | no | `crates/eps/src/dcs/tests.rs`, `crates/engine/src/tests/dcs.rs` | -| SVG / SVGZ | open, place, save | yes | yes (SVG Options, Preserve Editing, symbols, filters, rich text) | strongest format; tests in `crates/svg/tests`; text on a path follows basic shapes as their SVG 2 equivalent paths (#1527); CSS transforms and the `font` shorthand (#1565), percentage lengths in symbols (#1596), Inkscape flowed text as area type (#1568) and Inkscape pages as artboards (#1601) import; an unsupported filter is named in its warning (#1598); an artboard exported on its own (Export As with Use Artboards, Export for Screens, Asset Export) has the artboard's name as ``, Save the document's (#3544); attributes in other applications' XML namespaces (`plotter:pen="2"`) kept on their objects from import to export, as `data-*` attributes are (`crates/svg/tests/it/foreign_attributes.rs`); simple shapes export as `<rect>`, `<circle>`, `<ellipse>`, `<line>`, `<polygon>` and `<polyline>` where they draw the same as the path (#4652, `crates/svg/tests/it/basic_shapes.rs`); the regions of exported masks and filters (opacity masks, inverted masks, knockout groups) cover the art they apply to, and over type keep a region that covers any artwork (#6401, `crates/svg/tests/it/blend_export.rs`); SVG Options › Include Variable Data writes the text variables, data sets and bound type objects, and opening the SVG reads them back (`tests::variables::an_svg_with_variable_data_opens_with_its_variables_data_sets_and_bindings`) | +| SVG / SVGZ | open, place, save | yes | yes (SVG Options, Preserve Editing, symbols, filters, rich text) | strongest format; tests in `crates/svg/tests`; text on a path follows basic shapes as their SVG 2 equivalent paths (#1527); CSS transforms and the `font` shorthand (#1565), percentage lengths in symbols (#1596), Inkscape flowed text as area type (#1568) and Inkscape pages as artboards (#1601) import; an unsupported filter is named in its warning (#1598); an artboard exported on its own (Export As with Use Artboards, Export for Screens, Asset Export) has the artboard's name as `<title>`, Save the document's (#3544); attributes in other applications' XML namespaces (`plotter:pen="2"`) kept on their objects from import to export, as `data-*` attributes are (`crates/svg/tests/it/foreign_attributes.rs`); simple shapes export as `<rect>`, `<circle>`, `<ellipse>`, `<line>`, `<polygon>` and `<polyline>` where they draw the same as the path (#4652, `crates/svg/tests/it/basic_shapes.rs`); the regions of exported masks and filters (opacity masks, inverted masks, knockout groups) cover the art they apply to, and over type keep a region that covers any artwork (#6401, `crates/svg/tests/it/blend_export.rs`); a masked group, or a knockout group's masked group, whose content has a shadow, glow, blur or feather starts with a hidden, unpainted rectangle over the mask's region, so readers that draw a masked group only inside the box of its shapes draw those effects too (`crates/svg/tests/it/blend_export.rs`); SVG Options › Include Variable Data writes the text variables, data sets and bound type objects, and opening the SVG reads them back (`tests::variables::an_svg_with_variable_data_opens_with_its_variables_data_sets_and_bindings`) | | DXF | open, export | yes | yes (R12–2018) | R13–2018 closed SPLINE flags and control-point closure on import verified (#1299); circular cubic paths export as native CIRCLE/ARC where stroke semantics permit; R12 weighted strokes remain POLYLINE while non-circular curves keep the existing fallback (`crates/cad/src/tests.rs`); [Autodesk group 70](https://help.autodesk.com/cloudhelp/2024/ENU/AutoCAD-DXF/files/GUID-E1F884F8-AA90-4864-A215-3182D47A9C74.htm). DXF 2000–2018 LAYOUT objects write the paper image origin as 148/149 (was a stray 158), the shade plot codes (2004+) and the model type flag, and the plot style placeholder carries no subclass marker (#3085; structure test `r2000_and_later_files_have_the_structure_cad_apps_require`, checked with ezdxf's audit; not yet confirmed in Autodesk Fusion). DXF Options' Preset menu and `document.exportDxf`'s `dxfPreset: "cnc"` set the CNC / CAM options (#5500); VCarve QA remains open | | HP-GL/2 `.plt`, `.hpgl`, `.hgl`, `.hpg` | — | yes (pen moves, pens and widths, line types and attributes, circles, arcs, wedges and Bézier curves, filled and edged rectangles, wedges and polygons, encoded polylines, scaling and rotation; labels, symbol mode, raster images and hatching aren't drawn) | yes (`.plt`: each visible path once along its line, a pen per color or a pen table, type as outlines, clipping applied, HP-GL or HP-GL/2 with pen colors and encoded polylines) | recognized by its first instructions after any printer escapes, under its own extensions or one no other format reads; `crates/cad/src/hpgl/tests.rs`, `crates/cad/src/hpgl/write/tests.rs` (plots read back by the reader), `tests_hpgl.rs`, `import_fuzz.rs` | | DWG | open, export | no | no | no open spec; DXF instead | From e93b672b3bf73a15417f235cb854f94536c46285 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 19:36:59 -0800 Subject: [PATCH 029/108] Keyboard Shortcuts: panel menu commands with typed optional params can take a shortcut MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An undoable command without a menu path or a default key was listed only when every field of its params doc ended with `?`. A typed optional field such as `on?: bool`, `ids?: [id…]` or `artboard?: index=0` counted as required, so Fractional Widths, System Layout, Align to Pixel Grid, Embed Image, Update Links, Delete Slices, Switch Orientation, Distribute Spacing for artboards, Target Contents, Invert and other panel menu commands that act on the selection could not be given a shortcut. `runs_without_params` now reads the params doc with `names_a_required_field`, the parser the editor already uses for menu commands. The commands the new rule would list that set nothing, fail or only give data back when a key runs them with no params (the panel setters such as Fill and Character, the exports and saves without a path, the undo group's begin and end, Create Dimension) join `NEEDS_A_PARAM`, so they stay out of the list until the user gives one a key. New Symbol joins it too, since the Symbols panel runs it through Symbol Options. docs/mcp.md describes the rule and the full `NEEDS_A_PARAM` list. --- crates/ui-egui/src/shortcut_editor.rs | 107 +++++++++++++++++++++++--- docs/mcp.md | 26 ++++++- 2 files changed, 121 insertions(+), 12 deletions(-) diff --git a/crates/ui-egui/src/shortcut_editor.rs b/crates/ui-egui/src/shortcut_editor.rs index 4e02180017..26606c2763 100644 --- a/crates/ui-egui/src/shortcut_editor.rs +++ b/crates/ui-egui/src/shortcut_editor.rs @@ -765,12 +765,10 @@ fn chosen_path(items: &[(String, Value)]) -> Option<&str> { items.iter().find(|(_, p)| is_bare(p)).or(items.first()).map(|(path, _)| path.as_str()) } -/// Does a command's params doc (`{a?, b?} …`) say it runs with no params, as a shortcut runs it? +/// Does a command's params doc (`{a?, b?: bool} …`) say it runs with no params, as a shortcut runs +/// it? It does when it starts with `{` and [`names_a_required_field`] finds no field a call must give. fn runs_without_params(params: &str) -> bool { - params - .strip_prefix('{') - .and_then(|r| r.split_once('}')) - .is_some_and(|(fields, _)| fields.split(',').all(|f| f.trim().is_empty() || f.trim_end().ends_with('?'))) + params.starts_with('{') && !names_a_required_field(params) } /// Does the editor list `e` under `overrides`? An entry that [`needs_a_value`] is listed only while @@ -783,8 +781,13 @@ fn listed(overrides: &Overrides, e: &Entry) -> bool { /// with none, and that no item of the menu bar runs: Transparency and Opacity Mask Options need /// a value to set, Align and Distribute a direction, Delete Swatch and Move Swatch a swatch name, /// and the library, data set, text style and SVG filter loaders a file, which their menu items ask -/// for. -const NEEDS_A_PARAM: [&str; 20] = [ +/// for. The commands after them have no menu path: the setters of panels and dialogs (Fill, Stroke +/// Options, Character, Set Bounds), the exports and saves that give the file back without a `path` +/// (Save Document gives the file back when the document has no file yet; File › Save takes a key +/// instead), the undo group's begin and end, and the commands that need a point, a value or a name +/// (Create Dimension, Edit Freeform Point, Select by Color, Move Brush). New Symbol is left out +/// because the Symbols panel runs it through the Symbol Options dialog. +const NEEDS_A_PARAM: [&str; 74] = [ "transparency.set", "transparency.setOpacityMask", "stroke.set", @@ -805,6 +808,60 @@ const NEEDS_A_PARAM: [&str; 20] = [ "paraStyle.load", "textStyle.loadAll", "svgFilter.import", + "addon.pathtools.setAnchor", + "addon.shapes.configure", + "appearance.addEffect", + "artboard.align", + "artboard.distribute", + "assets.export", + "assets.export3D", + "assets.settings.set", + "attributes.set", + "brush.move", + "css.export", + "dimension.create", + "document.export", + "document.exportDxf", + "document.exportEps", + "document.exportForWeb", + "document.exportPdf", + "document.save", + "document.setup", + "edit.undoGroup.begin", + "edit.undoGroup.end", + "eyedropper.setOptions", + "file.package", + "library.createGroup", + "links.placementOptions", + "links.unembed", + "livePaint.gapOptions", + "object.blend.createSpine", + "object.blend.setEasing", + "object.intertwine.arrange", + "object.objectsOnPath.options", + "object.puppetWarp.pins", + "object.setBounds", + "object.setLiveShape", + "object.setOverprint", + "object.setProps", + "object.slice.select", + "paint.freeform.setPoint", + "paint.setFill", + "paint.setGradientGeom", + "paint.setStroke", + "perspective.grid.define", + "perspective.grid.set", + "perspective.plane.move", + "print.setup", + "select.color", + "select.globalEditOptions", + "stroke.setAdvanced", + "symbol.new", + "symbol.options", + "text.setFormat", + "text.setRangeStyle", + "text.setStyle", + "type.ruby", ]; /// The (label, params) of each menu bar item, by command id. @@ -907,7 +964,7 @@ fn a_menu_bar_item_runs(id: &str, params: &str) -> bool { /// Is engine command `c` listed in Edit › Keyboard Shortcuts whether or not an item of the menu bar /// runs it? A command with a menu path of its own is. One without (a panel menu item) is when a key /// alone can run it: it has a default key, or it is an undoable command, not an alias, whose params -/// doc ends each field with `?`. +/// doc names no field a call must give ([`runs_without_params`]). fn listed_on_its_own(c: &vectorcraft_engine::CommandSpec) -> bool { !c.menu.is_empty() || c.shortcut.is_some() || (c.journal && !vectorcraft_engine::cmd::is_alias(c.id) && runs_without_params(c.params)) } @@ -2309,11 +2366,39 @@ mod tests { for id in ["brush.duplicate", "path.convertAnchors", "document.json", "prefs.list"] { assert!(entry(id).is_none(), "{id}"); } - for (doc, bare) in - [("{}", true), ("{dx?, dy?} x", true), ("{id?|ids?, clip?}", true), ("{name, newName?}", false), ("{a?: {b}}", false), ("same as", false)] - { + // The Symbols panel runs New Symbol through Symbol Options, so it waits for a key the user gives it. + assert!(entry("symbol.new").is_some_and(|e| !listed(&Overrides::new(), &e))); + for (doc, bare) in [ + ("{}", true), + ("{dx?, dy?} x", true), + ("{id?|ids?, clip?}", true), + ("{name, newName?}", false), + ("{a?: {b}}", true), + ("{ids?|id?, on?: bool} turn it on or off", true), + ("{ids?: [id…] (the selection), anchors?: [index…]}", true), + ("{format?: a|b, size?: 1|3|5}", true), + ("{artboard?: index=0}", true), + ("{mode: a|b, on?: bool}", false), + ("same as", false), + ] { assert_eq!(runs_without_params(doc), bare, "{doc}"); } + // Panel menu commands whose params doc gives each optional field a type are listed too. + let none = Overrides::new(); + for id in [ + "type.fractionalWidths", + "type.systemLayout", + "object.setPixelAligned", + "links.embed", + "links.update", + "object.slice.delete", + "artboard.switchOrientation", + "appearance.targetContents", + "paint.invert", + "artboard.distributeSpacing", + ] { + assert!(entry(id).is_some_and(|e| listed(&none, &e)), "{id}"); + } let mut ov = Overrides::new(); assert!(assign(&mut ov, "symbol.breakLink", Some("Cmd+Alt+Shift+F9"), true).is_ok()); assert_eq!(effective_in(&ov, "symbol.breakLink").as_deref(), Some("Cmd+Alt+Shift+F9")); diff --git a/docs/mcp.md b/docs/mcp.md index 84c75a81d0..7a0d5192b9 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5616,6 +5616,15 @@ tool's active artboard in place, and the Distribute buttons then send the Distri can then be negative. Align to Selection sends `to: "selection"`. The Distribute buttons need two or more selected artboards with Align to Artboard, and three or more with Align to Selection. +Edit › Keyboard Shortcuts and `shortcuts.list` list an undoable command that is not an alias and has no menu path or +default shortcut, such as a panel menu's Break Link to Symbol (`symbol.breakLink`), when its params doc names no +required field and it is not one of the commands left out below. A field is optional when each of its names ends with +`?`, whatever type follows it (`on?: bool`, `ids?: [id…]`), when its name is followed directly by an `=` default +(`rows=10`), or when it starts with `…`. Such a command is listed in the group named by the first part of its id. +Commands listed this way include `type.fractionalWidths`, `type.systemLayout`, `object.setPixelAligned`, +`links.embed`, `links.update`, `object.slice.delete`, `artboard.switchOrientation`, `artboard.distributeSpacing`, +`appearance.targetContents` and `paint.invert`. + Edit › Keyboard Shortcuts and `shortcuts.list` leave out a command with no default shortcut when a key press cannot run it: no item of the menu bar runs it, it opens no dialog when run without params, and it is one of these: @@ -5625,7 +5634,22 @@ run it: no item of the menu bar runs it, it opens no dialog when run without par - a command that sets nothing or fails without a param: `transparency.set`, `transparency.setOpacityMask`, `stroke.set`, `layer.setProps`, `object.align`, `object.distribute`, `swatch.delete`, `swatch.move`, `swatch.spotOptions`, `edit.colors.adjustBalance`, `swatch.library.load`, `graphicStyle.loadLibrary`, - `symbol.loadLibrary`, `brush.loadLibrary`, `dataset.import` and `variable.loadLibrary`. + `symbol.loadLibrary`, `brush.loadLibrary`, `dataset.import`, `variable.loadLibrary`, `charStyle.load`, + `paraStyle.load`, `textStyle.loadAll` and `svgFilter.import`; +- a command without a menu path that sets nothing, fails or only gives data back without a param: + `addon.pathtools.setAnchor`, `addon.shapes.configure`, `appearance.addEffect`, `artboard.align`, + `artboard.distribute`, `assets.export`, `assets.export3D`, `assets.settings.set`, + `attributes.set`, `brush.move`, `css.export`, `dimension.create`, `document.export`, `document.exportDxf`, + `document.exportEps`, `document.exportForWeb`, `document.exportPdf`, `document.save`, `document.setup`, + `edit.undoGroup.begin`, `edit.undoGroup.end`, `eyedropper.setOptions`, `file.package`, `library.createGroup`, + `links.placementOptions`, `links.unembed`, `livePaint.gapOptions`, `object.blend.createSpine`, + `object.blend.setEasing`, `object.intertwine.arrange`, `object.objectsOnPath.options`, `object.puppetWarp.pins`, + `object.setBounds`, `object.setLiveShape`, `object.setOverprint`, `object.setProps`, `object.slice.select`, + `paint.freeform.setPoint`, `paint.setFill`, `paint.setGradientGeom`, `paint.setStroke`, `perspective.grid.define`, + `perspective.grid.set`, `perspective.plane.move`, `print.setup`, `select.color`, `select.globalEditOptions`, + `stroke.setAdvanced`, `symbol.options`, `text.setFormat`, `text.setRangeStyle`, `text.setStyle` and `type.ruby`; +- `symbol.new`, which the Symbols panel's New Symbol button and its New Symbol… menu item run through the Symbol + Options dialog. They list such a command while the user has changed its shortcut (`overridden: true` in `shortcuts.list`), and `shortcuts.set` can change or clear it. When every menu bar item that runs a command gives it the same params, a From 3ea152461832e3697b5279476eded0da9cc8ecf3 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Thu, 12 Nov 2026 21:48:37 -0800 Subject: [PATCH 030/108] Image Trace: Flat Logo traces a gray between black and white as one shape With a gray among the colors, an anti-aliased edge pixel of black on white is also a mix of black and gray, or of gray and white, and the unmixing took the mix with the smallest error, which often held the gray. A black disc and a gray square on white traced the gray as the square plus 8 to 24 slivers around the disc, with the colors found or named exactly. When another mix of two classes also reproduces an edge pixel, the pixel now takes it if that mix's classes lie nearer in the flat areas around the pixel and the pixel has a neighbor on each side of the left-out class, along the line between the other two. Pixels within a few levels of a class outside a flat area are checked the same way, and they now count toward the number of pixel values that decides when a busy image is averaged down further. A flat area that stands for no class, as with colors named some levels off, counts as holding the classes of its mix, and so do the pixels of exactly its color joined to it. Whether a hard-edged image is softened is still judged from each pixel's best mix. The slivers are removed around sharp edges and edges blurred by up to about half a pixel; an edge blurred by a pixel or more, or pixel noise of a level or more, can still leave some. Gray strokes two and three pixels wide beside black stay gray, and so does a one-pixel gray line between black and white of at least 13 joined pixels. These trace as black and white: a shorter one-pixel line, or one that falls between pixels or is blurred; a soft-edged gray stroke about two pixels wide touching black; and most or all of a soft-edged stroke about three pixels wide touching black, 12 pixels long or less. Docs: docs/image-trace-adjustments.md, docs/target-app-parity.md. --- crates/trace/src/logo/pipeline.rs | 69 ++-- crates/trace/src/logo/tests.rs | 239 ++++++++++++++ crates/trace/src/logo/unmix.rs | 523 ++++++++++++++++++++++++++++-- docs/image-trace-adjustments.md | 23 +- docs/target-app-parity.md | 1 + 5 files changed, 792 insertions(+), 63 deletions(-) diff --git a/crates/trace/src/logo/pipeline.rs b/crates/trace/src/logo/pipeline.rs index 766cf242dd..16bb1b3b08 100644 --- a/crates/trace/src/logo/pipeline.rs +++ b/crates/trace/src/logo/pipeline.rs @@ -6,7 +6,7 @@ use super::march::{area2, contours}; use super::outline::{Stats, Style, fit_outline}; use super::palette::{WHITE_MIN, auto_palette, flat_fraction, fold_tones, parse_hex, unexplained_colours}; use super::restore::RestoreParams; -use super::unmix::{Px, count_ambiguous, unmix}; +use super::unmix::{Px, Switched, count_ambiguous, unmix}; use crate::{Raster, TraceError, TraceParams, TraceResult, TracedPath}; use vectorcraft_geom::{Anchor, AnchorKind, PathData, Point, SubPath}; @@ -20,7 +20,7 @@ const FIELD_CELLS_MAX: usize = 6_000_000; const MIN_FLAT: f64 = 0.93; /// Most outlines of one colour (above the noise threshold) we will fit; more is refused, not truncated. const MAX_LOOPS_PER_CLASS: usize = if cfg!(test) { 500 } else { 20_000 }; -/// Most distinct pixel values `unmix` may have to work on (those that are not exactly one color). A busier image is +/// Most distinct pixel values `unmix` may have to work on (`count_ambiguous`). A busier image is /// averaged down further first, which bounds the time on pathological input. const EDGE_BUDGET: usize = 150_000; /// Palette colours closer than this (RGB distance) are one colour. @@ -320,27 +320,33 @@ fn keep_shape(s: &Shape, map: &ToSource, kept: &mut Vec<Kept>, anchors_made: &mu /// A hard-edged source (a GIF, say) has no anti-aliasing to read an edge position from, and its /// outlines would follow the pixel staircase. Blurring the coverage by under a pixel gives the -/// outline a smooth edge to find. Sources with plenty of blended edge pixels are left alone. -fn soften_if_aliased(planes: &mut [Vec<f32>], w: usize, h: usize) -> bool { +/// outline a smooth edge to find. Sources with plenty of blended edge pixels are left alone. The +/// pixels that took another mix than their best one (`switched`) are judged by their best mix. +fn soften_if_aliased(planes: &mut [Vec<f32>], switched: &Switched, w: usize, h: usize) -> bool { let n = w * h; - let dominant: Vec<usize> = - (0..n).map(|i| (0..planes.len()).max_by(|&a, &b| plane_at(planes, a, i).total_cmp(&plane_at(planes, b, i))).unwrap_or(0)).collect(); - let (mut boundary, mut blended) = (0usize, 0usize); - for y in 0..h { - for x in 0..w { - let i = y * w + x; - let d = dominant.get(i).copied().unwrap_or(0); - let strongest = (0..planes.len()).map(|c| plane_at(planes, c, i)).fold(0.0f32, f32::max); - if strongest < 0.9 { - blended += 1; - } - let differs = |j: usize| dominant.get(j).is_some_and(|&o| o != d); - if (x + 1 < w && differs(i + 1)) || (y + 1 < h && differs(i + w)) { - boundary += 1; + let aliased = { + let at = |c: usize, i: usize| match switched.binary_search_by_key(&i, |&(j, _)| j) { + Ok(s) => switched.get(s).and_then(|(_, col)| col.get(c)).copied().unwrap_or(0.0), + Err(_) => plane_at(planes, c, i), + }; + let dominant: Vec<usize> = (0..n).map(|i| (0..planes.len()).max_by(|&a, &b| at(a, i).total_cmp(&at(b, i))).unwrap_or(0)).collect(); + let (mut boundary, mut blended) = (0usize, 0usize); + for y in 0..h { + for x in 0..w { + let i = y * w + x; + let d = dominant.get(i).copied().unwrap_or(0); + let strongest = (0..planes.len()).map(|c| at(c, i)).fold(0.0f32, f32::max); + if strongest < 0.9 { + blended += 1; + } + let differs = |j: usize| dominant.get(j).is_some_and(|&o| o != d); + if (x + 1 < w && differs(i + 1)) || (y + 1 < h && differs(i + w)) { + boundary += 1; + } } } - } - let aliased = boundary > 0 && blended * 4 < boundary; + boundary > 0 && blended * 4 < boundary + }; if aliased { for p in planes.iter_mut() { blur_plane(p, w, h, 0.8); @@ -437,26 +443,27 @@ pub(crate) fn trace_logo(img: &Raster, params: &TraceParams, max_anchors: usize) let mut classes = classes_for(&palette, own_white || merge_white.is_some()); // A very busy image is averaged down further until the unmixing work is bounded. for _ in 0..6 { - if count_ambiguous(&pix, &classes) <= EDGE_BUDGET || w * h <= 16_384 { + if count_ambiguous(&pix, w, h, &classes) <= EDGE_BUDGET || w * h <= 16_384 { break; } (pix, w, h, factor) = working_copy(img, factor * 2); } - let (mut planes, residual) = unmix(&pix, w, h, &classes); - let mut planes = if params.logo_colors.is_empty() && palette.len() < MAX_COLOURS { + let (mut planes, residual, switched) = unmix(&pix, w, h, &classes); + let (mut planes, mut switched) = if params.logo_colors.is_empty() && palette.len() < MAX_COLOURS { // Colours too small to be found at first show up as pixels nothing explains: add them. let extra = unexplained_colours(&pix, w, h, &residual, &palette); if extra.is_empty() { - planes + (planes, switched) } else { palette.extend(extra.into_iter().take(MAX_COLOURS - palette.len())); // (A colour nothing explained may be one more tone of a colour that is there.) palette = fold_tones(&pix, palette); classes = classes_for(&palette, own_white); - unmix(&pix, w, h, &classes).0 + let (planes, _, switched) = unmix(&pix, w, h, &classes); + (planes, switched) } } else { - std::mem::take(&mut planes) + (std::mem::take(&mut planes), switched) }; if let Some(to) = merge_white && palette.len() < planes.len() @@ -467,10 +474,18 @@ pub(crate) fn trace_logo(img: &Raster, params: &TraceParams, max_anchors: usize) *t += *v; } } + for (_, col) in &mut switched { + if palette.len() < col.len() { + let white_weight = col.remove(palette.len()); + if let Some(t) = col.get_mut(to) { + *t += white_weight; + } + } + } } // Without a white class, `white` is an index no class has. let (white, transparent) = if own_white { (palette.len(), palette.len() + 1) } else { (usize::MAX, palette.len()) }; - let aliased = soften_if_aliased(&mut planes, w, h); + let aliased = soften_if_aliased(&mut planes, &switched, w, h); if own_white { fill_knockouts(&mut planes, w, h, white, transparent); } diff --git a/crates/trace/src/logo/tests.rs b/crates/trace/src/logo/tests.rs index 168ba05d7f..33ab678a1f 100644 --- a/crates/trace/src/logo/tests.rs +++ b/crates/trace/src/logo/tests.rs @@ -919,3 +919,242 @@ fn an_outline_fitted_without_area_is_left_out() { } } } + +/// A black disc and a gray square on white, the gray lying on the line from black to white: the +/// disc's edge pixels are blends of black and white, so the gray is one shape (the square) and no +/// gray lines the disc. Colors found and named exactly, the darker gray also named 52 levels off; +/// sharp and soft edges. +#[test] +fn a_gray_between_black_and_white_is_one_shape() { + const INK: [u8; 3] = [4, 4, 3]; + for gray in [[230u8, 230, 230], [200, 200, 200]] { + for blur in [0.0, 0.6] { + let img = render(120, 60, blur, |x, y| { + Some(if (x - 30.0).hypot(y - 30.0) <= 20.0 { + INK + } else if (60.0..=110.0).contains(&x) && (10.0..=50.0).contains(&y) { + gray + } else { + WHITE + }) + }); + // (A gray of 230 named 52 levels darker lies nearer white than its name, and is traced as white.) + let offs: &[Option<u8>] = if gray[0] == 200 { &[None, Some(0), Some(52)] } else { &[None, Some(0)] }; + for &by in offs { + let (p, gray_name) = match by { + None => (logo_params(), gray), + Some(by) => { + // Each name moved `by` levels toward mid-gray: the black lighter, the gray darker. + let names = [INK.map(|v| v.saturating_add(by)), gray.map(|v| v.saturating_sub(by))]; + let logo_colors = names.iter().map(|c| format!("#{:02X}{:02X}{:02X}", c[0], c[1], c[2])).collect(); + (TraceParams { logo_colors, ..logo_params() }, names[1]) + } + }; + let what = format!("gray {gray:?}, blur {blur}, names moved {by:?}"); + let res = trace(&img, &p); + let grays = res.paths.iter().filter(|t| t.color == gray_name).count(); + let paths: Vec<_> = res.paths.iter().map(|t| (t.color, t.pixels)).collect(); + assert_eq!(grays, 1, "{what}: {grays} gray paths; {paths:?}"); + assert_eq!(top_color(&res, Point::new(85.0, 30.0)), Some(gray_name), "{what}: the square"); + for k in 0..16 { + let a = f64::from(k) * std::f64::consts::TAU / 16.0; + let at = Point::new(30.0 + 20.0 * a.cos(), 30.0 + 20.0 * a.sin()); + assert_ne!(top_color(&res, at), Some(gray_name), "{what}: the disc's edge at {at:?}"); + } + } + } + } +} + +/// A one-pixel gray line between flat black and flat white, with the three colors named, stays a +/// gray line along its whole length, beside a black disc whose edge pixels are as light as the gray. +#[test] +fn a_one_pixel_gray_line_between_black_and_white_stays_gray() { + const INK: [u8; 3] = [4, 4, 3]; + for gray in [[230u8, 230, 230], [200, 200, 200], [128, 128, 128]] { + let img = render(120, 80, 0.0, |x, y| { + Some(if x < 40.0 || (x - 90.0).hypot(y - 40.0) <= 15.0 { + INK + } else if x < 41.0 { + gray + } else { + WHITE + }) + }); + let logo_colors = vec!["#040403".into(), format!("#{:02X}{:02X}{:02X}", gray[0], gray[1], gray[2]), "#FFFFFF".into()]; + let res = trace(&img, &TraceParams { logo_colors, ..logo_params() }); + let paths: Vec<_> = res.paths.iter().map(|t| (t.color, t.pixels)).collect(); + for y in 2..78 { + let at = Point::new(40.5, f64::from(y) + 0.5); + assert_eq!(top_color(&res, at), Some(gray), "gray {gray:?}: the line at {at:?}; {paths:?}"); + } + for k in 0..16 { + let a = f64::from(k) * std::f64::consts::TAU / 16.0; + let at = Point::new(90.0 + 15.0 * a.cos(), 40.0 + 15.0 * a.sin()); + assert_ne!(top_color(&res, at), Some(gray), "gray {gray:?}: the disc's edge at {at:?}"); + } + } +} + +/// A gray stroke 12 pixels long touching a black disc on white, with the three colors named: the +/// stroke's pixels join the disc's edge pixels that are as light as the gray, but no gray lines the +/// rest of the disc's edge, and a sharp stroke stays gray. Strokes two and three pixels wide outside +/// the disc, on and off the pixel grid, sharp and soft. A soft stroke about two pixels wide that +/// touches black is traced as black and white, and one about three pixels wide in part, so the +/// stroke's own color is checked on sharp strokes. +#[test] +fn a_gray_stroke_touching_a_black_disc_leaves_its_edge_black_and_white() { + const INK: [u8; 3] = [4, 4, 3]; + for gray in [[230u8, 230, 230], [200, 200, 200], [128, 128, 128]] { + for blur in [0.0, 0.6] { + // The disc reaches x = 42 to 43 along the stroke's rows; each stroke starts inside it. + for (sx, wide) in [(41.0, 4.0), (41.5, 4.0), (41.0, 5.0)] { + let img = render(120, 60, blur, |x, y| { + Some(if (x - 25.0).hypot(y - 28.0) <= 18.0 { + INK + } else if (sx..sx + wide).contains(&x) && (22.0..34.0).contains(&y) { + gray + } else { + WHITE + }) + }); + let logo_colors = vec!["#040403".into(), format!("#{:02X}{:02X}{:02X}", gray[0], gray[1], gray[2]), "#FFFFFF".into()]; + let res = trace(&img, &TraceParams { logo_colors, ..logo_params() }); + let paths: Vec<_> = res.paths.iter().map(|t| (t.color, t.pixels)).collect(); + let what = format!("gray {gray:?}, blur {blur}, stroke at {sx} {wide} px wide"); + if blur == 0.0 { + for y in 24..32 { + let at = Point::new(sx + wide - 1.0, f64::from(y) + 0.5); + assert_eq!(top_color(&res, at), Some(gray), "{what}: the stroke at {at:?}; {paths:?}"); + } + } + // Points on the disc's edge more than 30 degrees from the stroke (which spans about 20). + for k in 6..=58 { + let a = f64::from(k) * std::f64::consts::TAU / 64.0; + let at = Point::new(25.0 + 18.0 * a.cos(), 28.0 + 18.0 * a.sin()); + assert_ne!(top_color(&res, at), Some(gray), "{what}: the disc's edge at {at:?}; {paths:?}"); + } + } + } + } +} + +/// Stripes on white (black, a dark gray with a black disc on it, a light gray), with the colors +/// named 52 levels off: each gray then lies on the line between two other names, and the dark +/// stripe's rows beside white keep the stripe's color above and below the disc. Sharp and soft edges, +/// with and without white named. +#[test] +fn a_gray_stripe_beside_white_keeps_its_color_beside_a_black_disc() { + const INK: [u8; 3] = [5, 5, 3]; + for blur in [0.0, 0.6] { + let img = render(300, 160, blur, |x, y| { + let inside = |x0: f64, y0: f64, x1: f64, y1: f64| (x0..x1).contains(&x) && (y0..y1).contains(&y); + Some(if (x - 150.0).hypot(y - 80.0) <= 12.0 || inside(20.0, 20.0, 280.0, 50.0) { + INK + } else if inside(20.0, 65.0, 280.0, 95.0) { + [100, 100, 100] + } else if inside(20.0, 110.0, 280.0, 140.0) { + [190, 190, 190] + } else { + WHITE + }) + }); + for white in [false, true] { + let mut logo_colors: Vec<String> = ["#393937", "#989898", "#8A8A8A"].iter().map(|s| (*s).to_string()).collect(); + if white { + logo_colors.push("#FFFFFF".into()); + } + let res = trace(&img, &TraceParams { logo_colors, ..logo_params() }); + let what = format!("blur {blur}, white named {white}"); + let paths: Vec<_> = res.paths.iter().map(|t| (t.color, t.pixels)).collect(); + let stripe = top_color(&res, Point::new(60.0, 80.0)); + assert_ne!(stripe, Some([0x39, 0x39, 0x37]), "{what}: the stripe; {paths:?}"); + for x in [140.0, 145.0, 150.0, 155.0, 160.0] { + for y in [65.5, 94.5] { + assert_eq!(top_color(&res, Point::new(x, y)), stripe, "{what}: ({x}, {y}); {paths:?}"); + } + } + if blur == 0.0 { + let inks = res.paths.iter().filter(|t| t.color == [0x39, 0x39, 0x37]).count(); + assert_eq!(inks, 2, "{what}: {inks} paths in the black's name; {paths:?}"); + } + } + } +} + +/// Gray strokes two and three pixels wide on white (whole pixels of the gray), 3 and 4 px from a +/// black disc, and a two-pixel stroke six pixels long, fewer pixels than a line needs to keep its +/// class, 2 to 4.5 px from the disc: the strokes' pixels are blends of black and white too, but nothing +/// darker than the gray lies beside them, and they stay gray. +#[test] +fn thin_gray_strokes_beside_black_stay_gray() { + const INK: [u8; 3] = [4, 4, 3]; + for gray in [[230u8, 230, 230], [200, 200, 200]] { + for wide in [2.0, 3.0] { + let img = render(120, 60, 0.0, |x, y| { + Some(if (x - 25.0).hypot(y - 28.0) <= 18.0 { + INK + } else if ((47.0..47.0 + wide).contains(&x) && (8.0..50.0).contains(&y)) + || ((8.0..110.0).contains(&x) && (49.0..49.0 + wide).contains(&y)) + || ((44.0..46.0).contains(&x) && (16.0..22.0).contains(&y)) + { + gray + } else { + WHITE + }) + }); + let logo_colors = vec!["#040403".into(), format!("#{:02X}{:02X}{:02X}", gray[0], gray[1], gray[2])]; + let res = trace(&img, &TraceParams { logo_colors, ..logo_params() }); + let what = format!("gray {gray:?}, {wide} px strokes"); + let short = (17..21).map(|y| Point::new(45.0, f64::from(y) + 0.5)); + let long = [Point::new(47.0 + wide / 2.0, 20.0), Point::new(47.0 + wide / 2.0, 30.0), Point::new(25.0, 49.0 + wide / 2.0)]; + for at in long.into_iter().chain(short) { + let paths: Vec<_> = res.paths.iter().map(|t| (t.color, t.pixels)).collect(); + assert_eq!(top_color(&res, at), Some(gray), "{what}: {at:?}; {paths:?}"); + } + } + } +} + +/// A sharp black disc and a mid-gray square on white, with up to 2 levels of noise added to each +/// pixel: the edge pixels as light as the gray, read as blends of black and white, still count as +/// unblended when judging whether the source is aliased, so the trace is softened as without them +/// and no gray lines the disc. +#[test] +fn a_noisy_hard_edged_gray_between_black_and_white_is_one_shape() { + const GRAY: [u8; 3] = [128, 128, 128]; + let mut img = render(120, 60, 0.0, |x, y| { + Some(if (x - 30.0).hypot(y - 30.0) <= 20.0 { + [0, 0, 0] + } else if (60.0..=110.0).contains(&x) && (10.0..=50.0).contains(&y) { + GRAY + } else { + WHITE + }) + }); + for (i, px) in img.rgba.chunks_mut(4).enumerate() { + let mut h = (i as u64 ^ 0x9E37_79B9_7F4A_7C15).wrapping_mul(0x2545_F491_4F6C_DD1D); + h ^= h >> 29; + let d = (h % 5) as i32 - 2; + for c in px.iter_mut().take(3) { + *c = (i32::from(*c) + d).clamp(0, 255) as u8; + } + } + for named in [false, true] { + let p = if named { + TraceParams { logo_colors: vec!["#000000".into(), "#808080".into(), "#FFFFFF".into()], ..logo_params() } + } else { + logo_params() + }; + let res = trace(&img, &p); + let paths: Vec<_> = res.paths.iter().map(|t| (t.color, t.pixels)).collect(); + let grays = res.paths.iter().filter(|t| t.color == GRAY).count(); + assert_eq!(grays, 1, "named {named}: {grays} gray paths; {paths:?}"); + assert_eq!(top_color(&res, Point::new(85.0, 30.0)), Some(GRAY), "named {named}: the square"); + for k in 0..16 { + let a = f64::from(k) * std::f64::consts::TAU / 16.0; + let at = Point::new(30.0 + 20.0 * a.cos(), 30.0 + 20.0 * a.sin()); + assert_ne!(top_color(&res, at), Some(GRAY), "named {named}: the disc's edge at {at:?}; {paths:?}"); + } + } +} diff --git a/crates/trace/src/logo/unmix.rs b/crates/trace/src/logo/unmix.rs index cdfdfe52fd..3268c9c20a 100644 --- a/crates/trace/src/logo/unmix.rs +++ b/crates/trace/src/logo/unmix.rs @@ -3,7 +3,10 @@ //! An edge pixel of an anti-aliased logo is a blend of the colours that meet there. Reading it as //! "the nearest colour" throws away exactly the sub-pixel information that says where the edge //! runs, so each pixel is instead explained as a mix of at most three classes, whichever mix -//! reproduces the pixel best. +//! reproduces the pixel best. When another mix also reproduces it (with a gray between black and +//! white among the classes, a black-to-white edge pixel is a mix of black and gray as well as of +//! black and white), the pixel takes the mix whose classes lie nearest it in the flat areas around it, +//! when its neighbors show an edge between those classes. use std::collections::{HashMap, HashSet}; @@ -13,6 +16,20 @@ pub(crate) type Px = [f32; 4]; const LAMBDA: f64 = 30.0; /// Pixels this close (in 0..1 premultiplied RGBA) to a class are taken as exactly that class. const PURE: f64 = 4.0 / 255.0; +/// A mix whose squared error is at most this reproduces the pixel: it comes within [`PURE`] of it, +/// as a pixel taken as exactly one class does. +const REPRODUCES: f64 = PURE * PURE; +/// How far (in pixels, each way) a class is looked for around a pixel that two mixes reproduce. +const NEARBY: usize = 6; +/// A pixel whose neighbors are all this close to it (in 0..1 premultiplied RGBA) lies in a flat area. +const FLAT: f64 = 1.5 / 255.0; +/// How many joined pixels within [`PURE`] of one class are taken as art of that class, such as a +/// one-pixel line. The edge pixels of a curve that come within `PURE` of a class join in far fewer. +/// A straight edge whose anti-aliased pixels come within `PURE` of +/// a class gives the same pixels as a line of that class, and keeps the class too. A one-pixel line +/// between two classes that is shorter, falls between pixels or is blurred is read as a blend of +/// those two classes. +const LINE: usize = 2 * NEARBY + 1; struct Subset { idx: [usize; 3], @@ -90,21 +107,33 @@ fn subsets(classes: &[[f64; 4]]) -> Vec<Subset> { out } -/// How many distinct pixel values are not (nearly) exactly one class: the ones `unmix` has to work -/// on. A flat area whose color is near but not exactly a class counts once, however large it is. -pub(crate) fn count_ambiguous(pix: &[Px], classes: &[[f64; 4]]) -> usize { +/// How many distinct pixel values `unmix` has to work on: the values not (nearly) exactly one class, +/// and the values that are, at pixels outside a flat area ([`in_flat_area`]). A flat area whose color +/// is near but not exactly a class counts once, however large it is. +pub(crate) fn count_ambiguous(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4]]) -> usize { let mut seen = HashSet::new(); - for px in pix { + for (i, px) in pix.iter().take(width.saturating_mul(height)).enumerate() { let p = [f64::from(px[0]), f64::from(px[1]), f64::from(px[2]), f64::from(px[3])]; - if !classes.iter().any(|cv| (0..4).map(|j| (p[j] - cv[j]).powi(2)).sum::<f64>().sqrt() < PURE) { - seen.insert(px.map(f32::to_bits)); + let key = px.map(f32::to_bits); + if seen.contains(&key) { + continue; + } + if !classes.iter().any(|cv| (0..4).map(|j| (p[j] - cv[j]).powi(2)).sum::<f64>().sqrt() < PURE) + || !in_flat_area(pix, width, height, i % width, i / width) + { + seen.insert(key); } } seen.len() } -/// Coverage planes, one `width × height` plane per class (each pixel's weights sum to 1). -pub(crate) fn unmix(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4]]) -> (Vec<Vec<f32>>, Vec<f32>) { +/// The pixels that took another mix than their best one, in pixel order, each with every class's +/// weight before it did. +pub(crate) type Switched = Vec<(usize, Vec<f32>)>; + +/// Coverage planes, one `width × height` plane per class (each pixel's weights sum to 1), the +/// squared error each pixel's best mix leaves, and the pixels that took another mix ([`Switched`]). +pub(crate) fn unmix(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4]]) -> (Vec<Vec<f32>>, Vec<f32>, Switched) { let k = classes.len(); let n = width.saturating_mul(height); let mut planes = vec![vec![0.0f32; n]; k]; @@ -113,46 +142,384 @@ pub(crate) fn unmix(pix: &[Px], width: usize, height: usize, classes: &[[f64; 4] let subs = subsets(classes); // Each distinct pixel value is mixed once: a flat area that is near but not exactly a class // repeats one value. - let mut mixed: HashMap<[u32; 4], Mix> = HashMap::new(); + let mut mixed: HashMap<[u32; 4], Mixes> = HashMap::new(); + // The class each pixel stands for (the class nearest it, when every other class is at least + // twice as far). + let mut stands_for: Vec<Option<usize>> = vec![None; n]; + // The class each pixel comes within `PURE` of, where it does. + let mut pure: Vec<Option<usize>> = vec![None; n]; + // The pixels outside a flat area that another mix also reproduces, with their values. + let mut tied: Vec<(usize, [u32; 4])> = Vec::new(); for (i, px) in pix.iter().take(n).enumerate() { let p = [f64::from(px[0]), f64::from(px[1]), f64::from(px[2]), f64::from(px[3])]; // Fast path: a pixel that is (nearly) exactly one class. let mut near = (f64::MAX, 0usize); + let mut second = f64::MAX; for (c, cv) in classes.iter().enumerate() { let d: f64 = (0..4).map(|j| (p[j] - cv[j]).powi(2)).sum(); if d < near.0 { + second = near.0; near = (d, c); + } else if d < second { + second = d; } } + if let Some(q) = stands_for.get_mut(i) { + // (Squared distances: twice as far is four times the square.) + *q = (4.0 * near.0 <= second).then_some(near.1); + } + let key = px.map(f32::to_bits); if near.0.sqrt() < PURE { if let Some(v) = planes.get_mut(near.1).and_then(|pl| pl.get_mut(i)) { *v = 1.0; } + if let Some(q) = pure.get_mut(i) { + *q = Some(near.1); + } + // (An edge pixel can come within `PURE` of a class it holds none of: a black-to-white + // edge pixel as light as a gray class.) + if !in_flat_area(pix, width, height, i % width, i / width) + && !mixed.entry(key).or_insert_with(|| best_mixes(p, near, &subs)).tied.is_empty() + { + tied.push((i, key)); + } continue; } - let (res, weights) = mixed.entry(px.map(f32::to_bits)).or_insert_with(|| best_mix(p, near, &subs)); + let mixes = mixed.entry(key).or_insert_with(|| best_mixes(p, near, &subs)); if let Some(r) = residual.get_mut(i) { - *r = *res; + *r = mixes.residual; } - for &(c, wv) in weights.iter() { - if let Some(v) = planes.get_mut(c).and_then(|pl| pl.get_mut(i)) { - *v = wv; + set_weights(&mut planes, i, &mixes.best, 1.0); + // (A pixel in a flat area has no neighbor far enough from it for `across_edge`.) + if !mixes.tied.is_empty() && !in_flat_area(pix, width, height, i % width, i / width) { + tied.push((i, key)); + } + } + let mut switched = Vec::new(); + if tied.is_empty() { + return (planes, residual, switched); + } + // A pixel two mixes reproduce takes another mix of two classes whose farthest class lies nearer + // it than the best mix's does, in the flat areas around it ([`flat_classes`], [`RowDistances::around`]), + // when the pixel lies on an edge between that mix's classes ([`across_edge`]). For the best mix, + // the classes held by flat areas between two classes count as well ([`between_classes`]). A + // pixel within `PURE` of a class that is joined to at least [`LINE`] such pixels of that class + // (itself included) keeps it ([`pure_runs`]), as a one-pixel line of gray between black and white. + let flat = flat_classes(pix, &stands_for, width, height); + let between = between_classes(pix, &flat, &mixed, width, height); + let runs = pure_runs(&pure, width, height); + let mut flat_rows = RowDistances::new(|j| [flat.get(j).copied().flatten(), None], width, height, k); + let mut between_rows = (!between.is_empty()).then(|| RowDistances::new(|j| between.get(j).copied().unwrap_or([None; 2]), width, height, k)); + let mut dist = vec![NEARBY + 1; k]; + let mut kept = vec![NEARBY + 1; k]; + for (i, key) in tied { + if pure.get(i).copied().flatten().is_some() && runs.get(i).is_some_and(|&r| r >= LINE) { + continue; + } + let Some(mixes) = mixed.get(&key) else { continue }; + let edges: Vec<&Weights> = mixes.tied.iter().filter(|m| across_edge(pix, width, height, i, classes, &mixes.best, m)).collect(); + if edges.is_empty() { + continue; + } + flat_rows.around(i, &mut dist); + kept.copy_from_slice(&dist); + if let Some(rows) = &mut between_rows { + rows.around(i, &mut kept); + for (h, &d) in kept.iter_mut().zip(&dist) { + *h = (*h).min(d); + } + } + let now = farthest(&mixes.best, &kept); + let other = edges.into_iter().filter(|m| farthest(m, &dist) < now).min_by_key(|m| farthest(m, &dist)); + if let Some(other) = other { + switched.push((i, planes.iter().map(|pl| pl.get(i).copied().unwrap_or(0.0)).collect())); + // (`residual` keeps the best mix's error; the mix taken comes within `REPRODUCES` of the + // pixel as well.) + set_weights(&mut planes, i, &mixes.best, 0.0); + set_weights(&mut planes, i, other, 1.0); + } + } + (planes, residual, switched) +} + +/// Whether pixel `i` lies on an edge between the two classes of `other`, rather than in an area of +/// a class of `best` that `other` leaves out: for each such class, the pixel has a neighbor beyond +/// it toward each class of `other`, along the line between them. (A black-to-white edge pixel as +/// light as a gray has a darker neighbor and a lighter one; a gray stroke on white has no neighbor +/// darker than the gray.) +fn across_edge(pix: &[Px], width: usize, height: usize, i: usize, classes: &[[f64; 4]], best: &Weights, other: &Weights) -> bool { + let [(a, _), (b, _)] = other.as_slice() else { return false }; + let (Some(ca), Some(cb)) = (classes.get(*a), classes.get(*b)) else { return false }; + let ab: [f64; 4] = std::array::from_fn(|j| cb[j] - ca[j]); + let len2: f64 = ab.iter().map(|v| v * v).sum(); + if len2 <= 1e-12 { + return false; + } + let len = len2.sqrt(); + // Where `v` lies along the line from `a` to `b` (0 at `a`, 1 at `b`), and how far off it. + let place = |v: [f64; 4]| { + let t = (0..4).map(|j| (v[j] - ca[j]) * ab[j]).sum::<f64>() / len2; + let off = (0..4).map(|j| (v[j] - ca[j] - t * ab[j]).powi(2)).sum::<f64>().sqrt(); + (t, off) + }; + let (x, y) = (i % width.max(1), i / width.max(1)); + let neighbors: Vec<f64> = (y.saturating_sub(1)..(y + 2).min(height)) + .flat_map(|yy| (x.saturating_sub(1)..(x + 2).min(width)).map(move |xx| yy * width + xx)) + .filter(|&j| j != i) + .filter_map(|j| pix.get(j)) + .map(|q| place([f64::from(q[0]), f64::from(q[1]), f64::from(q[2]), f64::from(q[3])])) + .filter(|&(_, off)| off <= 2.0 * PURE) + .map(|(t, _)| t) + .collect(); + let left_out: Vec<usize> = best.iter().filter(|&&(c, w)| w > 0.0 && c != *a && c != *b).map(|&(c, _)| c).collect(); + !left_out.is_empty() + && left_out.iter().all(|&c| { + let Some(&cv) = classes.get(c) else { return false }; + let (tc, _) = place(cv); + neighbors.iter().any(|&t| (tc - t) * len > PURE) && neighbors.iter().any(|&t| (t - tc) * len > PURE) + }) +} + +/// How far the farthest class of `mix` lies, by the distances `dist` ([`RowDistances::around`]). +fn farthest(mix: &Weights, dist: &[usize]) -> usize { + mix.iter().filter(|&&(_, w)| w > 0.0).map(|&(c, _)| dist.get(c).copied().unwrap_or(NEARBY + 1)).max().unwrap_or(0) +} + +/// Sets pixel `i` of each class's plane in `weights` to the class's weight times `scale`. +fn set_weights(planes: &mut [Vec<f32>], i: usize, weights: &[(usize, f32)], scale: f32) { + for &(c, wv) in weights { + if let Some(v) = planes.get_mut(c).and_then(|pl| pl.get_mut(i)) { + *v = wv * scale; + } + } +} + +/// A class's weight in the mix of a flat area that stands for no class, from which the area +/// counts as holding that class. +const HOLDS: f32 = 0.25; + +/// The class each pixel stands for (`stands_for`) where the pixel lies in a flat area +/// ([`in_flat_area`]), and `None` elsewhere. +fn flat_classes(pix: &[Px], stands_for: &[Option<usize>], width: usize, height: usize) -> Vec<Option<usize>> { + (0..width.saturating_mul(height)) + .map(|i| stands_for.get(i).copied().flatten().filter(|_| in_flat_area(pix, width, height, i % width, i / width))) + .collect() +} + +/// The classes held by flat areas that stand for no class (a flat color between two classes, as +/// with colors named some levels off): the classes of at least [`HOLDS`] weight in the area's mix +/// (at most two, the heaviest), held also by the pixels of exactly its color joined to it, flat or +/// not (its rows beside another color, where a soft edge or a shape close by leaves no flat pixel). +/// Empty when there is no such area. +fn between_classes(pix: &[Px], flat: &[Option<usize>], mixed: &HashMap<[u32; 4], Mixes>, width: usize, height: usize) -> Vec<[Option<usize>; 2]> { + let mut held = Vec::new(); + // Pixels holding classes, from which the pixels of their color are reached. + let mut reach: Vec<usize> = Vec::new(); + for (i, f) in flat.iter().enumerate() { + if f.is_some() || !in_flat_area(pix, width, height, i % width, i / width) { + continue; + } + let Some(mixes) = pix.get(i).and_then(|px| mixed.get(&px.map(f32::to_bits))) else { continue }; + let mut heavy: Vec<(usize, f32)> = mixes.best.iter().copied().filter(|&(_, w)| w >= HOLDS).collect(); + heavy.sort_by(|a, b| b.1.total_cmp(&a.1)); + if heavy.is_empty() { + continue; + } + if held.is_empty() { + held = vec![[None; 2]; width.saturating_mul(height)]; + } + if let Some(slot) = held.get_mut(i) { + *slot = [heavy.first().map(|&(c, _)| c), heavy.get(1).map(|&(c, _)| c)]; + reach.push(i); + } + } + while let Some(i) = reach.pop() { + let (Some(&classes), Some(key)) = (held.get(i), pix.get(i).map(|px| px.map(f32::to_bits))) else { continue }; + let (x, y) = (i % width, i / width); + for yy in y.saturating_sub(1)..(y + 2).min(height) { + for xx in x.saturating_sub(1)..(x + 2).min(width) { + let j = yy * width + xx; + if let (Some(slot @ [None, None]), Some(q)) = (held.get_mut(j), pix.get(j)) + && q.map(f32::to_bits) == key + { + *slot = classes; + reach.push(j); + } } } } - (planes, residual) + held } -/// A pixel's mix: the squared error it leaves and each class's weight. -type Mix = (f32, Vec<(usize, f32)>); +/// For each of `k` classes, how far along each row the nearest pixel holding that class (`at`, the +/// classes pixel `j` holds) lies from each pixel, up to `NEARBY + 1` when none lies within +/// [`NEARBY`]. A row is worked out when it is first asked for, so a few pixels cost a few rows. +struct RowDistances<F> { + at: F, + width: usize, + k: usize, + /// Per row, once worked out: the distance for pixel `x` and class `c` at `x * k + c`. + rows: Vec<Option<Vec<u8>>>, +} + +impl<F: Fn(usize) -> [Option<usize>; 2]> RowDistances<F> { + const NONE: u8 = (NEARBY + 1) as u8; + + fn new(at: F, width: usize, height: usize, k: usize) -> Self { + Self { at, width, k, rows: vec![None; height] } + } + + fn row(&mut self, y: usize) -> &[u8] { + if self.rows.get(y).is_some_and(Option::is_none) { + let built = self.build(y); + if let Some(slot) = self.rows.get_mut(y) { + *slot = Some(built); + } + } + self.rows.get(y).and_then(Option::as_deref).unwrap_or(&[]) + } + + fn build(&self, y: usize) -> Vec<u8> { + let (width, k) = (self.width, self.k); + let mut row = vec![Self::NONE; width.saturating_mul(k)]; + // Toward the right, then toward the left, each from the last pixel holding the class. + let mut last = vec![Self::NONE; k]; + for x in 0..width { + let held = (self.at)(y * width + x); + for (c, d) in last.iter_mut().enumerate() { + *d = if held.contains(&Some(c)) { 0 } else { d.saturating_add(1).min(Self::NONE) }; + if let Some(r) = row.get_mut(x * k + c) { + *r = *d; + } + } + } + last.fill(Self::NONE); + for x in (0..width).rev() { + for (c, d) in last.iter_mut().enumerate() { + let Some(r) = row.get_mut(x * k + c) else { continue }; + *d = if *r == 0 { 0 } else { d.saturating_add(1).min(Self::NONE) }; + *r = (*r).min(*d); + } + } + row + } + + /// For each class, how far (in pixels, the larger of the two axes) the nearest pixel holding + /// that class lies from pixel `i`, into `dist` (one entry per class); `NEARBY + 1` when none + /// lies within [`NEARBY`]. + fn around(&mut self, i: usize, dist: &mut [usize]) { + let (width, k, height) = (self.width.max(1), self.k, self.rows.len()); + let (x, y) = (i % width, i / width); + dist.fill(NEARBY + 1); + for yy in y.saturating_sub(NEARBY)..(y + NEARBY + 1).min(height) { + let dy = yy.abs_diff(y); + let row = self.row(yy); + for (c, d) in dist.iter_mut().enumerate().take(k) { + if let Some(&r) = row.get(x * k + c) { + *d = (*d).min(usize::from(r).max(dy)); + } + } + } + } +} + +/// For each pixel within [`PURE`] of a class (`pure`), how many pixels within `PURE` of the same +/// class are joined to it (itself included, through the eight neighbors); 0 for other pixels. +fn pure_runs(pure: &[Option<usize>], width: usize, height: usize) -> Vec<usize> { + let n = width.saturating_mul(height); + let mut size = vec![0usize; n]; + let mut seen = vec![false; n]; + let mut stack = Vec::new(); + let mut members = Vec::new(); + for start in 0..n { + let Some(c) = pure.get(start).copied().flatten() else { continue }; + if seen.get(start).copied().unwrap_or(true) { + continue; + } + if let Some(s) = seen.get_mut(start) { + *s = true; + } + stack.push(start); + members.clear(); + while let Some(i) = stack.pop() { + members.push(i); + let (x, y) = (i % width, i / width); + for yy in y.saturating_sub(1)..(y + 2).min(height) { + for xx in x.saturating_sub(1)..(x + 2).min(width) { + let j = yy * width + xx; + if pure.get(j).copied().flatten() == Some(c) + && let Some(s) = seen.get_mut(j) + && !*s + { + *s = true; + stack.push(j); + } + } + } + } + for &i in &members { + if let Some(s) = size.get_mut(i) { + *s = members.len(); + } + } + } + size +} + +/// Whether every neighbor of the pixel at (`x`, `y`) inside the image lies within [`FLAT`] of it. +fn in_flat_area(pix: &[Px], width: usize, height: usize, x: usize, y: usize) -> bool { + let Some(p) = pix.get(y * width + x) else { return false }; + (y.saturating_sub(1)..(y + 2).min(height)).all(|yy| { + (x.saturating_sub(1)..(x + 2).min(width)).all(|xx| { + pix.get(yy * width + xx).is_some_and(|q| (0..4).map(|j| (f64::from(p[j]) - f64::from(q[j])).powi(2)).sum::<f64>().sqrt() <= FLAT) + }) + }) +} + +/// Each class's weight in a pixel's mix. +type Weights = Vec<(usize, f32)>; + +/// A mix tried for a pixel: its squared error with its penalty, the penalty, and its classes with +/// their weights (the first `n`). +#[derive(Clone, Copy)] +struct Candidate { + res: f64, + penalty: f64, + idx: [usize; 3], + w: [f64; 3], + n: usize, +} + +impl Candidate { + fn weights(&self) -> Weights { + self.idx.iter().zip(self.w).take(self.n).map(|(&c, w)| (c, w as f32)).collect() + } +} + +/// How a pixel value is mixed: the squared error the best mix leaves, each class's weight in it, +/// and the other mixes of two classes that reproduce the value ([`REPRODUCES`]). +struct Mixes { + residual: f32, + best: Weights, + tied: Vec<Weights>, +} /// The mix of at most three classes that reproduces `p` best, starting from the nearest single -/// class `near` (squared distance, class). -fn best_mix(p: [f64; 4], near: (f64, usize), subs: &[Subset]) -> Mix { +/// class `near` (squared distance, class), and the other mixes that also reproduce it. +fn best_mixes(p: [f64; 4], near: (f64, usize), subs: &[Subset]) -> Mixes { + let reproduces = |m: &Candidate| m.res - m.penalty <= REPRODUCES; // Best single class is the starting point; try every two- and three-class mix. - let mut best = (near.0, vec![(near.1, 1.0f64)]); - let mut best_penalty = 0.0; - for s in subs { + let mut top = Candidate { res: near.0, penalty: 0.0, idx: [near.1, 0, 0], w: [1.0, 0.0, 0.0], n: 1 }; + // The other mixes of two classes that reproduce the pixel, also when the best mix does not (a + // single class carries no penalty and can come nearer than an exact mix of two): only a mix of + // two is switched to ([`across_edge`]). A mix holding the nearest class when that class alone + // reproduces the pixel adds a class of next to no weight to it, and is left out. (At most one + // candidate per pair of classes, so the list stays small with many classes.) Each is kept with + // its subset's index, and the best mix found is left out of them at the end. + let single = reproduces(&top).then_some(near.1); + let mut top_at = None; + let mut pairs: Vec<(usize, Candidate)> = Vec::new(); + for (at, s) in subs.iter().enumerate() { let mut rhs = [0.0f64; 3]; for (j, r) in rhs.iter_mut().enumerate().take(s.n) { *r = (0..4).map(|c| s.cols[j][c] * p[c]).sum::<f64>() + LAMBDA * LAMBDA; @@ -180,12 +547,17 @@ fn best_mix(p: [f64; 4], near: (f64, usize), subs: &[Subset]) -> Mix { let m: f64 = (0..s.n).map(|j| w[j] * s.cols[j][c]).sum(); res += (pc - m).powi(2); } - if res < best.0 { - best = (res, (0..s.n).map(|j| (s.idx[j], w[j])).collect()); - best_penalty = s.penalty; + let m = Candidate { res, penalty: s.penalty, idx: s.idx, w, n: s.n }; + if m.n == 2 && reproduces(&m) && single.is_none_or(|c| m.idx[0] != c && m.idx[1] != c) { + pairs.push((at, m)); + } + if res < top.res { + top = m; + top_at = Some(at); } } - ((best.0 - best_penalty).max(0.0) as f32, best.1.into_iter().map(|(c, w)| (c, w as f32)).collect()) + let tied = pairs.iter().filter(|&&(at, _)| Some(at) != top_at).map(|(_, m)| m.weights()).collect(); + Mixes { residual: (top.res - top.penalty).max(0.0) as f32, best: top.weights(), tied } } #[cfg(test)] @@ -199,7 +571,7 @@ mod tests { #[test] fn pure_pixels_are_exact() { let pix = vec![[1.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0]]; - let (pl, _) = unmix(&pix, 2, 1, &classes()); + let (pl, _, _) = unmix(&pix, 2, 1, &classes()); assert_eq!((pl[0][0], pl[2][1]), (1.0, 1.0)); } @@ -207,7 +579,7 @@ mod tests { fn a_blend_of_two_colours_recovers_its_proportions() { // 30% red over 70% blue. let pix = vec![[0.3, 0.0, 0.7, 1.0]]; - let (pl, _) = unmix(&pix, 1, 1, &classes()); + let (pl, _, _) = unmix(&pix, 1, 1, &classes()); assert!((pl[0][0] - 0.3).abs() < 0.02, "red {}", pl[0][0]); assert!((pl[1][0] - 0.7).abs() < 0.02, "blue {}", pl[1][0]); } @@ -216,7 +588,7 @@ mod tests { fn a_half_transparent_edge_is_half_covered() { // Red at 40% coverage over nothing: premultiplied (0.4, 0, 0, 0.4). let pix = vec![[0.4, 0.0, 0.0, 0.4]]; - let (pl, _) = unmix(&pix, 1, 1, &classes()); + let (pl, _, _) = unmix(&pix, 1, 1, &classes()); assert!((pl[0][0] - 0.4).abs() < 0.02 && (pl[2][0] - 0.6).abs() < 0.02, "{:?}", (pl[0][0], pl[2][0])); } @@ -224,7 +596,7 @@ mod tests { fn a_colour_no_class_can_explain_leaves_a_large_residual() { // Green is none of red, blue or transparent, nor any blend of them. let pix = vec![[0.0, 0.8, 0.0, 1.0], [0.3, 0.0, 0.7, 1.0]]; - let (_, res) = unmix(&pix, 2, 1, &classes()); + let (_, res, _) = unmix(&pix, 2, 1, &classes()); assert!(res[0] > 0.1, "unexplained pixel residual {}", res[0]); assert!(res[1] < 1e-3, "an explained blend residual {}", res[1]); } @@ -235,8 +607,12 @@ mod tests { let off = [0.97, 0.02, 0.02, 1.0]; let mut pix = vec![off; 1000]; pix.extend([[0.3, 0.0, 0.7, 1.0], [1.0, 0.0, 0.0, 1.0], [0.0, 0.0, 0.0, 0.0]]); - assert_eq!(count_ambiguous(&pix, &classes()), 2); - let (pl, res) = unmix(&pix, pix.len(), 1, &classes()); + // (The pure red and transparent pixels lie outside a flat area, so they count too: `unmix` + // checks whether another mix reproduces them.) + assert_eq!(count_ambiguous(&pix, pix.len(), 1, &classes()), 4); + // Pure pixels in a flat area do not count. + assert_eq!(count_ambiguous(&[[1.0, 0.0, 0.0, 1.0]; 9], 3, 3, &classes()), 0); + let (pl, res, _) = unmix(&pix, pix.len(), 1, &classes()); assert!(pl[0][0] > 0.95, "red {}", pl[0][0]); for i in 1..1000 { assert_eq!((pl[0][i], pl[1][i], pl[2][i], res[i]), (pl[0][0], pl[1][0], pl[2][0], res[0]), "pixel {i}"); @@ -244,10 +620,89 @@ mod tests { assert!((pl[0][1000] - 0.3).abs() < 0.02 && (pl[1][1000] - 0.7).abs() < 0.02); } + #[test] + fn an_edge_pixel_two_mixes_reproduce_takes_the_classes_beside_it() { + // A light gray lies on the line from black to white. A row of flat black, one edge pixel, + // flat white: the edge pixel is a blend of black and white, with no gray in it, also when + // it comes within `PURE` of the gray (0.905), and when the gray alone, which carries no + // penalty, comes nearer it than any mix of two does without reproducing it (0.91). + let classes = vec![[0.9, 0.9, 0.9, 1.0], [0.0, 0.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 0.0]]; + let row = |left: [f32; 4], v: f32| { + let mut pix = vec![left; 5]; + pix.push([v, v, v, 1.0]); + pix.extend([[1.0f32, 1.0, 1.0, 1.0]; 5]); + pix + }; + for v in [0.1f32, 0.3, 0.7, 0.85, 0.905, 0.91, 0.95, 0.98] { + let (pl, _, _) = unmix(&row([0.0, 0.0, 0.0, 1.0], v), 11, 1, &classes); + assert_eq!(pl[0][5], 0.0, "gray in a {v} edge pixel"); + assert!((pl[2][5] - v).abs() < 0.02 && (pl[1][5] - (1.0 - v)).abs() < 0.02, "{v}: black {} white {}", pl[1][5], pl[2][5]); + } + // Beside flat gray, a gray-to-white edge pixel keeps its gray. + let (pl, _, _) = unmix(&row([0.9, 0.9, 0.9, 1.0], 0.95), 11, 1, &classes); + assert!((pl[0][5] - 0.5).abs() < 0.02 && pl[1][5] == 0.0, "gray {} black {}", pl[0][5], pl[1][5]); + // A gray pixel between white ones, flat black four pixels off: a gray stroke, kept. + let mut pix = vec![[0.0f32, 0.0, 0.0, 1.0]; 4]; + pix.extend([[1.0f32, 1.0, 1.0, 1.0]; 2]); + pix.push([0.9, 0.9, 0.9, 1.0]); + pix.extend([[1.0f32, 1.0, 1.0, 1.0]; 5]); + let (pl, _, _) = unmix(&pix, 12, 1, &classes); + assert_eq!((pl[0][6], pl[1][6]), (1.0, 0.0), "the stroke"); + } + + #[test] + fn a_column_of_pixels_as_light_as_a_class_keeps_it() { + // Flat black, one column at the gray's value, flat white. In `LINE` rows or more the column + // is gray art (a one-pixel line, or a straight edge giving the same pixels); in fewer rows it + // is an edge between black and white. + let classes = vec![[0.9, 0.9, 0.9, 1.0], [0.0, 0.0, 0.0, 1.0], [1.0, 1.0, 1.0, 1.0], [0.0, 0.0, 0.0, 0.0]]; + for (rows, gray) in [(LINE, 1.0), (LINE + 10, 1.0), (LINE - 1, 0.0), (3, 0.0)] { + let mut pix = Vec::new(); + for _ in 0..rows { + pix.extend([[0.0f32, 0.0, 0.0, 1.0]; 5]); + pix.push([0.9, 0.9, 0.9, 1.0]); + pix.extend([[1.0f32, 1.0, 1.0, 1.0]; 5]); + } + let (pl, _, _) = unmix(&pix, 11, rows, &classes); + for y in 0..rows { + assert_eq!(pl[0][y * 11 + 5], gray, "{rows} rows: gray in row {y}"); + } + } + } + + #[test] + fn row_distances_match_a_scan_of_the_window_around_each_pixel() { + // Three classes scattered over 23 x 17 pixels, some pixels holding two, most none. + let (w, h, k) = (23usize, 17usize, 3usize); + let at = |j: usize| -> [Option<usize>; 2] { + match (j * 7919) % 97 { + 0..=2 => [Some(0), None], + 3 => [Some(1), Some(2)], + 4 | 5 => [None, Some(2)], + _ => [None; 2], + } + }; + let mut rows = RowDistances::new(at, w, h, k); + let mut dist = vec![0; k]; + for i in 0..w * h { + let (x, y) = (i % w, i / w); + let mut want = vec![NEARBY + 1; k]; + for yy in y.saturating_sub(NEARBY)..(y + NEARBY + 1).min(h) { + for xx in x.saturating_sub(NEARBY)..(x + NEARBY + 1).min(w) { + for c in at(yy * w + xx).into_iter().flatten() { + want[c] = want[c].min(xx.abs_diff(x).max(yy.abs_diff(y))); + } + } + } + rows.around(i, &mut dist); + assert_eq!(dist, want, "pixel ({x}, {y})"); + } + } + #[test] fn weights_sum_to_one() { let pix = vec![[0.2, 0.1, 0.5, 0.8], [0.9, 0.0, 0.05, 0.95]]; - let (pl, _) = unmix(&pix, 2, 1, &classes()); + let (pl, _, _) = unmix(&pix, 2, 1, &classes()); for i in 0..2 { let s: f32 = pl.iter().map(|p| p[i]).sum(); assert!((s - 1.0).abs() < 1e-4, "pixel {i} sums to {s}"); diff --git a/docs/image-trace-adjustments.md b/docs/image-trace-adjustments.md index 11de4fbda6..c4e0202762 100644 --- a/docs/image-trace-adjustments.md +++ b/docs/image-trace-adjustments.md @@ -97,6 +97,24 @@ The trace then uses only the named colors, and white while white is a color of i color that was not named is traced too: each of its pixels goes to the named color, white or transparent that has the largest share in the blend of them that comes closest to the pixel. +**Flat Logo with a color between two others.** When a traced color lies between two others, as a gray +lies between black and white, an anti-aliased edge pixel between the outer two is also a blend of the +middle color and one of them. Flat Logo then reads the pixel as the blend of the colors that lie nearest +it in the flat areas within 6 pixels, when the pixel has a neighbor darker and a neighbor lighter than the +middle color, along the line between the other two. A black disc beside a gray square on white traces +with one gray shape, the square, and no gray slivers around the disc, when its edges are sharp or blurred +by up to about half a pixel. An edge blurred by a pixel or more can still leave gray slivers along the +disc, and so can an image with noise of a level or more in its pixels. A gray stroke two or three pixels +wide beside black has no darker pixel next to it and stays gray. A soft-edged gray stroke about two +pixels wide that touches black traces as black and white, and one about three pixels wide that touches +black can lose most or all of its gray when it is short (12 pixels long or less). A line of gray one +pixel wide between black and white stays gray when at least 13 of its pixels touch: such a line and a +straight black-to-white edge whose pixels are as light as the gray give the same pixels, and both +trace as gray. A one-pixel gray line between black and white that is shorter than 13 pixels, falls +between pixels or is blurred traces as black and white. A flat area whose color lies between two named colors, as when the colors are named +some levels off, counts as holding the named colors it is a blend of, and so do the pixels of exactly +its color that touch it. + **Large images.** An image of more than 1500 pixels on a side is traced as any other, only more slowly, and the trace says so: `imageTrace.make` returns the note in `warnings` and the status bar shows it (the [results optimization](https://helpx.adobe.com/illustrator/using/image-trace-results-optimization.html) @@ -106,8 +124,9 @@ most 1024 pixels on a side: a larger decoded raster is averaged down in whole-nu image is traced at 513, and a 16,000 × 12,000 image, decoded at 9,459 × 7,094, is traced at 946 × 710), and the trace names both sizes in `warnings`. Flat Logo gives that note in place of the slower-trace note for an image over 1500 pixels and in place of the 64-megapixel note. An image at most 1024 pixels on a side is traced at its own size, also when the named `logoColors` differ slightly from the -image's colors. Only an image with more than 150,000 different pixel values that are not exactly one traced -color is averaged down further: the factor doubles until at most 150,000 remain or the working copy has at +image's colors. Only an image with more than 150,000 different pixel values to unmix (values that are +not exactly one traced color, and values that are, at pixels outside a flat area) is averaged down +further: the factor doubles until at most 150,000 remain or the working copy has at most 16,384 pixels (at most six times). A trace that would make more than 8,000,000 anchor points (2,000,000 on the web) is refused to protect memory, with advice: raise Noise, lower Paths or Colors, or pick a lower-fidelity preset. A trace keeps diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 30b1e883d7..c016eb9333 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1320,6 +1320,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Image Trace Flat Logo mode:** a fourth mode beside Black and White, Grayscale and Color, for flat-colour logos. Each pixel is read as a blend of the logo's colours (found automatically or named), the blend is interpolated smoothly and every outline is placed where two colours are equally present, so edges are accurate to a fraction of a pixel. Outlines are then cleaned: corners the blur rounded are put back, near-straight runs and near-circular arcs become exact lines and arcs, the rest is fitted with as few Béziers as the tolerance allows, touching colours overlap by a hair so no gap opens, and an outline that strays from the raw contour is fitted plainly instead. Gradients and photos are refused with advice to use Color. Line art whose only solid area is white paper (strokes a pixel or two wide) takes its colours from the strokes' cores, with the lighter shades along a stroke's anti-aliased edge folded into its ink; a page whose ink (a channel at least 48 below white) covers under 1% of it traces to nothing, as blank paper does. *Measured* (a local experiment, not run in CI): a flat-colour logo's vector original was rendered down to a soft 199 × 100 px transparent PNG, traced, and the result compared with the original at 1600 px wide. The built-in colour presets (6 Colors, 16 Colors, High Fidelity Photo, Low Fidelity Photo) had a mean edge error of 2.5 to 3.4 px and region overlap of 0.88 to 0.91; Flat Logo had 0.78 px and 0.966 (0.48 px and 0.975 from a crisp source), in about 0.1 s. Limits: flat-colour art only; needle-thin sharp tips are shortened by about 1.7 source pixels because the blur erases them; it works at no more than 1024 px on the long side (larger images are averaged down first); only one logo family has been scored against a vector original. - **Image Trace, Flat Logo named colors only:** with `logoColors` named, `"logoWhite": false` traces those colors only, so white areas take the nearest of them and no white is added; a named white is kept, and enclosed transparent areas stay holes; code-drawn tests in `crates/trace` and `crates/engine`. - **Image Trace, Flat Logo flat-art check with named colors:** with `logoColors` named, whether the image is flat art is judged by its own colors, as many as are named, with white, or as the Colors setting gives, whichever is more. Named colors 20 levels off a flat badge's colors still trace it, a hatch on a light ground gives the same result with close and far named colors, a gradient's refusal score does not depend on how far the named colors are from it, and areas of colors that were not named are traced in the named colors instead of being refused; code-drawn tests in `crates/trace`. +- **Image Trace, Flat Logo with a color between two others:** an anti-aliased edge pixel between black and white is read as a blend of black and white, not of black and a gray that lies between them, when the flat areas around it and the pixels beside it show that edge, so a black disc beside a gray square on white, with sharp edges or edges blurred by up to about half a pixel, traces with one gray path, the square, instead of the square plus 8 to 24 gray slivers around the disc with the colors found or named exactly (an edge blurred by a pixel or more, or pixel noise of a level or more, can still leave gray slivers); gray strokes two and three pixels wide beside black stay gray (a soft-edged gray stroke about two pixels wide that touches black traces as black and white, and a short one about three pixels wide can lose most or all of its gray), and a one-pixel gray line of at least 13 touching pixels between black and white stays gray (a shorter one, or one that falls between pixels or is blurred, traces as black and white); code-drawn tests in `crates/trace`. - **Image Trace, Keep Colors:** `"keepColors": ["#rrggbb", …]` traces only the palette colors near a listed color (Abutting: each with the paths the trace of every color gives it; Overlapping: not reaching under the colors left out), in Black and White, Grayscale and Color; code-drawn tests in `crates/trace` and `crates/engine`. - **Advanced art:** live Blends (steps/distance/smooth colour, editable spine, anchor-targeted Blend tool, faithful interpolation, knockout), Envelope Distort (warp/mesh/top object, Reset, full Envelope Options, mesh handles, Edit Contents; type, images, symbols, gradients, patterns and appearance distorted everywhere), Liquify tools with options and pen pressure, Puppet Warp with rotating pins, Perspective Grid with presets, movable planes and projected type (choosing a perspective tool shows the grid; Hide Grid hides it with the tool still chosen), Gradient Mesh, Shape Builder (stroke-only open paths and lines cut the regions they cross and enclose regions of their own, and regions they bound merge without seams where the lines cross at rounded coordinates (#893); filled open paths count as closed; erase mode while Alt/Option is held: a minus pointer, red highlights of what will go, a click or drag deletes the regions touched, the pieces of open lines and the edges (outline pieces between the points where paths meet, opening their paths there) it passes over, one undo step, `shapeBuilder.merge {erase}` and `shapeBuilder.regions` edges over MCP), Live Paint (every path an edge, open lines included), Image Trace (12 presets, colour layers traced in parallel; a trace past two million anchor points is refused with advice rather than running out of memory, an image over 64 megapixels is traced scaled down to that size (aspect kept, paths at the image's own size) and one over 192 megapixels is refused, and a selection too large to outline shows its bounds (#525); Object › Image Trace › Make and Make and Expand trace at once with the Default preset, #543; with an image selected the Control bar and the Properties panel show Image Trace, whose arrow traces with any preset, Mask (`object.maskImage`: a clipping path on the image's outline, selected so its handles crop), Crop Image (a crop box on the image, starting on its part over the artboard, dragged by its handles or inside it, the outside dimmed, with X/Y/W/H, Apply and Cancel in the Control bar, Enter and Escape, #734; an image that isn't turned or skewed, isn't CMYK and can be read at its recorded size is cut from its own pixels when the crop edges fall on its pixel grid, copied as they are without resampling; any other image is drawn, #5534; `object.cropImage {rect}` for agents, `{trim: true}` cuts an image to its pixels that aren't fully transparent, pixel for pixel) and Embed or Unembed in place of Fill and Stroke; with an Image Trace object selected, its Preset (choosing another traces again), View, the Image Trace panel and Expand, plus Release in Properties; the five View modes (Tracing Result, with Outlines, Outlines, Outlines with Source Image, Source Image) redraw a trace on screen without tracing again, are saved with it and `imageTrace.setView` sets them, while exports and Expand keep the result; the panel's Advanced section is a header that stays open or closed as it was left (part of #641); Color mode's Palette: Limited, Full Tone (as many colours as the tones need, Less … More), Automatic (flat art with its own colours, else Full Tone; a heuristic) and Document Library (the most used colours of the document's swatches or a swatch library, filled with the swatch colours as they are), part of #641; Advanced › Create: Fills and/or Strokes, where lines up to the Stroke width trace as stroked centre lines (distance transform, thinning, a skeleton graph with spurs pruned, curve fitting; one width per line; without Fills, wider areas become stroked outlines), part of #641), pattern swatches with pattern editing mode, live Repeat (radial/grid/mirror). A single selected mirror repeat shows a prominent axis with a center move handle and two rotation handles. Drag the line or center to change spacing, or an end to change angle; Shift snaps rotation to 45°. The original artwork stays in place, the reflected copy previews live, Escape cancels and each drag takes one undo step through `object.repeat.options`. Controls follow zoom/view rotation and hide with edges or the bounding box. Engine and headless canvas regressions passed for gestures, history and visibility; native move, rotation and Escape screenshots were reviewed. [Public mirror-repeat reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-mirror-repeat-options.html). A single selected grid repeat shows a handle below the grid for rows, one right of it for columns and one past its bottom-right corner for both, and sliders between its first two columns and rows for the horizontal and vertical spacing; the source keeps its size, each drag is one undo step and Escape cancels it ([public grid-repeat reference](https://helpx.adobe.com/illustrator/desktop/paint-and-fill/create-and-edit-patterns/set-grid-repeat-options.html), #2691). Object › Expand turns radial, grid and mirror repeats into groups of their instances (#1765, #1756). Choosing the Blend tool again while it is active (its toolbar button, W or `tool.select`) finishes the blend: the object clicked first is dropped and the next click no longer adds to the blend just made, so the click after it starts a new blend ([Blending objects](https://web.archive.org/web/20241217212108/https://helpx.adobe.com/illustrator/using/blending-objects.html)). From 702b863306a82dccc299b072fb5a9dafb3ae9cf8 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 20:34:40 -0800 Subject: [PATCH 031/108] .ai import: reads Kinsoku, Kinsoku Shori Type, Burasagari and Bunri-Kinshi Paragraphs in a modern .ai text document now keep their East Asian line breaking settings: the Kinsoku set (None, Hard or Soft), Kinsoku Shori Type, Burasagari and Bunri-Kinshi. Each comes from the paragraph, else its paragraph style or a style that one is based on, else the document's defaults, as the other paragraph settings do. A value that cannot be read takes the paragraph style's value. A paragraph whose Kinsoku set is a custom set takes its paragraph style's set, and the import warns that custom Kinsoku sets were left out. .ai export does not write these settings. --- crates/eps/src/import/ate.rs | 178 ++++++++++++++++++++++++++- crates/eps/src/import/native/plan.rs | 6 +- docs/target-app-parity.md | 1 + 3 files changed, 182 insertions(+), 3 deletions(-) diff --git a/crates/eps/src/import/ate.rs b/crates/eps/src/import/ate.rs index 8d01b141d0..28994527a7 100644 --- a/crates/eps/src/import/ate.rs +++ b/crates/eps/src/import/ate.rs @@ -26,8 +26,8 @@ use std::collections::{BTreeMap, HashMap}; use kurbo::{BezPath, CubicBez, ParamCurve, ParamCurveArclen}; use vectorcraft_color::{Color, Paint}; use vectorcraft_doc::{ - CharStyle, HyphenationOptions, JustificationOptions, Justify, LineCap, LineJoin, Node, NodeId, NodeKind, ParaDirection, ParaStyle, PathAlign, - PathEffect, TabAlign, TabStop, TextKind, TextObject, TextRun, + Burasagari, CharStyle, HyphenationOptions, JustificationOptions, Justify, Kinsoku, KinsokuShoriType, LineCap, LineJoin, Node, NodeId, NodeKind, + ParaDirection, ParaStyle, PathAlign, PathEffect, TabAlign, TabStop, TextKind, TextObject, TextRun, }; use vectorcraft_geom::{Affine, PathData, Point, Rect}; @@ -405,6 +405,42 @@ struct Para { tabs: Vec<TabStop>, /// The paragraph has more than [`MAX_TABS`] stops: those past them were left out. tabs_truncated: bool, + /// Key 27: the Kinsoku set, `/nil` for None, else the index of one of the document's sets + /// ([`Texts::kinsoku_sets`]). `None`: the default. + kinsoku: Option<Kinsoku>, + /// Key 27 names a set of the document that isn't Hard or Soft: the paragraph takes the set it + /// would have without it. + kinsoku_custom: bool, + /// Key 25: Kinsoku Shori Type, 0 Push In First, 1 Push Out First, 2 Push Out Only. `None`: the + /// default. + kinsoku_type: Option<KinsokuShoriType>, + /// Key 24: Burasagari, 0 None, 1 Regular, 2 Force. `None`: the default. + burasagari: Option<Burasagari>, + /// Key 23: Bunri-Kinshi. + bunri_kinshi: bool, +} + +/// The name of the document's predefined Hard Kinsoku set (key 0 of its entry in the document's +/// Kinsoku sets). +const KINSOKU_HARD: &str = "PhotoshopKinsokuHard"; +/// The name of the document's predefined Soft Kinsoku set. +const KINSOKU_SOFT: &str = "PhotoshopKinsokuSoft"; +/// The warning when a paragraph's Kinsoku set is one VectorCraft doesn't have. +pub(crate) const KINSOKU_SETS_LEFT_OUT: &str = "custom Kinsoku sets were left out: their paragraphs take the set their paragraph style has"; + +/// The Kinsoku sets of text document `doc` (the list at key 0 of key 4 of its resources), in +/// order, each by its name (key 0 of the set): Hard or Soft, `None` for any other set. Those past +/// [`MAX_SHEETS`] are left out. +fn kinsoku_sets(doc: &Val) -> Vec<Option<Kinsoku>> { + let list = doc.get("0").and_then(|d| d.get("4")).and_then(|s| s.get("0")).map(Val::list).unwrap_or_default(); + list.iter() + .take(MAX_SHEETS) + .map(|s| match s.get("0").and_then(|r| r.get("0")).and_then(Val::str) { + Some(KINSOKU_HARD) => Some(Kinsoku::Hard), + Some(KINSOKU_SOFT) => Some(Kinsoku::Soft), + _ => None, + }) + .collect() } /// Most tab stops read for one paragraph. @@ -542,6 +578,9 @@ pub(super) struct Texts { /// The patterns that paint characters, by the name of the art style that gives each /// ([`Self::with_patterns`]). patterns: HashMap<String, Paint>, + /// The document's Kinsoku sets (key 4 of its resources), in order, each by its name (key 0): + /// Hard or Soft, `None` for any other set. + kinsoku_sets: Vec<Option<Kinsoku>>, } impl Texts { @@ -611,6 +650,7 @@ impl Texts { para_sheets: sheets("6"), frames: doc.get("0")?.get("8")?.get("0")?.list().to_vec(), patterns: HashMap::new(), + kinsoku_sets: kinsoku_sets(&doc), }) } @@ -749,7 +789,37 @@ impl Texts { chain.extend(self.para_sheets.first().and_then(|s| s.get("5"))); let pick = |k: &str| chain.iter().find_map(|s| s.get(k)).or_else(|| self.para_defaults.get(k)); let num = |k: &str| pick(k).and_then(Val::num).filter(|v| v.abs() < 1e5).unwrap_or(0.0); + // The East Asian settings: the first value along the chain that can be read, so one that + // can't be read takes the paragraph style's. + let levels = || chain.iter().copied().chain(std::iter::once(&self.para_defaults)); + let choice = |k: &str| { + levels().find_map(|s| match s.get(k) { + Some(Val::Num(v)) if *v == 0.0 || *v == 1.0 || *v == 2.0 => Some(*v as u8), + _ => None, + }) + }; + let set = |v: &Val| match v { + Val::Name(n) if n == "nil" => Some(Some(Kinsoku::None)), + Val::Num(i) if *i >= 0.0 && i.fract() == 0.0 => self.kinsoku_sets.get(*i as usize).copied(), + _ => None, + }; Para { + kinsoku: levels().find_map(|s| s.get("27").and_then(set).flatten()), + kinsoku_custom: levels().find_map(|s| s.get("27").and_then(set)).is_some_and(|k| k.is_none()), + kinsoku_type: choice("25").map(|v| match v { + 0 => KinsokuShoriType::PushInFirst, + 1 => KinsokuShoriType::PushOutFirst, + _ => KinsokuShoriType::PushOutOnly, + }), + burasagari: choice("24").map(|v| match v { + 0 => Burasagari::None, + 1 => Burasagari::Standard, + _ => Burasagari::Forced, + }), + bunri_kinshi: levels().find_map(|s| match s.get("23") { + Some(Val::Bool(b)) => Some(*b), + _ => None, + }) == Some(true), justify: pick("0").and_then(Val::num).map_or(0, |v| v.clamp(0.0, 6.0) as u8), rtl: pick("33").and_then(Val::num) == Some(1.0), first_indent: num("1"), @@ -1264,6 +1334,11 @@ impl Story { self.tabs_left_out.get() } + /// Does a paragraph have a Kinsoku set VectorCraft doesn't have ([`Para::kinsoku_custom`])? + pub(super) fn kinsoku_sets_left_out(&self) -> bool { + self.paras.iter().any(|(_, p)| p.kinsoku_custom) + } + /// Area type (`node`, the story's first frame as [`Self::node`] makes it with `template` and /// `to_doc`) whose first line the file lays out higher or lower than it is laid out here, as its /// page draws it: its first baseline is fixed where the file has it. The font's ascent below the @@ -1425,6 +1500,10 @@ fn para_style(p: &Para, scale: f64) -> ParaStyle { auto_leading: p.auto_leading.map_or(JustificationOptions::default().auto_leading, |a| (a * 1e6).round() / 1e4), ..JustificationOptions::default() }, + kinsoku: p.kinsoku.unwrap_or_default(), + kinsoku_type: p.kinsoku_type.unwrap_or_default(), + burasagari: p.burasagari.unwrap_or_default(), + bunri_kinshi: p.bunri_kinshi, ..ParaStyle::default() } } @@ -1496,6 +1575,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let justify = |own: &[u8]| para_style(&texts.para(Some(&read(&[b"/5 << ", own, b" >>"].concat()).unwrap())), 1.0).justify; // Right to left from the document's defaults, or the paragraph's own. @@ -1520,6 +1600,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let auto = |own: &[u8]| para_style(&texts.para(Some(&read(&[b"/5 << ", own, b" >>"].concat()).unwrap())), 1.0).justification.auto_leading; assert_eq!(auto(b""), JustificationOptions::default().auto_leading); @@ -1543,6 +1624,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let options = |own: &[u8], scale: f64| para_style(&texts.para(Some(&read(&[b"/5 << ", own, b" >>"].concat()).unwrap())), scale).hyphenation; let want = HyphenationOptions { words_longer_than: 6, after_first: 2, before_last: 2, hyphen_limit: 0, zone: 36.0, capitalized: true }; @@ -1561,12 +1643,93 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let own = |own: &[u8]| para_style(&bare.para(Some(&read(&[b"/5 << ", own, b" >>"].concat()).unwrap())), 1.0).hyphenation; assert_eq!(own(b""), d); assert_eq!(own(b"/10 0 /11 99 /12 2.5 /13 -1 /14 -3 /15 1"), d); } + /// The document's Kinsoku sets are known by their names, in order: the predefined Hard and + /// Soft sets, in either string form, and any other set as one VectorCraft doesn't have. + #[test] + fn the_documents_kinsoku_sets_are_known_by_name() { + let utf16: Vec<u8> = b"(\xfe\xff".iter().copied().chain(KINSOKU_SOFT.bytes().flat_map(|c| [0, c])).chain(*b")").collect(); + let doc = read( + &[ + b"/0 << /4 << /0 [ << /0 << /0 (PhotoshopKinsokuHard) /5 << /4 1 >> >> >> << /0 << /0 ".as_slice(), + &utf16, + b" >> >> << /0 << /0 (My Set) >> >> << /0 << >> >> ] >> >>", + ] + .concat(), + ) + .unwrap(); + assert_eq!(kinsoku_sets(&doc), [Some(Kinsoku::Hard), Some(Kinsoku::Soft), None, None]); + assert_eq!(kinsoku_sets(&read(b"/0 << >>").unwrap()), []); + } + + /// Keys 23 to 27 are the paragraph's East Asian settings: Bunri-Kinshi (23), Burasagari (24: + /// 0 None, 1 Regular, 2 Force), Kinsoku Shori Type (25: 0 Push In First, 1 Push Out First, 2 + /// Push Out Only) and the Kinsoku set (27: `/nil` for None, else the index of one of the + /// document's sets). A value that can't be read, and a set VectorCraft doesn't have, take the + /// paragraph style's, or else the document's. + #[test] + fn a_paragraph_keeps_its_east_asian_settings() { + let texts = Texts { + stories: vec![], + fonts: vec![], + defaults: Val::Dict(BTreeMap::new()), + para_defaults: read(b"/27 0 /25 2 /24 0 /23 false").unwrap(), + char_sheets: vec![], + // [Normal Paragraph Style] has the Soft set; the second style has Force burasagari. + para_sheets: vec![read(b"/5 << /27 1 >>").unwrap(), read(b"/5 << /24 2 /23 true >>").unwrap()], + frames: vec![], + patterns: HashMap::new(), + kinsoku_sets: vec![Some(Kinsoku::Hard), Some(Kinsoku::Soft), None], + }; + let para = |run: &[u8]| texts.para(Some(&read(run).unwrap())); + let settings = |run: &[u8]| { + let p = para_style(¶(run), 1.0); + (p.kinsoku, p.kinsoku_type, p.burasagari, p.bunri_kinshi) + }; + let normal = (Kinsoku::Soft, KinsokuShoriType::PushOutOnly, Burasagari::None, false); + assert_eq!(settings(b"/5 << >>"), normal); + assert_eq!(settings(b"/5 << /27 /nil /25 0 /24 1 /23 true >>"), (Kinsoku::None, KinsokuShoriType::PushInFirst, Burasagari::Standard, true)); + assert_eq!(settings(b"/5 << /27 0 /25 1 /24 2 >>"), (Kinsoku::Hard, KinsokuShoriType::PushOutFirst, Burasagari::Forced, false)); + // The paragraph style it is based on (key 6), then [Normal Paragraph Style]. + assert_eq!(settings(b"/5 << >> /6 1"), (Kinsoku::Soft, KinsokuShoriType::PushOutOnly, Burasagari::Forced, true)); + assert_eq!(settings(b"/5 << /23 false >> /6 1"), (Kinsoku::Soft, KinsokuShoriType::PushOutOnly, Burasagari::Forced, false)); + // A set VectorCraft doesn't have takes the paragraph style's, and the paragraph says so. + assert_eq!(settings(b"/5 << /27 2 >>"), normal); + assert!(para(b"/5 << /27 2 >>").kinsoku_custom); + assert!(!para(b"/5 << /27 0 >>").kinsoku_custom && !para(b"/5 << >>").kinsoku_custom); + // The story warns of it (the importer's warning). + assert!(story("あ\r", &[0.0], ¶(b"/5 << /27 2 >>")).kinsoku_sets_left_out()); + assert!(!story("あ\r", &[0.0], ¶(b"/5 << /27 1 >>")).kinsoku_sets_left_out()); + for unreadable in [ + b"/5 << /27 3 >>".as_slice(), + b"/5 << /27 -1 >>", + b"/5 << /27 0.5 >>", + b"/5 << /27 (PhotoshopKinsokuHard) >>", + b"/5 << /27 /Hard >>", + b"/5 << /25 3 >>", + b"/5 << /25 1.5 >>", + b"/5 << /25 -1 >>", + b"/5 << /24 /nil >>", + b"/5 << /24 true >>", + b"/5 << /23 1 >>", + b"/5 << /23 /nil >>", + ] { + assert_eq!(settings(unreadable), normal, "{}", String::from_utf8_lossy(unreadable)); + assert!(!para(unreadable).kinsoku_custom, "{}", String::from_utf8_lossy(unreadable)); + } + // Without any of the keys, VectorCraft's defaults. + let bare = Texts { para_defaults: Val::Dict(BTreeMap::new()), para_sheets: vec![], kinsoku_sets: vec![], ..texts }; + let p = para_style(&bare.para(Some(&read(b"/5 << >>").unwrap())), 1.0); + let d = ParaStyle::default(); + assert_eq!((p.kinsoku, p.kinsoku_type, p.burasagari, p.bunri_kinshi), (d.kinsoku, d.kinsoku_type, d.burasagari, d.bunri_kinshi)); + } + /// Key 30 holds the paragraph's tab stops: their positions (key 0), sorted, and alignments (key /// 1: 0 left, 1 center, 2 right, 3 decimal), scaled as sizes are. A stop that can't be read is /// left out. A user's price list keeps a right stop at 269.29 and a left one at 272.13. @@ -1581,6 +1744,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let tabs = |own: &[u8], scale: f64| { para_style(&texts.para(Some(&read(&[b"/5 << ", own, b" >>"].concat()).unwrap())), scale) @@ -1648,6 +1812,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], } .para(None); let mut s = story(" 80 mm ", &[0.0], ¶); @@ -1696,6 +1861,7 @@ mod tests { para_sheets: vec![], frames: cases.iter().map(|c| frame(c)).collect(), patterns: HashMap::new(), + kinsoku_sets: vec![], }; let vertical: Vec<bool> = (0..cases.len() + 1).map(|i| texts.frame_vertical(i)).collect(); assert_eq!(vertical, [true, false, false, false, false, false, false, false, false, false, false]); @@ -1714,6 +1880,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let tcy = |run: &[u8]| texts.style(Some(&read(run).unwrap())).tate_chu_yoko; assert!(tcy(b"/6 << /35 3 >>"), "the run's own"); @@ -1738,6 +1905,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let roman = |defaults: &[u8], run: &[u8]| texts(defaults).style(Some(&read(run).unwrap())).standard_vertical_roman; assert!(roman(b"/35 1", b"/6 << >>"), "the document's defaults"); @@ -1769,6 +1937,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let stroke = |run: &[u8]| { let s = char_style(&texts.style(Some(&read(run).unwrap())), 1.0, Affine::IDENTITY); @@ -1811,6 +1980,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], } .with_patterns(patterns) } @@ -1894,6 +2064,7 @@ mod tests { para_sheets: vec![], frames: vec![read(b"/0 << /0 [ 0 0 ] /2 << /0 0 >> >>").unwrap()], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let text = |kerns: &[u8]| -> TextObject { let node = texts(kerns).story(0).unwrap().node(NodeId(1), 0, (0.0, 0.0), Affine::IDENTITY).unwrap(); @@ -1961,6 +2132,7 @@ mod tests { para_sheets: vec![], frames: vec![], patterns: HashMap::new(), + kinsoku_sets: vec![], }; let direction = |own: &[u8]| para_style(&texts.para(Some(&read(&[b"/5 << ", own, b" >>"].concat()).unwrap())), 1.0).direction; assert_eq!(direction(b"/0 2"), Some(ParaDirection::RightToLeft), "from the document's defaults"); @@ -2009,6 +2181,7 @@ mod tests { para_sheets: vec![], frames: vec![read(doc.as_bytes()).unwrap()], patterns: HashMap::new(), + kinsoku_sets: vec![], }; texts.frame(0) } @@ -2667,6 +2840,7 @@ mod tests { para_sheets: vec![], frames: vec![read(doc.as_bytes()).unwrap()], patterns: HashMap::new(), + kinsoku_sets: vec![], }; texts.frame(0).unwrap() } diff --git a/crates/eps/src/import/native/plan.rs b/crates/eps/src/import/native/plan.rs index eaa50b6bbf..005b89397e 100644 --- a/crates/eps/src/import/native/plan.rs +++ b/crates/eps/src/import/native/plan.rs @@ -59,7 +59,7 @@ pub(super) fn make_slots( to_doc: Affine, warn: &mut Vec<String>, ) -> Vec<Option<Made>> { - let (mut taller, mut deeper, mut tabs_left_out) = (0, 0, false); + let (mut taller, mut deeper, mut tabs_left_out, mut kinsoku_left_out) = (0, 0, false, false); let made = infos .iter() .enumerate() @@ -68,6 +68,7 @@ pub(super) fn make_slots( let story = stories.get(k)?.as_ref()?; let mut node = story.node(NodeId(0), info.frame, t, to_doc)?; tabs_left_out |= story.tabs_left_out(); + kinsoku_left_out |= story.kinsoku_sets_left_out(); let mut region = story.region(t, to_doc); // The first line where the file has it, in the text document's frame (that of a // copied object is its original's, as its lines are). @@ -102,6 +103,9 @@ pub(super) fn make_slots( if tabs_left_out { warn.push(crate::import::ate::TABS_LEFT_OUT.into()); } + if kinsoku_left_out { + warn.push(crate::import::ate::KINSOKU_SETS_LEFT_OUT.into()); + } made } diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..43b20f2c80 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1348,6 +1348,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Type on a path with right-to-left text that does not fit shows the longest start of its text whose glyphs fit, also where tracking gives a letter a negative advance and a shorter start does not fit; the rest overflows or flows to the next threaded object (VectorCraft's own rule). Without hanging punctuation, and on a straight path or with no spacing, every start is measured without arranging it on the path again. With hanging punctuation, or spacing on a curve, when a letter has a negative advance, at most 32 of the starts that could fit are arranged one by one from the longest; when none of them fits, a binary search over the rest shows a start that fits, which is not always the longest (`overflowing_rtl_type_on_a_path_shows_the_longest_start_that_fits`, `the_longest_rtl_start_on_a_path_is_found_without_arranging_each_start`, `the_longest_rtl_start_on_a_path_is_the_one_each_start_gives` and `rtl_type_on_a_curve_whose_letters_take_the_line_back_is_arranged_a_bounded_number_of_times` in `crates/text/src/tests/bidi.rs`). Right-aligned and centered type on a curve with Spacing is placed by what its glyphs take where the line ends up, so text that fits is not cut off at the end bracket (`on_path_aligned_spaced_text_that_fits_shows_whole` in `crates/text/src/tests.rs`). The Paragraph panel menu's Kinsoku Shori Type (`text.setFormat {kinsokuType}`, with the East Asian options) picks Push In First, Push Out First or Push Out Only for each paragraph: a character the Kinsoku Set keeps off a line's start or end is set on the line, with the line's gaps next to CJK characters closed by at most a tenth of an em each to fit, or moved to the next line with the character before it. Push Out First pushes in only when pushing out would leave the line more than an em short. Push Out Only is the default, the setting is saved only when it is not, and paragraph styles carry it. The Paragraph panel menu's Bunri-Kinshi (`text.setFormat {bunriKinshi}`, with the East Asian options, and the East Asian Composition Settings section of Paragraph Style Options) keeps inseparable pairs on one line in each paragraph that has it: two em dashes, two ellipses, two two-dot leaders and the two halves of a vertical kana repeat mark (the pairs of W3C JLREQ's class cl-08, VectorCraft's set). Both composers and vertical type follow it, and justification adds no space inside a pair. It works with a Kinsoku Set only, is off by default and is saved only when on; editing the set of pairs is not available. + `.ai` import reads each paragraph's Kinsoku Set (None, Hard or Soft), Kinsoku Shori Type, Burasagari and Bunri-Kinshi from the file's editable text: the paragraph's own setting, else its paragraph style's or a style that one is based on, else the document's default. A paragraph with a custom Kinsoku set takes its paragraph style's set, and the importer warns about it. A value it cannot read takes its paragraph style's value too. `.ai` export does not write these settings. The Paragraph panel menu's Korean Line Break Anywhere (`text.setFormat {koreanLineBreakAnywhere}`, with the East Asian options, and the East Asian Composition Settings section of Paragraph Style Options) sets for each paragraph whether a line may break between any two Hangul syllables. When it is off, a word that contains Hangul breaks only at its spaces and after punctuation, or where the word is wider than the line, and takes no hyphen. New type has it off; paragraphs saved before the option read as on, so their lines do not move. The Paragraph panel menu's Reset Panel (`text.setStyle`, `text.setFormat` and `text.tabs.clear`) gives the selected type's paragraphs, or the paragraphs the Type tool's selection touches, Auto alignment, no indents or paragraph spacing, Hyphenate off with the default Hyphenation and Justification options, Auto direction, Bottom-to-Bottom Leading, the Line-end Punctuation Half Width Mojikumi Set, Regular burasagari, the Hard kinsoku set, Push Out Only, the Every-line Composer, Bunri-Kinshi, Roman Hanging Punctuation and Korean Line Break Anywhere off, no kashidas and no tab stops, as one undo step. The Paragraph panel menu's Hyphenation… (`ui.hyphenation`, `text.setFormat {wordsLongerThan, afterFirst, beforeLast, hyphenLimit, hyphenationZone, hyphenateCapitalized}`) sets each paragraph's hyphenation limits: the shortest word that breaks, the fewest letters on each side of the hyphen, the most hyphenated lines in a row, a zone at the right edge where the Single-line Composer breaks before a word instead of hyphenating it, and whether capitalized words break. The defaults are words longer than 5 letters, 3 letters on each side, no limit or zone, and capitalized words hyphenated; paragraph styles and the native file keep the options. From 774ffbbc21042d3916edf5c7cf4c4958a3fa0323 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 20:47:23 -0800 Subject: [PATCH 032/108] EPS import: KSC-Johab type reads one-byte ASCII codes The KSC-Johab CMaps had no code space listed, so type in a font over KSC-Johab-H or KSC-Johab-V read every code as two bytes, so two ASCII characters moved the point one em instead of two. The code space now follows Adobe's KSC-Johab-H CMap: <00>-<80>, <8441>-<D3FE>, <D831>-<DEFE> and <E031>-<F9FE> (https://github.com/adobe-type-tools/cmap-resources/blob/master/Adobe-Korea1-2/CMap/KSC-Johab-H). --- crates/eps/src/import/predefined_cmap.rs | 2 ++ crates/eps/src/import/tests_cid.rs | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/crates/eps/src/import/predefined_cmap.rs b/crates/eps/src/import/predefined_cmap.rs index c688ebf9ae..46890af653 100644 --- a/crates/eps/src/import/predefined_cmap.rs +++ b/crates/eps/src/import/predefined_cmap.rs @@ -279,6 +279,7 @@ fn code_space(cmap: &str) -> Option<CodeSpace> { const CNS_EUC: CodeSpace = &[(b"\x00", b"\x80"), (b"\xa1\xa1", b"\xfe\xfe"), (b"\x8e\xa1\xa1\xa1", b"\x8e\xa3\xfe\xfe")]; const KSC_PC: CodeSpace = &[(b"\x00", b"\x84"), (b"\xfe", b"\xff"), (b"\xa1\x41", b"\xfd\xfe")]; const UHC: CodeSpace = &[(b"\x00", b"\x80"), (b"\x81\x41", b"\xfe\xfe")]; + const JOHAB: CodeSpace = &[(b"\x00", b"\x80"), (b"\x84\x41", b"\xd3\xfe"), (b"\xd8\x31", b"\xde\xfe"), (b"\xe0\x31", b"\xf9\xfe")]; let stem = match cmap { "H" | "V" => "", _ => cmap.strip_suffix("-H").or_else(|| cmap.strip_suffix("-V"))?, @@ -301,6 +302,7 @@ fn code_space(cmap: &str) -> Option<CodeSpace> { "CNS-EUC" => CNS_EUC, "KSCpc-EUC" => KSC_PC, "KSCms-UHC" => UHC, + "KSC-Johab" => JOHAB, _ => return None, }) } diff --git a/crates/eps/src/import/tests_cid.rs b/crates/eps/src/import/tests_cid.rs index 8350cd514b..f63a77e09b 100644 --- a/crates/eps/src/import/tests_cid.rs +++ b/crates/eps/src/import/tests_cid.rs @@ -677,6 +677,10 @@ fn latin_names_ending_in_h_and_cmaps_that_cannot_be_read() { "/Ryumin-Light-GBT-H findfont 20 scalefont setfont <09092121> stringwidth abs 0.01 lt exch 60 sub abs 0.01 lt and", // A byte that starts no row-and-cell code is a code of its own, also before a tab: three. "/Ryumin-Light-GBT-H findfont 20 scalefont setfont <21092121> stringwidth abs 0.01 lt exch 60 sub abs 0.01 lt and", + // In the Johab code space each ASCII byte is a one-byte code and a Hangul code takes two + // bytes: three codes, across and down. + "/Ryumin-Light-KSC-Johab-H findfont 20 scalefont setfont <41428441> stringwidth abs 0.01 lt exch 60 sub abs 0.01 lt and", + "/Ryumin-Light-KSC-Johab-V findfont 20 scalefont setfont 10 100 moveto <41428441> show currentpoint 40 sub abs 0.01 lt exch 10 sub abs 0.01 lt and", ] { let r = super::tests::read(&format!("{cond} {{ 0 0 10 10 rectfill }} if")); assert!(all(&r.document).iter().any(|n| matches!(n.kind, NodeKind::Path { .. })), "{cond}"); From 5b24c0a55e9d6b20818f82a95e76df5884865f90 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 20:32:10 -0800 Subject: [PATCH 033/108] Actions: Batch errors name the step by its place in the commands sent action.batch drops Open steps before it plays each file or data set, and returned the per-file error of command.batch unchanged, so `batch step N` counted from 0 within the filtered steps. A failed step is now named ``action step N (`id`) failed: reason``, N being its place in the `commands` the caller sent, from 1, with skipped Open steps counted. The batch's own open, data set choice and destination steps keep their unnumbered errors, and command.batch messages are unchanged. A prefs.import step, which command.batch refuses when it reaches that step, rolling the batch back, is now refused before any file opens instead of failing each file or data set the batch plays. Docs: action.batch params text, docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/cmd/fileio/action_batch.rs | 205 +++++++++++++++++-- crates/engine/src/cmd/fileio/commands.rs | 2 +- docs/mcp.md | 7 +- docs/target-app-parity.md | 1 + 4 files changed, 200 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/cmd/fileio/action_batch.rs b/crates/engine/src/cmd/fileio/action_batch.rs index 232d5ba1f4..4e99f4ee3e 100644 --- a/crates/engine/src/cmd/fileio/action_batch.rs +++ b/crates/engine/src/cmd/fileio/action_batch.rs @@ -12,6 +12,8 @@ use serde_json::json; use super::super::{Result, Session, bad}; #[cfg(not(target_arch = "wasm32"))] use super::super::{check_switches, find_command, switch_or, text_param}; +#[cfg(not(target_arch = "wasm32"))] +use crate::EngineError; #[cfg(target_arch = "wasm32")] pub(super) fn action_batch(_: &mut Session, _: &Value) -> Result<Value> { @@ -58,6 +60,10 @@ pub(super) fn action_batch(s: &mut Session, p: &Value) -> Result<Value> { if id == "command.batch" || id == "action.batch" { return Err(bad(C, "batches cannot nest")); } + // `command.batch` refuses the batch when it reaches this step, which would fail every file or data set it plays. + if id == "prefs.import" { + return Err(bad(C, format!("commands[{i}]: `prefs.import` runs on its own, not as a batch step"))); + } if find_command(id).is_none() { return Err(bad( C, @@ -213,7 +219,7 @@ fn batch_folder(s: &mut Session, cmd: &str, p: &Value, override_open: bool, run: // open, so its artboard files count ([`dataset_output_paths`]). No output takes the name of a // source file in the destination folder, other than that file's own output, or of a subfolder // of the destination folder that holds source files. - let steps = filter_steps(run.steps, override_open, false); + let (steps, places) = filter_steps(run.steps, override_open, false); let run = Run { steps: &steps, ..*run }; let in_dest: Vec<Option<(String, bool)>> = files.iter().map(|path| name_in_folder(path, run.dest_folder)).collect(); let mut picker = @@ -228,7 +234,7 @@ fn batch_folder(s: &mut Session, cmd: &str, p: &Value, override_open: bool, run: let outputs = dataset_output_extensions(&run, doc, &ext); picker.pick(&base, |stem| output_names(run.dest_folder, stem, &outputs, doc), own.as_deref()) }; - match process_one_file(s, &run, path, &ext, pick) { + match process_one_file(s, &run, &places, path, &ext, pick) { Ok(row) => processed.push(row), Err(e) => { failed += 1; @@ -266,12 +272,12 @@ fn batch_datasets(s: &mut Session, cmd: &str, run: &Run<'_>) -> Result<Value> { } let doc_stem = st.path.as_deref().and_then(|p| std::path::Path::new(p).file_stem().and_then(|s| s.to_str())).unwrap_or("Untitled").to_string(); let stems = dataset_stems(&names, &doc_stem, run.dataset_file_naming, run, &st.doc)?; - let steps = filter_steps(run.steps, true, false); + let (steps, places) = filter_steps(run.steps, true, false); let run = Run { steps: &steps, ..*run }; let mut processed = Vec::new(); let mut failed = 0usize; for (name, stem) in names.iter().zip(&stems) { - match process_one_dataset(s, &run, name, stem) { + match process_one_dataset(s, &run, &places, name, stem) { Ok(row) => processed.push(row), Err(e) => { failed += 1; @@ -347,11 +353,13 @@ impl StemPicker { } } -/// Drop Open (and optionally Close) steps when the batch supplies the file itself. +/// Drop Open (and optionally Close) steps when the batch supplies the file itself → the steps that +/// stay, and the index of each in `cmds`. #[cfg(not(target_arch = "wasm32"))] -fn filter_steps(cmds: &[Value], drop_open: bool, drop_close: bool) -> Vec<Value> { +fn filter_steps(cmds: &[Value], drop_open: bool, drop_close: bool) -> (Vec<Value>, Vec<usize>) { cmds.iter() - .filter(|c| { + .enumerate() + .filter(|(_, c)| { let id = c.get("command").and_then(Value::as_str).unwrap_or(""); if drop_open && matches!(id, "document.open" | "file.open") { return false; @@ -361,14 +369,44 @@ fn filter_steps(cmds: &[Value], drop_open: bool, drop_close: bool) -> Vec<Value> } true }) - .cloned() - .collect() + .map(|(i, c)| (c.clone(), i)) + .unzip() +} + +/// Plays `commands`, the steps of `run` with their paths rewritten, as one `command.batch`. When a +/// step fails, the error names it by its place in the caller's `commands`, from 1, counting the Open +/// steps the batch skipped (`places` gives the index there of each step of `run`): +/// ``action step 3 (`object.move`) failed: …``. Any other error, such as one about the whole batch, +/// stays as it is. +#[cfg(not(target_arch = "wasm32"))] +fn play_steps(s: &mut Session, run: &Run<'_>, places: &[usize], commands: Vec<Value>) -> Result<Value> { + s.execute("command.batch", &json!({"label": run.label, "commands": commands})).map_err(|e| { + let text = e.to_string(); + let Some((n, id, reason)) = batch_step_failure(&text) else { return e }; + let same = run.steps.get(n).and_then(|c| c.get("command")).and_then(Value::as_str) == Some(id); + match places.get(n) { + Some(place) if same => EngineError::Other(format!("action step {} (`{id}`) failed: {reason}", place + 1)), + _ => e, + } + }) +} + +/// The step number, command id and reason in the error `command.batch` gives when one of its steps +/// fails (``batch step 2 (`object.move`) failed: …``); none for any other error. +#[cfg(not(target_arch = "wasm32"))] +fn batch_step_failure(e: &str) -> Option<(usize, &str, &str)> { + let rest = e.strip_prefix("batch step ")?; + let digits = rest.find(|c: char| !c.is_ascii_digit())?; + let n = rest[..digits].parse().ok()?; + let (id, reason) = rest[digits..].strip_prefix(" (`")?.split_once("`) failed: ")?; + Some((n, id, reason)) } #[cfg(not(target_arch = "wasm32"))] fn process_one_file( s: &mut Session, run: &Run<'_>, + places: &[usize], path: &str, ext: &str, stem_for: impl FnOnce(&vectorcraft_doc::Document) -> String, @@ -376,17 +414,17 @@ fn process_one_file( s.execute("document.open", &json!({"path": path}))?; let stem = stem_for(&s.doc()?.doc); let rewritten = rewrite_paths(run.steps, run.override_save, run.override_export, run.dest_folder, &stem, ext); - let batch = s.execute("command.batch", &json!({"label": run.label, "commands": rewritten}))?; + let batch = play_steps(s, run, places, rewritten)?; // Folder sources open a file per pass: close after Save and Close / Folder. finish_destination(s, run, &stem, ext, path, true)?; Ok(json!({"path": path, "result": batch})) } #[cfg(not(target_arch = "wasm32"))] -fn process_one_dataset(s: &mut Session, run: &Run<'_>, name: &str, stem: &str) -> Result<Value> { +fn process_one_dataset(s: &mut Session, run: &Run<'_>, places: &[usize], name: &str, stem: &str) -> Result<Value> { s.execute("dataset.select", &json!({"name": name}))?; let rewritten = rewrite_paths(run.steps, run.override_save, run.override_export, run.dest_folder, stem, "vectorcraft"); - let batch = s.execute("command.batch", &json!({"label": run.label, "commands": rewritten}))?; + let batch = play_steps(s, run, places, rewritten)?; // Data sets share one open document: write each row out but leave it open for the next. finish_destination(s, run, stem, "vectorcraft", "", false)?; Ok(json!({"dataset": name, "result": batch})) @@ -1454,7 +1492,8 @@ mod tests { assert_eq!((r["failed"].as_u64(), r["processed"].as_array().map(Vec::len)), (Some(rows), Some(rows as usize)), "{r}"); for row in r["processed"].as_array().unwrap() { let e = row["error"].as_str().unwrap_or_default(); - let want = format!("batch step 0 (`document.save`) failed: automation path rejected: outside the write root {root}: doc.vectorcraft"); + let want = + format!("action step 1 (`document.save`) failed: automation path rejected: outside the write root {root}: doc.vectorcraft"); assert_eq!(e, want, "{r}"); } assert!(!r.to_string().contains(&hidden), "{r}"); @@ -2224,4 +2263,144 @@ mod tests { .is_err() ); } + + /// The steps of the step-number tests: an Open the batch skips, a step that works, and one that + /// fails (an Align with nothing selected). + fn open_then_failing_align() -> Value { + json!([ + {"command": "document.open", "params": {"path": "/no/such/file.svg"}}, + {"command": "object.unlockAll", "params": {}}, + {"command": "object.align", "params": {}} + ]) + } + + /// The step a source's error names, after `action step ` and before ` failed: `. + fn named_step(r: &Value, row: usize) -> String { + let e = r["processed"][row]["error"].as_str().unwrap_or_default(); + assert!(!e.contains("batch step"), "{r}"); + e.strip_prefix("action step ").and_then(|e| e.split_once(" failed: ")).map(|(step, _)| step.to_string()).unwrap_or_else(|| e.to_string()) + } + + /// A failed step of a folder batch is named by its place in the `commands` sent, from 1, with the + /// Open step that Override Open skips counted; the reason follows unchanged. + #[test] + fn a_folder_batch_error_names_the_step_in_the_commands_sent() { + let src = tmp("step-number-src"); + write_svg(&src, "a.svg", "#f00"); + write_svg(&src, "b.svg", "#0f0"); + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 100, "height": 80})).unwrap(); + // `command.batch` itself still numbers its steps from 0. + let reason = s + .execute( + "command.batch", + &json!({"commands": [{"command": "object.unlockAll", "params": {}}, {"command": "object.align", "params": {}}]}), + ) + .unwrap_err() + .to_string(); + let reason = reason.strip_prefix("batch step 1 (`object.align`) failed: ").unwrap_or_else(|| panic!("{reason}")).to_string(); + for (stop, rows) in [(true, 1), (false, 2)] { + let r = s + .execute("action.batch", &json!({"folder": src.to_string_lossy(), "stopOnError": stop, "commands": open_then_failing_align()})) + .unwrap(); + assert_eq!(r["failed"], rows, "{r}"); + for row in 0..rows { + assert_eq!(r["processed"][row]["error"], format!("action step 3 (`object.align`) failed: {reason}"), "{r}"); + } + } + } + + /// With Override Open off, a recorded Open step runs, and its failure is named as the first step. + #[test] + fn a_recorded_open_that_fails_is_the_first_step() { + let src = tmp("step-number-open-src"); + write_svg(&src, "a.svg", "#f00"); + let mut s = Session::new(); + let r = s + .execute("action.batch", &json!({"folder": src.to_string_lossy(), "overrideOpen": false, "commands": open_then_failing_align()})) + .unwrap(); + assert_eq!(named_step(&r, 0), "1 (`document.open`)", "{r}"); + } + + /// A data set batch, which always skips Open steps, names a failed step by its place in the + /// `commands` sent for every data set it fails on. + #[test] + fn a_data_set_batch_error_names_the_step_in_the_commands_sent() { + let mut s = with_data_sets(&["Alpha", "Beta"]); + for (stop, rows) in [(true, 1), (false, 2)] { + let r = s.execute("action.batch", &json!({"source": "datasets", "stopOnError": stop, "commands": open_then_failing_align()})).unwrap(); + assert_eq!(r["failed"], rows, "{r}"); + for row in 0..rows { + assert_eq!(named_step(&r, row), "3 (`object.align`)", "{r}"); + } + } + } + + /// A recorded export that Override Export points into the destination folder keeps its place in + /// the `commands` sent when it fails. + #[test] + fn a_redirected_export_that_fails_keeps_its_place() { + let src = tmp("step-number-export-src"); + write_svg(&src, "a.svg", "#f00"); + let dest = tmp("step-number-export-out"); + // A file where the export's folder goes, so the export cannot write its files. + std::fs::write(dest.join("a"), "taken").unwrap(); + let mut s = Session::new(); + let r = s + .execute( + "action.batch", + &json!({ + "folder": src.to_string_lossy(), + "destinationFolder": dest.to_string_lossy(), + "commands": [ + {"command": "document.open", "params": {"path": "/no/such/file.svg"}}, + {"command": "object.unlockAll", "params": {}}, + {"command": "document.exportForScreens", "params": {"formats": [{"format": "svg"}]}} + ] + }), + ) + .unwrap(); + assert_eq!(r["failed"], 1, "{r}"); + assert_eq!(named_step(&r, 0), "3 (`document.exportForScreens`)", "{r}"); + } + + /// A source file that does not open, which the batch opens itself, gives the open's own error + /// with no step number. + #[test] + fn a_source_that_does_not_open_names_no_step() { + let src = tmp("step-number-bad-src"); + std::fs::write(src.join("a.svg"), "not an svg").unwrap(); + let mut s = Session::new(); + let r = s.execute("action.batch", &json!({"folder": src.to_string_lossy(), "commands": open_then_failing_align()})).unwrap(); + assert_eq!(r["failed"], 1, "{r}"); + let e = r["processed"][0]["error"].as_str().unwrap_or_default(); + assert!(!e.is_empty() && !e.contains("action step") && !e.contains("batch step"), "{r}"); + } + + /// A `prefs.import` step, which `command.batch` does not run, is refused before any file opens. + #[test] + fn a_prefs_import_step_is_refused_before_any_file_opens() { + let src = tmp("step-number-prefs-src"); + write_svg(&src, "a.svg", "#f00"); + let mut s = Session::new(); + let p = json!({"folder": src.to_string_lossy(), "commands": [{"command": "object.unlockAll"}, {"command": "prefs.import", "params": {}}]}); + let e = s.execute("action.batch", &p).unwrap_err().to_string(); + assert!(e.contains("commands[1]: `prefs.import` runs on its own, not as a batch step"), "{e}"); + assert!(s.active().is_none(), "no file was opened"); + } + + /// Only the error `command.batch` gives for a failed step is read as one. + #[test] + fn batch_step_failure_reads_only_a_step_error() { + assert_eq!(batch_step_failure("batch step 12 (`object.move`) failed: no selection"), Some((12, "object.move", "no selection"))); + for e in [ + "batch step (`object.move`) failed: no selection", + "batch step 99999999999999999999999 (`object.move`) failed: x", + "batch step 1 `object.move` failed: x", + "invalid parameters for `command.batch`: batches cannot nest", + "batch step 1", + ] { + assert_eq!(batch_step_failure(e), None, "{e}"); + } + } } diff --git a/crates/engine/src/cmd/fileio/commands.rs b/crates/engine/src/cmd/fileio/commands.rs index 28e12c115d..94917a3f27 100644 --- a/crates/engine/src/cmd/fileio/commands.rs +++ b/crates/engine/src/cmd/fileio/commands.rs @@ -117,7 +117,7 @@ pub fn specs() -> Vec<CommandSpec> { "Batch…", [], None, - "{commands: [{command, params}] (the action's steps), source?: folder (default) | datasets, folder? (required for folder: the source folder), includeSubdirs?: false, destination?: none (default: leave each file open) | saveAndClose (save over the source and close; for source datasets, save the open document over its own file after each data set, and refuse a document that was never saved, was converted from an older version or was restored by Data Recovery, unless a recorded Save or Save As step writes a file first; a Save or Save As step that overrideSave points into destinationFolder makes each data set's file the document's own) | folder (save or export into destinationFolder and close), destinationFolder? (required when destination is folder; also the folder Override Save/Export write into), datasetFileNaming?: fileNumber | fileDataSetName (default) | dataSetName (used only for source datasets; ignored for folder), overrideOpen?: true (skip document.open / file.open steps: the batch opens each source file), overrideSave?: true (point document.save / file.save / file.saveAs at destinationFolder/{stem}.{ext}), overrideExport?: true (point document.export / document.exportSelection the same way, and give document.exportForScreens / assets.export the folder destinationFolder/{stem}, one for each source file or data set, in which the export names its files as it does outside Batch), stopOnError?: true, label?} play the commands on every readable file in folder (and its subfolders when includeSubdirs; {stem} is the file's name without its extension and without trailing periods and spaces, with `-2`, `-3`… added to a name an earlier file used or whose file or folder has the name of one an earlier file wrote or of another source file or a folder of source files in destinationFolder), or on every data set of the open document. Data set names use the document stem plus a three-digit ordinal, the document stem and an underscore plus the data set name, or the data set name alone. Invalid file name characters become `-` and trailing periods and spaces are dropped; a name already used in the batch or whose output file or folder already exists in a destination folder the batch may read and write gets the next free `-2`, `-3` suffix before the format-derived extension. Caps: 500 files or data sets, 8 folder levels, 256 steps. Batches cannot nest. A switch (includeSubdirs, overrideOpen, overrideSave, overrideExport, stopOnError) that is not true or false, or a source, folder, destination, destinationFolder, datasetFileNaming or label that is not a string, is an error before any folder is made or file opened; null reads as left out. → {processed: [{path|dataset, result|error}…], count, failed, stopped, warning?} (warning: for source datasets, when Save and Close without such a step, or a Save, Save a Copy, Save as Template or export step (document.export, exportSelection, exportForScreens, exportPdf, exportEps, exportDxf, exportForWeb, exportForOffice) that writes a file and is not pointed into destinationFolder, saves every data set over the same file)", + "{commands: [{command, params}] (the action's steps), source?: folder (default) | datasets, folder? (required for folder: the source folder), includeSubdirs?: false, destination?: none (default: leave each file open) | saveAndClose (save over the source and close; for source datasets, save the open document over its own file after each data set, and refuse a document that was never saved, was converted from an older version or was restored by Data Recovery, unless a recorded Save or Save As step writes a file first; a Save or Save As step that overrideSave points into destinationFolder makes each data set's file the document's own) | folder (save or export into destinationFolder and close), destinationFolder? (required when destination is folder; also the folder Override Save/Export write into), datasetFileNaming?: fileNumber | fileDataSetName (default) | dataSetName (used only for source datasets; ignored for folder), overrideOpen?: true (skip document.open / file.open steps: the batch opens each source file), overrideSave?: true (point document.save / file.save / file.saveAs at destinationFolder/{stem}.{ext}), overrideExport?: true (point document.export / document.exportSelection the same way, and give document.exportForScreens / assets.export the folder destinationFolder/{stem}, one for each source file or data set, in which the export names its files as it does outside Batch), stopOnError?: true, label?} play the commands on every readable file in folder (and its subfolders when includeSubdirs; {stem} is the file's name without its extension and without trailing periods and spaces, with `-2`, `-3`… added to a name an earlier file used or whose file or folder has the name of one an earlier file wrote or of another source file or a folder of source files in destinationFolder), or on every data set of the open document. Data set names use the document stem plus a three-digit ordinal, the document stem and an underscore plus the data set name, or the data set name alone. Invalid file name characters become `-` and trailing periods and spaces are dropped; a name already used in the batch or whose output file or folder already exists in a destination folder the batch may read and write gets the next free `-2`, `-3` suffix before the format-derived extension. Caps: 500 files or data sets, 8 folder levels, 256 steps. Batches cannot nest, and a prefs.import step is refused (commands[i], from 0) before any file is opened. A switch (includeSubdirs, overrideOpen, overrideSave, overrideExport, stopOnError) that is not true or false, or a source, folder, destination, destinationFolder, datasetFileNaming or label that is not a string, is an error before any folder is made or file opened; null reads as left out. A step that fails is named in the error by its place in commands, from 1, counting the Open steps the batch skips (action step 3 (`object.align`) failed: …); the batch's own opening of a file, choosing of a data set and destination save, export or close give their errors without a step number. → {processed: [{path|dataset, result|error}…], count, failed, stopped, warning?} (warning: for source datasets, when Save and Close without such a step, or a Save, Save a Copy, Save as Template or export step (document.export, exportSelection, exportForScreens, exportPdf, exportEps, exportDxf, exportForWeb, exportForOffice) that writes a file and is not pointed into destinationFolder, saves every data set over the same file)", always, action_batch::action_batch ), diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..9cfd42b7f2 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5742,7 +5742,12 @@ files or data sets, 8 folder levels, 256 steps. `action.batch` refuses `includeS `` `stopOnError` must be true or false ``, and `source`, `folder`, `destination`, `destinationFolder`, `datasetFileNaming` or `label` given as anything but a string with `` `label` must be a string ``, naming the key. It checks them, and that `source` is `folder` or `datasets`, before it makes the destination folder or opens a file. -A null is read as a key left out. An action recorded in the Actions panel leaves the artboard out, +A null is read as a key left out. When a step fails on a file or data set, that row's `error` names the step by its +place in the `commands` sent, from 1, counting the Open steps the batch skips: with `commands` of an Open, an Unlock +All and an Align, a failed Align gives `` action step 3 (`object.align`) failed: `` and the reason. The batch's own +opening of a source file, choosing of a data set and destination save, export or close give their errors without a +step number. This numbering is VectorCraft's own rule. A `prefs.import` step is refused before any file is opened, +with `` commands[1]: `prefs.import` runs on its own, not as a batch step `` (counted from 0, as for an unknown command). An action recorded in the Actions panel leaves the artboard out, and its steps of these commands get the artboard that is active when the action plays. A press with the Selection, Direct Selection or Group Selection tool inside an artboard makes that artboard the active one; with the Selection tool, a Shift-click on an empty spot inside an artboard makes it active and keeps the selection. Choosing the Artboard diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..d1009e3578 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -762,6 +762,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Variables: Lock Variables (`variable.lock`, in the Variables panel's bottom bar and menu) stops variables from being defined, deleted or renamed until they are unlocked, while objects can still be bound and unbound and data sets still change and apply; the lock is saved with the document. - Batch…: Override Save and Override Export name each file with the extension of the format the step writes, however the step spells the format (`.svg` and `SVG` give `.svg`, `png8` gives `.png`), in `action.batch`. - Batch…: Override Export writes the files of an Export for Screens or Export Assets step into a folder for each source file or data set inside the destination folder, under the names the export gives them (`action.batch`). The folder and file names drop trailing periods and spaces (`a..svg` gives `a`). When two source files would get the same name that way (compared without case), or a later file's folder or file would take the name of an output an earlier file wrote, of a source file in the destination folder or, for data sets, of a file already there, Batch adds `-2`, `-3`… to the later one's name. + - Batch…: when a step fails on a file or data set, the error names the step by its place in the action's steps, from 1, counting the Open steps the batch skips (`action.batch`). This numbering is VectorCraft's own rule. Tests `cmd::fileio::action_batch::tests::{a_folder_batch_error_names_the_step_in_the_commands_sent, a_recorded_open_that_fails_is_the_first_step, a_data_set_batch_error_names_the_step_in_the_commands_sent, a_redirected_export_that_fails_keeps_its_place, a_source_that_does_not_open_names_no_step}`. - Actions panel menu: Save Actions… writes the current action set with all its actions to a file, and Load Actions… adds the set from such a file to the panel ([Manage a set of actions](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/manage-a-set-of-actions.html); `ui.actionSet.save`, `ui.actionSet.load`). The file is VectorCraft's own action set file (`.vcactions`); a loaded set named like one in the panel gets the next free number. - Actions panel menu: Save Actions… does not write a set with a step that sets a folder preference (the Fonts, Plug-ins, Templates and Recovery folders and the two scratch disks) to a folder, and names the action and the preference instead; an empty folder and the scratch disk choices Startup and None save. Export Preferences leaves out both scratch disks, and `ui.inspect` under automation read roots leaves such a folder outside them out of recorded steps. These are VectorCraft's own rules (`ui.actionSet.save`, `prefs.export`). - Actions panel menu: Load Actions… also reads action sets saved as `.aia` files ([Actions panel overview](https://helpx.adobe.com/illustrator/desktop/automate-visualize-data/automate-actions/actions-panel-overview.html); `actionSet.read`, `ui.actionSet.load`). VectorCraft's own rules: the set comes in with all its actions. A step with a label and no recorded values comes in as the one menu command with the step's label, when that command is directly in a top menu, is what its menu bar item runs with no values and opens no dialog. A step that is off in the file stays excluded from playback. The other steps, recorded menu items included, are left out, and the status bar says how many. From 5750843d731de8366c74a7ff584451940cc6bff0 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 20:45:08 -0800 Subject: [PATCH 034/108] Links: placed images in stored brush art get Links rows Linked images and placed documents in the art of the stored brushes (a scatter or art brush's art, a pattern brush's tiles) are listed in the Links panel after the other stored art, one row per linked or placed object in each brush tile, with the brush as owner (`{kind: brush, name, index, tile?}`). Check Links, the missing and modified files reported on open, the link watch, Find in Folder, Relink (including Relink All Instances), Update, Embed, Placement Options, Link Info and Go To act on them, and their tooltip names the brush. - vectorcraft-doc: `Document::mounted_art` holds art kept outside the document's trees while a command looks it up by id; the stored-art lookups, link visitors and `art_roots` include it, and `number_mounted_art` gives its objects ids of their own. - vectorcraft-brush: `stored_art::StoredArt` mounts the art of the brushes that hold images or placed documents and writes back only the entries whose art changed. Entries that do not read as a brush are left as stored. `brush::store` keeps ids of their own in that art, so a row keeps its id between commands. - vectorcraft-engine: the links commands, opening a document, saving a placed document's source, output of linked files and placed documents, color masks after Update or Relink, and Package relinking go through the mounted art. Brush art rows follow the general Links rule as VectorCraft's own application of it. --- crates/brush/src/lib.rs | 9 +- crates/brush/src/stored_art.rs | 176 ++++++++++++++++ crates/brush/src/tests.rs | 153 ++++++++++++++ crates/doc/src/document.rs | 2 + crates/doc/src/document_ext.rs | 6 +- crates/doc/src/lib.rs | 6 + crates/doc/src/links.rs | 14 +- crates/doc/src/placed_document.rs | 5 +- crates/doc/src/stored_art.rs | 62 +++++- crates/engine/src/cmd/addons/image/mask.rs | 3 +- crates/engine/src/cmd/linkfiles.rs | 5 +- crates/engine/src/cmd/links.rs | 222 ++++++++++++++------- crates/engine/src/cmd/package.rs | 26 ++- crates/engine/src/cmd/place.rs | 6 +- crates/engine/src/cmd/place/document.rs | 7 +- crates/engine/src/tests/links.rs | 217 ++++++++++++++++++++ crates/engine/src/tests/package.rs | 32 +++ crates/engine/src/tests/placed_document.rs | 51 +++++ crates/ui-egui/src/panels/links.rs | 5 +- crates/ui-egui/src/panels/tests_links.rs | 1 + docs/mcp.md | 18 +- docs/target-app-parity.md | 1 + 22 files changed, 916 insertions(+), 111 deletions(-) create mode 100644 crates/brush/src/stored_art.rs diff --git a/crates/brush/src/lib.rs b/crates/brush/src/lib.rs index 080462d0b6..0d8236f183 100644 --- a/crates/brush/src/lib.rs +++ b/crates/brush/src/lib.rs @@ -13,6 +13,7 @@ mod calli; mod colorize; mod defaults; +pub mod stored_art; pub mod track; mod warp; @@ -798,9 +799,15 @@ fn number_repeated_names(lib: &mut [Brush]) { } } -/// Store `lib` as the document's brush library. +/// Store `lib` as the document's brush library. When the art of a brush holds images or placed +/// documents, each object in that art whose id is 0 or repeats another object's is given a new +/// id ([`stored_art::StoredArt::persist_ids`]), so the Links panel lists it by the same id until it +/// changes. pub fn store(doc: &mut Document, lib: &[Brush]) { doc.unknown.insert(DOC_KEY.into(), serde_json::to_value(lib).unwrap_or_default()); + if lib.iter().any(|b| b.art().into_iter().any(stored_art::holds_files)) { + stored_art::StoredArt::persist_ids(doc); + } } /// Find a brush by name. diff --git a/crates/brush/src/stored_art.rs b/crates/brush/src/stored_art.rs new file mode 100644 index 0000000000..a386e2e181 --- /dev/null +++ b/crates/brush/src/stored_art.rs @@ -0,0 +1,176 @@ +//! The art of the stored brushes (a scatter or art brush's art, a pattern brush's tiles) as stored +//! art of the document ([`Document::mounted_art`]): set on the document while a command looks it up +//! by id or changes it, then written back into the library entries whose art changed. The Links +//! panel finds the images and placed documents in that art this way. + +use std::sync::Arc; + +use serde_json::{Value, json}; +use vectorcraft_doc::{Document, Node, NodeKind}; + +use crate::{Brush, BrushKind, DOC_KEY}; + +/// The brushes of a document's stored library whose art holds images or placed documents. +#[derive(Default)] +pub struct StoredArt { + entries: Vec<Entry>, + /// How many entries the stored library had when it was read. + read_entries: usize, +} + +/// A library entry whose brush's art holds images or placed documents. +struct Entry { + /// Its index in the stored library. + slot: usize, + /// The entry as it was read. + raw: Value, + brush: Brush, + /// The brush's art ([`Brush::art`]), each root with the `owner` the Links panel names for it. + art: Vec<(Arc<Node>, Value)>, +} + +/// What names each root of [`Brush::art`] among the brush's art: a pattern brush's tile, in the +/// same order; nothing for the one root of a scatter or art brush. +fn tiles(b: &Brush) -> Vec<Option<&'static str>> { + match &b.kind { + BrushKind::Pattern(p) => std::iter::once(Some("side")) + .chain( + [ + (p.outer_corner.is_some(), "outerCorner"), + (p.inner_corner.is_some(), "innerCorner"), + (p.start.is_some(), "start"), + (p.end.is_some(), "end"), + ] + .into_iter() + .filter(|(held, _)| *held) + .map(|(_, tile)| Some(tile)), + ) + .collect(), + _ => vec![None], + } +} + +/// Whether `n` or its subtree, opacity-mask art included, holds an image or a placed document. +pub(crate) fn holds_files(n: &Node) -> bool { + let mut found = false; + vectorcraft_doc::swatches::walk_with_masks(n, &mut |c| found |= matches!(c.kind, NodeKind::Image(_) | NodeKind::PlacedDocument(_))); + found +} + +impl StoredArt { + /// The brushes of `doc`'s stored library whose art holds an image or a placed document (opacity + /// masks included). An entry that does not read as a brush is left out, and so is left as it + /// is. A root's owner is + /// `{kind: "brush", name, index, tile?}`, with the name and index the brush has in the library as + /// the Brushes panel lists it ([`crate::library`], a repeated name numbered). + pub fn read(doc: &Document) -> Self { + let Some(stored) = doc.unknown.get(DOC_KEY) else { return Self::default() }; + let Some(list) = stored.as_array() else { return Self::default() }; + let listed = crate::parse_library(stored); + let parsed = list.iter().enumerate().filter_map(|(slot, raw)| Brush::from_json(raw.clone()).ok().map(|b| (slot, raw, b))); + let mut entries = vec![]; + for (index, (slot, raw, brush)) in parsed.enumerate() { + if !brush.art().into_iter().any(holds_files) { + continue; + } + let name = listed.get(index).map_or(brush.name.as_str(), |b| b.name.as_str()); + let art: Vec<(Arc<Node>, Value)> = brush + .art() + .into_iter() + .zip(tiles(&brush)) + .map(|(n, tile)| { + let mut owner = json!({ "kind": "brush", "name": name, "index": index }); + if let Some(tile) = tile { + owner["tile"] = json!(tile); + } + (Arc::new(n.clone()), owner) + }) + .collect(); + if !art.is_empty() { + entries.push(Entry { slot, raw: raw.clone(), brush, art }); + } + } + Self { entries, read_entries: list.len() } + } + + /// Gives the objects of the stored brushes' art that holds images or placed documents ids of + /// their own in `doc`'s library, as [`Self::mount`] gives them, and writes the brushes whose + /// ids changed back. Does nothing while art is set on `doc` ([`Document::mounted_art`]). + pub fn persist_ids(doc: &mut Document) { + if !doc.mounted_art.is_empty() { + return; + } + let art = Self::read(doc); + if !art.is_empty() { + art.mount(doc); + art.write_entries(doc); + } + } + + /// No stored brush's art holds an image or a placed document. + pub fn is_empty(&self) -> bool { + self.entries.is_empty() + } + + /// Sets the art on `doc` as [`Document::mounted_art`], each object with an id of its own + /// ([`Document::number_mounted_art`]: an id another stored object has, or none, is replaced, and + /// the id counter stands above them all). + pub fn mount(&self, doc: &mut Document) { + doc.mounted_art = self.entries.iter().flat_map(|e| e.art.iter().cloned()).collect(); + doc.number_mounted_art(); + } + + /// Takes [`Document::mounted_art`] off `doc` and writes each brush whose art changed (new ids + /// included) back into its library entry: the entry at its index when that entry is as it was + /// read or reads as the brush as it was apart from its name, else the first entry that reads as + /// the brush as it was, else the first that does apart from its name. An entry found apart from + /// its name keeps that name (the library was written again meanwhile, as placing a document's + /// brushes into it does, numbering a repeated name). The other entries are left as + /// they are. Then the art of brushes added meanwhile gets ids of its own + /// ([`Self::persist_ids`]). + pub fn write_back(self, doc: &mut Document) { + let read_entries = self.read_entries; + self.write_entries(doc); + if doc.unknown.get(DOC_KEY).and_then(Value::as_array).map(Vec::len) != Some(read_entries) { + Self::persist_ids(doc); + } + } + + /// [`Self::write_back`] without giving ids to the art of brushes added meanwhile. + fn write_entries(self, doc: &mut Document) { + let mut mounted = std::mem::take(&mut doc.mounted_art).into_iter(); + let mut changed = vec![]; + for e in self.entries { + let now: Vec<Arc<Node>> = mounted.by_ref().take(e.art.len()).map(|(n, _)| n).collect(); + if now.len() != e.art.len() || now.iter().zip(&e.art).all(|(a, (b, _))| Arc::ptr_eq(a, b)) { + continue; + } + let mut brush = e.brush.clone(); + for (slot, art) in brush.art_mut().into_iter().zip(now) { + *slot = Arc::unwrap_or_clone(art); + } + changed.push((e.slot, e.raw, e.brush, brush)); + } + let Some(list) = doc.unknown.get_mut(DOC_KEY).and_then(Value::as_array_mut) else { return }; + for (slot, raw, was, mut brush) in changed { + // The entry's name when it reads as `was` apart from its name. + let name_of = |entry: &Value| { + Brush::from_json(entry.clone()).ok().and_then(|mut b| { + let name = std::mem::replace(&mut b.name, was.name.clone()); + (b == was).then_some(name) + }) + }; + let at = match list.get(slot) { + Some(entry) if *entry == raw || name_of(entry).is_some() => Some(slot), + _ => list.iter().position(|e| name_of(e).as_ref() == Some(&was.name)).or_else(|| list.iter().position(|e| name_of(e).is_some())), + }; + let Some(entry) = at.and_then(|i| list.get_mut(i)) else { continue }; + if let Some(name) = name_of(entry) { + brush.name = name; + } + if let Ok(v) = serde_json::to_value(&brush) { + *entry = v; + } + } + } +} diff --git a/crates/brush/src/tests.rs b/crates/brush/src/tests.rs index 2d62a1a993..4484b97c19 100644 --- a/crates/brush/src/tests.rs +++ b/crates/brush/src/tests.rs @@ -973,6 +973,159 @@ fn repeated_brush_names_are_numbered_when_read() { assert_eq!(names.iter().collect::<std::collections::HashSet<_>>().len(), names.len()); } +/// Art of `w`×`h` points holding a linked image: a group of [`rect_art`] and the image, both with id 0. +fn linked_art(w: f64, h: f64) -> Node { + let image = Node::new( + NodeId(0), + NodeKind::Image(Box::new(vectorcraft_doc::ImageObject { + key: "k".into(), + width: 4, + height: 4, + xf: Affine::IDENTITY, + link: Some(vectorcraft_doc::LinkInfo::new("/art/a.png")), + placement: Default::default(), + pixels: None, + })), + ); + Node::group(NodeId(0), vec![std::sync::Arc::new(rect_art(w, h)), std::sync::Arc::new(image)]) +} + +/// The art of the stored brushes that holds images mounts on the document as stored art, each tile +/// with the brush, its place in the library and the tile as owner, its objects with ids of their +/// own; writing it back changes only the entries whose art changed, and leaves an entry that does +/// not read as a brush, a brush without art and a brush whose art holds no image as they were stored. +#[test] +fn stored_brush_art_mounts_and_writes_back_only_what_changed() { + use stored_art::StoredArt; + let mut d = Document::new(100.0, 100.0); + let layer_object = d.layers[0].id; + let mut side = linked_art(10.0, 4.0); + side.id = layer_object; + let pattern = + Brush { name: "Frame".into(), kind: BrushKind::Pattern(PatternBrush { side, start: Some(linked_art(4.0, 4.0)), ..Default::default() }) }; + let scatter = Brush { + name: "Dots".into(), + kind: BrushKind::Scatter(Scatter { art: linked_art(2.0, 2.0), colorization: Colorization::None, ..Default::default() }), + }; + // Written as a file holds it, without the ids `store` gives. + let lib = [calli(0.0, 100.0, 3.0), pattern, scatter, art_brush(rect_art(10.0, 4.0), ArtScale::Stretch)]; + d.unknown.insert(DOC_KEY.into(), serde_json::to_value(lib).unwrap()); + let odd = serde_json::json!({ "name": "Odd", "type": "unknown" }); + if let Some(list) = d.unknown.get_mut(DOC_KEY).and_then(serde_json::Value::as_array_mut) { + list.insert(1, odd.clone()); + } + let stored = d.unknown[DOC_KEY].clone(); + let art = StoredArt::read(&d); + art.mount(&mut d); + let owners: Vec<&serde_json::Value> = d.mounted_art.iter().map(|(_, o)| o).collect(); + assert_eq!( + owners, + [ + &serde_json::json!({ "kind": "brush", "name": "Frame", "index": 1, "tile": "side" }), + &serde_json::json!({ "kind": "brush", "name": "Frame", "index": 1, "tile": "start" }), + &serde_json::json!({ "kind": "brush", "name": "Dots", "index": 2 }), + ] + ); + let ids: Vec<NodeId> = d.mounted_art.iter().map(|(n, _)| n.id).collect(); + let mut all = vec![]; + d.visit_stored(|n, _| all.push(n.id)); + assert!(all.iter().all(|id| id.0 != 0) && !all[1..].contains(&layer_object), "{all:?}"); + assert_eq!(all.iter().collect::<std::collections::HashSet<_>>().len(), all.len(), "{all:?}"); + // The scatter brush's art changes; the pattern brush's tiles keep the ids mounting gave them. + d.stored_node_mut(ids[2]).unwrap().name = Some("changed".into()); + art.write_back(&mut d); + assert!(d.mounted_art.is_empty()); + let now = d.unknown[DOC_KEY].as_array().unwrap(); + assert_eq!(now.len(), 5); + assert_eq!((&now[0], &now[1], &now[4]), (&stored[0], &odd, &stored[4]), "the entries without images stay as stored"); + assert_ne!(now[2], stored[2], "the pattern brush keeps the ids its art was given"); + let lib = library(&d); + let Some(BrushKind::Pattern(p)) = lib.iter().find(|b| b.name == "Frame").map(|b| &b.kind) else { panic!("no pattern brush") }; + assert_eq!((p.side.id, p.start.as_ref().map(|n| n.id)), (ids[0], Some(ids[1]))); + assert_eq!(find(&d, "Dots").unwrap().art()[0].name.as_deref(), Some("changed")); + // Mounting again gives the same ids and changes nothing, so writing back leaves the library as it is. + let again = d.unknown[DOC_KEY].clone(); + let art = StoredArt::read(&d); + art.mount(&mut d); + assert_eq!(d.mounted_art.iter().map(|(n, _)| n.id).collect::<Vec<_>>(), ids); + art.write_back(&mut d); + assert_eq!(d.unknown[DOC_KEY], again); +} + +/// A brush whose stored name repeats an earlier brush's is named in its art's owner as the Brushes +/// panel lists it, numbered. +#[test] +fn stored_brush_art_owner_names_a_repeated_name_as_listed() { + use stored_art::StoredArt; + let mut d = Document::new(100.0, 100.0); + let scatter = Brush { name: "Dots".into(), kind: BrushKind::Scatter(Scatter { art: linked_art(2.0, 2.0), ..Default::default() }) }; + store(&mut d, &[scatter.clone(), scatter]); + StoredArt::read(&d).mount(&mut d); + let names: Vec<&serde_json::Value> = d.mounted_art.iter().map(|(_, o)| &o["name"]).collect(); + assert_eq!(names, ["Dots", "Dots 2"]); +} + +/// Storing a library whose brush art holds an image gives that art ids of its own, so mounting it +/// later gives the same ids whatever the document allocated in between; art without images keeps +/// the ids it was stored with. +#[test] +fn storing_brush_art_with_images_keeps_ids_of_its_own() { + use stored_art::StoredArt; + let mut d = Document::new(100.0, 100.0); + let mut art = linked_art(2.0, 2.0); + art.id = d.layers[0].id; + let scatter = Brush { name: "Dots".into(), kind: BrushKind::Scatter(Scatter { art, ..Default::default() }) }; + store(&mut d, &[scatter, art_brush(rect_art(10.0, 4.0), ArtScale::Stretch)]); + let lib = library(&d); + let stored = lib[0].art()[0].id; + assert_ne!(stored, d.layers[0].id); + assert_eq!(lib[1].art()[0].id, NodeId(0), "art without images is stored as it was"); + d.alloc_id(); + StoredArt::read(&d).mount(&mut d); + assert_eq!(d.mounted_art[0].0.id, stored); +} + +/// When the library is written again while the art is mounted, numbering a repeated name and +/// adding a brush (as placing a document's brushes into it does), writing back changes the entry +/// at its own place that reads as the brush apart from its new name, keeping that name, even when +/// an earlier brush is the same as the one it was, and gives the added brush's art ids of its own. +#[test] +fn brush_art_written_back_finds_its_renamed_entry_and_numbers_added_art() { + use stored_art::StoredArt; + /// `n` with ids from `next` on, in paint order. + fn numbered(mut n: Node, next: &mut u64) -> Node { + n.id = NodeId(*next); + *next += 1; + for c in n.children_mut().into_iter().flatten() { + *c = std::sync::Arc::new(numbered((**c).clone(), next)); + } + n + } + let mut d = Document::new(100.0, 100.0); + let scatter = + |n: &str| Brush { name: n.into(), kind: BrushKind::Scatter(Scatter { art: numbered(linked_art(2.0, 2.0), &mut 50), ..Default::default() }) }; + // Two brushes the same apart from the ids mounting gives the second. + d.unknown.insert(DOC_KEY.into(), serde_json::to_value([scatter("Dots"), scatter("Dots")]).unwrap()); + let art = StoredArt::read(&d); + art.mount(&mut d); + assert_eq!(d.mounted_art[0].0.id, NodeId(50)); + let second = d.mounted_art[1].0.id; + // The library is written again: the repeated name numbered, a brush whose art repeats an id added. + let mut added = scatter("New"); + if let BrushKind::Scatter(s) = &mut added.kind { + s.art.id = d.layers[0].id; + } + let lib = [library(&d), vec![added]].concat(); + d.unknown.insert(DOC_KEY.into(), serde_json::to_value(&lib).unwrap()); + assert_eq!(lib[1].name, "Dots 2"); + d.stored_node_mut(second).unwrap().name = Some("changed".into()); + art.write_back(&mut d); + let lib = library(&d); + assert_eq!(lib.iter().map(|b| b.name.as_str()).collect::<Vec<_>>(), ["Dots", "Dots 2", "New"]); + assert_eq!((lib[0].art()[0].name.as_deref(), lib[1].art()[0].name.as_deref()), (None, Some("changed"))); + assert_ne!(lib[2].art()[0].id, d.layers[0].id, "the added brush's art has ids of its own"); +} + #[test] fn brushes_serde_round_trip() { let lib = defaults().to_vec(); diff --git a/crates/doc/src/document.rs b/crates/doc/src/document.rs index 418e454b92..54130788e1 100644 --- a/crates/doc/src/document.rs +++ b/crates/doc/src/document.rs @@ -79,6 +79,7 @@ impl Document { index: _, guide_cache: _, inline_cycles: _, + mounted_art: _, } = self; *version == other.version && *title == other.title @@ -264,6 +265,7 @@ impl Document { index: Default::default(), guide_cache: Default::default(), inline_cycles: Default::default(), + mounted_art: vec![], }; let id = d.alloc_id(); d.layers.push(Arc::new(Node::layer(id, "Layer 1", LayerColor::Preset(0)))); diff --git a/crates/doc/src/document_ext.rs b/crates/doc/src/document_ext.rs index 0f1ec463c4..c29e8464ea 100644 --- a/crates/doc/src/document_ext.rs +++ b/crates/doc/src/document_ext.rs @@ -128,8 +128,8 @@ impl Document { } /// The roots of every tree of the document's art: the layers, symbol definitions, graph designs, - /// pattern swatches and the original of the pattern being edited. Opacity masks hang off nodes - /// in these trees. + /// pattern swatches, the original of the pattern being edited and [`Self::mounted_art`]. + /// Opacity masks hang off nodes in these trees. pub fn art_roots(&self) -> impl Iterator<Item = &Arc<Node>> { self.layers .iter() @@ -137,6 +137,7 @@ impl Document { .chain(self.graph_designs.iter().map(|g| &g.art)) .chain(self.patterns.iter().flat_map(|p| p.art.iter())) .chain(self.pattern_edit.iter().filter_map(|pe| pe.original.as_ref()).flat_map(|p| p.art.iter())) + .chain(self.mounted_art.iter().map(|(n, _)| n)) } /// [`Self::art_roots`], to change. @@ -147,6 +148,7 @@ impl Document { .chain(self.graph_designs.iter_mut().map(|g| &mut g.art)) .chain(self.patterns.iter_mut().flat_map(|p| p.art.iter_mut())) .chain(self.pattern_edit.iter_mut().filter_map(|pe| pe.original.as_mut()).flat_map(|p| p.art.iter_mut())) + .chain(self.mounted_art.iter_mut().map(|(n, _)| n)) } /// Does `wants` hold for a node anywhere in the document's art ([`Self::art_roots`]) or its diff --git a/crates/doc/src/lib.rs b/crates/doc/src/lib.rs index c51e099840..cb78d96ba9 100644 --- a/crates/doc/src/lib.rs +++ b/crates/doc/src/lib.rs @@ -367,6 +367,12 @@ pub struct Document { /// saved. #[serde(skip)] inline_cycles: inline::InlineCycles, + /// Art kept elsewhere in the document's data (the art of the stored brushes, which + /// `vectorcraft-brush` reads from [`Self::unknown`]) while it is set here, each root with the + /// `owner` the Links panel names for it, so the stored-art lookups ([`StoredRoot::Mounted`]) + /// find its objects too. Empty otherwise; never saved. + #[serde(skip)] + pub mounted_art: Vec<(Arc<Node>, serde_json::Value)>, } fn ppi72() -> f64 { diff --git a/crates/doc/src/links.rs b/crates/doc/src/links.rs index ffa9eac0cd..b2f46700eb 100644 --- a/crates/doc/src/links.rs +++ b/crates/doc/src/links.rs @@ -248,14 +248,15 @@ fn walk_all<'a>(n: &'a Node, f: &mut impl FnMut(&'a Node)) { impl Document { /// Visit every image object: in the layers, then in symbol definitions and pattern swatches, - /// opacity-mask art included. + /// then in [`Document::mounted_art`], opacity-mask art included. pub fn visit_images<'a>(&'a self, mut f: impl FnMut(&'a Node, &'a ImageObject)) { let roots = self .layers .iter() .chain(self.symbols.iter().map(|s| &s.art)) .chain(self.graph_designs.iter().map(|g| &g.art)) - .chain(self.patterns.iter().flat_map(|p| &p.art)); + .chain(self.patterns.iter().flat_map(|p| &p.art)) + .chain(self.mounted_art.iter().map(|(n, _)| n)); for root in roots { walk_all(root, &mut |n| { if let NodeKind::Image(im) = &n.kind { @@ -384,7 +385,8 @@ impl Align { impl Document { /// Rewrite linked file locations in both raster images and placed VectorCraft documents, - /// including those inside symbols, patterns and opacity masks. Used to make packages portable. + /// including those inside symbols, patterns, opacity masks and [`Document::mounted_art`]. Used to + /// make packages portable. pub fn update_links(&mut self, mut f: impl FnMut(&mut LinkInfo)) { fn walk(n: &mut Arc<Node>, f: &mut dyn FnMut(&mut LinkInfo)) { let n = Arc::make_mut(n); @@ -409,7 +411,8 @@ impl Document { .iter_mut() .chain(self.symbols.iter_mut().map(|s| &mut s.art)) .chain(self.graph_designs.iter_mut().map(|g| &mut g.art)) - .chain(self.patterns.iter_mut().flat_map(|p| &mut p.art)); + .chain(self.patterns.iter_mut().flat_map(|p| &mut p.art)) + .chain(self.mounted_art.iter_mut().map(|(n, _)| n)); for root in roots { walk(root, &mut f); } @@ -471,7 +474,8 @@ impl Document { .iter_mut() .chain(self.symbols.iter_mut().map(|s| &mut s.art)) .chain(self.graph_designs.iter_mut().map(|g| &mut g.art)) - .chain(self.patterns.iter_mut().flat_map(|p| &mut p.art)); + .chain(self.patterns.iter_mut().flat_map(|p| &mut p.art)) + .chain(self.mounted_art.iter_mut().map(|(n, _)| n)); for root in roots { update(root, &pick, &mut f); } diff --git a/crates/doc/src/placed_document.rs b/crates/doc/src/placed_document.rs index 86f7f6134c..cd423658d7 100644 --- a/crates/doc/src/placed_document.rs +++ b/crates/doc/src/placed_document.rs @@ -166,13 +166,15 @@ fn walk_all<'a>(n: &'a Node, f: &mut impl FnMut(&'a Node)) { } } -/// The roots of `d`'s art: layers, symbol definitions and pattern swatches. +/// The roots of `d`'s art: layers, symbol definitions, pattern swatches and +/// [`Document::mounted_art`]. fn roots(d: &Document) -> impl Iterator<Item = &Arc<Node>> { d.layers .iter() .chain(d.symbols.iter().map(|s| &s.art)) .chain(d.graph_designs.iter().map(|g| &g.art)) .chain(d.patterns.iter().flat_map(|p| &p.art)) + .chain(d.mounted_art.iter().map(|(n, _)| n)) } fn roots_mut(d: &mut Document) -> impl Iterator<Item = &mut Arc<Node>> { @@ -181,6 +183,7 @@ fn roots_mut(d: &mut Document) -> impl Iterator<Item = &mut Arc<Node>> { .chain(d.symbols.iter_mut().map(|s| &mut s.art)) .chain(d.graph_designs.iter_mut().map(|g| &mut g.art)) .chain(d.patterns.iter_mut().flat_map(|p| &mut p.art)) + .chain(d.mounted_art.iter_mut().map(|(n, _)| n)) } impl Document { diff --git a/crates/doc/src/stored_art.rs b/crates/doc/src/stored_art.rs index e623e0ed0e..cc0832b733 100644 --- a/crates/doc/src/stored_art.rs +++ b/crates/doc/src/stored_art.rs @@ -20,6 +20,8 @@ pub enum StoredRoot { GraphDesign(usize), /// Object `art` of pattern swatch `pattern` of [`Document::patterns`]. Pattern { pattern: usize, art: usize }, + /// Root `index` of [`Document::mounted_art`]. + Mounted(usize), } /// Where a stored object is: its root and, inside opacity-mask art, the object that mask belongs @@ -170,10 +172,12 @@ impl Document { .iter() .enumerate() .flat_map(|(p, def)| def.art.iter().enumerate().map(move |(a, n)| (n, StoredRoot::Pattern { pattern: p, art: a }))); - symbols.chain(designs).chain(patterns) + let mounted = self.mounted_art.iter().enumerate().map(|(i, (n, _))| (n, StoredRoot::Mounted(i))); + symbols.chain(designs).chain(patterns).chain(mounted) } - /// Every root of stored art: the layers, then the art of symbols, graph designs and patterns. + /// Every root of stored art: the layers, then the art of symbols, graph designs and patterns, + /// then [`Document::mounted_art`]. fn stored_roots(&self) -> impl Iterator<Item = (&Arc<Node>, StoredRoot)> { self.layers.iter().enumerate().map(|(i, l)| (l, StoredRoot::Layer(i))).chain(self.definition_roots()) } @@ -185,12 +189,13 @@ impl Document { StoredRoot::Symbol(i) => self.symbols.get_mut(i).map(|s| &mut s.art), StoredRoot::GraphDesign(i) => self.graph_designs.get_mut(i).map(|g| &mut g.art), StoredRoot::Pattern { pattern, art } => self.patterns.get_mut(pattern)?.art.get_mut(art), + StoredRoot::Mounted(i) => self.mounted_art.get_mut(i).map(|(n, _)| n), } } /// Visit every stored object with its place: the layer tree with the opacity-mask art of its /// objects, then the art of symbols, graph designs and pattern swatches (their definitions, - /// once each, never the copies instances and tiles draw). + /// once each, never the copies instances and tiles draw), then [`Document::mounted_art`]. pub fn visit_stored<'a>(&'a self, mut f: impl FnMut(&'a Node, StoredPlace)) { self.visit_stored_arcs(|n, place| f(n, place)); } @@ -238,6 +243,29 @@ impl Document { /// visited before them (the layer tree's own objects first) a new id, so every stored object /// can be named by its id. Returns how many changed; the id counter then stands above them. pub(crate) fn renumber_stored_duplicates(&mut self) -> usize { + self.renumber_duplicates_in(|_| true) + } + + /// Raises the id counter above the ids of [`Document::mounted_art`]'s objects, then gives those + /// objects whose id is 0, past the id range, or already taken by an object visited before them + /// (every other stored object first) a new id, as [`Self::renumber_stored_duplicates`] gives + /// them. Returns how many changed. + pub fn number_mounted_art(&mut self) -> usize { + let mut max = 0; + for (i, (root, _)) in self.mounted_art.iter().enumerate() { + visit(root, StoredPlace { root: StoredRoot::Mounted(i), mask_of: None }, &mut |n, _| { + if n.id.0 < MAX_NEXT_ID { + max = max.max(n.id.0); + } + }); + } + self.raise_next_id(max.saturating_add(1)); + self.renumber_duplicates_in(|r| matches!(r, StoredRoot::Mounted(_))) + } + + /// [`Self::renumber_stored_duplicates`] for the roots `pick` holds for only; the objects of the + /// others still count as taken. + fn renumber_duplicates_in(&mut self, pick: impl Fn(StoredRoot) -> bool) -> usize { let mut seen: HashSet<NodeId> = HashSet::new(); for l in &self.layers { l.walk(&mut |n| { @@ -250,9 +278,9 @@ impl Document { // Per root, the visiting indices of the nodes that take a new id. let mut fresh: Vec<(StoredRoot, HashSet<usize>)> = vec![]; for (root, r) in self.stored_roots() { - let (mut i, mut here) = (0, HashSet::new()); + let (mut i, mut here, take) = (0, HashSet::new(), pick(r)); visit(root, StoredPlace { root: r, mask_of: None }, &mut |n, place| { - if !place.in_layers() && (n.id.0 == 0 || n.id.0 >= MAX_NEXT_ID || !seen.insert(n.id)) { + if !place.in_layers() && (n.id.0 == 0 || n.id.0 >= MAX_NEXT_ID || !seen.insert(n.id)) && take { here.insert(i); } i += 1; @@ -355,6 +383,30 @@ mod tests { assert_eq!(d, again); } + /// Mounted art is found and changed by id after the other stored art, and numbering it gives + /// its objects that repeat another stored object's id, or have none, new ids above the counter, + /// leaving every other object's id and its own unique ones as they are. + #[test] + fn mounted_art_is_found_and_numbered_after_the_rest() { + let mut d = doc([12, 13, 14]); + let owner = serde_json::json!({ "kind": "brush" }); + d.mounted_art = vec![(Arc::new(masked(10, rect(0))), owner.clone()), (Arc::new(rect(15)), owner)]; + assert_eq!(d.stored_node(NodeId(15)).map(|(_, p)| p.root), Some(StoredRoot::Mounted(1))); + let before = d.clone(); + assert_eq!(d.number_mounted_art(), 2); + let mut ids = vec![]; + d.visit_stored(|n, _| ids.push(n.id.0)); + let unique: HashSet<u64> = ids.iter().copied().collect(); + assert_eq!(unique.len(), ids.len(), "{ids:?}"); + assert_eq!(&ids[..6], &[d.layers[0].id.0, 10, 11, 12, 13, 14], "the other art keeps its ids"); + assert_eq!(ids[8], 15, "a unique id is kept"); + assert!(ids.iter().all(|id| *id < d.peek_next_id()), "{ids:?} {}", d.peek_next_id()); + assert!(Arc::ptr_eq(&d.symbols[0].art, &before.symbols[0].art) && Arc::ptr_eq(&d.mounted_art[1].0, &before.mounted_art[1].0)); + d.stored_node_mut(NodeId(15)).unwrap().name = Some("changed".into()); + assert_eq!(d.mounted_art[1].0.name.as_deref(), Some("changed")); + assert_eq!(d.number_mounted_art(), 0, "a second pass changes nothing"); + } + #[test] fn renumbered_objects_on_path_keep_their_path_and_members() { // A symbol's Objects on Path group whose path repeats the layer's object 10 and whose diff --git a/crates/engine/src/cmd/addons/image/mask.rs b/crates/engine/src/cmd/addons/image/mask.rs index 786effbd2e..0dd8fabe3c 100644 --- a/crates/engine/src/cmd/addons/image/mask.rs +++ b/crates/engine/src/cmd/addons/image/mask.rs @@ -320,7 +320,8 @@ fn fresh(doc: &Document, n: &Node, cmd: &str) -> Option<Result<(ColorMask, Optio /// After an edit from `before` (`None`: everything is new, as after a document's links are read): /// the color masks of images in `doc`'s art ([`Document::art_roots`]: layers, symbols, graph -/// designs, patterns and the original of the pattern being edited, opacity mask art included) +/// designs, patterns, the original of the pattern being edited and the art of the stored brushes +/// while it is set on the document, opacity mask art included) /// whose own pixels were replaced are made again for the new pixels ([`Refresh::made`]). Only the /// art that changed since `before` is looked at. pub(crate) fn refresh(before: Option<&Document>, doc: &mut Document) { diff --git a/crates/engine/src/cmd/linkfiles.rs b/crates/engine/src/cmd/linkfiles.rs index 99295e5c79..fa8ef06856 100644 --- a/crates/engine/src/cmd/linkfiles.rs +++ b/crates/engine/src/cmd/linkfiles.rs @@ -144,9 +144,10 @@ fn find(s: &mut Session, p: &Value) -> Result<Value> { None | Some(Value::Null) => None, Some(_) => { // Images and placed documents in opacity-mask art and in the art of symbols, graph - // designs and patterns are named by their ids too (`links.list`). + // designs, patterns and stored brushes are named by their ids too (`links.list`). let ids = ids_param(p, "ids", C)?.unwrap_or_default(); - let kind = |id: &NodeId| st.doc.stored_node(*id).map(|(n, _)| &n.kind); + let doc = super::links::with_brush_art(&st.doc); + let kind = |id: &NodeId| doc.stored_node(*id).map(|(n, _)| &n.kind); if let Some(value) = ids.iter().find(|id| kind(id).is_none()).map(|id| id.0) { return Err(bad(C, format!("no such object id {value}"))); } diff --git a/crates/engine/src/cmd/links.rs b/crates/engine/src/cmd/links.rs index 3e1bc8b2ef..b5529abb2f 100644 --- a/crates/engine/src/cmd/links.rs +++ b/crates/engine/src/cmd/links.rs @@ -27,6 +27,7 @@ use std::path::{Component, Path, PathBuf}; use std::sync::Arc; use serde_json::{Value, json}; +use vectorcraft_brush::stored_art::StoredArt; use vectorcraft_doc::links::{Align, Preserve, hash_bytes}; use vectorcraft_doc::{ Appearance, DataValue, Document, ImageBlob, ImageObject, LinkInfo, Node, NodeId, NodeKind, PageBox, PlacedDocument, PlacementOptions, @@ -44,7 +45,7 @@ pub fn specs() -> Vec<CommandSpec> { "Check Links", [], None, - "{ids?: [image or placed document ids] (default: every linked image and placed document, in the layers and in opacity-mask art, symbols, graph designs and patterns)} where each linked file is and whether it changed since it was read → {links: [{name, path?, status: ok|modified|missing, ids, found?: path (found away from its path: relative to the document, or by name in its folder), preview: true (showing the low-resolution preview, not the file), refused?: why the path is not followed (another computer, a device or a URL: it counts as missing)}], missing, modified}; under automation read roots, path and found are left out when the file they name is outside the roots", + "{ids?: [image or placed document ids] (default: every linked image and placed document, in the layers and in opacity-mask art, symbols, graph designs, patterns and the art of stored brushes)} where each linked file is and whether it changed since it was read → {links: [{name, path?, status: ok|modified|missing, ids, found?: path (found away from its path: relative to the document, or by name in its folder), preview: true (showing the low-resolution preview, not the file), refused?: why the path is not followed (another computer, a device or a URL: it counts as missing)}], missing, modified}; under automation read roots, path and found are left out when the file they name is outside the roots", has_doc, check ), @@ -53,7 +54,7 @@ pub fn specs() -> Vec<CommandSpec> { "Update Links", [], None, - "{ids?: [image or placed document ids] (default: the linked images whose file was modified or is showing its preview, and placed documents whose file was modified)} read their linked files again; each keeps its bounds. Images and placed documents inside symbols, graph designs, patterns and opacity masks have ids of their own, as links.list gives them; those that show the same content as one read again are read again too. One undo step → {updated: [ids], missing: [ids], warnings?: [a DCS file's spot plate whose ink a swatch of the document already names, as file.place warns]}", + "{ids?: [image or placed document ids] (default: the linked images whose file was modified or is showing its preview, and placed documents whose file was modified)} read their linked files again; each keeps its bounds. Images and placed documents inside symbols, graph designs, patterns, opacity masks and the art of stored brushes have ids of their own, as links.list gives them; those that show the same content as one read again are read again too. One undo step → {updated: [ids], missing: [ids], warnings?: [a DCS file's spot plate whose ink a swatch of the document already names, as file.place warns]}", has_doc, update ), @@ -71,7 +72,7 @@ pub fn specs() -> Vec<CommandSpec> { "Relink", [], None, - "{ids?: [image or placed document ids] (default: the selected ones; with folder and nothing selected, every missing link), path | folder, scope?: selected (default: ids) | all (ids and every other object linked to the same file as one of them, in the layers, opacity-mask art, symbols, graph designs and patterns) | missingInFolder (with path: ids, then every other missing link whose file name is in path's folder, each to the file of its name there; names not there are in notFound; with copy, only images are looked for) | each (with paths), paths?: [{ids, path}] (with scope each, in place of ids, path and folder: each link to its own file; an id in two entries is an error), copy?: false (with path or paths, for images of a saved document: copy the file into the document's folder and link to the copy; the names Name.png, Name 2.png … Name 99.png are tried in turn until one is free, which gets the copy, or is a file with the same contents, which is used; an error for a DCS file that reads plate files of its own), preserve?: transforms|bounds|fileDimensions|fit|fill (how the new file takes each image's place this time, as links.placementOptions describes; default: each image's Placement Options; fit keeps the new file's aspect ratio inside the old bounds: Replace)} link images (or placed documents, each showing the same artboard or page of the new file) to the file at path, or each to the file of its link's name in folder; embedded images become linked; each keeps its bounds. One undo step → {relinked: [ids], notFound: [file names], copied?: [{from, to}], kept?: [{from, to}] (with copy; to is the file name alone when the document's folder is outside the automation read roots), warnings?: (as links.update's)}", + "{ids?: [image or placed document ids] (default: the selected ones; with folder and nothing selected, every missing link), path | folder, scope?: selected (default: ids) | all (ids and every other object linked to the same file as one of them, in the layers, opacity-mask art, symbols, graph designs, patterns and the art of stored brushes) | missingInFolder (with path: ids, then every other missing link whose file name is in path's folder, each to the file of its name there; names not there are in notFound; with copy, only images are looked for) | each (with paths), paths?: [{ids, path}] (with scope each, in place of ids, path and folder: each link to its own file; an id in two entries is an error), copy?: false (with path or paths, for images of a saved document: copy the file into the document's folder and link to the copy; the names Name.png, Name 2.png … Name 99.png are tried in turn until one is free, which gets the copy, or is a file with the same contents, which is used; an error for a DCS file that reads plate files of its own), preserve?: transforms|bounds|fileDimensions|fit|fill (how the new file takes each image's place this time, as links.placementOptions describes; default: each image's Placement Options; fit keeps the new file's aspect ratio inside the old bounds: Replace)} link images (or placed documents, each showing the same artboard or page of the new file) to the file at path, or each to the file of its link's name in folder; embedded images become linked; each keeps its bounds. One undo step → {relinked: [ids], notFound: [file names], copied?: [{from, to}], kept?: [{from, to}] (with copy; to is the file name alone when the document's folder is outside the automation read roots), warnings?: (as links.update's)}", has_doc, relink ), @@ -80,7 +81,7 @@ pub fn specs() -> Vec<CommandSpec> { "Links", [], None, - "{show?: all (default)|missing|modified|embedded, sort?: name|kind (file format)|status (missing, modified, ok, embedded); default: stacking order; top first, dcsTransparency?: false (Show DCS Transparency Interactions: mark the images placed from DCS files that are transparent, themselves or a group or layer holding them, or that overlap a visible object with its own transparency; it looks at every object, so it takes longer)} every image object and placed document the document stores, as the Links panel lists them: those in the layers, then those in opacity-mask art and in the art of symbols, graph designs and patterns (one row per stored object, never one per symbol instance or pattern tile) → {links: [{id, name, linked, status: ok|modified|missing|embedded, format (DCS for an image placed from a DCS file), pixelWidth, pixelHeight, path?, found?: path (found away from its path), page?, preview?: true (showing the saved preview), note?: said of an image past the decode allowance (shown at reduced size, or too large to draw), document?: true (a placed document: pageWidth and pageHeight in pt instead of pixels), dcsTransparency?: true (with dcsTransparency), owner?: {kind: layers|symbol|graphDesign|pattern, name? (of the symbol, graph design or pattern), maskOf?: id (in the opacity-mask art of that object)} (an object outside the layer tree)}], missing, modified, embedded}; under automation read roots, path and found are left out when the file they name is outside the roots", + "{show?: all (default)|missing|modified|embedded, sort?: name|kind (file format)|status (missing, modified, ok, embedded); default: stacking order; top first, dcsTransparency?: false (Show DCS Transparency Interactions: mark the images placed from DCS files that are transparent, themselves or a group or layer holding them, or that overlap a visible object with its own transparency; it looks at every object, so it takes longer)} every image object and placed document the document stores, as the Links panel lists them: those in the layers, then those in opacity-mask art and in the art of symbols, graph designs, patterns and stored brushes (one row per stored object, never one per symbol instance, pattern tile or brushed stroke) → {links: [{id, name, linked, status: ok|modified|missing|embedded, format (DCS for an image placed from a DCS file), pixelWidth, pixelHeight, path?, found?: path (found away from its path), page?, preview?: true (showing the saved preview), note?: said of an image past the decode allowance (shown at reduced size, or too large to draw), document?: true (a placed document: pageWidth and pageHeight in pt instead of pixels), dcsTransparency?: true (with dcsTransparency), owner?: {kind: layers|symbol|graphDesign|pattern|brush, name? (of the symbol, graph design, pattern or brush), index? (a brush's place in the Brushes panel, from 0), tile?: side|outerCorner|innerCorner|start|end (a pattern brush's tile), maskOf?: id (in the opacity-mask art of that object)} (an object outside the layer tree)}], missing, modified, embedded}; under automation read roots, path and found are left out when the file they name is outside the roots", has_doc, list ), @@ -89,7 +90,7 @@ pub fn specs() -> Vec<CommandSpec> { "Go To Link", [], None, - "{id?} select image or placed document `id` (default: the first selected one); the Links panel scrolls it into view → {id, bounds: [x0, y0, x1, y1], onCanvas: true}; one in opacity-mask art or in the art of a symbol, graph design or pattern has no place of its own on the canvas: the selection is cleared → {id, onCanvas: false, owner} (owner as links.list gives it)", + "{id?} select image or placed document `id` (default: the first selected one); the Links panel scrolls it into view → {id, bounds: [x0, y0, x1, y1], onCanvas: true}; one in opacity-mask art or in the art of a symbol, graph design, pattern or stored brush has no place of its own on the canvas: the selection is cleared → {id, onCanvas: false, owner} (owner as links.list gives it)", has_doc, go_to ), @@ -198,6 +199,8 @@ pub(crate) fn linked_groups(d: &Document) -> Vec<(String, Vec<u64>)> { /// visited before it has (art being edited on a layer and its definition) counts once, by its /// first place; without `ids` its content is still grouped. fn groups(d: &Document, ids: Option<&[NodeId]>) -> Vec<Group> { + let view = with_brush_art(d); + let d = &*view; let mut out: Vec<Group> = vec![]; let mut index: BTreeMap<(String, String, bool), usize> = BTreeMap::new(); // Looked up for every linked node: a set, not the list (which may repeat an id many times). @@ -234,13 +237,52 @@ fn stored(d: &Document, id: NodeId) -> Option<&Node> { d.stored_node(id).map(|(n, _)| &**n) } +/// `d` with the art of its stored brushes set on it ([`vectorcraft_brush::stored_art`]), so that +/// the images and placed documents in that art are visited and found by their ids as stored art; +/// `d` itself when no stored brush's art holds one or the art is set on it already. +pub(crate) fn with_brush_art(d: &Document) -> Cow<'_, Document> { + if !d.mounted_art.is_empty() { + return Cow::Borrowed(d); + } + let art = StoredArt::read(d); + if art.is_empty() { + return Cow::Borrowed(d); + } + let mut d = d.clone(); + art.mount(&mut d); + Cow::Owned(d) +} + +/// `f` run on `d` with the art of its stored brushes set on it as [`with_brush_art`] sets it; the +/// brushes whose art `f` changed are then written back into the library, the color masks of its +/// images made for their pixels first. The ids it gives that art are the ones [`with_brush_art`] +/// gives it in the same document. +pub(crate) fn editing_brush_art<T>(d: &mut Document, f: impl FnOnce(&mut Document) -> T) -> T { + if !d.mounted_art.is_empty() { + return f(d); + } + let art = StoredArt::read(d); + if art.is_empty() { + return f(d); + } + art.mount(d); + let before: Vec<Arc<Node>> = d.mounted_art.iter().map(|(n, _)| n.clone()).collect(); + let out = f(d); + if d.mounted_art.len() != before.len() || d.mounted_art.iter().zip(&before).any(|((n, _), b)| !Arc::ptr_eq(n, b)) { + super::refresh_color_masks(None, d); + } + art.write_back(d); + out +} + /// Of `ids`, the objects of `d` outside the layer tree (where [`Document::node`] finds none). fn nested_ids(d: &Document, ids: &[NodeId]) -> std::collections::HashSet<NodeId> { ids.iter().copied().filter(|id| d.node(*id).is_none()).collect() } /// `links.list`'s `owner` of an object stored at `place` of `d`, when it is not in the layer tree -/// itself: `{kind: layers|symbol|graphDesign|pattern, name?, maskOf?}`. +/// itself: `{kind: layers|symbol|graphDesign|pattern, name?, maskOf?}`, or for one in the art of a +/// stored brush, `{kind: brush, name, index, tile?, maskOf?}`. fn owner_json(d: &Document, place: StoredPlace) -> Option<Value> { if place.in_layers() { return None; @@ -250,6 +292,7 @@ fn owner_json(d: &Document, place: StoredPlace) -> Option<Value> { StoredRoot::Symbol(i) => json!({ "kind": "symbol", "name": d.symbols.get(i).map(|s| s.name.as_str()) }), StoredRoot::GraphDesign(i) => json!({ "kind": "graphDesign", "name": d.graph_designs.get(i).map(|g| g.name.as_str()) }), StoredRoot::Pattern { pattern, .. } => json!({ "kind": "pattern", "name": d.patterns.get(pattern).map(|p| p.name.as_str()) }), + StoredRoot::Mounted(i) => d.mounted_art.get(i).map_or_else(|| json!({}), |(_, owner)| owner.clone()), }; if let Some(m) = place.mask_of { owner["maskOf"] = json!(m.0); @@ -479,7 +522,8 @@ pub(crate) fn linked_files(d: &Document, base: LinkBase) -> Vec<LinkedFile> { /// again (Preferences › Use Low Resolution Proxy for Linked EPS keeps the preview on screen only). pub(crate) fn full_linked_images<'a>(d: &'a Document, base: LinkBase) -> (Cow<'a, Document>, Vec<String>) { let mut keys = BTreeSet::new(); - d.visit_images(|_, im| { + // The art of the stored brushes draws its images too. + with_brush_art(d).visit_images(|_, im| { if im.link.is_some() && d.images.get(&im.key).is_some_and(ImageBlob::is_proxy) { keys.insert(im.key.clone()); } @@ -747,7 +791,7 @@ struct Nested<'a> { impl Nested<'_> { /// Every root of `d`: the layers (whose own objects are left alone), then the art of symbols, - /// graph designs and patterns. + /// graph designs and patterns, then [`Document::mounted_art`]. fn run(mut self, d: &mut Document) { let first = d.peek_next_id(); self.next = first; @@ -757,7 +801,7 @@ impl Nested<'_> { for root in d.symbols.iter_mut().map(|s| &mut s.art).chain(d.graph_designs.iter_mut().map(|g| &mut g.art)) { self.root(root); } - for root in d.patterns.iter_mut().flat_map(|p| &mut p.art) { + for root in d.patterns.iter_mut().flat_map(|p| &mut p.art).chain(d.mounted_art.iter_mut().map(|(n, _)| n)) { self.root(root); } for _ in first..self.next { @@ -1229,8 +1273,14 @@ impl Resolved { /// found away from their path take the new path. A link nothing is known of whose image, or placed /// document, shows a preview (a file another app wrote kept only that) was never read: its file is /// read now, into the object's bounds, which isn't a change to report. A placed document whose -/// file's bytes are gone isn't showing a preview. Nothing here is an undo step. +/// file's bytes are gone isn't showing a preview. Links in the art of the stored brushes count too, +/// and that art keeps the ids they are listed by. Nothing here is an undo step. pub fn resolve(d: &mut Document, base: LinkBase, update: bool, low_res_proxy_eps: bool) -> Resolved { + editing_brush_art(d, |d| resolve_links(d, base, update, low_res_proxy_eps)) +} + +/// [`resolve`] in the art `d` stores. +fn resolve_links(d: &mut Document, base: LinkBase, update: bool, low_res_proxy_eps: bool) -> Resolved { let mut out = Resolved::default(); // The image (with its preview) and hash of each file read for a preview here, by path: images // of other keys linking to the same file share them, rather than each reading, decoding and @@ -1381,8 +1431,8 @@ fn set_links(d: &mut Document, ids: &[NodeId], link: &LinkInfo) { } /// Placed documents of the document saved at `path` (document `saved` of `s`) in the other open -/// documents, in the layers, symbols, graph designs, patterns and opacity masks: read again from -/// the new file, each as one Update Links step of its document. +/// documents, in the layers, symbols, graph designs, patterns, opacity masks and the art of the +/// stored brushes: read again from the new file, each as one Update Links step of its document. pub(crate) fn refresh_placed(s: &mut Session, saved: u64, path: &str) { let path = absolute_path(path); let targets: Vec<usize> = s @@ -1392,7 +1442,7 @@ pub(crate) fn refresh_placed(s: &mut Session, saved: u64, path: &str) { .filter(|(_, st)| st.uid != saved) .filter(|(_, st)| { let mut placed = false; - st.doc.visit_placed(|_, p| placed |= p.link.path == path); + with_brush_art(&st.doc).visit_placed(|_, p| placed |= p.link.path == path); placed }) .map(|(i, _)| i) @@ -1449,7 +1499,7 @@ fn link_target(link: &LinkInfo, base: LinkBase) -> PathBuf { /// `d` (looking from `base`) as saved to `dest`: the links' paths relative to its folder written /// in; `None` when they are already. A link whose file is not at its path is written relative to /// where its file is found, else to the place its relative path names. Links in the layers, -/// symbols, graph designs, patterns and opacity masks are all set. +/// symbols, graph designs, patterns, opacity masks and the art of the stored brushes are all set. pub fn with_relative_paths(d: &Document, base: LinkBase, dest: &str) -> Option<Document> { let dest = absolute_path(dest); let dir = Path::new(&dest).parent()?; @@ -1458,23 +1508,29 @@ pub fn with_relative_paths(d: &Document, base: LinkBase, dest: &str) -> Option<D let mut look = |l: &LinkInfo| { wanted.entry((l.path.clone(), l.relative.clone())).or_insert_with(|| relative_path(&link_target(l, base), dir)); }; - d.visit_images(|_, im| im.link.iter().for_each(&mut look)); - d.visit_placed(|_, p| look(&p.link)); + let view = with_brush_art(d); + view.visit_images(|_, im| im.link.iter().for_each(&mut look)); + view.visit_placed(|_, p| look(&p.link)); wanted.retain(|(_, stored), rel| rel != stored); if wanted.is_empty() { return None; } let key = |l: &LinkInfo| (l.path.clone(), l.relative.clone()); let mut d = d.clone(); - d.update_links_where(|l| wanted.contains_key(&key(l)), |l| l.relative = wanted.get(&key(l)).cloned().flatten()); + editing_brush_art(&mut d, |d| d.update_links_where(|l| wanted.contains_key(&key(l)), |l| l.relative = wanted.get(&key(l)).cloned().flatten())); Some(d) } /// Sets each link of `d`, a copy of a document looking from `base`, to the path where that /// document finds its file, and its relative path to it as that document's links have them, so -/// the copy finds the same files. Links in the layers, symbols, graph designs, patterns and opacity -/// masks are all set. +/// the copy finds the same files. Links in the layers, symbols, graph designs, patterns, opacity +/// masks and the art of the stored brushes are all set. pub(crate) fn with_found_paths(d: &mut Document, base: LinkBase) { + editing_brush_art(d, |d| set_found_paths(d, base)); +} + +/// [`with_found_paths`] in the art `d` stores. +fn set_found_paths(d: &mut Document, base: LinkBase) { // The new path and relative path of each link by what `locate` reads of it: its path, relative // path and name. type PathAndRelative = (String, Option<String>); @@ -1629,7 +1685,9 @@ fn update_where(s: &mut Session, ids: Option<Vec<NodeId>>, path: Option<&str>) - let updated: Vec<u64> = reads.iter().flat_map(|(g, _)| ids_json(&g.ids)).collect(); let warnings = spot_swatch_notes(&st.doc, reads.iter().map(|(_, read)| read)); if !reads.is_empty() { - s.edit("Update Links", |d, _| reads.into_iter().try_for_each(|(g, read)| install_read(d, &g.ids, read, None, Some(&g))))?; + s.edit("Update Links", |d, _| { + editing_brush_art(d, |d| reads.into_iter().try_for_each(|(g, read)| install_read(d, &g.ids, read, None, Some(&g)))) + })?; } let mut out = json!({ "updated": updated, "missing": missing }); if !warnings.is_empty() { @@ -1756,9 +1814,10 @@ fn relink(s: &mut Session, p: &Value) -> Result<Value> { Some(Path::new(&doc).parent().map(Path::to_path_buf).ok_or_else(no_folder)?) } }; + let doc = with_brush_art(&st.doc); // An image or a placed document, with its link. let image = |id: &NodeId| { - stored(&st.doc, *id).and_then(|n| match &n.kind { + stored(&doc, *id).and_then(|n| match &n.kind { NodeKind::Image(im) => Some(im.link.as_ref()), NodeKind::PlacedDocument(p) => Some(Some(&p.link)), _ => None, @@ -1788,7 +1847,7 @@ fn relink(s: &mut Session, p: &Value) -> Result<Value> { let paths: BTreeSet<&str> = ids.iter().filter_map(|id| image(id).flatten()).map(|l| l.path.as_str()).collect(); let mut given: BTreeSet<NodeId> = ids.iter().copied().collect(); let mut more = vec![]; - st.doc.visit_stored(|n, _| { + doc.visit_stored(|n, _| { if let Some((l, _, _)) = linked(n) && paths.contains(l.path.as_str()) && n.id.0 != 0 @@ -1799,7 +1858,7 @@ fn relink(s: &mut Session, p: &Value) -> Result<Value> { }); ids.extend(more); } - if copy_to.is_some() && ids.iter().any(|id| matches!(stored(&st.doc, *id).map(|n| &n.kind), Some(NodeKind::PlacedDocument(_)))) { + if copy_to.is_some() && ids.iter().any(|id| matches!(stored(&doc, *id).map(|n| &n.kind), Some(NodeKind::PlacedDocument(_)))) { return Err(bad(C, "copy takes images only: relink placed documents where their files are")); } // (ids, the file) per file to read. @@ -1835,7 +1894,7 @@ fn relink(s: &mut Session, p: &Value) -> Result<Value> { let mut images = vec![]; let mut documents: Vec<((u32, bool, PageBox), Vec<NodeId>)> = vec![]; for id in ids { - match stored(&st.doc, id).map(|n| &n.kind) { + match stored(&doc, id).map(|n| &n.kind) { Some(NodeKind::PlacedDocument(pl)) => { let k = (pl.page(), pl.bounding, pl.page_box); match documents.iter_mut().find(|(e, _)| *e == k) { @@ -1886,9 +1945,10 @@ fn relink(s: &mut Session, p: &Value) -> Result<Value> { } } let relinked: Vec<u64> = reads.iter().flat_map(|(ids, _)| ids_json(ids)).collect(); + drop(doc); let warnings = spot_swatch_notes(&s.doc()?.doc, reads.iter().map(|(_, read)| read)); if !reads.is_empty() { - s.edit("Relink", |d, _| reads.into_iter().try_for_each(|(ids, read)| install_read(d, &ids, read, preserve, None)))?; + s.edit("Relink", |d, _| editing_brush_art(d, |d| reads.into_iter().try_for_each(|(ids, read)| install_read(d, &ids, read, preserve, None))))?; } not_found.sort(); not_found.dedup(); @@ -1998,14 +2058,15 @@ fn selected_images(st: &crate::DocState, keep: impl Fn(&ImageObject) -> bool) -> st.selection.objects.iter().copied().filter(|id| image_of(&st.doc, *id).is_some_and(&keep)).collect() } -/// `id`, else the first selected image. -fn image_param(st: &crate::DocState, p: &Value, cmd: &str) -> Result<NodeId> { +/// `id` (looked up in `doc`, the document of `st` as [`with_brush_art`] gives it), else the first +/// selected image. +fn image_param(st: &crate::DocState, doc: &Document, p: &Value, cmd: &str) -> Result<NodeId> { let id = object_param(p, "id", cmd)? .or_else(|| selected_images(st, |_| true).first().copied()) .ok_or_else(|| bad(cmd, "select an image, or pass id"))?; - match image_of(&st.doc, id) { + match image_of(doc, id) { Some(_) => Ok(id), - None if stored(&st.doc, id).is_none() => Err(crate::EngineError::NoNode(id)), + None if stored(doc, id).is_none() => Err(crate::EngineError::NoNode(id)), None => Err(bad(cmd, format!("object {} is not an image", id.0))), } } @@ -2028,13 +2089,14 @@ fn placement_of(d: &Document, id: NodeId) -> Option<PlacementOptions> { } } -/// `id`, else the first selected image or placed document. -fn linked_param(st: &crate::DocState, p: &Value, cmd: &str) -> Result<NodeId> { - let first = || st.selection.objects.iter().copied().find(|id| placement_of(&st.doc, *id).is_some()); +/// `id` (looked up in `doc`, the document of `st` as [`with_brush_art`] gives it), else the first +/// selected image or placed document. +fn linked_param(st: &crate::DocState, doc: &Document, p: &Value, cmd: &str) -> Result<NodeId> { + let first = || st.selection.objects.iter().copied().find(|id| placement_of(doc, *id).is_some()); let id = object_param(p, "id", cmd)?.or_else(first).ok_or_else(|| bad(cmd, "select an image, or pass id"))?; - match placement_of(&st.doc, id) { + match placement_of(doc, id) { Some(_) => Ok(id), - None if stored(&st.doc, id).is_none() => Err(crate::EngineError::NoNode(id)), + None if stored(doc, id).is_none() => Err(crate::EngineError::NoNode(id)), None => Err(bad(cmd, format!("object {} is not an image or a linked file", id.0))), } } @@ -2141,10 +2203,12 @@ fn list(s: &mut Session, p: &Value) -> Result<Value> { let interactions = if switch_or(p, "dcsTransparency", false, C)? { dcs_transparency(&st.doc) } else { BTreeSet::new() }; let statuses = statuses(st); // The layer tree's objects, top first as the Layers panel lists them, then the others in the - // order they are stored (opacity-mask art, symbols, graph designs, patterns), each once. + // order they are stored (opacity-mask art, symbols, graph designs, patterns, the art of the + // stored brushes), each once. + let doc = with_brush_art(&st.doc); let (mut objects, mut nested) = (vec![], vec![]); let mut seen = std::collections::HashSet::new(); - st.doc.visit_stored(|n, place| { + doc.visit_stored(|n, place| { if matches!(n.kind, NodeKind::Image(_) | NodeKind::PlacedDocument(_)) && n.id.0 != 0 && seen.insert(n.id) { if place.in_layers() { objects.push((n, place)) } else { nested.push((n, place)) } } @@ -2196,7 +2260,7 @@ fn list(s: &mut Session, p: &Value) -> Result<Value> { if preview { row["preview"] = json!(true); } - if let Some(owner) = owner_json(&st.doc, place) { + if let Some(owner) = owner_json(&doc, place) { row["owner"] = owner; } if interactions.contains(&n.id) { @@ -2218,10 +2282,13 @@ fn list(s: &mut Session, p: &Value) -> Result<Value> { fn go_to(s: &mut Session, p: &Value) -> Result<Value> { let st = s.doc()?; - let id = linked_param(st, p, "links.goTo")?; - // An object in mask art or a definition has no place of its own on the canvas: the selection - // is cleared, and the reply names what holds it. - if let Some(owner) = st.doc.stored_node(id).and_then(|(_, place)| owner_json(&st.doc, place)) { + let doc = with_brush_art(&st.doc); + let id = linked_param(st, &doc, p, "links.goTo")?; + // An object in mask art, a definition or a stored brush's art has no place of its own on the + // canvas: the selection is cleared, and the reply names what holds it. + let owner = doc.stored_node(id).and_then(|(_, place)| owner_json(&doc, place)); + drop(doc); + if let Some(owner) = owner { s.select(|_, sel| sel.set([]))?; return Ok(json!({ "id": id.0, "onCanvas": false, "owner": owner })); } @@ -2233,7 +2300,8 @@ fn go_to(s: &mut Session, p: &Value) -> Result<Value> { fn embed(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "links.embed"; let st = s.doc()?; - let kind = |id: &NodeId| stored(&st.doc, *id).map(|n| &n.kind); + let doc = with_brush_art(&st.doc); + let kind = |id: &NodeId| stored(&doc, *id).map(|n| &n.kind); let linked = |id: &NodeId| match kind(id) { Some(NodeKind::Image(im)) => im.link.is_some(), Some(NodeKind::PlacedDocument(_)) => true, @@ -2285,17 +2353,20 @@ fn embed(s: &mut Session, p: &Value) -> Result<Value> { _ => missing.extend(g.ids), } } + drop(doc); if !done.is_empty() || !documents.is_empty() { s.edit("Embed", |d, _| { - for (ids, read) in reads { - install(d, &ids, read, Some(Preserve::Bounds), None)?; - } - for id in &done { - if let Some(Node { kind: NodeKind::Image(im), .. }) = d.stored_node_mut(*id) { - im.link = None; + editing_brush_art(d, |d| { + for (ids, read) in reads { + install(d, &ids, read, Some(Preserve::Bounds), None)?; } - } - documents.iter().try_for_each(|id| super::place::document::expand(d, *id, C)) + for id in &done { + if let Some(Node { kind: NodeKind::Image(im), .. }) = d.stored_node_mut(*id) { + im.link = None; + } + } + documents.iter().try_for_each(|id| super::place::document::expand(d, *id, C)) + }) })?; } done.extend(documents); @@ -2318,9 +2389,10 @@ fn convert_image(bytes: &[u8], ext: &str) -> std::result::Result<Vec<u8>, String fn unembed(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "links.unembed"; let st = s.doc()?; - let id = image_param(st, p, C)?; - let n = stored(&st.doc, id).ok_or(crate::EngineError::NoNode(id))?; - let im = image_of(&st.doc, id).ok_or_else(|| bad(C, format!("object {} is not an image", id.0)))?; + let doc = with_brush_art(&st.doc); + let id = image_param(st, &doc, p, C)?; + let n = stored(&doc, id).ok_or(crate::EngineError::NoNode(id))?; + let im = image_of(&doc, id).ok_or_else(|| bad(C, format!("object {} is not an image", id.0)))?; if im.link.is_some() { return Err(bad(C, format!("image {} is linked already", id.0))); } @@ -2345,7 +2417,8 @@ fn unembed(s: &mut Session, p: &Value) -> Result<Value> { let img = linked_image(&bytes, Some(&path))?; write_file(&path, &bytes)?; let read = (link_info(&path, &bytes), img); - s.edit("Unembed", |d, _| install(d, &[id], read, Some(Preserve::Bounds), None))?; + drop(doc); + s.edit("Unembed", |d, _| editing_brush_art(d, |d| install(d, &[id], read, Some(Preserve::Bounds), None)))?; Ok(json!({ "id": id.0, "path": path })) } @@ -2403,9 +2476,10 @@ fn scale_rotation(xf: Affine, (px, py): (f64, f64)) -> (Value, Value) { (json!([a.hypot(b) / px * 100.0, c.hypot(d) / py * 100.0]), json!((-b).atan2(a).to_degrees() + 0.0)) } -/// Link Info of placed document `id`. -fn placed_info(st: &crate::DocState, id: NodeId) -> Result<Value> { - let n = stored(&st.doc, id).ok_or(crate::EngineError::NoNode(id))?; +/// Link Info of placed document `id` (looked up in `doc`, the document of `st` as +/// [`with_brush_art`] gives it). +fn placed_info(st: &crate::DocState, doc: &Document, id: NodeId) -> Result<Value> { + let n = stored(doc, id).ok_or(crate::EngineError::NoNode(id))?; let NodeKind::PlacedDocument(pl) = &n.kind else { return Err(bad("links.info", format!("object {} is not a placed document", id.0))) }; let size = n.geometric_bounds().unwrap_or_default(); let (scale, rotation) = scale_rotation(pl.xf, (1.0, 1.0)); @@ -2430,13 +2504,19 @@ fn placed_info(st: &crate::DocState, id: NodeId) -> Result<Value> { fn info(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "links.info"; - let id = linked_param(s.doc()?, p, C)?; - if image_of(&s.doc()?.doc, id).is_none() { - return placed_info(s.doc()?, id); - } + let id = { + let st = s.doc()?; + let doc = with_brush_art(&st.doc); + let id = linked_param(st, &doc, p, C)?; + if image_of(&doc, id).is_none() { + return placed_info(st, &doc, id); + } + id + }; let mut out = super::place::image_info(s, &json!({ "id": id.0 }))?; let st = s.doc()?; - let im = image_of(&st.doc, id).ok_or_else(|| bad(C, format!("object {} is not an image", id.0)))?; + let doc = with_brush_art(&st.doc); + let im = image_of(&doc, id).ok_or_else(|| bad(C, format!("object {} is not an image", id.0)))?; let (px, py) = file_pt(&st.doc, &im.key); out["effectivePpi"] = out["ppi"].take(); out["ppi"] = json!([72.0 / px, 72.0 / py]); @@ -2453,9 +2533,10 @@ fn info(s: &mut Session, p: &Value) -> Result<Value> { fn placement_options(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "links.placementOptions"; let st = s.doc()?; + let doc = with_brush_art(&st.doc); let ids = - ids_param(p, "ids", C)?.unwrap_or_else(|| st.selection.objects.iter().copied().filter(|id| placement_of(&st.doc, *id).is_some()).collect()); - if let Some(id) = ids.iter().find(|id| placement_of(&st.doc, **id).is_none()) { + ids_param(p, "ids", C)?.unwrap_or_else(|| st.selection.objects.iter().copied().filter(|id| placement_of(&doc, *id).is_some()).collect()); + if let Some(id) = ids.iter().find(|id| placement_of(&doc, **id).is_none()) { return Err(bad(C, format!("object {} is not an image or a linked file", id.0))); } if ids.is_empty() { @@ -2474,7 +2555,8 @@ fn placement_options(s: &mut Session, p: &Value) -> Result<Value> { None | Some(Value::Null) => None, Some(v) => Some(v.as_bool().ok_or_else(|| bad(C, "clip must be true or false"))?), }; - let first = ids.first().and_then(|id| placement_of(&st.doc, *id)).unwrap_or_default(); + let first = ids.first().and_then(|id| placement_of(&doc, *id)).unwrap_or_default(); + drop(doc); if preserve.is_none() && align.is_none() && clip.is_none() { return Ok(json!({ "placement": placement_json(first) })); } @@ -2484,11 +2566,13 @@ fn placement_options(s: &mut Session, p: &Value) -> Result<Value> { o.clip = clip.unwrap_or(o.clip); }; s.edit("Placement Options", |d, _| { - for id in &ids { - if let Some(o) = d.stored_node_mut(*id).and_then(placement_mut) { - set(o); + editing_brush_art(d, |d| { + for id in &ids { + if let Some(o) = d.stored_node_mut(*id).and_then(placement_mut) { + set(o); + } } - } + }); Ok(()) })?; let mut shown = first; diff --git a/crates/engine/src/cmd/package.rs b/crates/engine/src/cmd/package.rs index 8d6f53d55b..315a737c59 100644 --- a/crates/engine/src/cmd/package.rs +++ b/crates/engine/src/cmd/package.rs @@ -229,7 +229,7 @@ impl<'a> Collector<'a> { Some((d, base)) => super::links::linked_files(d, base), None => super::links::linked_files(doc, LinkBase::file(Some(source))), }; - doc.visit_placed(|_, p| { + super::links::with_brush_art(doc).visit_placed(|_, p| { let page = (p.link.page.unwrap_or(1), p.bounding, p.page_box); let pages = placed.entry(p.link.path.clone()).or_default(); if !pages.contains(&page) { @@ -389,16 +389,20 @@ impl<'a> Collector<'a> { } if self.opts.relink { // The child files have already been rewritten; the hash and size of each - // target must reflect the *packaged* bytes rather than the original. - doc.update_links(|link: &mut LinkInfo| { - if let Some(copy) = local.get(&link.path) { - let relative = relative_in_package(destination, ©.name); - link.path = self.root.as_ref().map_or_else(|| copy.name.clone(), |r| r.join(©.name).to_string_lossy().into_owned()); - link.relative = Some(relative); - link.size = copy.size; - link.hash = copy.hash.clone(); - link.modified = None; - } + // target must reflect the *packaged* bytes rather than the original. The links in the + // art of the stored brushes are written back into the brush library. + let root = &self.root; + super::links::editing_brush_art(doc, |doc| { + doc.update_links(|link: &mut LinkInfo| { + if let Some(copy) = local.get(&link.path) { + let relative = relative_in_package(destination, ©.name); + link.path = root.as_ref().map_or_else(|| copy.name.clone(), |r| r.join(©.name).to_string_lossy().into_owned()); + link.relative = Some(relative); + link.size = copy.size; + link.hash = copy.hash.clone(); + link.modified = None; + } + }) }); } if let Some(s) = self.sections.get_mut(section) { diff --git a/crates/engine/src/cmd/place.rs b/crates/engine/src/cmd/place.rs index 20f19ef803..a558545e4e 100644 --- a/crates/engine/src/cmd/place.rs +++ b/crates/engine/src/cmd/place.rs @@ -962,8 +962,10 @@ pub(crate) fn image_info(s: &mut Session, p: &Value) -> Result<Value> { (None, [id]) => *id, _ => return Err(bad(C, "select one image or pass id")), }; - // An image in opacity-mask art or a definition's art is found by its id too (`links.list`). - let n = st.doc.stored_node(id).map(|(n, _)| &**n).ok_or(EngineError::NoNode(id))?; + // An image in opacity-mask art, a definition's art or a stored brush's art is found by its id + // too (`links.list`). + let doc = super::links::with_brush_art(&st.doc); + let n = doc.stored_node(id).map(|(n, _)| &**n).ok_or(EngineError::NoNode(id))?; let NodeKind::Image(im) = &n.kind else { return Err(bad(C, format!("object {} is not an image", id.0))) }; // Effective resolution: 72 pt per inch over the points one pixel spans along each axis. let [a, b, c, d, ..] = im.xf.as_coeffs(); diff --git a/crates/engine/src/cmd/place/document.rs b/crates/engine/src/cmd/place/document.rs index 8e4afaa295..8b00e95152 100644 --- a/crates/engine/src/cmd/place/document.rs +++ b/crates/engine/src/cmd/place/document.rs @@ -330,7 +330,8 @@ pub(crate) fn node(d: &mut Document, s: &Source, link: LinkInfo, bounding: bool) } /// `d` for output: linked images and placed documents that keep only their previews get their -/// files back, else output as their previews, with a warning. +/// files back, else output as their previews, with a warning. The art of the stored brushes counts +/// too. pub(crate) fn full_documents(d: &Document) -> (Cow<'_, Document>, Vec<String>) { let (d, mut warnings) = super::super::links::full_linked_images(d, Default::default()); let doc = match &d { @@ -339,7 +340,7 @@ pub(crate) fn full_documents(d: &Document) -> (Cow<'_, Document>, Vec<String>) { }; let mut need: Vec<PlacedDocument> = vec![]; let mut seen = std::collections::HashSet::new(); - doc.visit_placed(|_, p| { + super::super::links::with_brush_art(doc).visit_placed(|_, p| { if doc.images.get(&p.key).is_some_and(ImageBlob::is_proxy) && seen.insert(p.key.clone()) { need.push(p.clone()); } @@ -370,7 +371,7 @@ pub(crate) fn full_documents(d: &Document) -> (Cow<'_, Document>, Vec<String>) { "{n} placed documents output as their previews: their files can't be found, or changed since they were read (relink or update them)" ), }); - out.placed_as_previews(&previews); + super::super::links::editing_brush_art(&mut out, |out| out.placed_as_previews(&previews)); } (Cow::Owned(out), warnings) } diff --git a/crates/engine/src/tests/links.rs b/crates/engine/src/tests/links.rs index e683b156e1..62d3e36bad 100644 --- a/crates/engine/src/tests/links.rs +++ b/crates/engine/src/tests/links.rs @@ -768,6 +768,223 @@ fn nested_objects_that_repeat_ids_open_with_ids_of_their_own() { assert!(image(&s, layer_image).link.is_some(), "the image in the layers stays linked"); } +/// The files of the linked images that the stored brushes of [`brush_links`] are made of: a scatter +/// brush's, an art brush's and a pattern brush's side tile. +const BRUSHED: [(&str, &str, &str); 3] = [("scatter.png", "scatter", "Specks"), ("art.png", "art", "Band"), ("side.png", "pattern", "Frame")]; + +/// A document whose stored brushes are made of [`BRUSHED`]'s linked images in `dir`. The art +/// brush's image is still in the layers too, so its brush art repeats that object's id; the other +/// two images were cleared from the layers. +fn brush_links(dir: &Folder) -> (Session, NodeId) { + for (i, (name, ..)) in (0u8..).zip(BRUSHED) { + write(&dir.file(name), &png(20, 10, [30 + 60 * i, 120, 90])); + } + let mut s = session(); + let mut kept = NodeId(0); + for (name, kind, brush) in BRUSHED { + let id = place(&mut s, &dir.file(name)); + s.execute("brush.new", &json!({"type": kind, "name": brush, "ids": [id.0]})).unwrap(); + if kind == "art" { + kept = id; + } else { + s.execute("edit.clear", &json!({"ids": [id.0]})).unwrap(); + } + } + s.execute("select.set", &json!({"ids": []})).unwrap(); + (s, kept) +} + +/// The image in the art of stored brush `name`, as the document stores it. +fn brush_image(s: &Session, name: &str) -> ImageObject { + let b = vectorcraft_brush::find(&s.doc().unwrap().doc, name).unwrap_or_else(|| panic!("no brush {name}")); + let mut found = None; + b.art()[0].walk(&mut |n| { + if let (None, NodeKind::Image(im)) = (&found, &n.kind) { + found = Some((**im).clone()); + } + }); + found.unwrap_or_else(|| panic!("no image in brush {name}")) +} + +/// The id of the image in the art of stored brush `name`, as the document stores it. +fn brush_image_id(s: &Session, name: &str) -> u64 { + let b = vectorcraft_brush::find(&s.doc().unwrap().doc, name).unwrap(); + let mut found = None; + b.art()[0].walk(&mut |n| { + if found.is_none() && matches!(n.kind, NodeKind::Image(_)) { + found = Some(n.id.0); + } + }); + found.unwrap() +} + +/// Images in the art of stored brushes are listed after the others, one row per image in each brush tile, +/// each with an id no other object has (the layer tree keeps its own), the brush named as what holds it; Check +/// Links and the missing filter count them, and the ids stay the same from one list to the next. +#[test] +fn links_in_stored_brush_art_are_listed_and_checked_with_ids() { + let dir = Folder::new("brush-ids"); + let (mut s, kept) = brush_links(&dir); + let list = s.execute("links.list", &json!({})).unwrap(); + let rows = list["links"].as_array().unwrap(); + let owners: Vec<(&str, &Value)> = rows.iter().map(|r| (r["name"].as_str().unwrap(), &r["owner"])).collect(); + let library = vectorcraft_brush::library(&s.doc().unwrap().doc); + let index = |name: &str| library.iter().position(|b| b.name == name).unwrap(); + assert_eq!( + owners, + [ + ("art.png", &Value::Null), + ("scatter.png", &json!({"kind": "brush", "name": "Specks", "index": index("Specks")})), + ("art.png", &json!({"kind": "brush", "name": "Band", "index": index("Band")})), + ("side.png", &json!({"kind": "brush", "name": "Frame", "index": index("Frame"), "tile": "side"})), + ], + "{list}" + ); + assert_eq!(rows[0]["id"], json!(kept.0), "the layer tree keeps its ids: {list}"); + let ids: std::collections::BTreeSet<u64> = rows.iter().map(|r| r["id"].as_u64().unwrap()).collect(); + assert_eq!(ids.len(), 4, "{list}"); + assert!(!ids.contains(&0), "{list}"); + assert!(rows.iter().all(|r| r["status"] == "ok" && r["linked"] == true), "{list}"); + assert_eq!(s.execute("links.list", &json!({})).unwrap(), list, "the same ids each time"); + let other = super::rect(&mut s, 0.0, 0.0, 5.0, 5.0); + s.execute("edit.clear", &json!({"ids": [other.0]})).unwrap(); + assert_eq!(s.execute("links.list", &json!({})).unwrap(), list, "the same ids after other objects are made"); + let check = s.execute("links.check", &json!({})).unwrap(); + assert_eq!(check["links"].as_array().unwrap().len(), 3, "{check}"); + std::fs::remove_file(dir.file("side.png")).unwrap(); + let check = s.execute("links.check", &json!({})).unwrap(); + assert_eq!(check["missing"].as_u64(), Some(1), "{check}"); + let missing = s.execute("links.list", &json!({"show": "missing"})).unwrap(); + assert_eq!(missing["links"][0]["id"], rows[3]["id"], "{missing}"); +} + +/// Every links command takes the id of an image in a stored brush's art and acts on that brush's art, +/// never on the image in the layers whose id the art repeated: Link Info, Go To (which clears the +/// selection and names the brush), Placement Options, Relink, Update and Embed. The ids each change +/// gives the art are kept in the library, so the next list names the same rows. +#[test] +fn links_commands_act_on_images_in_stored_brush_art_by_id() { + let dir = Folder::new("brush-act"); + let (mut s, kept) = brush_links(&dir); + let band = row_id_owned(&mut s, "art.png", "brush"); + assert_ne!(band, kept.0); + let info = s.execute("links.info", &json!({"id": band})).unwrap(); + assert_eq!((info["fileName"].as_str(), info["status"].as_str(), info["id"].as_u64()), (Some("art.png"), Some("ok"), Some(band)), "{info}"); + s.execute("select.set", &json!({"ids": [kept.0]})).unwrap(); + let go = s.execute("links.goTo", &json!({"id": band})).unwrap(); + assert_eq!( + (go["onCanvas"].clone(), go["owner"]["kind"].clone(), go["owner"]["name"].clone()), + (json!(false), json!("brush"), json!("Band")), + "{go}" + ); + assert!(s.doc().unwrap().selection.objects.is_empty(), "nothing on the canvas is selected"); + s.execute("links.placementOptions", &json!({"ids": [band], "preserve": "fit"})).unwrap(); + assert_eq!(s.execute("links.placementOptions", &json!({"ids": [band]})).unwrap()["placement"]["preserve"], "fit"); + assert_eq!(brush_image(&s, "Band").placement.preserve, vectorcraft_doc::links::Preserve::Fit); + assert_eq!(brush_image_id(&s, "Band"), band, "the brush keeps the id it is listed by"); + assert_ne!(image(&s, kept).placement.preserve, vectorcraft_doc::links::Preserve::Fit, "the image in the layers is left as it was"); + // Relink: the brush's image shows the new file; the image in the layers keeps its file. + let other = dir.file("other.png"); + write(&other, &png(40, 20, BLUE)); + let r = s.execute("links.relink", &json!({"ids": [band], "path": other})).unwrap(); + assert_eq!(r["relinked"], json!([band]), "{r}"); + assert_eq!(brush_image(&s, "Band").link.unwrap().path, other); + assert_eq!(image(&s, kept).link.unwrap().path, dir.file("art.png")); + assert_eq!(row_id_owned(&mut s, "other.png", "brush"), band, "{}", s.execute("links.list", &json!({})).unwrap()); + // Update: a changed file is read again for the scatter brush's image. + let dots = row_id_owned(&mut s, "scatter.png", "brush"); + let changed = png(30, 30, RED); + write(&dir.file("scatter.png"), &changed); + let r = s.execute("links.update", &json!({"ids": [dots]})).unwrap(); + assert_eq!(r["updated"], json!([dots]), "{r}"); + assert_eq!(brush_image(&s, "Specks").link.unwrap().size, Some(changed.len() as u64)); + // Embed: the pattern brush's side tile keeps its pixels and no longer links. + let frame = row_id_owned(&mut s, "side.png", "brush"); + let r = s.execute("links.embed", &json!({"ids": [frame]})).unwrap(); + assert_eq!(r["embedded"], json!([frame]), "{r}"); + assert!(brush_image(&s, "Frame").link.is_none()); + let embedded = s.execute("links.list", &json!({"show": "embedded"})).unwrap(); + assert_eq!(embedded["links"][0]["id"], json!(frame), "{embedded}"); + // Relink All Instances takes the image in the layers and the brush's image of the same file. + let r = s.execute("links.relink", &json!({"ids": [kept.0], "path": dir.file("scatter.png"), "scope": "all"})).unwrap(); + assert_eq!(r["relinked"], json!([kept.0]), "{r}"); + let r = s.execute("links.relink", &json!({"ids": [dots], "path": other, "scope": "all"})).unwrap(); + let mut relinked: Vec<u64> = r["relinked"].as_array().unwrap().iter().map(|v| v.as_u64().unwrap()).collect(); + relinked.sort(); + let mut both = vec![kept.0, dots]; + both.sort(); + assert_eq!(relinked, both, "{r}"); + assert_eq!(image(&s, kept).link.unwrap().path, other); + // One undo step puts the brushes back as they were. + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(brush_image(&s, "Specks").link.unwrap().path, dir.file("scatter.png")); +} + +/// The id of the `links.list` row of file `name` whose owner is of `kind`. +fn row_id_owned(s: &mut Session, name: &str, kind: &str) -> u64 { + let list = s.execute("links.list", &json!({})).unwrap(); + let row = list["links"].as_array().unwrap().iter().find(|r| r["name"] == name && r["owner"]["kind"] == kind); + row.unwrap_or_else(|| panic!("{name} in {kind}: {list}"))["id"].as_u64().unwrap() +} + +/// A document saved with links in its stored brushes opens with them reported by the ids the list +/// gives them, and a library entry that does not read as a brush is kept as it was. +#[test] +fn links_in_stored_brush_art_open_by_id_and_unreadable_entries_stay() { + let dir = Folder::new("brush-open"); + let (mut s, _) = brush_links(&dir); + let odd = json!({"name": "Odd", "type": "unknown", "art": {"id": 3}}); + s.edit("Odd brush", |d, _| { + if let Some(list) = d.unknown.get_mut(vectorcraft_brush::DOC_KEY).and_then(Value::as_array_mut) { + list.push(odd.clone()); + } + Ok(()) + }) + .unwrap(); + let path = dir.file("poster.vectorcraft"); + save(&mut s, &path); + std::fs::remove_file(dir.file("scatter.png")).unwrap(); + let r = open(&mut s, &path); + let dots = row_id_owned(&mut s, "scatter.png", "brush"); + assert_eq!(r["missingLinks"][0]["ids"], json!([dots]), "{r}"); + assert_eq!(brush_image_id(&s, "Specks"), dots, "the library keeps the ids opening gave"); + let band = row_id_owned(&mut s, "art.png", "brush"); + s.execute("links.embed", &json!({"ids": [band]})).unwrap(); + let doc = &s.doc().unwrap().doc; + let stored = doc.unknown[vectorcraft_brush::DOC_KEY].as_array().unwrap(); + assert_eq!(stored.last(), Some(&odd), "the unreadable entry is left as it was"); + assert!(doc.mounted_art.is_empty()); +} + +/// The Color Mask of an image in a stored brush's art is made again for the new pixels when Update +/// reads the image's changed file. +#[test] +fn updating_an_image_in_stored_brush_art_makes_its_color_mask_again() { + let dir = Folder::new("brush-mask"); + let path = dir.file("logo.png"); + write(&path, &png(12, 10, RED)); + let mut s = session(); + let id = place(&mut s, &path); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + let hide_white = json!({"background": "colors", "colors": "#ffffff", "contiguous": false, "tolerance": 0, "softness": 0}); + s.execute("addon.image.colorMask", &hide_white).unwrap(); + s.execute("brush.new", &json!({"type": "scatter", "name": "Masked", "ids": [id.0]})).unwrap(); + s.execute("edit.clear", &json!({"ids": [id.0]})).unwrap(); + write(&path, &png(14, 10, BLUE)); + let row = row_id_owned(&mut s, "logo.png", "brush"); + let r = s.execute("links.update", &json!({"ids": [row]})).unwrap(); + assert_eq!(r["updated"], json!([row]), "{r}"); + let doc = &s.doc().unwrap().doc; + let brush = vectorcraft_brush::find(doc, "Masked").unwrap(); + let mut masks = vec![]; + brush.art()[0].walk(&mut |n| { + if let (NodeKind::Image(im), Some(m)) = (&n.kind, Document::color_mask_of(n)) { + masks.push((m.made_for(im), doc.images.contains_key(&m.key))); + } + }); + assert_eq!(masks, [(true, true)], "the mask is made for the new pixels"); +} + /// An image that Placement Options clip, alone in a group the user made, goes into a new clip group /// inside that group when its file grows, in the layers and in a symbol's art; the user's group /// stays a plain group. diff --git a/crates/engine/src/tests/package.rs b/crates/engine/src/tests/package.rs index e61c4bb4a4..952693d7c1 100644 --- a/crates/engine/src/tests/package.rs +++ b/crates/engine/src/tests/package.rs @@ -90,6 +90,38 @@ fn two_links_and_a_font_are_collected_and_relinked() { assert!(s.doc().unwrap().doc.images.values().all(|b| !b.is_proxy()), "the copies' pixels"); } +/// A file linked only from a stored brush's art is copied, and the packaged document's brush +/// links to the copy. +#[test] +fn a_file_linked_from_a_stored_brush_is_collected_and_relinked() { + let dir = Folder::new("package-brush"); + let file = dir.file("art/leaf.png"); + write(&file, &png(40, 20, RED)); + let mut s = session(); + let id = place(&mut s, &file); + run(&mut s, "brush.new", json!({"type": "scatter", "name": "Leaves Here", "ids": [id.0]})); + run(&mut s, "edit.clear", json!({"ids": [id.0]})); + save(&mut s, &dir.file("poster.vectorcraft")); + let out = dir.file("out"); + let r = run(&mut s, "file.package", json!({"folder": out, "copyFonts": false})); + let files: Vec<&str> = r["files"].as_array().unwrap().iter().map(|f| f.as_str().unwrap()).collect(); + assert!(files.contains(&"Links/leaf.png"), "{r}"); + let root = std::path::Path::new(&out).join("poster Folder"); + std::fs::remove_dir_all(dir.0.join("art")).unwrap(); + let r = open(&mut s, &root.join("poster.vectorcraft").to_string_lossy()); + assert_eq!(r["missingLinks"], json!([]), "{r}"); + let brush = vectorcraft_brush::find(&s.doc().unwrap().doc, "Leaves Here").unwrap(); + let mut paths = vec![]; + brush.art()[0].walk(&mut |n| { + if let vectorcraft_doc::NodeKind::Image(im) = &n.kind { + paths.push(im.link.as_ref().map(|l| (l.path.clone(), l.relative.clone()))); + } + }); + let [Some((path, relative))] = paths.as_slice() else { panic!("{paths:?}") }; + assert!(std::path::Path::new(path).starts_with(root.join("Links")), "{path}"); + assert_eq!(relative.as_deref(), Some("Links/leaf.png")); +} + #[test] fn an_unsaved_document_cant_be_packaged() { let mut s = session(); diff --git a/crates/engine/src/tests/placed_document.rs b/crates/engine/src/tests/placed_document.rs index 2420ef265c..c639fc9232 100644 --- a/crates/engine/src/tests/placed_document.rs +++ b/crates/engine/src/tests/placed_document.rs @@ -1042,6 +1042,57 @@ fn saving_a_document_refreshes_its_placed_copies_inside_symbols_and_patterns() { assert_eq!(hashes, [hash.clone(), hash], "the symbol's, then the pattern's"); } +/// Saving a document reads it again for its placed copy in the art of a stored brush of another +/// open document, the only place that document shows it. +#[test] +fn saving_a_document_refreshes_its_placed_copy_in_a_stored_brush() { + let dir = Folder::new("placed-refresh-brush"); + let src = dir.file("logo.vectorcraft"); + source(&src, 100.0, 50.0, RED, 0); + let mut s = session(); + let id = place(&mut s, &src); + s.execute("brush.new", &json!({"type": "scatter", "name": "Logos", "ids": [id.0]})).unwrap(); + s.execute("edit.clear", &json!({"ids": [id.0]})).unwrap(); + let parent = s.active_index().unwrap(); + s.execute("document.open", &json!({"path": src})).unwrap(); + s.execute("select.all", &json!({})).unwrap(); + s.execute("paint.setFill", &json!({"color": "#1414e6"})).unwrap(); + s.execute("document.save", &json!({})).unwrap(); + let hash = Some(vectorcraft_doc::links::hash_bytes(&std::fs::read(&src).unwrap())); + let doc = &s.documents()[parent]; + assert_eq!(doc.history.undo.last().unwrap().label, "Update Links"); + let brush = vectorcraft_brush::find(&doc.doc, "Logos").unwrap(); + let mut hashes = vec![]; + brush.art()[0].walk(&mut |n| { + if let NodeKind::PlacedDocument(p) = &n.kind { + hashes.push(p.link.hash.clone()); + } + }); + assert_eq!(hashes, [hash]); +} + +/// A placed document kept only in a stored brush's art, whose file is gone and of which the +/// document holds only the preview, is output as its preview with the warning that says so. +#[test] +fn a_placed_document_in_a_stored_brush_without_its_file_is_output_as_its_preview() { + let dir = Folder::new("placed-brush-preview"); + let src = dir.file("logo.vectorcraft"); + // Content of its own: files read are cached by content, and this one is removed. + source(&src, 100.0, 50.0, RED, 3); + let mut s = session(); + let id = place(&mut s, &src); + s.execute("brush.new", &json!({"type": "scatter", "name": "Logos", "ids": [id.0]})).unwrap(); + // The copy in the layers has the save keep only the preview. + let doc_path = dir.file("poster.vectorcraft"); + save(&mut s, &doc_path); + std::fs::remove_file(&src).unwrap(); + let r = open(&mut s, &doc_path); + assert_eq!(r["missingLinks"].as_array().map(Vec::len), Some(1), "{r}"); + s.execute("edit.clear", &json!({"ids": [id.0]})).unwrap(); + let svg = s.execute("document.serialize", &json!({"format": "svg"})).unwrap(); + assert!(svg["warnings"].to_string().contains("1 placed document output as its preview"), "{svg}"); +} + #[test] fn link_info_gives_the_artboards_size_not_pixels() { let dir = Folder::new("placed-info"); diff --git a/crates/ui-egui/src/panels/links.rs b/crates/ui-egui/src/panels/links.rs index 2fb130ae3e..f9d9b524c9 100644 --- a/crates/ui-egui/src/panels/links.rs +++ b/crates/ui-egui/src/panels/links.rs @@ -360,8 +360,8 @@ fn badge(ui: &Ui, r: egui::Rect, status: &str) { } /// The tooltip of row `r`. A row outside the layer tree also names where it is stored -/// (`links.list`'s `owner`): the symbol, graph design or pattern whose art holds it, and the object -/// whose opacity mask holds it, by `mask` (that object's name) or else by its id. +/// (`links.list`'s `owner`): the symbol, graph design, pattern or brush whose art holds it, and the +/// object whose opacity mask holds it, by `mask` (that object's name) or else by its id. pub(super) fn status_tip(r: &Value, mask: Option<String>) -> String { let tip = file_tip(r); let owner = &r["owner"]; @@ -370,6 +370,7 @@ pub(super) fn status_tip(r: &Value, mask: Option<String>) -> String { Some("symbol") => Some(tl!("Symbols")), Some("graphDesign") => Some(tl!("Graph Design")), Some("pattern") => Some(tl!("Pattern")), + Some("brush") => Some(tl!("Brushes")), _ => None, }; let tip = match art { diff --git a/crates/ui-egui/src/panels/tests_links.rs b/crates/ui-egui/src/panels/tests_links.rs index 8055c1288c..6b773e9d3b 100644 --- a/crates/ui-egui/src/panels/tests_links.rs +++ b/crates/ui-egui/src/panels/tests_links.rs @@ -189,6 +189,7 @@ fn a_nested_rows_tooltip_names_what_holds_it() { assert_eq!(tip(json!({"kind": "symbol", "name": "Mark"}), None), "/x/a.png\nSymbols: Mark"); assert_eq!(tip(json!({"kind": "pattern", "name": "Dots"}), None), "/x/a.png\nPattern: Dots"); assert_eq!(tip(json!({"kind": "graphDesign", "name": "Bar"}), None), "/x/a.png\nGraph Design: Bar"); + assert_eq!(tip(json!({"kind": "brush", "name": "Leaf", "index": 2}), None), "/x/a.png\nBrushes: Leaf"); assert_eq!(tip(json!({"kind": "layers", "maskOf": 7}), Some("<Ellipse>")), "/x/a.png\nOpacity Mask: <Ellipse>"); assert_eq!(tip(json!({"kind": "symbol", "name": "Mark", "maskOf": 7}), None), "/x/a.png\nSymbols: Mark\nOpacity Mask: 7"); // A row in the layers says only its file. diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..5d49589002 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6992,7 +6992,7 @@ comes back to the front, following the same preference. `links.check` reports ev `missing`), `links.update {ids?}` reads modified files again and `links.relink {ids?, path | folder}` points images at another file (or each at the file of its name in a folder); images keep their bounds, one undo step each. `links.relink`'s `scope` picks which links take the new file (Relink's Replace choice): `selected` (the default) relinks `ids`; `all` also relinks every other stored object linked to the same file as -one of them, in the layers, opacity-mask art, symbols, graph designs and patterns; `missingInFolder` relinks `ids` to `path`, then every other missing link to the file of its name in +one of them, in the layers, opacity-mask art, symbols, graph designs, patterns and the art of the stored brushes; `missingInFolder` relinks `ids` to `path`, then every other missing link to the file of its name in `path`'s folder, and lists the names not there in `notFound` (with `copy`, only missing images are looked for); `each` takes `paths: [{ids, path}]` in place of `ids`, `path` and `folder` and relinks each link to its own file. An unknown scope, `paths` without `each`, `each` with `ids`, `path` or `folder`, an entry without `path` or `ids`, an id in two entries and `missingInFolder` with `folder` are @@ -7000,9 +7000,11 @@ errors, and nothing is relinked. Each call is one undo step. The Links panel's R (`ui.relinkDialog`) with a Replace menu of these four choices. A PNG, JPEG, another file (or each at the file of its name in a folder); images keep their bounds, one undo step each. `links.update`, and `document.open` when it reads a modified file, also read the file again for the images and placed -documents inside symbols, graph designs, patterns and opacity masks that show the same content. Those objects have ids +documents inside symbols, graph designs, patterns, opacity masks and the art of the stored brushes (a scatter or art +brush's art, a pattern brush's tiles) that show the same content. Those objects have ids of their own: `links.list`, `links.check`, `links.findFiles`, the `missingLinks`, `modifiedLinks` and `updatedLinks` -rows and the link watch list them, and every `links.*` command takes their ids. Opening a document gives an object +rows and the link watch list them, and every `links.*` command takes their ids. A `links.*` command that changes a +brush's art writes it back into the brush library with those ids. Opening a document gives an object there whose id is 0 or already used by another object a new id, and the next save writes it. Saving a document also reads it again for the placed documents of it inside that art in the other open documents. A PNG, JPEG, GIF or WebP file whose pixels can't be read is not shown: `links.relink` fails with "the image's pixels can't be @@ -7244,10 +7246,12 @@ listed in `warnings`. ASCII and binary DXF files are read; DWG files answer an e `links.list {show?: all|missing|modified|embedded, sort?: name|kind|status}` lists every image in the layers, top first, as the Links panel does, then every image and placed document in opacity-mask art and in the art of symbols, -graph designs and patterns, one row per stored object (never one per symbol instance or pattern tile): `{id, name, -linked, status: ok|modified|missing|embedded, format, pixelWidth, pixelHeight, path?, found?, page?, preview?, note?, -owner?}` (`owner`, for an object outside the layer tree: `{kind: layers|symbol|graphDesign|pattern, name?, maskOf?}`, -`maskOf` naming the object whose opacity mask holds it; `note`: the image takes more than the decode allowance, 2 GiB +graph designs, patterns and stored brushes, one row per stored object (never one per symbol instance, pattern tile or +brushed stroke): `{id, name, linked, status: ok|modified|missing|embedded, format, pixelWidth, pixelHeight, path?, +found?, page?, preview?, note?, owner?}` (`owner`, for an object outside the layer tree: +`{kind: layers|symbol|graphDesign|pattern|brush, name?, maskOf?, index?, tile?}`, `maskOf` naming the object whose +opacity mask holds it, `index` a brush's place in the library as `brush.list` lists it and `tile` the pattern brush tile +that holds it: `side`, `outerCorner`, `innerCorner`, `start` or `end`; `note`: the image takes more than the decode allowance, 2 GiB or 512 MiB in the web app, as RGBA or as decoded, and it is drawn at the largest size within the allowance ("shown at reduced size"; the document keeps the whole file) or, when it can't be read that way or has more pixels than the allowance has bytes, drawn as a crossed gray box on the canvas and left out of exports ("too large to draw"); `document.open` and `file.place` say the same in their `warnings`). `links.info {id?}` is the Link Info: `image.info`'s fields plus diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..26f3e4035b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1772,6 +1772,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - In the Links panel, Shift-click selects a range of links and Ctrl/Cmd-click adds or removes one. - When a document opens with notes and with linked files that changed on disk (Update Links: Manually) or, on the web, can't be read, the status bar shows the line about the linked files, then counts the notes and names the first, and hovering it lists the notes. The same holds when the line about modified files follows the Linked File Not Found dialog, and File › New from Template… shows the notes of the file it opens as File › Open does (`an_open_with_modified_links_keeps_link_notice_and_import_notes_reachable`, `new_from_template_preserves_open_warnings`, `an_open_with_unreadable_links_keeps_import_notes_reachable`, `modified_links_after_the_missing_ones_keep_the_open_notes`, `combined_open_and_link_status_lists_notes_on_hover_and_for_accessibility`). - Linked images and placed documents kept only in symbols, graph designs, patterns or opacity masks are listed in the Links panel after the layers' own, one row per stored object, with their status in its Missing and Modified filters, in Check Links, in the missing and modified files reported when a document opens, in the link watch and in Find in Folder; Relink, Update, Embed, Placement Options and Link Info act on them, and Go To says they have no place on the canvas. Opening a document gives such an object whose id is 0 or repeats another object's a new id. + - Linked images and placed documents in the art of the stored brushes (a scatter or art brush's art, a pattern brush's tiles) get Links panel rows of their own the same way, one per linked or placed object in each brush tile, naming the brush; Relink, Update, Embed, Placement Options, Link Info and Go To act on that art and write it back into the brush library, and the ids they are listed by are kept there. Evidence: `links_in_stored_brush_art_are_listed_and_checked_with_ids`, `links_commands_act_on_images_in_stored_brush_art_by_id`, `links_in_stored_brush_art_open_by_id_and_unreadable_entries_stay`. - Linked files another app changes while their document is open follow Preferences › File Handling › Update Links, as they do when it opens: Automatically reads them again (an Update Links undo step), Ask When Modified offers to, Manually leaves them modified in the Links panel. The desktop app compares the active document’s linked files by size and modification time every two seconds and when its window comes back to the front, on a worker thread; a file still being written is tried again (`links.updateChanged`). - A look at the linked files whose worker thread ends without a result, such as after a panic, no longer stops later looks: the app clears it, stops asking for a frame every 100 ms, and the next look starts on schedule (`crates/engine/src/tests/linkwatch.rs`, `crates/ui-egui/src/tests/place.rs`). - Import and paste, 2026-10-13: a multi-artboard `.ai` with notes beside its artboards opens from its editing data, a page's art past its artboard no longer lying over the page before it (#1528); a `.ai` gradient whose stops are listed upwards keeps each midpoint on the stop that starts its part of the ramp (#1530); SVG text on a path follows basic shapes (circle, ellipse, rect, line, polyline, polygon) as their SVG 2 equivalent paths (#1531, fixes #1527); PDFs whose alpha soft masks are drawn as images import with the mask instead of empty art (#1551); EPS and PostScript type set in Type 42 (TrueType) fonts imports at its size instead of 1000 times too large (#1553); PDF and EPS import keep a clipping path whose bounding box covers the page but whose shape doesn't (#1544, fixes #1542). Opening or placing a file with an image too large to decode says so, and the Links panel shows it on the row (#1540, part of #1479). Paste takes a PDF or EPS another app copied as editable vector art: from the macOS pasteboard (with SVG), EPS on Windows beside PDF, and `.eps` files copied in a file manager, with the new command `clipboard.importEps` (#1538, fixes #1499). From 4416640bf4a326dcd4e533dfc76a05c4656b30da Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 20:43:34 -0800 Subject: [PATCH 035/108] 3D: Expand as Wireframes outlines each face's own stroke under a later Outline Stroke Expand as Wireframes reshaped the faces of a 3D effect with the geometry effects after it, but the faces it built carried no stroke. An Outline Stroke after the 3D effect then outlined a plain 1 pt stroke with miter joins, while the canvas outlines the round-joined stroke each face is drawn with: the seam stroke (half the facet's thickness, 0.05 to 0.75 pt; 0.75 pt on Revolve) or the 0.5 pt wire edge of the Classic Wireframe surface. The wireframe's faces now carry that stroke, so the expanded edges lie where the drawn outlines lie. --- crates/effects/src/revolve.rs | 21 +++++--- crates/effects/src/solids.rs | 13 +++-- crates/effects/src/solids/classic.rs | 8 ++- crates/effects/src/solids/wireframe.rs | 52 ++++++++++++++------ crates/effects/src/solids/wireframe/tests.rs | 36 ++++++++++++-- 5 files changed, 99 insertions(+), 31 deletions(-) diff --git a/crates/effects/src/revolve.rs b/crates/effects/src/revolve.rs index 74b23340cd..d1e119a807 100644 --- a/crates/effects/src/revolve.rs +++ b/crates/effects/src/revolve.rs @@ -8,6 +8,7 @@ use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, FillLayer, N use vectorcraft_geom::{PathData, PathEl, Point, Rect, Vec2}; use vectorcraft_three_d::{Edge, Revolve}; +use crate::solids::wireframe::WireFace; use crate::solids::{ Profile, Scope, is_container, members, object_profile, past_effect, profile, reshape_members, resolve_for, solid_paints, union_bounds, }; @@ -635,10 +636,16 @@ pub(crate) fn revolve_meshes(n: &Node, total: &mut usize, limit: usize) -> Resul /// effect on the object, the surface in its top visible fill (else its stroke); with it on fills and strokes, one surface for each of /// them, reshaped by the geometry effects after each one's Revolve; on a group or layer, one for /// each member, about one shared axis. The swatches and patterns named by a live-effect plug-in -/// after a fill's or stroke's Revolve are looked up in `doc`. -pub(crate) fn revolve_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec<PathData>, String> { - let faces = |path: &PathData, b: Rect, options: Revolve| -> Result<Vec<PathData>, String> { - Ok(vectorcraft_three_d::revolve(path, b, options)?.iter().map(vectorcraft_three_d::Face::path).collect()) +/// after a fill's or stroke's Revolve are looked up in `doc`. Each face carries the width of the +/// stroke the canvas draws around it ([`surface`]). +pub(crate) fn revolve_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec<WireFace>, String> { + let faces = |path: &PathData, b: Rect, fx: &Effect, options: Revolve| -> Result<Vec<WireFace>, String> { + if fx.id == CLASSIC_REVOLVE { + let p = merged_params(&fx.id, &fx.params); + let facets = vectorcraft_three_d::revolve_facets(path, b, options)?; + return Ok(facets.iter().map(|f| WireFace { path: f.path(), stroke: crate::solids::classic::stroke_width(f, &p) }).collect()); + } + Ok(vectorcraft_three_d::revolve(path, b, options)?.iter().map(|f| WireFace { path: f.path(), stroke: SEAM_WIDTH }).collect()) }; if is_container(n) { let index = n @@ -654,7 +661,7 @@ pub(crate) fn revolve_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec let options = shared_options(&shapes, fx_options(fx))?; let mut out = vec![]; for s in shapes.iter().filter(|s| surface_item(&s.items).is_some()) { - out.extend(faces(&s.path, b, options)?); + out.extend(faces(&s.path, b, fx, options)?); } return Ok(out); } @@ -667,7 +674,7 @@ pub(crate) fn revolve_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec return Err("the revolved object has no fill or stroke".into()); } let b = path.bounds().ok_or("Revolve requires a shape with at least two anchors")?; - return faces(&path, b, fx_options(fx)); + return faces(&path, b, fx, fx_options(fx)); } let path = geometry(&path, &n.appearance.effects, &ctx); let mut out = vec![]; @@ -677,7 +684,7 @@ pub(crate) fn revolve_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec { let p = geometry(&path, item.effects().get(..index).unwrap_or_default(), &ctx.item(item)); let b = p.bounds().ok_or("Revolve requires a shape with at least two anchors")?; - let surface = faces(&p, b, fx_options(fx))?; + let surface = faces(&p, b, fx, fx_options(fx))?; out.extend(crate::solids::wireframe::reshaped(surface, item.effects().get(index + 1..).unwrap_or_default(), &GeomContext { doc, ..ctx })); } } diff --git a/crates/effects/src/solids.rs b/crates/effects/src/solids.rs index 7500af0617..8c53cd2aee 100644 --- a/crates/effects/src/solids.rs +++ b/crates/effects/src/solids.rs @@ -559,10 +559,8 @@ fn surface(n: &Node, facets: Vec<Facet>, paint: &Paint, opacity: f32, blend: Ble .into_iter() .map(|face| { // Adjacent facets, antialiased on their own, would leave hairline seams: a narrow - // stroke of the same paint closes them. No wider than the facet is thick, though: seen - // at a grazing angle a facet can be thinner than the stroke, and its stroke would then - // paint over its neighbours. - let seam = (face.thickness() / 2.0).clamp(0.05, 0.75); + // stroke of the same paint closes them ([`seam_width`]). + let seam = seam_width(&face); if let Some(g) = face.rgb_gradient && (paint.color().is_some() || matches!(paint, Paint::Gradient(_))) { @@ -592,6 +590,13 @@ fn surface(n: &Node, facets: Vec<Facet>, paint: &Paint, opacity: f32, blend: Ble group } +/// The width of the stroke of a facet's own paint that closes the seams between `face` and its +/// neighbors. No wider than the facet is thick: seen at a grazing angle a facet can be thinner than +/// the stroke, and its stroke would then paint over its neighbors. +pub(crate) fn seam_width(face: &Facet) -> f64 { + (face.thickness() / 2.0).clamp(0.05, 0.75) +} + /// Is a surface of `facets` in `paint` one composite of all its facets when [`surface`] draws it /// whole: a solid color under colored lights with smooth shading? fn composites_facets(facets: &[Facet], paint: &Paint, colored: bool) -> bool { diff --git a/crates/effects/src/solids/classic.rs b/crates/effects/src/solids/classic.rs index 23d8d0ffad..29c05406a2 100644 --- a/crates/effects/src/solids/classic.rs +++ b/crates/effects/src/solids/classic.rs @@ -192,6 +192,12 @@ fn shaded(c: Color, tone: f64, spec: f64, shade: Option<Color>) -> Color { Color::rgb(r, g, b) } +/// The width of the stroke [`surface`] draws around `face` with parameters `p`: a wire edge on +/// Wireframe, else the seam between faces. +pub(crate) fn stroke_width(face: &Facet, p: &Value) -> f64 { + if classic_shading(p).surface == ClassicSurface::Wireframe { WIRE } else { super::seam_width(face) } +} + /// One solid's faces in paint `paint`, as a group with the paint's opacity and blend mode, one child /// for each facet: the edges of the faces on Wireframe, else each face filled in its paint shaded by /// its tone and highlight. A gradient with transparent stops is shaded opaque and then masked by @@ -213,7 +219,7 @@ pub(crate) fn surface(n: &Node, facets: Vec<Facet>, source: &Paint, opacity: f32 } let (tone, spec) = shading.tone(face.normal, &lights); // A narrow stroke of the face's own paint closes the hairline seams between faces. - let seam = (face.thickness() / 2.0).clamp(0.05, 0.75); + let seam = super::seam_width(&face); let items = match paint.color() { // Unshaded (No Shading, no shading color, or a face in full light) with no // highlight: the paint itself, its color space and swatch kept. diff --git a/crates/effects/src/solids/wireframe.rs b/crates/effects/src/solids/wireframe.rs index e6e7d89ab5..1e19a21c15 100644 --- a/crates/effects/src/solids/wireframe.rs +++ b/crates/effects/src/solids/wireframe.rs @@ -4,13 +4,13 @@ use std::collections::{HashMap, HashSet, VecDeque}; use std::sync::Arc; use vectorcraft_doc::color::{Color, Paint}; -use vectorcraft_doc::{Appearance, Document, Effect, Node, NodeId}; +use vectorcraft_doc::{Appearance, AppearanceItem, Document, Effect, FillLayer, Node, NodeId}; use vectorcraft_geom::{Anchor, CubicBez, PathData, Point, SubPath}; use vectorcraft_three_d::Facet; use super::{ - Profile, ROTATE, built_solids, facets, geometry, has_solid, is_container, is_plane, is_three_d, label_of, members, object_profile, region, - reshape_members, resolve, resolve_for, solid, solid_paint_sources, solid_parts, union_bounds, + CLASSIC_EXTRUDE, CLASSIC_ROTATE, Profile, ROTATE, built_solids, facets, geometry, has_solid, is_container, is_plane, is_three_d, label_of, + members, object_profile, region, reshape_members, resolve, resolve_for, solid, solid_paint_sources, solid_parts, union_bounds, }; use crate::{GeomContext, is_geometry}; @@ -54,7 +54,7 @@ pub fn three_d_wireframe_in(doc: Option<&Document>, n: &Node) -> Result<Vec<Path // cuts it ([`crate::revolve_art_in`]). let n = &*if revolve { resolve_for(doc, n, label, false)? } else { resolve(doc, n, label)? }; let faces = if revolve { crate::revolve::revolve_face_paths(doc, n)? } else { solid_face_paths(doc, n)? }; - let faces = after_geometry(doc, n, faces, revolve); + let faces: Vec<PathData> = after_geometry(doc, n, faces, revolve).into_iter().map(|f| f.path).collect(); let wire = edges(&faces)?; if wire.is_empty() { return Err(format!("{label} draws no faces for this object")); @@ -65,29 +65,46 @@ pub fn three_d_wireframe_in(doc: Option<&Document>, n: &Node) -> Result<Vec<Path /// `faces` reshaped by the visible geometry effects after the 3D effect of `n`'s own that drew them /// ([`reshaped`]): its first visible Revolve when `revolve` is set, else its first visible Extrude & /// Bevel, Inflate or Rotate. -fn after_geometry(doc: Option<&Document>, n: &Node, faces: Vec<PathData>, revolve: bool) -> Vec<PathData> { +fn after_geometry(doc: Option<&Document>, n: &Node, faces: Vec<WireFace>, revolve: bool) -> Vec<WireFace> { let fx = &n.appearance.effects; let drawn = if revolve { fx.iter().position(|e| e.visible && crate::revolve::is_revolve(&e.id)) } else { solid(fx).map(|(i, _)| i) }; let Some(index) = drawn else { return faces }; reshaped(faces, fx.get(index + 1..).unwrap_or_default(), &GeomContext { doc, ..GeomContext::of(n) }) } +/// One face of a drawn 3D surface: its outline and the width of the stroke the canvas draws around +/// it (the seam between faces, or a wire edge), which a later Outline Stroke outlines. +pub(crate) struct WireFace { + pub(crate) path: PathData, + pub(crate) stroke: f64, +} + /// `faces` reshaped by the visible geometry effects in `later` (the effects after a 3D effect), as /// they reshape the faces of the drawn surface ([`crate::reshape::reshape_leaves`]): each effect /// reshapes each face on its own, about the bounds all the faces have before it, and the faces keep -/// to one budget of anchors together. `ctx` gives the object's id, the seed of a random Transform, -/// and the document. -pub(crate) fn reshaped(faces: Vec<PathData>, later: &[Effect], ctx: &GeomContext) -> Vec<PathData> { +/// to one budget of anchors together. Each face is filled and carries its round-joined stroke, as on +/// the canvas, so an Outline Stroke outlines that stroke. `ctx` gives the object's id, the seed of a +/// random Transform, and the document. +pub(crate) fn reshaped(faces: Vec<WireFace>, later: &[Effect], ctx: &GeomContext) -> Vec<WireFace> { let after: Vec<&Effect> = later.iter().filter(|e| e.visible && is_geometry(&e.id)).collect(); if after.is_empty() { return faces; } let id = NodeId(ctx.seed); - let fill = Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 0.0); - let mut art = Node::group(id, faces.into_iter().map(|f| Arc::new(Node::path(id, f, fill.clone()))).collect()); + let paint = Paint::solid(Color::BLACK); + let face = |f: WireFace| { + let items = + vec![AppearanceItem::Fill(FillLayer::new(paint.clone())), AppearanceItem::Stroke(crate::lighting::seam_stroke(paint.clone(), f.stroke))]; + Arc::new(Node::path(id, f.path, Appearance { items, ..Default::default() })) + }; + let mut art = Node::group(id, faces.into_iter().map(face).collect()); crate::reshape::reshape_leaves(&mut art, &after, later, ctx.doc); let mut out = vec![]; - art.walk(&mut |c| out.extend(c.path_data().cloned())); + art.walk(&mut |c| { + if let Some(path) = c.path_data() { + out.push(WireFace { path: path.clone(), stroke: c.appearance.stroke().map_or(0.0, |s| s.width) }); + } + }); out } @@ -95,7 +112,7 @@ pub(crate) fn reshaped(faces: Vec<PathData>, later: &[Effect], ctx: &GeomContext /// on the object, its solids; with it on fills and strokes, the solid of each; on a group or layer, /// the solids of its members, about one shared axis. The swatches and patterns named by a live-effect /// plug-in after a fill's or stroke's 3D effect are looked up in `doc`. -fn solid_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec<PathData>, String> { +fn solid_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec<WireFace>, String> { if is_container(n) { let (index, fx) = solid(&n.appearance.effects).ok_or("a 3D effect on a group's fill or stroke draws nothing")?; let mut shapes = members(n, label_of(&fx.id))?; @@ -126,17 +143,20 @@ fn solid_face_paths(doc: Option<&Document>, n: &Node) -> Result<Vec<PathData>, S /// Rotate (Classic) turn every fill and stroke; Extrude & Bevel and Inflate build a solid from each shape's /// top fill and from the outline of each stroke. A stroke whose solid is past the limits is left out, /// as it is left out of the drawn art; past the limits of the object's solids together, the result -/// is an error, as the canvas draws the source art. -fn facet_paths(fx: &Effect, shapes: &[Profile]) -> Result<Vec<PathData>, String> { +/// is an error, as the canvas draws the source art. Each facet carries the width of the stroke the +/// canvas draws around it. +fn facet_paths(fx: &Effect, shapes: &[Profile]) -> Result<Vec<WireFace>, String> { let label = label_of(&fx.id); let b = union_bounds(shapes).ok_or_else(|| format!("{label} requires a shape with at least two anchors"))?; let p = crate::merged_params(&fx.id, &fx.params); + let classic = fx.id == CLASSIC_EXTRUDE || fx.id == CLASSIC_ROTATE; + let face = |f: &Facet| WireFace { path: f.path(), stroke: if classic { super::classic::stroke_width(f, &p) } else { super::seam_width(f) } }; let mut out = vec![]; if is_plane(&fx.id) { for s in shapes { for item in &s.items { let (area, rule) = region(&s.path, s.rule, item); - out.extend(facets(ROTATE, &area, rule, b, &p)?.iter().map(Facet::path)); + out.extend(facets(ROTATE, &area, rule, b, &p)?.iter().map(face)); } } return Ok(out); @@ -144,7 +164,7 @@ fn facet_paths(fx: &Effect, shapes: &[Profile]) -> Result<Vec<PathData>, String> let (parts, bounds) = solid_parts(shapes, b); // The solids the art draws, each past the limits of the object's solids together as it is. for f in built_solids(&fx.id, &p, &parts, bounds, vectorcraft_three_d::MAX_OBJECT_FACES) { - out.extend(f?.iter().flatten().map(Facet::path)); + out.extend(f?.iter().flatten().map(face)); } Ok(out) } diff --git a/crates/effects/src/solids/wireframe/tests.rs b/crates/effects/src/solids/wireframe/tests.rs index 792fbdb28a..3d92d3d277 100644 --- a/crates/effects/src/solids/wireframe/tests.rs +++ b/crates/effects/src/solids/wireframe/tests.rs @@ -163,13 +163,43 @@ fn revolve_classic_and_rotate_classic_expand_too() { fn later_geometry_effects_reshape_each_face_on_its_own() { let n = solid_square(super::super::EXTRUDE, json!({})); let fx = [crate::new_effect("path.offsetPath", &json!({"offset": 1.0})).unwrap()]; - let out = reshaped(vec![square(0.0, 0.0, 10.0), square(10.0, 0.0, 10.0)], &fx, &GeomContext::of(&n)); - assert_eq!(out.len(), 2, "{out:?}"); - let (a, b) = (out[0].bounds().unwrap(), out[1].bounds().unwrap()); + let faces = [square(0.0, 0.0, 10.0), square(10.0, 0.0, 10.0)].map(|path| WireFace { path, stroke: 0.75 }); + let out = reshaped(faces.into(), &fx, &GeomContext::of(&n)); + assert_eq!(out.len(), 2); + let (a, b) = (out[0].path.bounds().unwrap(), out[1].path.bounds().unwrap()); assert!((a.x0 + 1.0).abs() < 1e-3 && (a.x1 - 11.0).abs() < 1e-3, "{a:?}"); assert!((b.x0 - 9.0).abs() < 1e-3 && (b.x1 - 21.0).abs() < 1e-3, "{b:?}"); } +/// An Outline Stroke after a 3D effect outlines the stroke each face is drawn with (the seam between +/// faces, or a Classic wire edge), not a plain 1 pt stroke: the wireframe covers the outlined faces +/// the canvas draws, in the same place. +#[test] +fn a_later_outline_stroke_outlines_the_stroke_each_face_is_drawn_with() { + let outline = || crate::new_effect("path.outlineStroke", &json!({})).unwrap(); + let cases = [ + (super::super::EXTRUDE, json!({})), + (super::super::CLASSIC_EXTRUDE, json!({})), + (super::super::CLASSIC_EXTRUDE, json!({"surface": "wireframe"})), + (super::super::INFLATE, json!({})), + (ROTATE, json!({})), + (crate::REVOLVE, json!({})), + (crate::CLASSIC_REVOLVE, json!({})), + (crate::CLASSIC_REVOLVE, json!({"surface": "wireframe"})), + ]; + for (id, params) in cases { + let mut n = solid_square(id, params.clone()); + n.appearance.effects.push(outline()); + let wire = three_d_wireframe_in(None, &n).unwrap_or_else(|e| panic!("{id} {params}: {e}")); + let art = if crate::revolve::is_revolve(id) { crate::revolve_art(&n) } else { super::super::solid_art(&n) }.unwrap(); + let drawn = crate::group::shape_art(None, &art, None).unwrap(); + let (w, a) = (bounds(&wire), bounds(&face_paths(&drawn))); + for (x, y) in [(w.x0, a.x0), (w.y0, a.y0), (w.x1, a.x1), (w.y1, a.y1)] { + assert!((x - y).abs() < 1e-6, "{id} {params}: {w:?} {a:?}"); + } + } +} + /// A geometry effect after a fill's 3D effect moves that fill's edges, as it moves its drawn surface. #[test] fn a_geometry_effect_after_a_fill_s_3d_effect_reshapes_its_edges() { From c08d42fd588ca7f98fd2312d6651b7b4c1d66d09 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 20:57:53 -0800 Subject: [PATCH 036/108] Web: Data Recovery's lock snapshots use the monotonic clock The browser build stamped each snapshot of the Web Locks held with Date.now() and judged its age against Date.now(). After the system clock was set back, an old snapshot read as fresh, so a tab could report no lock on an area another tab still held. Snapshots are now stamped and aged with vectorcraft_ui_egui::now_ms(), and a snapshot stamped later than now is not trusted. --- apps/vectorcraft-web/src/locks.rs | 53 ++++++++++++++++++++++++++++--- apps/vectorcraft-web/src/main.rs | 2 +- 2 files changed, 50 insertions(+), 5 deletions(-) diff --git a/apps/vectorcraft-web/src/locks.rs b/apps/vectorcraft-web/src/locks.rs index 7eb2e6cdb7..dffd87868a 100644 --- a/apps/vectorcraft-web/src/locks.rs +++ b/apps/vectorcraft-web/src/locks.rs @@ -8,23 +8,40 @@ //! Pages that aren't secure (plain `http://` other than localhost) and older browsers have none: //! heartbeats alone decide there. +#[cfg(target_arch = "wasm32")] use std::cell::RefCell; +#[cfg(target_arch = "wasm32")] use std::collections::{BTreeMap, BTreeSet}; +#[cfg(target_arch = "wasm32")] use std::sync::{Arc, Mutex}; +#[cfg(target_arch = "wasm32")] use js_sys::{Function, Promise, Reflect}; +#[cfg(target_arch = "wasm32")] use vectorcraft_engine::cmd::recovery::Hold; +#[cfg(target_arch = "wasm32")] use wasm_bindgen::JsCast as _; +#[cfg(target_arch = "wasm32")] use wasm_bindgen::JsValue; +#[cfg(target_arch = "wasm32")] use wasm_bindgen::closure::Closure; /// How often the snapshot of the locks held is refreshed (ms). +#[cfg(target_arch = "wasm32")] const REFRESH_MS: i32 = 10_000; /// How old a snapshot may be and still be trusted (ms). A lock asked for after the snapshot was /// taken comes with a heartbeat, which stays fresh for at least three minutes, so anything under /// that is safe; an older snapshot counts every area as held. const FRESH_MS: f64 = 60_000.0; +/// Whether a snapshot asked for at `asked` can still be trusted at `now`, both in ms on +/// [`vectorcraft_ui_egui::now_ms`]'s clock: it is at most [`FRESH_MS`] old, and not stamped later +/// than `now`. +fn trusted(asked: f64, now: f64) -> bool { + (0.0..=FRESH_MS).contains(&(now - asked)) +} + +#[cfg(target_arch = "wasm32")] thread_local! { /// What releases each lock this tab holds, by name: it resolves the promise the lock is held /// by (wasm runs on one thread). @@ -32,26 +49,31 @@ thread_local! { } /// The locks of the page, named `<prefix><area>`. +#[cfg(target_arch = "wasm32")] #[derive(Clone)] pub struct WebLocks { prefix: &'static str, - /// The areas whose locks were held at the last snapshot, and when it was asked for (ms since - /// the epoch). `navigator.locks.query()` is asynchronous, so the snapshot is refreshed every + /// The areas whose locks were held at the last snapshot, and when it was asked for (ms on + /// [`vectorcraft_ui_egui::now_ms`]'s monotonic clock, which a change to the system clock does + /// not move). `navigator.locks.query()` is asynchronous, so the snapshot is refreshed every /// [`REFRESH_MS`] and read from here. seen: Arc<Mutex<(f64, BTreeSet<String>)>>, } /// `navigator.locks`, if the browser has it here. +#[cfg(target_arch = "wasm32")] fn manager() -> Option<JsValue> { let locks = Reflect::get(&web_sys::window()?.navigator(), &"locks".into()).ok()?; locks.is_object().then_some(locks) } /// Method `name` of `obj`. +#[cfg(target_arch = "wasm32")] fn method(obj: &JsValue, name: &str) -> Option<Function> { Reflect::get(obj, &name.into()).ok()?.dyn_into().ok() } +#[cfg(target_arch = "wasm32")] impl WebLocks { /// The page's Web Locks with a first snapshot of them, kept fresh from then on; `None` when /// the browser has none or won't say which are held (heartbeats alone decide then). @@ -75,7 +97,7 @@ impl WebLocks { /// Take a new snapshot of the locks held. async fn refresh(&self) -> Option<()> { let m = manager()?; - let asked = js_sys::Date::now(); + let asked = vectorcraft_ui_egui::now_ms(); let query: Promise = method(&m, "query")?.call0(&m).ok()?.dyn_into().ok()?; let snapshot = wasm_bindgen_futures::JsFuture::from(query).await.ok()?; let held = js_sys::Array::from(&Reflect::get(&snapshot, &"held".into()).ok()?); @@ -91,7 +113,7 @@ impl WebLocks { /// Does a tab hold `area`'s lock? Yes when the last snapshot is too old to tell. pub fn held(&self, area: &str) -> bool { let seen = self.seen.lock().unwrap_or_else(|e| e.into_inner()); - js_sys::Date::now() - seen.0 > FRESH_MS || seen.1.contains(area) + !trusted(seen.0, vectorcraft_ui_egui::now_ms()) || seen.1.contains(area) } /// Hold `area`'s lock until the returned hold is dropped (or the page goes). @@ -110,8 +132,10 @@ impl WebLocks { } /// A lock this tab holds (by name), released when dropped. +#[cfg(target_arch = "wasm32")] struct LockHold(String); +#[cfg(target_arch = "wasm32")] impl Drop for LockHold { fn drop(&mut self) { if let Some(resolve) = RELEASE.with(|r| r.borrow_mut().remove(&self.0)) { @@ -120,3 +144,24 @@ impl Drop for LockHold { } } } + +#[cfg(test)] +mod tests { + use super::*; + + #[test] + fn a_snapshot_is_trusted_for_a_minute() { + assert!(trusted(1_000.0, 1_000.0)); + assert!(trusted(1_000.0, 1_000.0 + FRESH_MS)); + assert!(!trusted(1_000.0, 1_001.0 + FRESH_MS)); + // Before the first snapshot every area counts as held. + assert!(!trusted(f64::NEG_INFINITY, 0.0)); + } + + #[test] + fn a_snapshot_stamped_later_than_now_is_not_trusted() { + // A clock that went back reads an old snapshot as taken in the future. + assert!(!trusted(5_000_000.0, 1_000.0)); + assert!(!trusted(1_001.0, 1_000.0)); + } +} diff --git a/apps/vectorcraft-web/src/main.rs b/apps/vectorcraft-web/src/main.rs index 3808c281f9..457d8d4640 100644 --- a/apps/vectorcraft-web/src/main.rs +++ b/apps/vectorcraft-web/src/main.rs @@ -25,7 +25,7 @@ mod api; mod fonts; #[cfg(any(target_arch = "wasm32", test))] mod keys; -#[cfg(target_arch = "wasm32")] +#[cfg(any(target_arch = "wasm32", test))] mod locks; #[cfg(any(target_arch = "wasm32", test))] mod pencil; From ab0ae9f88055872e65c927f7a85498a7f001149b Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 20:59:14 -0800 Subject: [PATCH 037/108] Type: area type insets stop at the frame's edges, not at an edge its contours share An edge that two contours of an area type frame share lies inside the frame, and lines already run across it. Inset Spacing still kept text clear of it, so a frame of contours that meet along an edge left a gap of twice the inset at the seam. The inset now applies only beside the stretches of edges that bound the frame, counted by parity as the line spans are. A negative text wrap offset no longer shrinks a wrap object beside an edge two of its contours share. --- crates/text/src/layout/region.rs | 107 ++++++++++++++++++++++++++++--- docs/target-app-parity.md | 2 +- 2 files changed, 99 insertions(+), 10 deletions(-) diff --git a/crates/text/src/layout/region.rs b/crates/text/src/layout/region.rs index 34c48942d5..b8bad9a246 100644 --- a/crates/text/src/layout/region.rs +++ b/crates/text/src/layout/region.rs @@ -120,7 +120,8 @@ fn near_segment_in_band(a: Point, b: Point, top: f64, bottom: f64, r: f64) -> Op } /// [`band_intervals`] less every x at which some point of the band `top..bottom` is closer than -/// `inset` to an edge of `polys` (holes included), measured from the edge itself. +/// `inset` to an edge of `polys` (holes included), measured from the edge itself. A stretch of an +/// edge that contours meet along bounds no part of the shape, so the inset does not apply beside it. fn band_inset_intervals(polys: &[Vec<Point>], top: f64, bottom: f64, inset: f64) -> Vec<(f64, f64)> { let iv = band_intervals(polys, top, bottom); if inset <= 0.0 || iv.is_empty() { @@ -130,10 +131,68 @@ fn band_inset_intervals(polys: &[Vec<Point>], top: f64, bottom: f64, inset: f64) return vec![]; } let (top, bottom) = (top.min(bottom), top.max(bottom)); - let near = polys.iter().flat_map(|p| (0..p.len()).filter_map(move |i| near_segment_in_band(p[i], p[(i + 1) % p.len()], top, bottom, inset))); + let edges = boundary_segments(polys, |lo, hi| hi > top - inset && lo < bottom + inset); + let near = edges.into_iter().filter_map(|(a, b)| near_segment_in_band(a, b, top, bottom, inset)); subtract_intervals(&iv, &union_intervals(near.collect())) } +/// The stretches of the edges of `polys` that bound the shape (even-odd), among the edges whose y +/// range `lo..hi` `keep` accepts. Edges that lie exactly along one line and overlap there (contours +/// that meet along an edge, however each one divides it) count by parity, as in +/// [`slant_boundaries`]: a stretch that an even number of them cover has the shape on both sides +/// and is left out. Edges of no length are left out. At most [`MAX_EDGE_PAIRS`] pairs are compared; +/// edges left unpaired count whole. +fn boundary_segments(polys: &[Vec<Point>], keep: impl Fn(f64, f64) -> bool) -> Vec<(Point, Point)> { + fn root(parent: &mut [usize], mut i: usize) -> usize { + while parent[i] != i { + parent[i] = parent[parent[i]]; + i = parent[i]; + } + i + } + let mut edges: Vec<(Point, Point)> = polys + .iter() + .flat_map(|p| (0..p.len()).map(move |i| (p[i], p[(i + 1) % p.len()]))) + .filter(|&(a, b)| a != b && keep(a.y.min(b.y), a.y.max(b.y))) + .collect(); + // Edges along one line overlap in x, so only edges whose x ranges overlap are compared. + edges.sort_by(|u, v| u.0.x.min(u.1.x).total_cmp(&v.0.x.min(v.1.x))); + let mut parent: Vec<usize> = (0..edges.len()).collect(); + let mut pairs = 0; + 'edges: for (i, &(p, q)) in edges.iter().enumerate() { + // The x ranges of edges along one line can differ by rounding, as in `slant_boundaries`. + let scale = p.x.abs().max(p.y.abs()).max(q.x.abs()).max(q.y.abs()).max(1.0); + let x1 = p.x.max(q.x) + 4.0 * f64::EPSILON * scale; + for (j, &(r, s)) in edges.iter().enumerate().skip(i + 1).take_while(|(_, o)| o.0.x.min(o.1.x) <= x1) { + pairs += 1; + if pairs > MAX_EDGE_PAIRS { + break 'edges; + } + if on_line_exactly(p, q, r) && on_line_exactly(p, q, s) { + let (a, b) = (root(&mut parent, i), root(&mut parent, j)); + parent[a] = b; + } + } + } + let mut groups: Vec<(usize, usize)> = (0..edges.len()).map(|i| (root(&mut parent, i), i)).collect(); + groups.sort_unstable(); + let mut out = Vec::new(); + for run in groups.chunk_by(|a, b| a.0 == b.0) { + if let [(_, i)] = run { + out.push(edges[*i]); + continue; + } + // The stretches an odd number of the edges cover: pairs of their ends, sorted along the + // line by whichever coordinate changes more along it. + let (p, q) = edges[run[0].1]; + let by_x = (q.x - p.x).abs() >= (q.y - p.y).abs(); + let mut ends: Vec<Point> = run.iter().flat_map(|&(_, i)| [edges[i].0, edges[i].1]).collect(); + ends.sort_by(|a, b| if by_x { a.x.total_cmp(&b.x) } else { a.y.total_cmp(&b.y) }); + out.extend(ends.as_chunks::<2>().0.iter().filter(|c| c[0] != c[1]).map(|c| (c[0], c[1]))); + } + out +} + /// Union of sorted-or-not intervals. fn union_intervals(mut v: Vec<(f64, f64)>) -> Vec<(f64, f64)> { v.sort_by(|a, b| a.0.total_cmp(&b.0)); @@ -500,6 +559,9 @@ fn eroded_cover(polys: &[Vec<Point>], top: f64, bottom: f64, d: f64) -> Vec<(f64 cuts.dedup(); } } + // A stretch of an edge that contours meet along bounds no part of the shape, so the shape is + // not shrunk beside it. + let edges = boundary_segments(polys, |lo, hi| hi > top - r && lo < bottom + r); let mut out = Vec::new(); // A band of no height keeps its two equal cuts: one piece of no height, measured at its y. for w in cuts.windows(2) { @@ -510,13 +572,10 @@ fn eroded_cover(polys: &[Vec<Point>], top: f64, bottom: f64, d: f64) -> Vec<(f64 } // The points closer than `d` to an edge make a convex shape, so a vertical line within // the piece lies in it when both its ends do. - let near = polys.iter().flat_map(|p| { - (0..p.len()).filter_map(move |i| { - let (s, t) = (p[i], p[(i + 1) % p.len()]); - let (u, v) = (near_segment(s, t, a, r)?, near_segment(s, t, b, r)?); - let (x, y) = (u.0.max(v.0), u.1.min(v.1)); - (y > x).then_some((x, y)) - }) + let near = edges.iter().filter_map(|&(s, t)| { + let (u, v) = (near_segment(s, t, a, r)?, near_segment(s, t, b, r)?); + let (x, y) = (u.0.max(v.0), u.1.min(v.1)); + (y > x).then_some((x, y)) }); out.extend(subtract_intervals(&cover, &union_intervals(near.collect()))); } @@ -1090,6 +1149,36 @@ fn inset_keeps_text_clear_of_a_hole_s_sloped_edges() { assert_spans(&spans[0], &[(5.0, 36.0 - clear), (64.0 + clear, 95.0)]); } +/// The inset is not kept beside an edge two contours share, vertical, horizontal or slanted with an +/// extra anchor on one side, and is still kept beside the part of an edge only one contour covers. +#[cfg(test)] +#[test] +fn inset_is_not_kept_beside_an_edge_two_contours_share() { + let opts = LayoutOptions { inset: 5.0, ..LayoutOptions::default() }; + let side = closed(&[&[(0.0, 0.0), (50.0, 0.0), (50.0, 100.0), (0.0, 100.0)], &[(50.0, 0.0), (100.0, 0.0), (100.0, 100.0), (50.0, 100.0)]]); + assert_spans(&cell_spans(&side, &opts, &[], 40.0, 44.0)[0], &[(5.0, 95.0)]); + let seam = closed(&[&[(0.0, 0.0), (100.0, 0.0), (100.0, 50.0), (0.0, 50.0)], &[(0.0, 50.0), (100.0, 50.0), (100.0, 100.0), (0.0, 100.0)]]); + assert_spans(&cell_spans(&seam, &opts, &[], 46.0, 54.0)[0], &[(5.0, 95.0)]); + let slanted = + closed(&[&[(0.0, 0.0), (40.0, 0.0), (50.0, 50.0), (60.0, 100.0), (0.0, 100.0)], &[(40.0, 0.0), (100.0, 0.0), (100.0, 100.0), (60.0, 100.0)]]); + assert_spans(&cell_spans(&slanted, &opts, &[], 40.0, 44.0)[0], &[(5.0, 95.0)]); + // The lower contour covers only the left half of the upper one's bottom edge: the right half + // and the corner where they meet still keep the inset. + let step = closed(&[&[(0.0, 0.0), (100.0, 0.0), (100.0, 50.0), (0.0, 50.0)], &[(0.0, 50.0), (50.0, 50.0), (50.0, 100.0), (0.0, 100.0)]]); + assert_spans(&cell_spans(&step, &opts, &[], 46.0, 48.0)[0], &[(5.0, 50.0 - 21f64.sqrt())]); +} + +/// A negative wrap offset does not shrink a wrap object beside an edge two of its contours share, +/// with or without Invert Wrap. +#[cfg(test)] +#[test] +fn negative_wrap_offset_does_not_shrink_beside_an_edge_two_contours_share() { + let left: &[(f64, f64)] = &[(40.0, 40.0), (50.0, 40.0), (50.0, 60.0), (40.0, 60.0)]; + let right: &[(f64, f64)] = &[(50.0, 40.0), (60.0, 40.0), (60.0, 60.0), (50.0, 60.0)]; + assert_spans(&wrap_spans(&[left, right], -5.0, false, 44.0, 50.0), &[(0.0, 45.0), (55.0, 100.0)]); + assert_spans(&wrap_spans(&[left, right], -5.0, true, 46.0, 54.0), &[(45.0, 55.0)]); +} + /// In a frame of columns, the inset is kept once from a column's inner edge and once from the /// frame's sloped edge. #[cfg(test)] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..44deaa7924 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1316,7 +1316,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Paragraph alignment:** the shared Paragraph/Properties alignment row leaves every button unselected when the paragraphs it acts on differ. Auto resolves per paragraph; choosing an alignment uses the existing command. Headless paragraph_mixed_alignment_* regressions exercise mixed → Center → Undo, caret/uniform states, Unicode range boundaries, Auto/direction, split runs and grouped text. These regressions and full integration CI pass. Original captures confirm mixed → Center → Undo in the existing alignment-button layout. The [public Paragraph panel guide](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/paragraph-panel-overview.html) lists the seven controls, but does not specify mixed-state rendering. Other paragraph fields remain outside this change; scores and hours unchanged. For Auto Size area type in columns, the bisection for the frame's height runs on the lines of the one-column layout, and its result is checked with at most two layouts of the columns. When the text wraps around objects or does not fit the one-column layout, or when the check fails, the columns are laid out at every step of the bisection, as before. Typing at the start of a story of 50,000 characters in 2 columns took 1,670 ms a keystroke and now takes 292 ms (release build, `auto_height_in_columns_typing_timing`). Exports to PDF, EPS, SVG, EMF, WMF and the raster formats warn about the area type and type on a path that they draw without the text that doesn't fit, and give their ids, as Print and Print Preview do. - On a shaped area type frame, Inset Spacing keeps text that far from the frame's edge, holes included, measured from the edge itself rather than along the line; the archived help treats the inset as the space an area type object leaves between its text and the path that bounds it (<https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=317>, <https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=325>). A rectangular frame keeps its inset from each side as before, and a column's inner edges keep it once. Tests: `layout::region::inset_on_a_shaped_frame_is_measured_from_its_sloped_edge`, `inset_keeps_text_clear_of_a_hole_s_sloped_edges`, `inset_applies_once_at_a_column_s_edge_and_at_the_frame_s_edge`. + On a shaped area type frame, Inset Spacing keeps text that far from the frame's edge, holes included, measured from the edge itself rather than along the line; the archived help treats the inset as the space an area type object leaves between its text and the path that bounds it (<https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=317>, <https://web.archive.org/web/20220911143322/https://helpx.adobe.com/pdf/cs6/illustrator_reference.pdf#page=325>). A rectangular frame keeps its inset from each side as before, and a column's inner edges keep it once. An edge that two contours of the frame share lies inside the frame, so text runs across it with no inset on either side, and a negative text wrap offset does not shrink a wrap object beside such an edge. Tests: `layout::region::inset_on_a_shaped_frame_is_measured_from_its_sloped_edge`, `inset_keeps_text_clear_of_a_hole_s_sloped_edges`, `inset_applies_once_at_a_column_s_edge_and_at_the_frame_s_edge`, `inset_is_not_kept_beside_an_edge_two_contours_share`, `negative_wrap_offset_does_not_shrink_beside_an_edge_two_contours_share`. An edit copies a thread's story only when it changes one of the thread's frames: with a story of 50,000 characters threaded through 8 frames with a style change at every word, moving another object took 7.8 ms and now takes 0.013 ms, and a frame of a drag took 7.2 ms and now takes 0.012 ms (release build, `threaded_story_edit_timing`). When a story flows through threaded area type, each frame is measured with the whole paragraphs of the story that it needs and a few more, not with the whole rest of the story, and it keeps the same text as before. A story of 1,500 one-line paragraphs (55,892 bytes) through 40 frames was laid out over 2,126,762 bytes of text while the frames were measured, and is now laid out over 21,035 (`thread::tests::many_frames_measure_about_the_text_they_take`). Area type with its lines aligned to the center, the bottom or justified vertically, and type on a path whose first paragraph is aligned Left, Justify Left, Justify All or Auto, are measured the same way: the same story through 40 area frames aligned to the center was laid out over 2,126,762 bytes and is now laid out over 21,035, through 40 paths aligned Left over 2,135,202 bytes and now over 20,583, and through 40 paths aligned Justify All over 2,135,202 bytes and now over 20,583 (same test). Shrink Text to Fit, Dynamic Text, Optical Margin Alignment and Roman Hanging Punctuation on a path, a path aligned to the center or the right, horizontal type on a path whose first paragraph is set right to left or with right-to-left text in the rest of the story, and a frame whose share ends in the story's last paragraph are still measured with the whole rest. A paragraph that continues from one threaded frame into the next has its first-line indent and bullet or number in the frame where it starts; in the next frame its first line starts where its wrapped lines start. In frames that are no longer threaded, copies of a frame and point type converted from one, the first paragraph has its indent and bullet or number again. From 7abd11d19db2dae884b05e69ad8a9398b2fb603a Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:07:28 -0800 Subject: [PATCH 038/108] Plug-ins: windows and processes take turns on the Plug-ins folder Two windows or processes using one Plug-ins folder could interleave their writes: an install from one could leave its module with the other's grant, a grant written for one plug-in could drop one written for another, and plug-in settings and cache changes could lose each other's keys or pass the cache caps together. Each change to the folder now runs in one turn on disabled.lock, the file the disabled list was already locked with: - plugin.install takes the turn before it reads the stored grants and holds it through the module, grant, put-back and disabled-list writes; plugin.remove holds it through grant removal and storage deletion. - Grant writes, the disabled list, loading the folder, and the plug-ins' settings and cache changes read and write in a turn. - When disabled.lock can't be locked, plugin.install and plugin.remove fail and change nothing, plugin.setEnabled keeps its change in the process, and loading the folder writes nothing to it. Docs: docs/plugins.md, docs/mcp.md, the plugin.install and plugin.remove params text, docs/target-app-parity.md. --- crates/engine/src/cmd/plugin.rs | 127 ++++++++++------ crates/engine/src/store.rs | 233 ++++++++++++++++++++++------- crates/engine/src/tests/plugins.rs | 214 +++++++++++++++++++++++++- crates/engine/tests/plugin_fuzz.rs | 5 +- docs/mcp.md | 4 +- docs/plugins.md | 8 +- docs/target-app-parity.md | 1 + 7 files changed, 482 insertions(+), 110 deletions(-) diff --git a/crates/engine/src/cmd/plugin.rs b/crates/engine/src/cmd/plugin.rs index 3fa082bdb0..867f256b4c 100644 --- a/crates/engine/src/cmd/plugin.rs +++ b/crates/engine/src/cmd/plugin.rs @@ -51,6 +51,7 @@ use vectorcraft_doc::{Effect, Node}; use vectorcraft_plugins::{Budget, Command, Kind, Plugin, effect, export, objects, registry, safe_mode}; use super::{CommandSpec, EngineError, NodeId, Result, Session, always, bad, cmd, has_doc, ids_param, str_param, switch_or}; +use crate::store::StoreTurn; use vectorcraft_plugins::permissions::{self, Grant, GrantToken, Permission}; @@ -683,6 +684,9 @@ thread_local! { /// Tests: runs once in the next `plugin.install` on this thread after it installs and before it /// writes the store. pub(crate) static BEFORE_STORE: std::cell::RefCell<Option<Box<dyn FnOnce()>>> = const { std::cell::RefCell::new(None) }; + /// Tests: runs once on this thread when [`keep_installed`] has written the module to the store + /// and before it writes the grant. + pub(crate) static BEFORE_GRANT_STORED: std::cell::RefCell<Option<Box<dyn FnOnce()>>> = const { std::cell::RefCell::new(None) }; /// Tests: runs once on this thread when [`hold_plugin_changes`] finds the lock held and waits. pub(crate) static WHILE_WAITING: std::cell::RefCell<Option<Box<dyn FnOnce()>>> = const { std::cell::RefCell::new(None) }; } @@ -718,7 +722,9 @@ pub(crate) fn hold_plugin_changes() -> std::sync::MutexGuard<'static, ()> { /// the next start → its `plugin.list` entry. A refused install changes neither the plug-in store /// nor the plug-ins and grants of the process. A module that lists no permissions ends any grant /// held for its id. A `plugin.remove` in another session waits until the install has written the -/// store. +/// store. With a plug-in store, all of it happens in a turn on the store ([`StoreTurn`]), so another +/// process using the same folder changes it before or after; when the store can't be locked, nothing +/// is installed. fn install(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "plugin.install"; // One use: spent whatever this install does. @@ -736,8 +742,11 @@ fn install(s: &mut Session, p: &Value) -> Result<Value> { { return Err(bad(C, "the module doesn't have the SHA-256 `hash` gives: nothing was installed")); } - // A removal in another session waits until the store holds what this install wrote. + // A removal in another session waits until the store holds what this install wrote, and so + // does a change of the store by another process. let _held = hold_plugin_changes(); + let turn = + s.plugin_store_turn().map_err(|e| EngineError::Other(format!("{C}: {}: {e}: nothing was installed", crate::store::STORE_NOT_LOCKED)))?; // The grant the checks below count on, the approval included. The install checks it again, // with the plug-in installed under the id, before anything is stored: another session may // change either in between. @@ -844,41 +853,12 @@ fn install(s: &mut Session, p: &Value) -> Result<Value> { } // The plug-in gets the settings and cache kept for its id. A module without permissions takes // the id over, so nothing the user approved for the id applies any more. - let installed = registry::install_checked(plugin, update, check, || s.attach_plugin_storage(&id), err)?; + let installed = registry::install_checked(plugin, update, check, || s.attach_plugin_storage(&turn, &id), err)?; #[cfg(test)] if let Some(between) = BEFORE_STORE.take() { between(); } - // Installed plug-ins stay installed after a restart (#2541). The module is written first and its - // grant only once it is there; when the grant can't be written, the store gets the module it - // held back. A failed write of that module is only logged: the store then holds the new module, - // which the grant doesn't cover. A write that reports a failure may still have put the old - // module back, so the store is read again to tell which module it holds. A stored module that - // can't be read back isn't replaced by one that needs a grant. - let previous = s.stored_plugin_bytes(&id); - let mut stored = (previous.is_ok() || !asks) && s.store_plugin(&id, &bytes); - let holds_new = |s: &Session| s.stored_plugin_bytes(&id).is_ok_and(|held| held.as_deref() == Some(&bytes[..])); - if asks { - if stored && !s.store_grant(&id, Some(g)) { - stored = !s.put_back_plugin(&id, previous.ok().flatten().as_deref()) && holds_new(s); - } - } else { - // When the write failed, the old stored module stays in the folder and needs its grant at - // the next launch. A grant that can't be removed still approves the old bytes, so the store - // gets the module it held back. When that module can't be read or written back, or there - // was none, no module goes with the grant, and the grant stops counting for every session in - // the process attached to the folder. A grants file that is too large or doesn't hold a list - // approves nothing, and the new module stays; one that can't be opened or read may approve - // the old bytes once it reads again. - let writes = s.grant_writes(); - if stored && !s.store_grant(&id, None) && s.holds_plugin_grant(&id) { - let back = previous.as_ref().is_ok_and(|held| s.put_back_plugin(&id, held.as_deref())); - stored = !back && holds_new(s); - if !back || matches!(previous, Ok(None)) { - s.ignore_stored_grant(&id, writes); - } - } - } + let stored = keep_installed(s, &turn, &id, &bytes, asks.then_some(g)); // Installing a disabled plug-in again (an updated version) turns it on for the next launch too, // also when it is disabled by its stored file alone (it stopped a launch while loading). When // the new version could not replace the stored file, the old one stays disabled. @@ -891,8 +871,9 @@ fn install(s: &mut Session, p: &Value) -> Result<Value> { } } if changed { - s.store_disabled_plugins(); + s.store_disabled_plugins_in(&turn); } + drop(turn); let mut v = describe_installed(&installed); if !unknown.is_empty() { v["unknownCommands"] = json!(unknown); @@ -900,6 +881,53 @@ fn install(s: &mut Session, p: &Value) -> Result<Value> { Ok(v) } +/// Keeps the plug-in `id` that `plugin.install` installed, its module `bytes`, in the plug-in store, +/// in `turn`, with `grant` when its module lists permissions (`None`: it lists none, and the grant +/// held for the id is removed) → whether the store now holds the new module (`false` without a +/// store). +/// +/// Installed plug-ins stay installed after a restart (#2541). The module is written first and its +/// grant only once it is there; when the grant can't be written, the store gets the module it held +/// back. A failed write of that module is only logged: the store then holds the new module, which +/// the grant doesn't cover. A write that reports a failure may still have put the old module back, +/// so the store is read again to tell which module it holds. A stored module that can't be read back +/// isn't replaced by one that needs a grant. +pub(crate) fn keep_installed(s: &Session, turn: &StoreTurn, id: &str, bytes: &[u8], grant: Option<Grant>) -> bool { + let asks = grant.is_some(); + let previous = s.stored_plugin_bytes(id); + let mut stored = (previous.is_ok() || !asks) && s.store_plugin(turn, id, bytes); + #[cfg(test)] + if let Some(between) = BEFORE_GRANT_STORED.take() { + between(); + } + let holds_new = |s: &Session| s.stored_plugin_bytes(id).is_ok_and(|held| held.as_deref() == Some(bytes)); + match grant { + Some(g) => { + if stored && !s.store_grant_in(turn, id, Some(g)) { + stored = !s.put_back_plugin(turn, id, previous.ok().flatten().as_deref()) && holds_new(s); + } + } + None => { + // When the write failed, the old stored module stays in the folder and needs its grant + // at the next launch. A grant that can't be removed still approves the old bytes, so the + // store gets the module it held back. When that module can't be read or written back, or + // there was none, no module goes with the grant, and the grant stops counting for every + // session in the process attached to the folder. A grants file that is too large or + // doesn't hold a list approves nothing, and the new module stays; one that can't be + // opened or read may approve the old bytes once it reads again. + let writes = s.grant_writes(); + if stored && !s.store_grant_in(turn, id, None) && s.holds_plugin_grant(id) { + let back = previous.as_ref().is_ok_and(|held| s.put_back_plugin(turn, id, held.as_deref())); + stored = !back && holds_new(s); + if !back || matches!(previous, Ok(None)) { + s.ignore_stored_grant(id, writes); + } + } + } + } + stored +} + /// `plugin.inspect`: what installing the module would install, without installing it, whether that /// needs the user to grant its permissions first (`needsApproval`) and whether it would take /// another module's place (`needsReplace`). @@ -992,15 +1020,17 @@ fn load_folder(s: &Session, folder: &str) -> Value { None if crate::file_access::current().is_none() => Ok(()), None => Err(format!("automation path rejected: {} isn't valid text", f.display())), }; - // A `plugin.install` in another session finishes writing the store first. + // A `plugin.install` in another session or process finishes writing the store first. When the + // store can't be locked, the folder still loads, and the store isn't written. let _held = hold_plugin_changes(); + let turn = s.plugin_store_turn().unwrap_or_else(|_| StoreTurn::unheld()); match registry::load_folder_where(std::path::Path::new(folder), allow, s.plugin_folder_approver()) { Ok(r) => { for id in &r.loaded { - s.attach_plugin_storage(id); + s.attach_plugin_storage(&turn, id); } if r.disabled_changed { - s.store_disabled_plugins(); + s.store_disabled_plugins_in(&turn); } json!({"folder": folder, "loaded": r.loaded, "failed": r.failed.iter().map(|(f, e)| json!({"file": f, "error": e})).collect::<Vec<_>>()}) } @@ -1140,6 +1170,9 @@ fn set_enabled(s: &mut Session, p: &Value) -> Result<Value> { (None, None) => return Err(bad(C, "give `id` or `file` (see plugin.safeMode)")), }; let items: Vec<&safe_mode::Item> = std::iter::once(&item).chain(stored.as_ref()).collect(); + // The list is changed and saved in one turn on the plug-in store, so that an install in another + // process doesn't change the store in between. + let turn = s.plugin_store_turn().ok(); if enabled && !safe_mode::disabled().iter().any(|i| items.iter().any(|item| i.same(item))) { return Err(bad(C, "that plug-in isn't disabled (see plugin.safeMode)")); } @@ -1149,7 +1182,7 @@ fn set_enabled(s: &mut Session, p: &Value) -> Result<Value> { } // Without a plug-in folder (a session confined to automation roots), or when the list there // can't take the change, the change stays in this process and goes with the next change that saves. - let saved = !changed || s.store_disabled_plugins(); + let saved = !changed || turn.as_ref().is_some_and(|turn| s.store_disabled_plugins_in(turn)); Ok(json!({"changed": changed, "saved": saved, "disabled": safe_mode::disabled().iter().map(shown_item).collect::<Vec<_>>()})) } @@ -1164,31 +1197,35 @@ fn info(_: &mut Session, p: &Value) -> Result<Value> { fn remove(s: &mut Session, p: &Value) -> Result<Value> { let id = str_param(p, "id").ok_or_else(|| bad("plugin.remove", "missing `id`"))?; - // An install in another session finishes its store writes first. + // An install in another session or process finishes its store writes first. When the store + // can't be locked, nothing is removed. let _held = hold_plugin_changes(); + let turn = s + .plugin_store_turn() + .map_err(|e| EngineError::Other(format!("plugin.remove: {}: {e}: nothing was removed", crate::store::STORE_NOT_LOCKED)))?; let installed = registry::get(id).is_some(); // Settings and cache the store keeps for an id that isn't installed are deleted too. let stored = !installed && vectorcraft_plugins::manifest::valid_id(id) && s.has_plugin_storage(id); // Installed again, it asks again. A grant that can't be removed still approves the module, and // so may a grants file that can't be opened or read. One that is too large or doesn't hold a // list approves nothing and doesn't stop the removal. - let forget = || s.store_grant(id, None) || !s.holds_plugin_grant(id); + let forget = || s.store_grant_in(&turn, id, None) || !s.holds_plugin_grant(id); // Its settings and cache are moved aside and its grant removed before anything is deleted: when // either can't be done, the plug-in stays installed, as it was, and a second `plugin.remove` // tries again. let failed = if installed || stored { - s.remove_plugin_storage(id, forget).err().map(|e| e.to_string()) + s.remove_plugin_storage(&turn, id, forget).err().map(|e| e.to_string()) } else { (!forget()).then(|| crate::store::GRANT_NOT_REMOVED.to_string()) }; if let Some(e) = failed { if installed { - s.attach_plugin_storage(id); + s.attach_plugin_storage(&turn, id); } return Err(EngineError::Other(e)); } registry::revoke(id); - s.unstore_plugin(id); + s.unstore_plugin(&turn, id); if !stored && (!installed || !registry::remove(id)) { return Err(err(vectorcraft_plugins::Error::NotFound(id.into()))); } @@ -1248,7 +1285,7 @@ pub fn specs() -> Vec<CommandSpec> { "Install Plug-in", [], None, - "{path: a .wasm file (desktop) | dataBase64: the module (+ name?: shown as its source), replace?: bool (true once the user agreed: a module with other bytes than the plug-in installed with its id, or with none installed, one whose id has settings or a cache in the plug-in store, installs only with it, takes that plug-in's place and gets its settings and cache; false: one whose id is installed is refused; left out, the same module installs again), name?: file name (with dataBase64), allowHeavy?: bool (a filter whose manifest asks for a heavy budget, budget \"heavy\" in plugin.inspect, installs only with it), grant?: [permission] (a plug-in whose manifest lists permissions, needsApproval in plugin.inspect, installs only when grant holds every one of them; the grant is recorded with the module's hash and covers only that module, so a module with other bytes needs a new grant even when it lists the same permissions; installing a module that lists no permissions forgets the grant held for its id; a refused install keeps the grant, a failed write of the module to the plug-in store leaves the grant in the store, and a stored module that is disabled or not read in Safe Mode keeps the grant for its id; with a plug-in store attached, only the grants kept there count; a request's allowHeavy and grant are refused unless the session was started with vectorcraft-cli --allow-plugin-grants: in the desktop app a person approves the install, see ui.installPlugin, and a module whose hash is already recorded, by a person's approval or by a grant accepted under that flag, needs no grant), hash?: string (the module's SHA-256 as plugin.inspect gave it: a module with other bytes is refused)} validate and install a WebAssembly plug-in for this session (a module whose commandAllowlist names a command no plug-in may call, such as one that reads or writes files, is refused) → its plugin.list entry, plus unknownCommands?: [id] (commandAllowlist ids no command has; a call of one fails)", + "{path: a .wasm file (desktop) | dataBase64: the module (+ name?: shown as its source), replace?: bool (true once the user agreed: a module with other bytes than the plug-in installed with its id, or with none installed, one whose id has settings or a cache in the plug-in store, installs only with it, takes that plug-in's place and gets its settings and cache; false: one whose id is installed is refused; left out, the same module installs again), name?: file name (with dataBase64), allowHeavy?: bool (a filter whose manifest asks for a heavy budget, budget \"heavy\" in plugin.inspect, installs only with it), grant?: [permission] (a plug-in whose manifest lists permissions, needsApproval in plugin.inspect, installs only when grant holds every one of them; the grant is recorded with the module's hash and covers only that module, so a module with other bytes needs a new grant even when it lists the same permissions; installing a module that lists no permissions forgets the grant held for its id; a refused install keeps the grant, a failed write of the module to the plug-in store leaves the grant in the store, and a stored module that is disabled or not read in Safe Mode keeps the grant for its id; with a plug-in store attached, only the grants kept there count; a request's allowHeavy and grant are refused unless the session was started with vectorcraft-cli --allow-plugin-grants: in the desktop app a person approves the install, see ui.installPlugin, and a module whose hash is already recorded, by a person's approval or by a grant accepted under that flag, needs no grant), hash?: string (the module's SHA-256 as plugin.inspect gave it: a module with other bytes is refused)} validate and install a WebAssembly plug-in for this session (with a plug-in store, the install waits while another window or process changes the store and writes the module and its grant before that window or process changes it again; when the store's disabled.lock can't be locked, nothing is installed) (a module whose commandAllowlist names a command no plug-in may call, such as one that reads or writes files, is refused) → its plugin.list entry, plus unknownCommands?: [id] (commandAllowlist ids no command has; a call of one fails)", always, install ), @@ -1266,7 +1303,7 @@ pub fn specs() -> Vec<CommandSpec> { "Remove Plug-in", [], None, - "{id} uninstall a plug-in (its live effects then leave the geometry as it is) and delete the settings and cache it kept (when their folder can't be moved aside, or its grant can't be removed from the plug-in store, the command fails and the plug-in stays installed; when the settings can't be moved back either, the error names the folder they stay in, and the next load, install or removal of the plug-in moves them back); for an id that isn't installed, deletes the settings and cache the plug-in store still keeps for it → {removed}", + "{id} uninstall a plug-in (its live effects then leave the geometry as it is) and delete the settings and cache it kept (when their folder can't be moved aside, or its grant can't be removed from the plug-in store, the command fails and the plug-in stays installed; when the settings can't be moved back either, the error names the folder they stay in, and the next load, install or removal of the plug-in moves them back); for an id that isn't installed, deletes the settings and cache the plug-in store still keeps for it; it waits while another window or process changes the plug-in store, and when the store's disabled.lock can't be locked, the command fails and nothing is removed → {removed}", always, remove ), diff --git a/crates/engine/src/store.rs b/crates/engine/src/store.rs index 8a18ce9824..9c555d82f7 100644 --- a/crates/engine/src/store.rs +++ b/crates/engine/src/store.rs @@ -17,9 +17,8 @@ //! * **Plug-ins**: the module of each plug-in `plugin.install` installs, as a `.wasm` file named //! after its id (as Illustrator keeps plug-ins in its Plug-ins folder); `plugin.remove` deletes it. //! Attaching the folder installs them again, except in Safe Mode and except the ones the user -//! disabled, which `disabled.json` in the same folder lists (`plugin.setEnabled`; a window locks -//! `disabled.lock` while it writes the list). The Additional Plug-ins Folder preference is not -//! copied: it is loaded from where it is. `grants.json` holds what the user granted the plug-ins +//! disabled, which `disabled.json` in the same folder lists (`plugin.setEnabled`). The Additional +//! Plug-ins Folder preference is not copied: it is loaded from where it is. `grants.json` holds what the user granted the plug-ins //! stored there that list permissions (id, module hash, permissions); a stored plug-in whose //! permissions it doesn't grant is skipped with a log record, and stays in the folder. //! * **Plug-in settings and caches**: `storage/id-<id>/` in the plug-in store, the id written as @@ -27,6 +26,11 @@ //! keeps with the `settings` and `cache` permissions ([`PluginStorage`]): `settings.json` and a //! `cache` folder with one file per entry. The host names every file; a plug-in only names keys. //! Replacing a plug-in keeps them, and `plugin.remove` deletes them. +//! * **Turns on the plug-in store**: a window or process locks `disabled.lock` in the plug-in folder +//! ([`StoreTurn`]) while it reads and changes the stored plug-ins, `grants.json`, `disabled.json` +//! and the plug-ins' settings and caches, so that two of them using one folder change it one after +//! the other: an install's module and grant are written in one turn, and a grant written for one +//! plug-in doesn't undo another one's. //! //! The files are untrusted input like any other: sizes and counts are capped, a file that does not //! parse is skipped with a log record, and every write is atomic. @@ -62,12 +66,15 @@ pub const MAX_PLUGIN_STORE: u64 = 512 << 20; const PLUGIN_EXT: &str = "wasm"; /// The file in the plug-in folder that lists the plug-ins the user disabled. pub const DISABLED_FILE: &str = "disabled.json"; -/// The file in the plug-in folder that a window locks while it reads and writes [`DISABLED_FILE`]. +/// The file in the plug-in folder that a window locks while it reads and changes the plug-in store +/// ([`StoreTurn`]), [`DISABLED_FILE`] included. pub const DISABLED_LOCK: &str = "disabled.lock"; /// The file in the plug-in store that holds the permissions the user granted. const GRANTS_FILE: &str = "grants.json"; /// The error of a `plugin.remove` that can't remove the plug-in's grant from [`GRANTS_FILE`]. pub(crate) const GRANT_NOT_REMOVED: &str = "the plug-in's grant can't be removed from the plug-in store"; +/// The error of a change to the plug-in store that can't take its turn ([`StoreTurn`]). +pub(crate) const STORE_NOT_LOCKED: &str = "the plug-in store can't be locked"; /// The largest grants file read. const MAX_GRANTS_FILE: u64 = 1 << 20; /// The folder in the plug-in store that holds each plug-in's settings and cache. @@ -84,7 +91,7 @@ const CACHE_EXT: &str = "bin"; /// A write to a folder that holds more is refused as full. pub(crate) const MAX_CACHE_SCAN: usize = storage::MAX_CACHE_ENTRIES * 2; /// Held while a plug-in's settings or cache change, so two runs can't pass a cap together or lose -/// each other's settings. +/// each other's settings. Taken after the plug-in store's turn ([`StoreTurn`]), never before it. static PLUGIN_DATA_LOCK: Mutex<()> = Mutex::new(()); /// The state of each plug-in folder's storage, shared by every storage made for the folder until /// the plug-in is removed, which closes it and drops it. @@ -99,7 +106,7 @@ const MAX_GRANT_WRITES_KEPT: usize = 256; struct IgnoredGrants { /// The grants that should be gone but could not be removed: no session in the process counts /// them ([`Session::ignore_stored_grant`]) until one writes the store's grants for the id - /// ([`Session::store_grant`]). + /// ([`Session::store_grant_in`]). ignored: BTreeSet<(PathBuf, String)>, /// The latest grant writes of the process, at most [`MAX_GRANT_WRITES_KEPT`], each with the /// count of writes it made ([`IgnoredGrants::writes`]). @@ -217,23 +224,53 @@ fn write_atomic(_: &Path, _: &[u8]) -> std::io::Result<()> { Err(std::io::Error::new(std::io::ErrorKind::Unsupported, "no file system")) } -/// [`DISABLED_LOCK`] in `dir`, locked until the file is dropped, waiting while another window holds -/// it; `None` when it can't be opened or locked. +/// [`DISABLED_LOCK`] in the plug-in store `dir`, locked until the file is dropped, waiting while +/// another window or process holds it, or another handle in this process. The file is opened for +/// reading and writing (a handle that only appends can't be locked on Windows) and is never +/// replaced or removed, so that every window locks the same file. #[cfg(not(target_arch = "wasm32"))] -fn lock_disabled(dir: &Path) -> Option<std::fs::File> { - let opened = std::fs::create_dir_all(dir) - .and_then(|()| std::fs::File::options().create(true).truncate(false).read(true).write(true).open(dir.join(DISABLED_LOCK))); - let file = opened.and_then(|f| f.lock().map(|()| f)); - if let Err(e) = &file { - log::warn!("can't lock {}: {e}", dir.join(DISABLED_LOCK).display()); +fn lock_store(dir: &Path) -> std::io::Result<std::fs::File> { + std::fs::create_dir_all(dir)?; + let file = std::fs::File::options().create(true).truncate(false).read(true).write(true).open(dir.join(DISABLED_LOCK))?; + match file.try_lock() { + Ok(()) => return Ok(file), + Err(std::fs::TryLockError::WouldBlock) => {} + Err(std::fs::TryLockError::Error(e)) => return Err(e), } - file.ok() + #[cfg(test)] + if let Some(waiting) = WHILE_STORE_LOCKED.take() { + waiting(); + } + file.lock()?; + Ok(file) } /// The browser has no folders to keep anything in. #[cfg(target_arch = "wasm32")] -fn lock_disabled(_: &Path) -> Option<std::fs::File> { - None +fn lock_store(_: &Path) -> std::io::Result<std::fs::File> { + Err(std::io::Error::new(std::io::ErrorKind::Unsupported, "no file system")) +} + +/// A turn on a plug-in store ([`Session::plugin_store_turn`]): while it is held, no other window or +/// process that takes one reads and changes the store's plug-ins, grants, disabled list, settings +/// or caches. Dropping it ends the turn. A turn is taken once per operation and handed to the +/// functions it calls, since a second lock of the same file by the same thread waits for ever. +pub(crate) struct StoreTurn { + /// [`DISABLED_LOCK`], locked; `None` without a store, and for a load that goes ahead without + /// a turn ([`Session::plugin_store_turn_for_load`]), which then writes nothing to the store. + lock: Option<std::fs::File>, +} + +impl StoreTurn { + /// A turn that isn't held, for a load that goes ahead without one: it writes nothing. + pub(crate) fn unheld() -> Self { + StoreTurn { lock: None } + } + + /// Whether the store may be written in this turn. + fn held(&self) -> bool { + self.lock.is_some() + } } #[cfg(test)] @@ -252,6 +289,15 @@ thread_local! { /// Tests: writing the `.delete` file beside a folder about to be deleted ([`delete_aside`]) /// fails on this thread, as on a full volume. pub(crate) static MARKER_WRITE_FAILS: std::cell::Cell<bool> = const { std::cell::Cell::new(false) }; + /// Tests: runs once on this thread when locking the plug-in store ([`lock_store`]) finds it + /// locked and waits. + pub(crate) static WHILE_STORE_LOCKED: std::cell::RefCell<Option<Box<dyn FnOnce()>>> = const { std::cell::RefCell::new(None) }; + /// Tests: runs once on this thread when a grant write has read `grants.json` and before it + /// writes the file. + pub(crate) static AFTER_GRANTS_READ: std::cell::RefCell<Option<Box<dyn FnOnce()>>> = const { std::cell::RefCell::new(None) }; + /// Tests: runs once on this thread when a change of a plug-in's settings has read them and + /// before it writes them. + pub(crate) static AFTER_SETTINGS_READ: std::cell::RefCell<Option<Box<dyn FnOnce()>>> = const { std::cell::RefCell::new(None) }; } /// Remove `dir/file` → whether it is gone; a file that isn't there is what was wanted. @@ -401,11 +447,14 @@ impl Session { /// Keep the plug-ins this session installs in `dir`, take the disabled plug-ins saved there /// ([`DISABLED_FILE`]), and install the stored ones ([`Session::load_stored_plugins`]). pub fn attach_plugin_store(&mut self, dir: PathBuf) { - let disabled = - read_capped(&dir.join(DISABLED_FILE), safe_mode::MAX_DISABLED_FILE_BYTES).map(|b| safe_mode::parse_disabled_file(&b)).unwrap_or_default(); - safe_mode::set_disabled(disabled); + let path = dir.join(DISABLED_FILE); self.plugin_dir = Some(dir); - self.load_stored_plugins(); + // A `plugin.install` in another session or process writes the store before this reads it. + let _held = crate::cmd::plugin::hold_plugin_changes(); + let turn = self.plugin_store_turn_for_load(); + let disabled = read_capped(&path, safe_mode::MAX_DISABLED_FILE_BYTES).map(|b| safe_mode::parse_disabled_file(&b)).unwrap_or_default(); + safe_mode::set_disabled(disabled); + self.load_stored_plugins_in(&turn); } /// Install the plug-ins kept in the plug-in folder: none in Safe Mode, and none the user @@ -415,14 +464,25 @@ impl Session { /// stays in the folder with its grant. A grant for an id whose stored module lists no /// permissions is forgotten; one that can't be removed from the grants file doesn't count for /// any session in the process attached to the folder until the file can be written for the id - /// ([`Session::ignore_stored_grant`]). + /// ([`Session::ignore_stored_grant`]). The folder is read and changed in one turn on it + /// ([`Session::plugin_store_turn_for_load`]). pub fn load_stored_plugins(&mut self) { + if self.plugin_dir.is_none() || safe_mode::active() { + return; + } + // A `plugin.install` in another session or process writes the store before this reads it. + let _held = crate::cmd::plugin::hold_plugin_changes(); + let turn = self.plugin_store_turn_for_load(); + self.load_stored_plugins_in(&turn); + } + + /// [`Session::load_stored_plugins`] in `turn`, while [`crate::cmd::plugin::hold_plugin_changes`] + /// is held. + fn load_stored_plugins_in(&mut self, turn: &StoreTurn) { let Some(dir) = self.plugin_dir.clone() else { return }; if safe_mode::active() { return; } - // A `plugin.install` in another session writes the store before this reads it. - let _held = crate::cmd::plugin::hold_plugin_changes(); let grants = self.counted_grants(&dir); let limits = vectorcraft_plugins::Limits::default(); let mut left = MAX_PLUGIN_STORE; @@ -454,7 +514,7 @@ impl Session { Some(g) => { asks_nothing.remove(&m.id); vectorcraft_plugins::registry::grant(GrantToken::from_engine_grants_file(g.clone())); - vectorcraft_plugins::registry::set_storage(&m.id, plugin_storage(Some(&dir), &m.id)); + vectorcraft_plugins::registry::set_storage(&m.id, plugin_storage(Some(&dir), &m.id, turn)); if let Err(e) = vectorcraft_plugins::registry::install(plugin.with_source(path.display().to_string())) { log::warn!("skipping the stored plug-in {}: {e}", path.display()); } @@ -466,7 +526,7 @@ impl Session { } Ok(plugin) => { asks_nothing.insert(plugin.id().to_string()); - vectorcraft_plugins::registry::set_storage(plugin.id(), plugin_storage(Some(&dir), plugin.id())); + vectorcraft_plugins::registry::set_storage(plugin.id(), plugin_storage(Some(&dir), plugin.id(), turn)); if let Err(e) = vectorcraft_plugins::registry::install(plugin.with_source(path.display().to_string())) { log::warn!("skipping the stored plug-in {}: {e}", path.display()); } @@ -483,13 +543,34 @@ impl Session { }; if named { let writes = self.grant_writes(); - if !self.store_grant(id, None) && self.holds_plugin_grant(id) { + if !self.store_grant_in(turn, id, None) && self.holds_plugin_grant(id) { self.ignore_stored_grant(id, writes); } } } } + /// Take a turn on the attached plug-in store ([`StoreTurn`]), waiting while another window or + /// process holds one; without a store, a turn that writes nothing. An error, with a log record, + /// when the lock file can't be made, opened or locked. Taken after + /// [`crate::cmd::plugin::hold_plugin_changes`] when both are needed, and never by a thread that + /// holds a turn already. + pub(crate) fn plugin_store_turn(&self) -> std::io::Result<StoreTurn> { + let Some(dir) = self.plugin_dir.as_deref() else { return Ok(StoreTurn::unheld()) }; + lock_store(dir) + .map(|file| StoreTurn { lock: Some(file) }) + .inspect_err(|e| log::warn!("can't lock {}: {e}", dir.join(DISABLED_LOCK).display())) + } + + /// [`Session::plugin_store_turn`] for a load, which goes ahead without the turn when the store + /// folder isn't there (nothing is stored) or can't be locked, and then writes nothing to it. + pub(crate) fn plugin_store_turn_for_load(&self) -> StoreTurn { + match self.plugin_dir.as_deref() { + Some(dir) if dir.is_dir() => self.plugin_store_turn().unwrap_or_else(|_| StoreTurn::unheld()), + _ => StoreTurn::unheld(), + } + } + /// Write the disabled plug-ins saved for the next launch to the plug-in folder → whether they /// went there, every change included (`false` without a folder, and when a plug-in turned off /// found the file's list full: [`safe_mode::Merged::complete`]). The changes this launch made are applied to the list @@ -499,8 +580,15 @@ impl Session { /// a file that can't be read (too large, say) or that a later version wrote /// ([`safe_mode::read_disabled_file`]): it is kept as it is. pub fn store_disabled_plugins(&self) -> bool { + self.plugin_store_turn().is_ok_and(|turn| self.store_disabled_plugins_in(&turn)) + } + + /// [`Session::store_disabled_plugins`] in `turn`; `false` when it isn't held. + pub(crate) fn store_disabled_plugins_in(&self, turn: &StoreTurn) -> bool { let Some(dir) = self.plugin_dir.as_deref() else { return false }; - let Some(_turn) = lock_disabled(dir) else { return false }; + if !turn.held() { + return false; + } let path = dir.join(DISABLED_FILE); let theirs = match read_capped(&path, safe_mode::MAX_DISABLED_FILE_BYTES) { Ok(bytes) => match safe_mode::read_disabled_file(&bytes) { @@ -580,10 +668,10 @@ impl Session { grants } - /// Write the module `bytes` of the plug-in `id` to the store → whether they went there (`false` - /// without a folder). - pub(crate) fn store_plugin(&self, id: &str, bytes: &[u8]) -> bool { - self.plugin_dir.as_deref().is_some_and(|dir| put(dir, &format!("{}.{PLUGIN_EXT}", file_stem(id)), bytes)) + /// Write the module `bytes` of the plug-in `id` to the store in `turn` → whether they went there + /// (`false` without a folder, and when `turn` isn't held). + pub(crate) fn store_plugin(&self, turn: &StoreTurn, id: &str, bytes: &[u8]) -> bool { + turn.held() && self.plugin_dir.as_deref().is_some_and(|dir| put(dir, &format!("{}.{PLUGIN_EXT}", file_stem(id)), bytes)) } /// The module the store holds for the plug-in `id`: `None` without a folder or such a file, and @@ -601,14 +689,15 @@ impl Session { /// Return the store's module for the plug-in `id` to `previous`, the bytes it held before a /// write ([`Session::stored_plugin_bytes`]): with `None`, the file is removed. → whether the /// write reported success; a write that reports a failure may still have put `previous` back. - pub(crate) fn put_back_plugin(&self, id: &str, previous: Option<&[u8]>) -> bool { + /// In `turn`, the one the write was made in. + pub(crate) fn put_back_plugin(&self, turn: &StoreTurn, id: &str, previous: Option<&[u8]>) -> bool { #[cfg(test)] if PUT_BACK_FAILS.get() { return false; } let back = match previous { - Some(bytes) => self.store_plugin(id, bytes), - None => self.unstore_plugin(id), + Some(bytes) => self.store_plugin(turn, id, bytes), + None => self.unstore_plugin(turn, id), }; #[cfg(test)] if PUT_BACK_FAILS_AFTER_WRITE.get() { @@ -623,15 +712,23 @@ impl Session { self.plugin_dir.as_ref().map(|dir| dir.join(format!("{}.{PLUGIN_EXT}", file_stem(id))).display().to_string()) } + /// Tests: [`Session::store_grant_in`] in a turn of its own ([`Session::plugin_store_turn`]); + /// `false` when it can't be taken. + #[cfg(test)] + pub(crate) fn store_grant(&self, id: &str, grant: Option<vectorcraft_plugins::permissions::Grant>) -> bool { + self.plugin_store_turn().is_ok_and(|turn| self.store_grant_in(&turn, id, grant)) + } + /// Record in the store what the user granted plug-in `id` (`None`: nothing), leaving the store's /// other grants as they are; with none left, remove the file. Entries this version can't use /// are written back as they were, except one for `id`. A grants file that is too large, can't /// be read or doesn't hold a list is left as it is, with a log record, and nothing is recorded; - /// so is one whose new content would be larger than `MAX_GRANTS_FILE`. → whether the store now - /// holds what was asked (`false` without a folder). When it does, the grant kept for `id` counts - /// again, for every session in the process attached to the store ([`Session::ignore_stored_grant`]). - pub(crate) fn store_grant(&self, id: &str, grant: Option<vectorcraft_plugins::permissions::Grant>) -> bool { - let done = self.write_grant(id, grant); + /// so is one whose new content would be larger than `MAX_GRANTS_FILE`. The file is read and + /// written in `turn`. → whether the store now holds what was asked (`false` without a folder, + /// and when `turn` isn't held). When it does, the grant kept for `id` counts again, for every + /// session in the process attached to the store ([`Session::ignore_stored_grant`]). + pub(crate) fn store_grant_in(&self, turn: &StoreTurn, id: &str, grant: Option<vectorcraft_plugins::permissions::Grant>) -> bool { + let done = turn.held() && self.write_grant(id, grant); if done && let Some(key) = self.plugin_dir.as_deref().map(plugin_store_key) { let mut shared = IGNORED_PLUGIN_GRANTS.lock().unwrap_or_else(|e| e.into_inner()); let entry = (key, id.to_string()); @@ -648,7 +745,7 @@ impl Session { done } - /// How many grant writes the sessions of the process have made ([`Session::store_grant`]). + /// How many grant writes the sessions of the process have made ([`Session::store_grant_in`]). /// Taken before a write that may fail, for [`Session::ignore_stored_grant`]. pub(crate) fn grant_writes(&self) -> u64 { IGNORED_PLUGIN_GRANTS.lock().unwrap_or_else(|e| e.into_inner()).writes @@ -661,7 +758,7 @@ impl Session { } /// Stop counting the attached store's grant for the plug-in `id`, in every session in the - /// process attached to the same folder, until [`Session::store_grant`] next succeeds for it in + /// process attached to the same folder, until [`Session::store_grant_in`] next succeeds for it in /// one of them: for a grant that should be gone and could not be removed, which would otherwise /// approve the bytes it covers. `writes` is [`Session::grant_writes`] from before the failed /// write: when a session has written the store's grants for `id` since, the file holds what that @@ -687,6 +784,10 @@ impl Session { return false; } }; + #[cfg(test)] + if let Some(between) = AFTER_GRANTS_READ.take() { + between(); + } let others = file.other.len(); file.other.retain(|entry| entry.get("id").and_then(serde_json::Value::as_str) != Some(id)); let changed = match grant { @@ -724,16 +825,17 @@ impl Session { }) } - /// Remove the plug-in `id` from the store → whether its file is gone (`false` without a folder). - pub(crate) fn unstore_plugin(&self, id: &str) -> bool { - self.plugin_dir.as_deref().is_some_and(|dir| take(dir, &format!("{}.{PLUGIN_EXT}", file_stem(id)))) + /// Remove the plug-in `id` from the store in `turn` → whether its file is gone (`false` without a + /// folder, and when `turn` isn't held). + pub(crate) fn unstore_plugin(&self, turn: &StoreTurn, id: &str) -> bool { + turn.held() && self.plugin_dir.as_deref().is_some_and(|dir| take(dir, &format!("{}.{PLUGIN_EXT}", file_stem(id)))) } /// Keep the settings and cache of plug-in `id` in the attached plug-in store from now on; without /// one, nowhere (its storage calls then fail as unavailable). Settings and cache that a removal - /// kept are moved back first ([`plugin_storage`]). - pub(crate) fn attach_plugin_storage(&self, id: &str) { - vectorcraft_plugins::registry::set_storage(id, plugin_storage(self.plugin_dir.as_deref(), id)); + /// kept are moved back first, in `turn` ([`plugin_storage`]). + pub(crate) fn attach_plugin_storage(&self, turn: &StoreTurn, id: &str) { + vectorcraft_plugins::registry::set_storage(id, plugin_storage(self.plugin_dir.as_deref(), id, turn)); } /// Does the attached plug-in store have a folder of settings and cache for plug-in `id`, or one @@ -757,9 +859,13 @@ impl Session { /// that rename fails too, the error also names both paths and the reason, and the next attach or /// removal for the id moves the folder back. Once `forget` returns `true`, the folder and the /// kept settings are deleted ([`delete_aside`]); what that deletion leaves stays, with a log - /// record, and a later call for the id tries to delete it again. - pub(crate) fn remove_plugin_storage(&self, id: &str, forget: impl FnOnce() -> bool) -> Result<(), StorageError> { + /// record, and a later call for the id tries to delete it again. All of it happens in `turn`; + /// with a store and a turn that isn't held, nothing changes and this fails. + pub(crate) fn remove_plugin_storage(&self, turn: &StoreTurn, id: &str, forget: impl FnOnce() -> bool) -> Result<(), StorageError> { let not_forgotten = || StorageError::Io(GRANT_NOT_REMOVED.to_string()); + if self.plugin_dir.is_some() && !turn.held() { + return Err(StorageError::Io(STORE_NOT_LOCKED.to_string())); + } vectorcraft_plugins::registry::set_storage(id, None); let Some(dir) = &self.plugin_dir else { return if forget() { Ok(()) } else { Err(not_forgotten()) }; @@ -943,13 +1049,16 @@ fn restore_removed(path: &Path) -> std::io::Result<()> { /// Where plug-in `id` keeps its settings and cache in the plug-in store `dir`. Settings and cache /// that a removal kept are moved back first ([`restore_removed`]); when that fails, the failure is /// logged and there is no storage (its calls fail as unavailable), so that nothing the plug-in -/// writes takes their place. A later attach or load tries again. -fn plugin_storage(dir: Option<&Path>, id: &str) -> Option<Arc<dyn Storage>> { +/// writes takes their place. A later attach or load tries again. They are moved in `turn`; when it +/// isn't held, they stay where they are, as when moving them fails. +fn plugin_storage(dir: Option<&Path>, id: &str, turn: &StoreTurn) -> Option<Arc<dyn Storage>> { let dir = dir?; let data = plugin_data_dir(dir, id); if !is_link(&dir.join(PLUGIN_DATA_DIR)) { let _held = PLUGIN_DATA_LOCK.lock().unwrap_or_else(|e| e.into_inner()); - if let Err(e) = restore_removed(&data) { + let kept_aside = || std::fs::symlink_metadata(&data).is_err() && aside_paths(&data).iter().any(|a| is_kept(a)); + let restored = if turn.held() || !kept_aside() { restore_removed(&data) } else { Err(std::io::Error::other(STORE_NOT_LOCKED)) }; + if let Err(e) = restored { log::warn!("can't move the settings and cache of {} back: {e}", data.display()); return None; } @@ -1088,6 +1197,12 @@ impl PluginStorage { Ok(()) } + /// A turn on the plug-in store ([`lock_store`]), taken before [`PLUGIN_DATA_LOCK`], so that a + /// window or process changing the same settings or cache waits for this change. + fn turn(&self) -> Result<std::fs::File, StorageError> { + lock_store(&self.root).map_err(|e| StorageError::Io(format!("{STORE_NOT_LOCKED}: {e}"))) + } + fn kept(&self) -> MutexGuard<'_, Kept> { self.state.kept.lock().unwrap_or_else(|e| e.into_inner()) } @@ -1212,6 +1327,8 @@ impl PluginStorage { impl Storage for PluginStorage { fn setting(&self, key: &str, meter: &mut Meter) -> Result<Option<Vec<u8>>, StorageError> { + // Reading may move a settings file that doesn't read aside. + let _turn = self.turn()?; let _held = PLUGIN_DATA_LOCK.lock().unwrap_or_else(|e| e.into_inner()); self.open()?; let mut kept = self.kept(); @@ -1219,10 +1336,15 @@ impl Storage for PluginStorage { } fn set_setting(&self, key: &str, value: &[u8], meter: &mut Meter) -> Result<(), StorageError> { + let _turn = self.turn()?; let _held = PLUGIN_DATA_LOCK.lock().unwrap_or_else(|e| e.into_inner()); self.open()?; let mut kept = self.kept(); let settings = &mut self.read_settings(&mut kept.settings, meter)?.values; + #[cfg(test)] + if let Some(between) = AFTER_SETTINGS_READ.take() { + between(); + } if value.len() > storage::MAX_SETTING_BYTES || (!settings.contains_key(key) && settings.len() >= storage::MAX_SETTINGS) { return Err(StorageError::Full); } @@ -1234,6 +1356,7 @@ impl Storage for PluginStorage { } fn delete_setting(&self, key: &str, meter: &mut Meter) -> Result<bool, StorageError> { + let _turn = self.turn()?; let _held = PLUGIN_DATA_LOCK.lock().unwrap_or_else(|e| e.into_inner()); self.open()?; let mut kept = self.kept(); @@ -1258,6 +1381,8 @@ impl Storage for PluginStorage { } fn set_cache_entry(&self, name: &str, value: &[u8], meter: &mut Meter) -> Result<(), StorageError> { + // The cache's size and count are added up and the entry written in one turn. + let _turn = self.turn()?; let _held = PLUGIN_DATA_LOCK.lock().unwrap_or_else(|e| e.into_inner()); self.open()?; let path = self.entry_path(name); @@ -1281,6 +1406,7 @@ impl Storage for PluginStorage { } fn remove_cache_entry(&self, name: &str) -> Result<bool, StorageError> { + let _turn = self.turn()?; let _held = PLUGIN_DATA_LOCK.lock().unwrap_or_else(|e| e.into_inner()); self.open()?; let path = self.entry_path(name); @@ -1296,6 +1422,7 @@ impl Storage for PluginStorage { } fn clear_cache(&self) -> Result<u64, StorageError> { + let _turn = self.turn()?; let _held = PLUGIN_DATA_LOCK.lock().unwrap_or_else(|e| e.into_inner()); self.open()?; let dir = self.cache_dir(); diff --git a/crates/engine/src/tests/plugins.rs b/crates/engine/src/tests/plugins.rs index 499f2d15c6..a294cc9036 100644 --- a/crates/engine/src/tests/plugins.rs +++ b/crates/engine/src/tests/plugins.rs @@ -1921,6 +1921,12 @@ fn disabled_plugins_name_files_outside_the_read_root_by_their_names() { run(&mut s, "plugin.remove", json!({"id": id})); } +/// The files and folders in the plug-in store `dir`, without the file windows lock while they +/// change it. +fn store_files(dir: &std::path::Path) -> usize { + std::fs::read_dir(dir).unwrap().filter(|e| e.as_ref().is_ok_and(|e| e.file_name() != crate::store::DISABLED_LOCK)).count() +} + /// #2541: a plug-in installed in a session with a plug-in store is installed again in the next /// session that attaches the store, and Remove Plug-in takes it out of the store. #[test] @@ -1931,14 +1937,14 @@ fn installed_plugins_are_kept_in_the_store() { let mut s = session(); s.attach_plugin_store(folder.0.clone()); install_wat(&mut s, &src); - assert_eq!(std::fs::read_dir(&folder.0).unwrap().count(), 1, "one file in the store"); + assert_eq!(store_files(&folder.0), 1, "one file in the store"); vectorcraft_plugins::registry::remove(id); let mut next = session(); next.attach_plugin_store(folder.0.clone()); assert!(vectorcraft_plugins::registry::get(id).is_some(), "installed again from the store"); run(&mut next, "plugin.remove", json!({"id": id})); - assert_eq!(std::fs::read_dir(&folder.0).unwrap().count(), 0, "removed from the store"); + assert_eq!(store_files(&folder.0), 0, "removed from the store"); // A file that isn't a plug-in is skipped; the store still attaches. std::fs::write(folder.0.join("broken.wasm"), b"\0asm?").unwrap(); @@ -3274,6 +3280,198 @@ fn a_store_loaded_while_installing_loads_the_new_version() { run(&mut s, "plugin.remove", json!({"id": id})); } +/// A grant of `doc.read` to plug-in `id`, the module with the SHA-256 `hash`. +fn doc_read_grant(id: &str, hash: &str) -> vectorcraft_plugins::permissions::Grant { + serde_json::from_value(json!({"id": id, "hash": hash, "permissions": ["doc.read"]})).unwrap() +} + +/// A session that uses the plug-in store `dir` without loading it, as another process using the +/// same folder does: it doesn't wait for the installs and removals of this process's sessions. +fn other_process(dir: std::path::PathBuf) -> Session { + let mut s = Session::new(); + s.plugin_dir = Some(dir); + s +} + +/// Waits on this thread for a turn on a plug-in store, telling `waiting` before it waits. +fn tell_when_waiting(waiting: std::sync::mpsc::Sender<&'static str>) { + crate::store::WHILE_STORE_LOCKED.set(Some(Box::new(move || { + let _ = waiting.send("waiting"); + }))); +} + +/// The ids `grants.json` in `dir` holds grants for, and the hash of each. +fn stored_grant_hashes(dir: &std::path::Path) -> std::collections::BTreeMap<String, String> { + let entries: Vec<Value> = serde_json::from_slice(&std::fs::read(dir.join("grants.json")).unwrap()).unwrap(); + entries.iter().map(|e| (e["id"].as_str().unwrap().to_string(), e["hash"].as_str().unwrap().to_string())).collect() +} + +/// An install into a `Plug-ins` folder that another process also installs the same id into keeps a +/// module with its own grant: the other process's install waits for this one's turn on the folder, +/// between this install's module and its grant, and then writes both of its own. +#[test] +fn installs_from_two_processes_into_one_store_keep_each_module_with_its_grant() { + use vectorcraft_plugins::permissions::sha256_hex; + let folder = crate::tests_links::Folder::new("plugin-store-installs-take-turns"); + let id = "test.engine.permissions.installsturns"; + let ours = asking(id, r#"["doc.read"]"#, &json!({"objects": []})); + let theirs = asking(id, r#"["doc.read"]"#, &json!({"objects": [], "documentData": null})); + let mut s = session(); + s.attach_plugin_store(folder.0.clone()); + + let (said, heard) = std::sync::mpsc::channel::<&'static str>(); + let (handed, other) = std::sync::mpsc::channel(); + let (dir, module) = (folder.0.clone(), theirs.clone()); + crate::cmd::plugin::BEFORE_GRANT_STORED.set(Some(Box::new(move || { + let thread = std::thread::spawn(move || { + tell_when_waiting(said.clone()); + let other = other_process(dir); + let turn = other.plugin_store_turn().unwrap(); + let stored = crate::cmd::plugin::keep_installed(&other, &turn, id, &module, Some(doc_read_grant(id, &sha256_hex(&module)))); + let _ = said.send(if stored { "stored" } else { "not stored" }); + }); + // The other install has written the store, or waits for this one. + let first = heard.recv().unwrap_or("gone"); + let _ = handed.send((first, thread)); + }))); + run(&mut s, "plugin.install", json!({"dataBase64": vectorcraft_format::base64_encode(&ours), "grant": ["doc.read"]})); + let (first, thread) = other.recv().unwrap(); + thread.join().unwrap(); + + let module = std::fs::read(s.stored_plugin_file(id).unwrap()).unwrap(); + assert_eq!(stored_grant_hashes(&folder.0).get(id), Some(&sha256_hex(&module)), "the stored grant covers the stored module"); + assert_eq!(module, theirs, "the install that waited wrote last"); + assert_eq!(first, "waiting", "the other install waits for this one"); + run(&mut s, "plugin.remove", json!({"id": id})); +} + +/// Grants written for two plug-ins into one `Plug-ins` folder by two processes are both kept: the +/// second write reads `grants.json` only once the first has written it. +#[test] +fn grants_written_by_two_processes_into_one_store_keep_both() { + let folder = crate::tests_links::Folder::new("plugin-store-grants-take-turns"); + let (ours, theirs) = ("test.engine.permissions.grantturnsa", "test.engine.permissions.grantturnsb"); + let hash = vectorcraft_plugins::permissions::sha256_hex(b"module"); + let s = other_process(folder.0.clone()); + + let (said, heard) = std::sync::mpsc::channel::<&'static str>(); + let (handed, other) = std::sync::mpsc::channel(); + let (dir, other_hash) = (folder.0.clone(), hash.clone()); + crate::store::AFTER_GRANTS_READ.set(Some(Box::new(move || { + let thread = std::thread::spawn(move || { + tell_when_waiting(said.clone()); + let written = other_process(dir).store_grant(theirs, Some(doc_read_grant(theirs, &other_hash))); + let _ = said.send(if written { "written" } else { "not written" }); + }); + // The other write has written the file, or waits for this one. + let first = heard.recv().unwrap_or("gone"); + let _ = handed.send((first, thread)); + }))); + assert!(s.store_grant(ours, Some(doc_read_grant(ours, &hash))), "the grant is written"); + let (first, thread) = other.recv().unwrap(); + thread.join().unwrap(); + + let kept = stored_grant_hashes(&folder.0); + assert_eq!(kept.keys().map(String::as_str).collect::<Vec<_>>(), [ours, theirs], "both grants are kept"); + assert_eq!(first, "waiting", "the other write waits for this one"); +} + +/// A setting a plug-in changes in one process and another setting it changes in a second process +/// using the same `Plug-ins` folder are both kept: the second process waits for the first's turn on +/// the folder and reads what it wrote. The second process is this test run again with +/// `VECTORCRAFT_TEST_PLUGIN_SETTINGS_STORE` naming the folder; it prints when it waits and when it +/// is done. +#[test] +fn settings_changed_by_two_processes_keep_both() { + use std::io::{BufRead, Write}; + use vectorcraft_plugins::storage::Meter; + const CHILD: &str = "VECTORCRAFT_TEST_PLUGIN_SETTINGS_STORE"; + const NAME: &str = "tests::plugins::settings_changed_by_two_processes_keep_both"; + let id = "test.engine.storagetwoprocesses"; + // Nothing a removal kept is moved back, so the storage is made without a turn on the folder. + let attached = |s: &Session| { + s.attach_plugin_storage(&crate::store::StoreTurn::unheld(), id); + vectorcraft_plugins::registry::storage(id).unwrap() + }; + if let Some(dir) = std::env::var_os(CHILD) { + let st = attached(&other_process(std::path::PathBuf::from(dir))); + crate::store::WHILE_STORE_LOCKED.set(Some(Box::new(|| { + println!("settings-child-waiting"); + let _ = std::io::stdout().flush(); + }))); + st.set_setting("theirs", b"2", &mut Meter::unlimited()).unwrap(); + println!("settings-child-done"); + let _ = std::io::stdout().flush(); + return; + } + let folder = crate::tests_links::Folder::new("plugin-settings-two-processes"); + let st = attached(&other_process(folder.0.clone())); + + let (handed, child) = std::sync::mpsc::channel(); + let dir = folder.0.clone(); + crate::store::AFTER_SETTINGS_READ.set(Some(Box::new(move || { + let mut process = std::process::Command::new(std::env::current_exe().unwrap()) + .args(["--exact", NAME, "--nocapture", "--test-threads=1"]) + .env(CHILD, &dir) + .stdout(std::process::Stdio::piped()) + .spawn() + .unwrap(); + let mut lines = std::io::BufReader::new(process.stdout.take().unwrap()).lines(); + // The other process has written the settings, or waits for this change. + let first = lines + .by_ref() + .map_while(std::io::Result::ok) + .find_map(|l| ["waiting", "done"].into_iter().find(|said| l.contains(&format!("settings-child-{said}")))); + let _ = handed.send((first, process, lines)); + }))); + st.set_setting("ours", b"1", &mut Meter::unlimited()).unwrap(); + let (first, mut process, lines) = child.recv().unwrap(); + let rest: Vec<String> = lines.map_while(std::io::Result::ok).collect(); + assert!(process.wait().unwrap().success(), "the other process failed: {rest:?}"); + + let file: std::collections::BTreeMap<String, String> = + serde_json::from_slice(&std::fs::read(crate::store::plugin_data_dir(&folder.0, id).join("settings.json")).unwrap()).unwrap(); + assert_eq!(file.keys().map(String::as_str).collect::<Vec<_>>(), ["ours", "theirs"], "both settings are kept"); + assert_eq!(first, Some("waiting"), "the other process waits for this change"); + vectorcraft_plugins::registry::set_storage(id, None); +} + +/// When the `Plug-ins` folder can't be locked (here `disabled.lock` is a folder), `plugin.install` +/// and `plugin.remove` change nothing and say why: the plug-in installed with the id, its grant and +/// the stored module stay as they were. +#[test] +fn a_store_that_cant_be_locked_refuses_installs_and_removals() { + use vectorcraft_plugins::{permissions::sha256_hex, registry}; + let folder = crate::tests_links::Folder::new("plugin-store-not-locked"); + let id = "test.engine.permissions.notlocked"; + let first = asking(id, r#"["doc.read"]"#, &json!({"objects": []})); + let second = asking(id, r#"["doc.read"]"#, &json!({"objects": [], "documentData": null})); + let mut s = session(); + s.attach_plugin_store(folder.0.clone()); + run(&mut s, "plugin.install", json!({"dataBase64": vectorcraft_format::base64_encode(&first), "grant": ["doc.read"]})); + let lock = folder.0.join(crate::store::DISABLED_LOCK); + std::fs::remove_file(&lock).unwrap(); + std::fs::create_dir(&lock).unwrap(); + let grants = std::fs::read(folder.0.join("grants.json")).unwrap(); + + let update = json!({"dataBase64": vectorcraft_format::base64_encode(&second), "grant": ["doc.read"], "replace": true}); + let refused = s.execute("plugin.install", &update).unwrap_err().to_string(); + assert!(refused.contains(crate::store::STORE_NOT_LOCKED) && refused.contains("nothing was installed"), "{refused}"); + assert_eq!(registry::get(id).map(|p| p.hash().to_string()), Some(sha256_hex(&first)), "the installed plug-in stays"); + assert_eq!(registry::granted(id).map(|g| g.hash), Some(sha256_hex(&first)), "its grant stays"); + assert_eq!(std::fs::read(s.stored_plugin_file(id).unwrap()).unwrap(), first, "the store keeps its module"); + assert_eq!(std::fs::read(folder.0.join("grants.json")).unwrap(), grants, "and its grant"); + + let refused = s.execute("plugin.remove", &json!({"id": id})).unwrap_err().to_string(); + assert!(refused.contains(crate::store::STORE_NOT_LOCKED) && refused.contains("nothing was removed"), "{refused}"); + assert!(registry::get(id).is_some(), "the plug-in stays installed"); + assert!(std::path::Path::new(&s.stored_plugin_file(id).unwrap()).exists(), "and stored"); + + std::fs::remove_dir(&lock).unwrap(); + run(&mut s, "plugin.remove", json!({"id": id})); + assert!(registry::get(id).is_none()); +} + /// Runs the test `name` of this module again in a process of its own → whether this is that /// process. The list of disabled plug-ins is kept for the whole process, and the other tests here /// read it again each time they attach a plug-in store. @@ -3740,7 +3938,7 @@ fn granted_permissions_are_kept_and_folders_skip_the_rest() { let mut third = session(); third.attach_plugin_store(folder.0.clone()); assert!(vectorcraft_plugins::registry::get(id).is_none(), "nobody granted it"); - assert_eq!(std::fs::read_dir(&folder.0).unwrap().count(), 1, "the module stays in the store"); + assert_eq!(store_files(&folder.0), 1, "the module stays in the store"); // The Additional Plug-ins Folder skips it with a note until it is granted. let dir = crate::tests_links::Folder::new("plugin-folder-grants"); @@ -4678,7 +4876,7 @@ fn plugin_storage_is_capped_and_survives_a_damaged_settings_file() { // An id that differs only in case has storage of its own, which removing this one leaves. let upper_id = "test.engine.StorageCaps"; - s.attach_plugin_storage(upper_id); + s.attach_plugin_storage(&s.plugin_store_turn().unwrap(), upper_id); let upper = vectorcraft_plugins::registry::storage(upper_id).unwrap(); assert_eq!(upper.setting("k0", m).unwrap(), None); upper.set_setting("k0", b"upper", m).unwrap(); @@ -4690,13 +4888,13 @@ fn plugin_storage_is_capped_and_survives_a_damaged_settings_file() { // Removing the plug-in closes the storage a run still holds, even one from before the plug-in // was replaced, so nothing is written back. - s.attach_plugin_storage(id); + s.attach_plugin_storage(&s.plugin_store_turn().unwrap(), id); run(&mut s, "plugin.remove", json!({"id": id})); assert_eq!(st.set_setting("zoom", b"again", m), Err(StorageError::Unavailable)); assert_eq!(st.set_cache_entry("tile", b"again", m), Err(StorageError::Unavailable)); assert!(!dir.exists()); assert_eq!(upper.setting("k0", m).unwrap(), Some(b"upper".to_vec())); - s.remove_plugin_storage(upper_id, || true).unwrap(); + s.remove_plugin_storage(&s.plugin_store_turn().unwrap(), upper_id, || true).unwrap(); } /// Files larger than the storage reads are not read: a settings file larger than 1 MiB, although @@ -4874,12 +5072,12 @@ fn removing_a_plugin_drops_its_settings_from_memory() { std::fs::create_dir_all(file.parent().unwrap()).unwrap(); std::fs::write(&file, &bytes).unwrap(); set_modified(&file, written); - s.attach_plugin_storage(id); + s.attach_plugin_storage(&s.plugin_store_turn().unwrap(), id); let st = vectorcraft_plugins::registry::storage(id).unwrap(); let mut m = Meter::unlimited(); assert_eq!(st.setting("zoom", &mut m).unwrap(), Some(b"hello".to_vec())); assert_eq!(m.used(), bytes.len() as u64, "read from the file"); - s.remove_plugin_storage(id, || true).unwrap(); + s.remove_plugin_storage(&s.plugin_store_turn().unwrap(), id, || true).unwrap(); } /// The cache's total stays in memory while the cache folder keeps its time; a write and a clear diff --git a/crates/engine/tests/plugin_fuzz.rs b/crates/engine/tests/plugin_fuzz.rs index 58cc302279..20546835c1 100644 --- a/crates/engine/tests/plugin_fuzz.rs +++ b/crates/engine/tests/plugin_fuzz.rs @@ -950,9 +950,10 @@ proptest! { prop_assert_eq!(theirs.setting("mine", m).unwrap(), Some(b"kept".to_vec())); prop_assert_eq!(theirs.cache_entry("mine", m).unwrap(), Some(b"kept".to_vec())); prop_assert_eq!(theirs.cache_bytes(), 4); - // The host names every file: the store holds the two modules, their grants and their folders. + // The host names every file: the store holds the two modules, their grants, their folders and + // the file windows lock while they change the store. let names = |dir: &std::path::Path| std::fs::read_dir(dir).unwrap().filter_map(Result::ok).map(|e| e.file_name()).collect::<Vec<_>>(); - prop_assert!(names(&folder).len() <= 4, "{:?}", names(&folder)); + prop_assert!(names(&folder).len() <= 5, "{:?}", names(&folder)); prop_assert!(names(&folder.join("storage")).len() <= 2, "{:?}", names(&folder.join("storage"))); let _ = s.execute("plugin.remove", &json!({"id": "fuzz.storage"})); let _ = s.execute("plugin.remove", &json!({"id": "fuzz.storage.other"})); diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..935a57f28e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9587,7 +9587,9 @@ and turn, shear and flip about it (`origin`). WebAssembly plug-ins ([plugins.md](plugins.md)) are reached through commands; the desktop app and an unconfined `vectorcraft-cli` keep the ones `plugin.install` installs in a `Plug-ins` folder next to the preferences and install -them again at startup (`plugin.remove` deletes them there): +them again at startup (`plugin.remove` deletes them there). A window or process locks `disabled.lock` in that folder +while it changes it, so installs, removals, grants and plug-in settings from two of them do not mix; when the file can't +be locked, `plugin.install` and `plugin.remove` fail and change nothing: `plugin.install {path | dataBase64}` installs one, `plugin.list` / `plugin.info {id}` describe them (parameters, schema, defaults). An object filter runs on the selected paths and compound paths with `plugin.run {id, params}` (one undo step; it may change, delete or add objects, and the result is selected). A filter whose manifest lists `inputs` diff --git a/docs/plugins.md b/docs/plugins.md index 5f1479748e..c2c7617cea 100644 --- a/docs/plugins.md +++ b/docs/plugins.md @@ -269,7 +269,13 @@ capability model proposed for PhotoCraft plug-ins while `plugin.install` checks a module, the install is refused, before anything is written to the `Plug-ins` folder, if the other plug-in would need `replace: true` or the changed grant no longer approves the module. A `plugin.remove` in another session waits until the install has written the `Plug-ins` folder, and then removes the - module and its grant. Loading the `Plug-ins` folder or a plug-ins folder in another session waits for it too. When + module and its grant. Loading the `Plug-ins` folder or a plug-ins folder in another session waits for it too. + Another process using the same `Plug-ins` folder, for example `vectorcraft-cli` beside the app, waits as well: each + window or process locks `disabled.lock` in the folder while it reads and changes the stored modules, `grants.json`, + `disabled.json` and the plug-ins' settings and caches. An install therefore keeps a module with its own grant, and a + grant or setting written in one process does not undo one written in another. When `disabled.lock` can't be + locked, `plugin.install` and `plugin.remove` fail and change nothing, `plugin.setEnabled` keeps its change in the + process until a later change can be saved, and loading the folder writes nothing to it. When an install of a module that lists no permissions can't write the module to the `Plug-ins` folder, or can't remove the grant from `grants.json`, the folder keeps the module it held and `grants.json` keeps the grant. The new module runs until the session ends. When the grant can't be diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..1f2409904a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1943,6 +1943,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **A dialog's OK runs what it was opened for:** `ui.dialog.set`, and MCP's `answer_dialog` through it, can set a `__` field only when it is a control of that kind of dialog (a section or tab shown, a link between two fields, a name or search being typed). Every other `__` field, such as the `__command` and `__params` of a confirmation or the generic parameter dialog, a plug-in command dialog's `__command` and `__plugin`, or the paste a swatch conflict waits to finish, is refused with "the `<kind>` dialog cannot set protected field `<field>`"; the request sets no field, and with `action: "confirm"` OK does not run. Regressions: `crates/ui-egui/src/tests/automation.rs`, `crates/ui-egui/src/control/tests.rs`. Scores and hours unchanged. - **Only an approval records a plug-in grant (G17):** `vectorcraft_plugins::registry::grant` takes a `GrantToken`, which the engine makes after an approval and when it loads `grants.json`, and `registry::install`, `install_bytes` and folder loads refuse a module that lists permissions no recorded grant gives this very module (`Error::NeedsApproval`), leaving the plug-in under its id and the revision as they were. A module without `permissions`, or with an empty list, installs as before. `docs/plugins.md` says what the approval does not protect against (native code linked into the app, another program running as the same user, the unsigned `grants.json`). Regressions: `crates/plugins/src/registry.rs`, `crates/plugins/tests/grant_sites.rs`, `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged. - **A refused plug-in install writes nothing (G17):** `plugin.install` checks the plug-in installed under the module's id and its grant again while it records the grant and installs the module (`registry::install_checked`), and only then writes the module and its grant to the `Plug-ins` folder, attaches its settings and cache and turns a disabled plug-in on. When another session installed a plug-in with the id that would need `replace: true`, or changed the grant the checks relied on, the install is refused and the folder, `grants.json`, the disabled list and the installed plug-in stay as they were. Without a plug-in store, the approval comes from the grant the install checks again. A `plugin.remove`, or a load of the folder or of a plug-ins folder, in another session waits until the install has written the folder. VectorCraft's own rule. Regressions: `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged. +- **Windows and processes take turns on the Plug-ins folder:** each one locks `disabled.lock` in the `Plug-ins` folder while it reads and changes the stored modules, `grants.json`, `disabled.json` and the plug-ins' settings and caches, so two installs of one id keep each module with its own grant, and grants or settings written by two processes are all kept. When the file can't be locked, `plugin.install` and `plugin.remove` fail and change nothing. VectorCraft's own rule. Regressions: `crates/engine/src/tests/plugins.rs`. Scores and hours unchanged. - **Plug-in approval waits before OK (G17):** the approval dialog's OK stays disabled until its question has been on screen in the focused window for half a second, VectorCraft's own value; a click, Enter, Space, or a press begun before then installs nothing, and the dialog stays open. The wait starts over for every new question, even one that reads the same, and when the window gets the focus back, so a question swapped in just before a click is not approved by it. Cancel works at once. Regressions: `crates/ui-egui/src/tests/plugins.rs`. Scores and hours unchanged. - **An install automation asked for needs the person to start it (G17):** an approval question that a control request, MCP, injected input or a file dialog one of them opened leads to keeps OK disabled and refuses every confirm, a person's click included; it says to choose Object › Plug-ins › Install Plug-in…, and `ui.installPlugin` answers `approval: "personMustStartInstall"`. The person's own Install Plug-in…, File › Open or drop inspects the module again and asks a new question. Automation's `replace: true` no longer skips the question about taking another module's place, and that question now opens in the approval dialog for everyone. VectorCraft's own rule. Regressions: `crates/ui-egui/src/tests/automation.rs`, `crates/ui-egui/src/tests/plugins.rs`. Scores and hours unchanged. - **A plug-in with no permissions ends its id's grant (G17):** installing a module that lists no permissions under a granted id forgets the grant, in the process and in `grants.json`, so the formerly approved bytes need a new approval. Attaching a `Plug-ins` folder whose module for that id lists no permissions forgets it too, and plug-in folders forget the process's grant. A refused install leaves the grant. Regressions: `crates/engine/src/tests/plugins.rs`, `crates/engine/tests/plugin_safe_mode.rs`. Scores and hours unchanged. From 5d6d04e8eda8a4c8486b95abf347325f2cf70462 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:14:31 -0800 Subject: [PATCH 039/108] i18n: translate 124 more status and error messages into Japanese On main, the untranslated report lists 167 status and error messages under "messages, all 23 languages checked": no complete-message catalog has a row for them, so the Japanese interface shows them in English. - ja.tsv gains 114 @msg rows for the listed messages: image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, 3D and Revolve limits, and script, zip, line and file errors. The 53 listed messages that #7211, #7378 and #7405 translate are left out. - It gains 10 @msg rows for messages other catalogs translate and Japanese lacked: the Banner Hems and Grommets errors, a parameter range and the failed recovery save. The three script and RTF parsing errors that #7314 adds are left out. Placeholders, parameter names, command ids and literal values stay as the English writes them, and the rows follow the catalog's Japanese message conventions. --- crates/ui-egui/src/i18n/ja.tsv | 128 +++++++++++++++++++++++++++++++++ 1 file changed, 128 insertions(+) diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index 71de1ce91c..3c2794e567 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -7188,3 +7188,131 @@ breakText Glyphs 字形 Grommets ハトメ Grommet Inset 端からハトメまでの距離 Diameter 直径 + +# Messages no catalog translated yet: image export and color profiles, color books and swatch exchange files, 3D and Revolve, and script, zip, line and file errors. +@msg 3D effects require finite coordinates within 100 million points 3D 効果には 1 億ポイント以内の有限の座標が必要です +@msg 3D effects require one to ten lights 3D 効果にはライトが 1~10 個必要です +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP の色深度 {_1}: 1、4、8、16、24、32 ビット/ピクセルのいずれかにしてください +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP のエンコードに失敗しました: {width} × {height} ピクセルは形式またはピクセルバッファーに収まりません +@msg GIF encoding failed: the palette image is malformed GIF のエンコードに失敗しました: パレット画像の形式が正しくありません +@msg GIF encoding failed: {e} GIF のエンコードに失敗しました: {e} +@msg JPEG colour profile: {e} JPEG のカラープロファイル: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG のエンコードに失敗しました: ピクセルバッファーが画像サイズと一致しません +@msg JPEG encoding failed: {e} JPEG のエンコードに失敗しました: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG のエンコードに失敗しました: ピクセルバッファーが画像サイズと一致しません +@msg PNG encoding failed: the palette image is malformed PNG のエンコードに失敗しました: パレット画像の形式が正しくありません +@msg PNG encoding failed: {e} PNG のエンコードに失敗しました: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG のエンコードに失敗しました: {width} × {height} ピクセルは有効な画像サイズではありません +@msg PSD colour profile: {e} PSD のカラープロファイル: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD のエンコードに失敗しました: ピクセルバッファーが画像サイズと一致しません +@msg Revolve profile contains invalid coordinates 回転体のプロファイルに無効な座標が含まれています +@msg Revolve profile is too complex 回転体のプロファイルが複雑すぎます +@msg Revolve projection is not finite 回転体の投影が有限ではありません +@msg Revolve requires finite profile coordinates within 100 million points 回転体には 1 億ポイント以内の有限のプロファイル座標が必要です +@msg Revolve surface is too complex; reduce Segments or simplify the profile 回転体のサーフェスが複雑すぎます。分割数を減らすか、プロファイルを単純化してください +@msg Revolve surface is too complex; simplify the profile 回転体のサーフェスが複雑すぎます。プロファイルを単純化してください +@msg Revolve visibility cannot split the projected boundary 回転体の可視判定で投影された境界線を分割できません +@msg Revolve visibility creates too many fragments 回転体の可視判定で生成される断片が多すぎます +@msg Revolve visibility creates too many vector anchors 回転体の可視判定で生成されるベクトルのアンカーポイントが多すぎます +@msg Revolve visibility exceeds its geometry work limit 回転体の可視判定がジオメトリ計算の上限を超えています +@msg Revolve visibility exceeds its spatial index limit 回転体の可視判定が空間インデックスの上限を超えています +@msg Revolve visibility has too many boundary crossings 回転体の可視判定で境界線の交差が多すぎます +@msg Revolve visibility has too many input anchors 回転体の可視判定に入力されるアンカーポイントが多すぎます +@msg Revolve visibility requires convex cap sectors 回転体の可視判定には凸状のキャップのセクターが必要です +@msg Revolve visibility requires finite projected faces 回転体の可視判定には有限の投影面が必要です +@msg SVG options: {e} SVG オプション: {e} +@msg Save for Web settings: {e} Web 用に保存の設定: {e} +@msg TIFF colour profile: {e} TIFF のカラープロファイル: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF のエンコードに失敗しました: ピクセルバッファーが画像サイズと一致しません +@msg TIFF encoding failed: {e} TIFF のエンコードに失敗しました: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa の色深度 {_1}: 16、24、32 ビット/ピクセルのいずれかにしてください +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa のエンコードに失敗しました: ピクセルバッファーが画像サイズと一致しません +@msg The 3D projection is not finite 3D の投影が有限ではありません +@msg The 3D shadow is too complex; turn Shadows off or simplify the art 3D のシャドウが複雑すぎます。シャドウをオフにするか、アートを単純化してください +@msg The shape contains invalid coordinates シェイプに無効な座標が含まれています +@msg Too many Revolve faces for visibility evaluation 可視判定を行うには回転体の面が多すぎます +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft がスウォッチ交換ファイルから読み込めるカラーとグループは {ASE_MAX_ENTRIES} 個までですが、このライブラリには {entries} 個あります +@msg WebP encoding failed: {e} WebP のエンコードに失敗しました: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` には smallThumb、mediumThumb、largeThumb、smallList、largeList のいずれかを指定してください +@msg a line can't run from a point to itself ラインの始点と終点に同じポイントは指定できません +@msg a line needs at least two points ラインには少なくとも 2 つのポイントが必要です +@msg a number cannot be read 数値を読み取れません +@msg a swatch exchange block is too long スウォッチ交換ファイルのブロックが長すぎます +@msg a swatch exchange name is too long スウォッチ交換ファイルの名前が長すぎます +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels {sw} × {sh} の画像を {width} × {height} ピクセルにサイズ変更できません +@msg a {width} × {height} image is too large {width} × {height} の画像は大きすぎます +@msg a {width} × {height} image: {e} {width} × {height} の画像: {e} +@msg an image could not be written: {e} 画像を書き出せませんでした: {e} +@msg an image that couldn't be read was left out 読み込めなかった画像は除外されました +@msg can't open “{name}”: {e} 「{name}」を開けません: {e} +@msg cannot align zip entries to {align} bytes ZIP のエントリを {align} バイト境界に揃えられません +@msg cannot open the automation {kind} root `{_1}`: {e} 自動化の {kind} ルート `{_1}` を開けません: {e} +@msg cannot read profile: {0} プロファイルを読み込めません: {0} +@msg color book version {version} isn't supported (only 1) カラーブックのバージョン {version} には対応していません (対応しているのは 1 のみ) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) 色空間 {other} のカラーブックには対応していません (対応しているのは RGB、CMYK、Lab のみ) +@msg file name too long to zip: {_1} ファイル名が長すぎて ZIP に格納できません: {_1} +@msg file name too long to zip: {name} ファイル名が長すぎて ZIP に格納できません: {name} +@msg freeform line {i}: {e} フリーフォームのライン {i}: {e} +@msg freeform point {i}: {e} フリーフォームのポイント {i}: {e} +@msg give `{key}` or `{other}`, not both `{key}` と `{other}` のどちらか一方を指定してください (両方は指定できません) +@msg grayscale profiles can't be working spaces yet グレースケールのプロファイルはまだ作業用スペースにできません +@msg input contains NaN or infinite coordinates 入力に NaN または無限大の座標が含まれています +@msg input path could not be closed 入力パスを閉じられませんでした +@msg invalid ICC profile: {0} 無効な ICC プロファイル: {0} +@msg invalid scale {scale} 倍率 {scale} は無効です +@msg its localized names take more than {_1} KB ローカライズされた名前が {_1} KB を超えています +@msg its objects are nested too deep ({e}) オブジェクトの入れ子が深すぎます ({e}) +@msg its tag table lists the `{_1}` tag more than once タグテーブルに `{_1}` タグが複数回記載されています +@msg not a graphic style library: {e} グラフィックスタイルライブラリではありません: {e} +@msg not a swatch library (.vcswatches or .gpl) スウォッチライブラリではありません (.vcswatches または .gpl) +@msg not a swatch library (format `{_1}`) スウォッチライブラリではありません (形式: `{_1}`) +@msg not a swatch library: {e} スウォッチライブラリではありません: {e} +@msg not an action set file ({e}) アクションセットファイルではありません ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray プロファイルの色空間 {other} は RGB、CMYK、グレースケールのいずれでもありません +@msg regular expression too large 正規表現が大きすぎます +@msg script file is not UTF-8 text: {value} スクリプトファイルは UTF-8 テキストではありません: {value} +@msg stop {i}: {e} 分岐点 {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) スウォッチ交換ファイルのバージョン {major}.{minor} には対応していません (対応しているのは 1.x のみ) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors カラーブックのカラーが {ASE_MAX_ENTRIES} 色を超えています +@msg the color book is cut short カラーブックが途中で切れています +@msg the color book's names take more than {_1} MB カラーブックの名前が {_1} MB を超えています +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution 画像が {w} × {h} ピクセルになります。ラスター書き出しの上限は 1 辺 {MAX_RASTER_SIDE} ピクセル、{_1} メガピクセルです: 倍率または解像度を下げてください +@msg the optimised image can't be read back: {e} 最適化した画像を読み戻せません: {e} +@msg the pixel buffer doesn't match the image size ピクセルバッファーが画像サイズと一致しません +@msg the preview: {e} プレビュー: {e} +@msg the request may not read the New Document profiles folder このリクエストには新規ドキュメントプロファイルのフォルダーを読み込む権限がありません +@msg the shapes are too degenerate to combine シェイプの形状がつぶれすぎていて結合できません +@msg the shapes cross themselves and each other too often to combine シェイプ自身やシェイプ同士の交差が多すぎて結合できません +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups スウォッチ交換ファイルのカラーとグループが {ASE_MAX_ENTRIES} 個を超えています +@msg the swatch exchange file is cut short スウォッチ交換ファイルが途中で切れています +@msg the {_1} plate can't be read: {e} {_1} 版を読み込めません: {e} +@msg this binary DXF file is damaged or cut short このバイナリ DXF ファイルは壊れているか途中で切れています +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that DWG 図面は読み込めません: CAD アプリで DXF として保存し、そのファイルを開いてください +@msg too many classes 文字クラスが多すぎます +@msg too many groups グループが多すぎます +@msg too many layers for PSD (at most 32767) PSD にはレイヤーが多すぎます (最大 32767) +@msg too many swatch exchange blocks スウォッチ交換ファイルのブロックが多すぎます +@msg unknown colour profile: {0} 不明なカラープロファイル: {0} +@msg {_1} clashes with a built-in profile name {_1} は組み込みのプロファイル名と重複しています +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} ピクセルは GIF には大きすぎます (1 辺最大 65535 ピクセル): 解像度を下げてください +@msg {_1}: no usable transform to/from sRGB {_1}: sRGB との間で使用できる変換がありません +@msg {name} is not a CMYK profile {name} は CMYK プロファイルではありません +@msg {name} is not an RGB profile {name} は RGB プロファイルではありません +@msg {path}: could not be read {path}: 読み込めませんでした +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} ピクセルは JPEG には大きすぎます (1 辺最大 65535 ピクセル): 解像度を下げてください +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} ピクセルは Targa には大きすぎます (1 辺最大 65535 ピクセル): 解像度を下げてください +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} ピクセルは PSD には大きすぎます (1 辺最大 {MAX_SIDE} ピクセル): 解像度を下げてください + +# Messages other catalogs translate and Japanese did not: Banner Hems and Grommets, a parameter range and the recovery save. +@msg `{key}` must be from 0.01 to 1000 pt `{key}` は 0.01~1000 pt にしてください +@msg select the banner, or mark every artboard バナーを選択するか、すべてのアートボードにマークを付けてください +@msg the banner has no width or height バナーに幅または高さがありません +@msg the grommet inset is too large for the banner 端からハトメまでの距離がバナーに対して大きすぎます +@msg the hem is too deep for the banner 折り返しがバナーに対して深すぎます +@msg the spacing makes more than {MAX_GROMMETS} grommets この間隔ではハトメが {MAX_GROMMETS} 個を超えます +@msg there is no banner to mark マークを付けるバナーがありません +@msg turn on at least one side 少なくとも 1 つの辺をオンにしてください +@msg with no hem and no grommets there is nothing to mark 折り返しもハトメもないため、マークを付けるものがありません +@msg {saving} failed: {e} {saving} に失敗しました: {e} From 6b9e7e9fa6390f1d75b53db0181f1ca61d627171 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:16:40 -0800 Subject: [PATCH 040/108] Automation: replies hide a file or missing folder on the way to the recovery folder When a recovery copy fails because a folder on the way to the recovery folder is a file or is missing, the error names that folder, not the recovery folder. Replies to a client confined to read roots hid only the recovery folder itself, so the full path of that ancestor stayed visible. A reply now also hides each ancestor of a recovery folder that it writes as a whole path. The check compares text only and does not look anything up on disk. Follows #7287. --- crates/ui-egui/src/control.rs | 32 +++++++++++++++++++++++++++-- crates/ui-egui/src/control/tests.rs | 30 +++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/control.rs b/crates/ui-egui/src/control.rs index 2779bc7f6d..26f67a0365 100644 --- a/crates/ui-egui/src/control.rs +++ b/crates/ui-egui/src/control.rs @@ -1274,7 +1274,9 @@ pub fn handle(app: &mut VectorcraftApp, ctx: &egui::Context, req: &ControlReques /// Hides in `reply` the libraries hidden now and in `before`, and the paths outside the read root that /// `sent`, the request's params, holds ([`handle`]), and the recovery folders outside the read root -/// that are in use or that a failure message named. The `path` and `files` entries of the reply's +/// that are in use or that a failure message named, with each folder on the way to one that the reply +/// writes as a whole path ([`writes_whole_path`]): a failure names a file or a missing folder there. +/// The `path` and `files` entries of the reply's /// `result`, at any depth, that name a file the request gave inside the write roots, the file it /// wrote, stay as given ([`written_paths`]). fn hide_in_reply(app: &VectorcraftApp, reply: &mut Value, sent: &Value, before: Hiding) { @@ -1288,16 +1290,42 @@ fn hide_in_reply(app: &VectorcraftApp, reply: &mut Value, sent: &Value, before: hiding.merge(before); let mut paths = Vec::new(); sent_paths(sent, &mut paths); - // The status text of a recovery copy that failed names the recovery folder it went to. + // The status text of a recovery copy that failed names the recovery folder it went to, or the + // first folder on the way to it that is a file or is missing. let current = vectorcraft_engine::cmd::recovery::folder(&app.session).map(|(f, _)| f); for folder in app.recovery.named.iter().chain(current.as_ref()) { collect_sent_paths(&json!(folder), true, &mut paths); + for on_the_way in std::path::Path::new(folder).ancestors().skip(1).map(|p| p.to_string_lossy()) { + if !on_the_way.is_empty() && writes_whole_path(reply, &on_the_way) { + collect_sent_paths(&json!(on_the_way), true, &mut paths); + } + } } hiding.set_hidden(paths, cfg!(windows)); hide_library_ids(reply, &hiding); restore_written_paths(reply, kept); } +/// Does `v` write `path` in a string or a key at any depth with no path text before it (a letter, a +/// digit, `_`, `-`, `.`, `~` or a separator) or after it ([`continues_path`]), a Windows path +/// ([`splits_at_backslash`]) with either separator and in any case of ASCII letters too? Only the text +/// is compared: nothing on disk is looked up. +fn writes_whole_path(v: &Value, path: &str) -> bool { + let windows = splits_at_backslash(path); + let path_before = + |before: &str| before.chars().next_back().is_some_and(|c| c.is_alphanumeric() || matches!(c, '_' | '-' | '.' | '~' | '/' | '\\')); + let whole = |s: &str| { + let spellings = if windows { vec![path.replace('\\', "/"), path.replace('/', "\\")] } else { vec![path.to_string()] }; + spellings.iter().any(|p| occurrences(s, p, windows).into_iter().any(|at| !path_before(&s[..at]) && !continues_path(&s[at + p.len()..]))) + }; + match v { + Value::String(s) => whole(s), + Value::Array(items) => items.iter().any(|item| writes_whole_path(item, path)), + Value::Object(fields) => fields.iter().any(|(key, item)| whole(key) || writes_whole_path(item, path)), + _ => false, + } +} + /// The strings that `v`'s path params hold at any depth ([`vectorcraft_engine::file_access::is_path_key`]) /// that name a file inside the write roots; `v` is a path param's value when `path_param` is set. fn written_paths(v: &Value, path_param: bool, out: &mut Vec<String>) { diff --git a/crates/ui-egui/src/control/tests.rs b/crates/ui-egui/src/control/tests.rs index b60b1adfdc..d914c3624d 100644 --- a/crates/ui-egui/src/control/tests.rs +++ b/crates/ui-egui/src/control/tests.rs @@ -474,6 +474,36 @@ fn a_recovery_folder_outside_the_read_root_is_hidden_in_the_status() { assert_eq!(inspect(&mut app, format!("Copies go to {inside}")), json!(format!("Copies go to {inside}"))); } +/// `ui.inspect` shows a file on the way to a recovery folder outside the read root, which a failed +/// recovery copy names, by its name, and a missing folder on the way too. A path that only begins or +/// only ends with a folder on the way stays. +#[test] +fn a_file_on_the_way_to_a_recovery_folder_outside_the_read_root_is_hidden_in_the_status() { + let mut app = VectorcraftApp::new(Session::new(), Services::default()); + let outside = crate::tests_folder::Folder::new("recovery-in-the-way"); + let file = outside.file("private", b"a file"); + let folder = std::path::Path::new(&file).join("recovery").to_string_lossy().into_owned(); + app.session.recovery.set_default_folder(Some(folder)); + let root = crate::tests_folder::Folder::new("recovery-in-the-way-root"); + let roots = vectorcraft_engine::file_access::AutomationRoots::new(&[root.as_path()], &[]).unwrap(); + let inspect = |app: &mut VectorcraftApp, status: String| { + app.ui.status = status; + let reply = vectorcraft_engine::file_access::confine(roots.as_ref(), || input_request(app, "ui.inspect", json!({}))); + reply["result"]["ui"]["status"].clone() + }; + let status = format!("Couldn't save recovery data: {file} is not a folder"); + assert_eq!(inspect(&mut app, status), "Couldn't save recovery data: private is not a folder"); + let missing = outside.join("gone"); + let folder = missing.join("recovery").to_string_lossy().into_owned(); + app.session.recovery.set_default_folder(Some(folder)); + let status = format!("Couldn't save recovery data: couldn't make {}", missing.display()); + assert_eq!(inspect(&mut app, status), "Couldn't save recovery data: couldn't make gone"); + let under = format!("Copies go near {}", outside.join("other.svg").display()); + assert_eq!(inspect(&mut app, under.clone()), json!(under)); + let longer = format!("Copies go near /work{}", missing.display()); + assert_eq!(inspect(&mut app, longer.clone()), json!(longer)); +} + /// A path outside the read root that a request sent is shown by its file name in a reply that succeeded /// as in one that failed. #[test] From 6bd675528390e04386d8c0e40ef7f37a61939e50 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 19:02:06 -0800 Subject: [PATCH 041/108] Effects: a clipping path's geometry effects shape the clip on the canvas A clipping path with Roughen, Transform or another effect that reshapes a path drew its own fill and stroke reshaped, but the canvas and raster export still clipped the art by the plain path. SVG and PDF export bake the effect into the path before writing the clip path, so the screen and a saved SVG showed different art. effects::clip_outline now applies the live geometry effects in the clipping path before taking its region: the path's or compound path's own effects, the effects of its fills and strokes (the region is then the union of the paths they give, as an export bakes them), the effects of a compound path's paths, of a group's visible members and of a nested clip group's clipping path, shown or hidden, and a group's own effects as an export evaluates them. Raster effects such as Gaussian Blur leave the region as it is. The renderer, the engine commands that measure a clip region (flatten, arrowheads, cutting) and the writers use it; the writers receive the baked document, so their output for a path with effects does not change. The renderer measures a clip group by the region its clipping path's effects give it, so a view or tile that shows only the moved part of the clip still draws the clipped art, and it drops cached clip regions that hold a plug-in effect when plug-ins change. Two rules change in every export as well as on the canvas: - When the clip group, or a group around it, has a geometry effect of its own, the clipping path's effects apply first and its gradients move with them. #7114 left the clipping path's effects live under the group's effect, so they applied after it. - Type used as a clipping path keeps its own effects when a group's effect outlines it. #2073 and #2290 outlined it without them, to match the plain clip the canvas drew. --- crates/effects/src/bake.rs | 14 +- crates/effects/src/bake/tests.rs | 6 +- crates/effects/src/clip.rs | 113 ++++++++- crates/effects/src/group.rs | 14 +- crates/effects/src/group/tests.rs | 8 +- crates/effects/src/reshape.rs | 18 +- crates/effects/src/tests.rs | 1 + crates/effects/src/tests/clipfx.rs | 315 ++++++++++++++++++++++++++ crates/render/src/fx/bounds.rs | 11 + crates/render/src/renderer/nodes.rs | 5 +- crates/render/src/tests/clip.rs | 36 +++ crates/render/src/tests/container.rs | 6 +- crates/render/src/tests/memory.rs | 10 + crates/svg/tests/it/effects_export.rs | 31 +++ docs/target-app-parity.md | 1 + 15 files changed, 563 insertions(+), 26 deletions(-) create mode 100644 crates/effects/src/tests/clipfx.rs diff --git a/crates/effects/src/bake.rs b/crates/effects/src/bake.rs index 7e42147443..fe1f355c9a 100644 --- a/crates/effects/src/bake.rs +++ b/crates/effects/src/bake.rs @@ -26,13 +26,13 @@ use vectorcraft_geom::{Affine, FillRule, PathData, Rect, Vec2}; use crate::distort::{transform_move, transform_offsets}; use crate::group::{has_own_paint, paints}; -use crate::reshape::{as_art, geometry_effects, glyph_outlines, outline_nested_text, reshape_leaves}; +use crate::reshape::{as_art, clipping_text_outline, geometry_effects, glyph_outlines, outline_nested_text, reshape_leaves}; use crate::{ GeomContext, adjust_in_document, apply_geometry_carrying, crop_marks_art, evaluate_container, has_adjustment, has_crop_marks, has_geometry, - has_item_geometry, has_pathfinder, is_pathfinder, merged_params, needs_outline, outline_text, reshape, + has_item_geometry, has_pathfinder, is_pathfinder, merged_params, needs_outline, reshape, }; -fn item_effects(item: &AppearanceItem) -> &[vectorcraft_doc::Effect] { +pub(crate) fn item_effects(item: &AppearanceItem) -> &[vectorcraft_doc::Effect] { match item { AppearanceItem::Fill(f) => &f.effects, AppearanceItem::Stroke(s) => &s.effects, @@ -73,7 +73,7 @@ fn geometry(n: &Node) -> Option<(PathData, FillRule)> { /// `path` with the geometry effects of `effects` applied, and how gradients follow them /// ([`crate::Carry`]). -fn apply(effects: &[vectorcraft_doc::Effect], path: &PathData, ctx: &GeomContext) -> (PathData, crate::Carry) { +pub(crate) fn apply(effects: &[vectorcraft_doc::Effect], path: &PathData, ctx: &GeomContext) -> (PathData, crate::Carry) { if !has_geometry(effects) || path.is_empty() { return (path.clone(), crate::Carry::default()); } @@ -85,7 +85,7 @@ fn apply(effects: &[vectorcraft_doc::Effect], path: &PathData, ctx: &GeomContext /// context of) applied, and `carried` (`item` as the object's effects left it) with its gradient /// moved along with them and the Transform effects the geometry pass left out hidden /// ([`crate::Carry::hide_skipped`]). -fn apply_item(item: &AppearanceItem, carried: &AppearanceItem, g: &PathData, ctx: &GeomContext) -> (PathData, AppearanceItem) { +pub(crate) fn apply_item(item: &AppearanceItem, carried: &AppearanceItem, g: &PathData, ctx: &GeomContext) -> (PathData, AppearanceItem) { let (ig, carry) = apply(item_effects(item), g, &ctx.item(item)); let mut ap = Appearance { items: vec![carried.clone()], ..Default::default() }; if carry.moves(&ap) { @@ -402,7 +402,7 @@ fn container_keeping_type(d: &Document, n: &Node) -> Option<Node> { last => Some(Node::group(c.id, copies.into_iter().chain(last).map(Arc::new).collect())), } } - None if clipping => outline_text(c).map(|o| Node { visible: c.visible, ..o }), + None if clipping => clipping_text_outline(c), None => as_art(Some(d), c, None), }; if let Some(o) = art { @@ -464,7 +464,7 @@ fn piece(d: &mut Document, n: &Node, path: PathData, rule: FillRule, item: Appea /// `n`'s geometry with its object-level geometry effects applied, its fill rule, the context of /// its effects, and `n` without those effects, its gradients moved along with them. -fn leaf_base(n: &Node) -> Option<(PathData, FillRule, GeomContext<'_>, Node)> { +pub(crate) fn leaf_base(n: &Node) -> Option<(PathData, FillRule, GeomContext<'_>, Node)> { let (base, rule) = geometry(n)?; let ctx = GeomContext::of(n); let mut m = n.clone(); diff --git a/crates/effects/src/bake/tests.rs b/crates/effects/src/bake/tests.rs index 2bcc026340..6d1cb35ebd 100644 --- a/crates/effects/src/bake/tests.rs +++ b/crates/effects/src/bake/tests.rs @@ -753,7 +753,7 @@ fn type_outlined_next_to_type_that_stays_type_keeps_its_look() { } #[test] -fn type_in_a_clipping_group_with_a_fill_of_its_own_is_outlined_plain() { +fn type_in_a_clipping_group_with_a_fill_of_its_own_keeps_its_effect() { if skip_without_craft_fonts() { return; } @@ -768,9 +768,9 @@ fn type_in_a_clipping_group_with_a_fill_of_its_own_is_outlined_plain() { g.children_mut().unwrap().push(Arc::new(clip)); let d = bake_document(&doc_with(g)).unwrap(); assert_eq!(type_origins(&d), [(20.0, 60.0), (220.0, 60.0)]); - // The type clips by its plain outlines, as the canvas clips by them: its own effect is left out. + // The type clips by its outlines moved by its own effect, as the canvas clips by them. let b = d.node(NodeId(59)).and_then(|n| n.geometric_bounds()).unwrap(); - assert!(b.y0 > 30.0 && b.y1 < 70.0, "{b:?}"); + assert!(b.y0 > 330.0 && b.y1 < 370.0, "{b:?}"); } #[test] diff --git a/crates/effects/src/clip.rs b/crates/effects/src/clip.rs index a3e31f1842..e39deb32b5 100644 --- a/crates/effects/src/clip.rs +++ b/crates/effects/src/clip.rs @@ -7,9 +7,118 @@ use vectorcraft_geom::{BezPath, FillRule, PathData}; /// The clipping path `clip` of a clip group as one path and fill rule: compound paths keep their /// holes, even-odd paths their rule, text clips by its glyph outlines and a group by the union of -/// its members. `None` when there is nothing to clip by (the clipped art is then hidden). +/// its members. The live geometry effects of the clipping path (and of the members it clips by) +/// reshape the region, as they reshape what it paints, and so do the geometry effects of a path's +/// fills and strokes: the region is then the union of the paths they give, as an export bakes them. +/// `None` when there is nothing to clip by (the clipped art is then hidden). pub fn clip_outline(clip: &Node) -> Option<(BezPath, FillRule)> { - clip.clip_outline(Some(&outline_text), &unite) + match clip_effects_applied(clip, true) { + Some(m) => m.clip_outline(Some(&outline_text), &unite), + None => clip.clip_outline(Some(&outline_text), &unite), + } +} + +/// `n`, the clipping path of a clip group, with the live geometry effects of everything it clips by +/// applied, innermost first, and removed: a path or compound path with effects becomes a path of +/// its reshaped geometry that keeps its fills, strokes and other effects (its gradients follow the +/// effects, as an export bakes it), the paths of a compound path and the visible members of a group +/// are reshaped by their own effects before the effects around them, a group's or layer's own +/// effects reshape its members as an export evaluates them, and other objects with effects (type) +/// become a path of their reshaped region. The geometry effects of a path's fills and strokes stay +/// live, for the export to bake. `None` when nothing in it has a geometry effect. Effects on the +/// clip group or around it then reshape the result, after its own. +pub(crate) fn with_clip_effects_applied(n: &Node) -> Option<Node> { + clip_effects_applied(n, false) +} + +/// [`with_clip_effects_applied`]; with `region` set, a path or compound path whose fills or strokes +/// have geometry effects becomes a group of one unpainted path per fill and stroke, reshaped by the +/// path's effects and then by that fill's or stroke's, whose union [`clip_outline`] clips by. +fn clip_effects_applied(n: &Node, region: bool) -> Option<Node> { + let mut m: Option<Node> = None; + let members: &[std::sync::Arc<Node>] = match &n.kind { + NodeKind::Group { children, clip: true } => children.get(..1).unwrap_or_default(), + NodeKind::Group { children, .. } | NodeKind::Layer { children, .. } | NodeKind::Compound { children, .. } => children, + _ => &[], + }; + // A group or layer clips by its visible members after its shaper; a compound path by all of + // its paths, and a nested clip group by its clipping path, shown or hidden + // ([`Node::clip_shapes`]). + let all = matches!(n.kind, NodeKind::Compound { .. } | NodeKind::Group { clip: true, .. }); + let skip = usize::from(matches!(n.kind, NodeKind::Group { clip: false, .. } | NodeKind::Layer { .. }) && n.extras().shaper.is_some()); + // The paths of a compound path draw with the compound path's fills and strokes, and stay paths. + let compound = matches!(n.kind, NodeKind::Compound { .. }); + for (i, c) in members.iter().enumerate().skip(skip).filter(|(_, c)| all || c.visible) { + if let Some(r) = clip_effects_applied(c, region && !compound) + && let Some(slot) = m.get_or_insert_with(|| n.clone()).children_mut().and_then(|ch| ch.get_mut(i)) + { + *slot = std::sync::Arc::new(r); + } + } + let items = region + && matches!(n.kind, NodeKind::Path { .. } | NodeKind::Compound { .. }) + && n.appearance.items.iter().any(|i| crate::has_geometry(crate::bake::item_effects(i))); + if items && let Some((g, rule, ctx, p)) = crate::bake::leaf_base(m.as_ref().unwrap_or(n)) { + let children = n + .appearance + .items + .iter() + .zip(&p.appearance.items) + .map(|(item, carried)| { + let (ig, _) = crate::bake::apply_item(item, carried, &g, &ctx); + let mut piece = Node::path(n.id, ig, Appearance::default()); + if let NodeKind::Path { rule: r, .. } = &mut piece.kind { + *r = rule; + } + std::sync::Arc::new(piece) + }) + .collect(); + let mut out = Node::new(n.id, NodeKind::Group { children, clip: false }); + out.visible = n.visible; + return Some(out); + } + if !crate::has_geometry(&n.appearance.effects) { + return m; + } + let cur = m.as_ref().unwrap_or(n); + // A group's or layer's effects reshape each of its members (a clip group's its clipping + // path), as an export evaluates them; otherwise they reshape its region, below. + if matches!(cur.kind, NodeKind::Group { .. } | NodeKind::Layer { .. }) + && let Some(e) = crate::group::evaluate_container(None, cur) + { + return Some(e); + } + // A path or compound path, as an export bakes it. + if let Some((g, rule, _, mut p)) = crate::bake::leaf_base(cur) { + let clipping = match &cur.kind { + NodeKind::Path { clipping, .. } => *clipping, + NodeKind::Compound { children, .. } => children.iter().any(|c| matches!(c.kind, NodeKind::Path { clipping: true, .. })), + _ => false, + }; + p.kind = Node::path(n.id, g, Appearance::default()).kind; + if let NodeKind::Path { rule: r, clipping: c, .. } = &mut p.kind { + (*r, *c) = (rule, clipping); + } + return Some(p); + } + // Type, as its painted outlines that its effects reshape as an export evaluates them. + if matches!(cur.kind, NodeKind::Text(_)) + && let Some(mut o) = crate::outline_text(cur) + { + o.visible = n.visible; + o.appearance.effects = n.appearance.effects.clone(); + if let Some(e) = crate::group::evaluate_container(None, &o) { + return Some(e); + } + } + let (bp, rule) = cur.clip_outline(Some(&outline_text), &unite)?; + let (g, _) = crate::bake::apply(&n.appearance.effects, &PathData::from_bezpath(&bp), &crate::GeomContext::of(n)); + let mut p = Node::path(n.id, g, Appearance::default()); + if let NodeKind::Path { rule: r, .. } = &mut p.kind { + *r = rule; + } + p.visible = n.visible; + Some(p) } /// The knockout shape of a piece of a mesh-warped image ([`Node::knockout_outline`]) painted opaque diff --git a/crates/effects/src/group.rs b/crates/effects/src/group.rs index bb2f605a91..75f9bdd817 100644 --- a/crates/effects/src/group.rs +++ b/crates/effects/src/group.rs @@ -838,9 +838,10 @@ pub fn evaluate_container(doc: Option<&Document>, n: &Node) -> Option<Node> { /// Replace each visible member of `n` with geometry or Pathfinder effects of its own, at every /// depth of its groups and layers, by the art it draws ([`evaluate_container`], /// [`crate::reshape::own_effects_art`]), so the geometry effects of `n` reshape what its members -/// draw. A clip group's clipping path stays as it is, and so do images, symbol instances and the -/// other objects that `own_effects_art` leaves alone, and a group or layer with a 3D effect with -/// everything in it. Calls nested in one another, through the +/// draw. A clip group's clipping path only takes the geometry effects in it into its geometry +/// ([`crate::clip::with_clip_effects_applied`]). Images, symbol instances and the other objects +/// that `own_effects_art` leaves alone stay as they are, and so does a group or layer with a 3D +/// effect with everything in it. Calls nested in one another, through the /// groups and layers it walks and the art it evaluates (symbol art and Pathfinder members /// included), stop at [`vectorcraft_doc::depth::MAX_DEPTH`] deep, and together they replace at /// most [`crate::SYMBOL_ART_MAX_NODES`] members: past either limit, members stay as they are. @@ -848,6 +849,13 @@ pub(crate) fn members_as_drawn(doc: Option<&Document>, n: &mut Node) { let Some(_frame) = DrawnFrame::enter() else { return }; let clip = usize::from(n.clips()); let Some(ch) = n.children_mut() else { return }; + // The clipping path's own geometry effects shape it before the effects around it do. + if clip == 1 + && let Some(first) = ch.first_mut() + && let Some(applied) = crate::clip::with_clip_effects_applied(first) + { + *first = Arc::new(applied); + } for c in ch.iter_mut().skip(clip).filter(|c| c.visible) { if !DrawnFrame::take_member() { return; diff --git a/crates/effects/src/group/tests.rs b/crates/effects/src/group/tests.rs index c6e2a78c73..1411df4b44 100644 --- a/crates/effects/src/group/tests.rs +++ b/crates/effects/src/group/tests.rs @@ -747,9 +747,9 @@ fn a_baked_group_that_keeps_its_type_applies_its_members_effects_first() { assert!((w - 250.0).abs() < 1e-6, "{w}"); } -/// A clip group's clipping path keeps its own effects; the clipped members take theirs first. +/// A clip group's clipping path and the clipped members take their own effects first. #[test] -fn a_clipping_path_keeps_its_own_effects_under_a_groups_effects() { +fn a_clipping_path_takes_its_own_effects_before_a_groups_effects() { let mut clip = with_effect(square_at_100(), offset_10()); clip.id = NodeId(2); if let NodeKind::Path { clipping, .. } = &mut clip.kind { @@ -762,7 +762,9 @@ fn a_clipping_path_keeps_its_own_effects_under_a_groups_effects() { let clip_group = art.children().unwrap()[0].clone(); let ch = clip_group.children().unwrap(); assert!(matches!(ch[0].kind, NodeKind::Path { clipping: true, .. }), "{:?}", ch[0].kind); - assert_eq!(crate::reshape::geometry_effects(&ch[0]).len(), 1, "the clipping path keeps its Offset Path"); + assert!(crate::reshape::geometry_effects(&ch[0]).is_empty(), "the clipping path's Offset Path is applied"); + let w = ch[0].geometric_bounds().unwrap().width(); + assert!((w - 60.0).abs() < 0.5, "grown by 10 on each side, then scaled to 50 %: {w}"); assert!(matches!(ch[1].kind, NodeKind::Group { .. }) && crate::reshape::geometry_effects(&ch[1]).is_empty(), "the member is drawn as its art"); } diff --git a/crates/effects/src/reshape.rs b/crates/effects/src/reshape.rs index 8c829d9e0b..78d9ee522a 100644 --- a/crates/effects/src/reshape.rs +++ b/crates/effects/src/reshape.rs @@ -678,18 +678,28 @@ fn instances_as_art(doc: Option<&Document>, n: &mut Node, outline: OutlineHook, } } +/// Type `t` in a clip group's clipping path as its outlines ([`outline_text`]) with its +/// visibility, or with geometry effects as a path of the region they give it, which is what +/// [`crate::clip_outline`] clips by. +pub(crate) fn clipping_text_outline(t: &Node) -> Option<Node> { + if let Some(p) = crate::clip::with_clip_effects_applied(t) { + return Some(p); + } + let o = outline_text(t)?; + Some(Node { visible: t.visible, ..o }) +} + /// Replace type anywhere inside `n` by its outlines, as art that keeps the type's look /// ([`as_art`]). Type in a clip group's clipping path (all of `n` when `clipping` is set) becomes -/// its plain outlines ([`outline_text`]) with its visibility, which is what -/// [`crate::clip_outline`] clips by. The swatches and patterns that live-effect plug-ins painting -/// their pieces name are looked up in `doc`. +/// its outlines with its visibility and effects ([`clipping_text_outline`]). The swatches and +/// patterns that live-effect plug-ins painting their pieces name are looked up in `doc`. pub(crate) fn outline_nested_text(doc: Option<&Document>, n: &mut Node, clipping: bool) { let clips = n.clips(); let Some(ch) = n.children_mut() else { return }; for (i, c) in ch.iter_mut().enumerate() { let clipping = clipping || (clips && i == 0); let art = match &c.kind { - NodeKind::Text(_) if clipping => outline_text(c).map(|o| Node { visible: c.visible, ..o }), + NodeKind::Text(_) if clipping => clipping_text_outline(c), NodeKind::Text(_) => as_art(doc, c, None), _ => None, }; diff --git a/crates/effects/src/tests.rs b/crates/effects/src/tests.rs index 627cc1be03..5c04cb5deb 100644 --- a/crates/effects/src/tests.rs +++ b/crates/effects/src/tests.rs @@ -4,6 +4,7 @@ use vectorcraft_geom::{Affine, PathData, Point, Rect, Shape, SubPath, shapes}; use super::*; +mod clipfx; mod imageoutline; mod painted; mod rasterfollow; diff --git a/crates/effects/src/tests/clipfx.rs b/crates/effects/src/tests/clipfx.rs new file mode 100644 index 0000000000..c513be72c3 --- /dev/null +++ b/crates/effects/src/tests/clipfx.rs @@ -0,0 +1,315 @@ +//! Live effects on the clipping path of a clip group: the region it clips to takes the shape its +//! geometry effects give it, on the canvas as in an export. + +use std::sync::Arc; + +use serde_json::{Value, json}; +use vectorcraft_color::{Color, Paint}; +use vectorcraft_doc::{Appearance, Document, Effect, Node, NodeId, NodeKind}; +use vectorcraft_geom::{Rect, Shape, shapes}; + +use crate::{bake_document, clip_outline}; + +fn fx(id: &str, params: Value) -> Effect { + Effect { id: id.into(), params, visible: true } +} + +/// A 100 pt square clipping path at (50, 50) with `effects`. +fn clipping_path(id: u64, effects: Vec<Effect>) -> Node { + let mut p = Node::path(NodeId(id), shapes::rectangle(Rect::new(50.0, 50.0, 150.0, 150.0)), Appearance::default()); + if let NodeKind::Path { clipping, .. } = &mut p.kind { + *clipping = true; + } + p.appearance.effects = effects; + p +} + +/// A clip group: `clip` clipping a red 200 pt square at the origin. +fn clip_group(id: u64, clip: Node) -> Node { + let art = Node::path( + NodeId(id + 100), + shapes::rectangle(Rect::new(0.0, 0.0, 200.0, 200.0)), + Appearance::basic(Paint::solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 0.0), + ); + Node::new(NodeId(id), NodeKind::Group { children: vec![Arc::new(clip), Arc::new(art)], clip: true }) +} + +fn bounds(n: &Node) -> Rect { + clip_outline(n).map(|(bp, _)| bp.bounding_box()).unwrap() +} + +/// The clipping path of the first clip group in `doc` after an export bakes it. +fn baked_clip(doc: &Document) -> Arc<Node> { + fn first(n: &Arc<Node>) -> Option<Arc<Node>> { + match &n.kind { + NodeKind::Group { children, clip: true } => children.first().cloned(), + _ => n.children()?.iter().find_map(first), + } + } + let baked = bake_document(doc).unwrap(); + baked.layers.iter().find_map(first).unwrap() +} + +#[test] +fn transform_moves_the_clip() { + let clip = clipping_path(1, vec![fx("distort.transform", json!({"moveH": 60}))]); + let b = bounds(&clip); + assert!((b.x0 - 110.0).abs() < 1e-6 && (b.x1 - 210.0).abs() < 1e-6, "the clip moves with the clipping path: {b:?}"); + assert!((b.y0 - 50.0).abs() < 1e-6 && (b.y1 - 150.0).abs() < 1e-6, "{b:?}"); +} + +#[test] +fn roughen_clips_as_an_export_does() { + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + let group = clip_group(1, clipping_path(2, vec![fx("distort.roughen", json!({"size": 10, "detail": 10, "relative": false}))])); + d.insert(Some(layer), 0, group.clone()).unwrap(); + let NodeKind::Group { children, .. } = &group.kind else { panic!("not a group") }; + let live = clip_outline(&children[0]).unwrap(); + let exported = clip_outline(&baked_clip(&d)).unwrap(); + assert_eq!(live.1, exported.1); + assert_eq!(live.0, exported.0, "the canvas clips by the outline the export writes"); + assert_ne!(live.0.bounding_box(), Rect::new(50.0, 50.0, 150.0, 150.0), "the roughened outline, not the plain square"); +} + +#[test] +fn nested_members_keep_their_effects() { + // A group as the clipping path: its member's Transform effect moves its part of the region. + let moved = clipping_path(2, vec![fx("distort.transform", json!({"moveV": 60}))]); + let group = Node::group(NodeId(1), vec![Arc::new(moved)]); + let b = bounds(&group); + assert!((b.y0 - 110.0).abs() < 1e-6 && (b.y1 - 210.0).abs() < 1e-6, "{b:?}"); + // A clip group as the clipping path clips by its own clipping path, effects and all. + let nested = clip_group(3, clipping_path(4, vec![fx("distort.transform", json!({"moveH": -30}))])); + let b = bounds(&nested); + assert!((b.x0 - 20.0).abs() < 1e-6 && (b.x1 - 120.0).abs() < 1e-6, "{b:?}"); + // So does the nested clip group's own effect. + let mut nested = clip_group(7, clipping_path(8, vec![])); + nested.appearance.effects.push(fx("distort.transform", json!({"moveH": 30}))); + let b = bounds(&nested); + assert!((b.x0 - 80.0).abs() < 1e-6 && (b.x1 - 180.0).abs() < 1e-6, "{b:?}"); + // The group's own Transform effect applies on top of its members'. + let mut group = Node::group(NodeId(5), vec![Arc::new(clipping_path(6, vec![fx("distort.transform", json!({"moveV": 60}))]))]); + group.appearance.effects.push(fx("distort.transform", json!({"moveH": 10}))); + let b = bounds(&group); + assert!((b.x0 - 60.0).abs() < 1e-6 && (b.y0 - 110.0).abs() < 1e-6, "{b:?}"); +} + +#[test] +fn a_roughened_group_clips_as_an_export_does() { + // Two members side by side, Roughen on the group: each member is roughened, as in the export. + let member = |id: u64, x: f64| { + Arc::new(Node::path( + NodeId(id), + shapes::rectangle(Rect::new(x, 50.0, x + 40.0, 150.0)), + Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 0.0), + )) + }; + let mut clip = Node::group(NodeId(2), vec![member(3, 50.0), member(4, 110.0)]); + clip.appearance.effects.push(fx("distort.roughen", json!({"size": 10, "detail": 10, "relative": false}))); + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + d.insert(Some(layer), 0, clip_group(1, clip.clone())).unwrap(); + let live = clip_outline(&clip).unwrap(); + assert_eq!(live.0, clip_outline(&baked_clip(&d)).unwrap().0, "the canvas clips by the outline the export writes"); + assert_ne!(live.0.bounding_box(), Rect::new(50.0, 50.0, 150.0, 150.0)); +} + +#[test] +fn a_compound_paths_member_keeps_its_effect() { + // A ring whose hole a Transform effect moves 20 pt right, as the export bakes it. + let ring = |effects: Vec<Effect>| { + let outer = Node::path(NodeId(3), shapes::rectangle(Rect::new(50.0, 50.0, 150.0, 150.0)), Appearance::default()); + let mut hole = Node::path(NodeId(4), shapes::rectangle(Rect::new(75.0, 75.0, 125.0, 125.0)), Appearance::default()); + hole.appearance.effects = effects; + Node::new(NodeId(2), NodeKind::Compound { children: vec![Arc::new(outer), Arc::new(hole)], rule: vectorcraft_geom::FillRule::EvenOdd }) + }; + let moved = ring(vec![fx("distort.transform", json!({"moveH": 20}))]); + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + d.insert(Some(layer), 0, clip_group(1, moved.clone())).unwrap(); + let live = clip_outline(&moved).unwrap(); + assert_eq!(live, clip_outline(&baked_clip(&d)).unwrap(), "the canvas clips by the outline the export writes"); + assert_ne!(live, clip_outline(&ring(vec![])).unwrap(), "the hole moves"); +} + +#[test] +fn the_clipping_paths_effects_apply_before_the_clip_groups() { + // Scale 50 % on the clipping path, then Offset Path 10 on its clip group: the region is the + // half-size square grown by 10, as if the clipping path had been drawn at half size. + let group = |clip: Node| { + let mut g = clip_group(1, clip); + g.appearance.effects.push(fx("path.offsetPath", json!({"offset": 10}))); + g + }; + let scaled = group(clipping_path(2, vec![fx("distort.transform", json!({"scaleH": 50, "scaleV": 50}))])); + let mut half = clipping_path(2, vec![]); + if let NodeKind::Path { path, .. } = &mut half.kind { + *path = shapes::rectangle(Rect::new(75.0, 75.0, 125.0, 125.0)); + } + let want = bounds(&group(half)); + let got = bounds(&scaled); + assert!((got.x0 - want.x0).abs() < 0.5 && (got.x1 - want.x1).abs() < 0.5, "{got:?} against {want:?}"); + assert!((want.x0 - 65.0).abs() < 0.5, "{want:?}"); + // The clip group as the canvas evaluates it for its effect, and as an export bakes it. + let evaluated = crate::evaluate_container(None, &scaled).unwrap(); + let NodeKind::Group { children, clip: true } = &evaluated.kind else { panic!("not a clip group") }; + let b = clip_outline(&children[0]).unwrap().0.bounding_box(); + assert!((b.x0 - want.x0).abs() < 0.5 && (b.x1 - want.x1).abs() < 0.5, "evaluated: {b:?} against {want:?}"); + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + d.insert(Some(layer), 0, scaled).unwrap(); + let b = clip_outline(&baked_clip(&d)).unwrap().0.bounding_box(); + assert!((b.x0 - want.x0).abs() < 0.5 && (b.x1 - want.x1).abs() < 0.5, "exported: {b:?} against {want:?}"); +} + +#[test] +fn nested_effects_apply_before_the_clip_groups() { + // The clip group grows its clipping path by 10 (Offset Path). Inside the clipping path a + // Transform moves a member 60 pt right: the region grows from the moved member. + let evaluated = |clip: Node| { + let mut g = clip_group(1, clip); + g.appearance.effects.push(fx("path.offsetPath", json!({"offset": 10}))); + let e = crate::evaluate_container(None, &g).unwrap(); + let NodeKind::Group { children, clip: true } = &e.kind else { panic!("not a clip group") }; + clip_outline(&children[0]).unwrap().0.bounding_box() + }; + let moved = || clipping_path(3, vec![fx("distort.transform", json!({"moveH": 60}))]); + let close = |a: Rect, b: Rect| (a.x0 - b.x0).abs() < 0.5 && (a.x1 - b.x1).abs() < 0.5 && (a.y0 - b.y0).abs() < 0.5; + let want = Rect::new(100.0, 40.0, 220.0, 160.0); + // A group holding the member. + let b = evaluated(Node::group(NodeId(2), vec![Arc::new(moved())])); + assert!(close(b, want), "group: {b:?}"); + // A compound path of the member, with a Transform of its own moving it 10 pt down. + let mut compound = Node::new(NodeId(2), NodeKind::Compound { children: vec![Arc::new(moved())], rule: vectorcraft_geom::FillRule::NonZero }); + compound.appearance.effects.push(fx("distort.transform", json!({"moveV": 10}))); + let b = evaluated(compound); + assert!(close(b, Rect::new(100.0, 50.0, 220.0, 170.0)), "compound: {b:?}"); +} + +#[test] +fn clipping_type_keeps_its_effect_where_other_type_stays_type() { + // Type moved 30 pt right by its Transform clips a red square, beside other type, in a group + // that a Transform moves 10 pt down: the export keeps the other type as type and outlines the + // clipping type, which still clips where the canvas clips. + use vectorcraft_doc::text::{CharStyle, TextObject}; + let text = |id: u64, effects: Vec<Effect>| { + let style = CharStyle { size: 40.0, fill: Paint::solid(Color::BLACK), ..Default::default() }; + let mut t = Node::new(NodeId(id), NodeKind::Text(Box::new(TextObject::point(vectorcraft_geom::Point::new(5.0, 60.0), "IIII", style)))); + t.appearance.effects = effects; + t + }; + let clipped = clip_group(2, text(3, vec![fx("distort.transform", json!({"moveH": 30}))])); + let mut outer = Node::group(NodeId(1), vec![Arc::new(clipped), Arc::new(text(5, vec![]))]); + outer.appearance.effects.push(fx("distort.transform", json!({"moveV": 10}))); + fn clip_of(n: &Node) -> Option<Rect> { + match &n.kind { + NodeKind::Group { children, clip: true } => Some(clip_outline(children.first()?)?.0.bounding_box()), + _ => n.children()?.iter().find_map(|c| clip_of(c)), + } + } + if vectorcraft_text::CRAFT_FONTS.is_empty() { + eprintln!("skipped: built without craft-fonts (set CRAFT_FONTS_DIR to a craft-fonts checkout to run it)"); + return; + } + let plain = clip_outline(&text(3, vec![])).unwrap().0.bounding_box(); + let canvas = clip_of(&crate::evaluate_container(None, &outer).unwrap()).unwrap(); + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + d.insert(Some(layer), 0, outer).unwrap(); + let baked = bake_document(&d).unwrap(); + let mut exported = None; + for l in &baked.layers { + exported = exported.or_else(|| clip_of(l)); + } + let exported = exported.unwrap(); + assert!((canvas.x0 - plain.x0 - 30.0).abs() < 0.5 && (canvas.y0 - plain.y0 - 10.0).abs() < 0.5, "{canvas:?} from {plain:?}"); + assert!((exported.x0 - canvas.x0).abs() < 0.5 && (exported.y0 - canvas.y0).abs() < 0.5, "exported {exported:?}, canvas {canvas:?}"); + // The outlined clipping type keeps its black fill, which paints behind the clipped art. + let outlined = crate::reshape::clipping_text_outline(&text(3, vec![fx("distort.transform", json!({"moveH": 30}))])).unwrap(); + fn fills(n: &Node) -> usize { + n.appearance.items.iter().filter(|i| matches!(i, vectorcraft_doc::AppearanceItem::Fill(f) if f.paint != Paint::None)).count() + + n.children().into_iter().flatten().map(|c| fills(c)).sum::<usize>() + } + assert!(fills(&outlined) > 0, "{outlined:?}"); +} + +#[test] +fn a_painted_clipping_paths_gradient_follows_its_effect() { + // A clipping path filled with a gradient placed across it, moved 60 pt right by its Transform + // effect, in a clip group with an effect of its own: the gradient moves with the path. + use vectorcraft_color::{Gradient, GradientGeom, GradientKind, GradientPaint, GradientStop}; + let stops = vec![GradientStop::new(0.0, Color::BLACK), GradientStop::new(1.0, Color::WHITE)]; + let geom = GradientGeom { start: (50.0, 100.0).into(), end: (150.0, 100.0).into(), aspect: 1.0, focal: None }; + let placed = Paint::Gradient(Box::new(GradientPaint { geom: Some(geom), ..GradientPaint::new(Gradient::new(GradientKind::Linear, stops)) })); + let mut clip = clipping_path(2, vec![fx("distort.transform", json!({"moveH": 60}))]); + clip.appearance = Appearance { effects: clip.appearance.effects.clone(), ..Appearance::basic(placed, Paint::None, 0.0) }.into(); + let mut group = clip_group(1, clip); + group.appearance.effects.push(fx("path.offsetPath", json!({"offset": 0}))); + let evaluated = crate::evaluate_container(None, &group).unwrap(); + let NodeKind::Group { children, clip: true } = &evaluated.kind else { panic!("not a clip group") }; + let Paint::Gradient(g) = children[0].appearance.fill_paint() else { panic!("no gradient") }; + let start = g.geom.unwrap().start; + assert!((start.x - 110.0).abs() < 1e-6, "the gradient starts at the moved path's left edge: {start:?}"); +} + +#[test] +fn a_nested_clip_groups_hidden_clipping_path_keeps_its_effect() { + // A clip group used as a clipping path clips by its clipping path whether it is shown or not. + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + let mut hidden = clipping_path(4, vec![fx("distort.transform", json!({"moveH": -30}))]); + hidden.visible = false; + let outer = clip_group(1, clip_group(3, hidden)); + d.insert(Some(layer), 0, outer.clone()).unwrap(); + let NodeKind::Group { children, .. } = &outer.kind else { panic!("not a group") }; + let b = bounds(&children[0]); + assert!((b.x0 - 20.0).abs() < 1e-6 && (b.x1 - 120.0).abs() < 1e-6, "{b:?}"); + assert_eq!(clip_outline(&children[0]), clip_outline(&baked_clip(&d)), "the canvas clips by the outline the export writes"); +} + +#[test] +fn a_fills_geometry_effect_shapes_the_clip_as_an_export_does() { + // The clipping path's fill has a Transform effect moving it 60 pt right; the path has none. + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + let mut clip = clipping_path(2, vec![]); + clip.appearance = Appearance::basic(Paint::solid(Color::rgb(0.0, 0.0, 0.0)), Paint::None, 0.0).into(); + for item in &mut clip.appearance.items { + if let vectorcraft_doc::AppearanceItem::Fill(f) = item { + f.effects.push(fx("distort.transform", json!({"moveH": 60}))); + } + } + let group = clip_group(1, clip); + d.insert(Some(layer), 0, group.clone()).unwrap(); + let NodeKind::Group { children, .. } = &group.kind else { panic!("not a group") }; + let live = clip_outline(&children[0]).unwrap(); + let exported = clip_outline(&baked_clip(&d)).unwrap(); + assert_eq!(live.0.bounding_box(), exported.0.bounding_box(), "the canvas clips by the outline the export writes"); + assert!((live.0.bounding_box().x1 - 210.0).abs() < 1e-6, "the moved fill reaches 210: {:?}", live.0.bounding_box()); + // A path of a compound clipping path with a fill effect of its own stays part of the region. + let mut member = clipping_path(4, vec![]); + member.appearance = children[0].appearance.clone(); + let other = Node::path(NodeId(5), shapes::rectangle(Rect::new(0.0, 0.0, 20.0, 20.0)), Appearance::default()); + let compound = + Node::new(NodeId(3), NodeKind::Compound { children: vec![Arc::new(member), Arc::new(other)], rule: vectorcraft_geom::FillRule::NonZero }); + assert_eq!(bounds(&compound), Rect::new(0.0, 0.0, 150.0, 150.0)); +} + +#[test] +fn a_hidden_member_with_an_effect_adds_nothing() { + let shown = Node::path(NodeId(3), shapes::rectangle(Rect::new(50.0, 50.0, 100.0, 100.0)), Appearance::default()); + let mut hidden = clipping_path(4, vec![fx("distort.transform", json!({"moveH": 200}))]); + hidden.visible = false; + let group = Node::group(NodeId(2), vec![Arc::new(shown), Arc::new(hidden)]); + assert_eq!(bounds(&group), Rect::new(50.0, 50.0, 100.0, 100.0)); +} + +#[test] +fn raster_and_hidden_effects_leave_the_clip_as_it_is() { + let mut hidden = fx("distort.transform", json!({"moveH": 60})); + hidden.visible = false; + for effects in [vec![], vec![fx("blur.gaussian", json!({"radius": 10}))], vec![hidden]] { + assert_eq!(bounds(&clipping_path(1, effects)), Rect::new(50.0, 50.0, 150.0, 150.0)); + } +} diff --git a/crates/render/src/fx/bounds.rs b/crates/render/src/fx/bounds.rs index 13a6dad415..9219ca6d57 100644 --- a/crates/render/src/fx/bounds.rs +++ b/crates/render/src/fx/bounds.rs @@ -664,6 +664,17 @@ fn cull_bounds_in(symbols: &SymbolBoxes, n: &Node, after_reshape: bool, brush: b let b = n.visual_bounds_with(symbols)?; let b = match &n.kind { NodeKind::Text(t) => vectorcraft_geom::union_opt(Some(b), glyphs_box(t, n.appearance.outset())).unwrap_or(b), + // The geometry effects in a clipping path move or grow the region it clips to + // ([`effects::clip_outline`]) past its plain shape, and its stroke paints along it. + NodeKind::Group { children, clip: true } | NodeKind::Layer { children, clip: true, .. } => match children.first() { + Some(c) if effects::needs_bake(c) => { + let s = c.appearance.outset(); + let region = effects::clip_outline(c).map(|(bp, _)| bp.bounding_box().inflate(s, s)); + let painted = if has_fx(c) { visual_bounds(symbols, c) } else { None }; + vectorcraft_geom::union_opt(vectorcraft_geom::union_opt(Some(b), region), painted).unwrap_or(b) + } + _ => b, + }, _ => b, }; let a = live_content_reach(symbols, n); diff --git a/crates/render/src/renderer/nodes.rs b/crates/render/src/renderer/nodes.rs index f649453663..15bd354496 100644 --- a/crates/render/src/renderer/nodes.rs +++ b/crates/render/src/renderer/nodes.rs @@ -122,7 +122,8 @@ impl Renderer { /// When a plug-in has been installed or removed since the last check /// ([`effects::plugin_revision`]), drop what the caches keep from plug-in effects: the effect /// geometry of paths with a plug-in effect, the cull bounds of objects that have one or hold one, - /// of symbol instances and of the objects that hold them, and the art drawn for the effects of + /// of symbol instances and of the objects that hold them, the regions of clipping paths that + /// have one or hold one, and the art drawn for the effects of /// objects that have a plug-in effect or hold one. Rasters of raster effects and evaluations of live objects hold /// the revision in their keys when what they draw has a plug-in effect (`fx::Inputs`, /// `live::resources_key`). @@ -148,6 +149,8 @@ impl Renderer { self.geom.retain(|_, e| !holds_plugin_effect(&e.node) && !holds_instance(&e.node)); // The art of a group holds what its members' plug-in effects draw. self.fx_arts.retain(|(node, ..)| !holds_plugin_effect(node)); + // A clipping path's plug-in effects shape the region it clips to. + self.clips.retain(|(node, _)| !holds_plugin_effect(node)); } } diff --git a/crates/render/src/tests/clip.rs b/crates/render/src/tests/clip.rs index 7b04c02e2d..cdd2028441 100644 --- a/crates/render/src/tests/clip.rs +++ b/crates/render/src/tests/clip.rs @@ -95,6 +95,42 @@ fn nothing_to_clip_by_hides_the_art() { assert_eq!(r.pixel(50, 50), CLEAR); } +#[test] +fn the_clipping_paths_geometry_effects_shape_the_clip() { + // A Transform effect moving the left half 50 pt right: the right half shows instead. + let mut d = Document::new(100.0, 100.0); + let mut clip = Node::path(d.alloc_id(), rect(Rect::new(0.0, 0.0, 50.0, 100.0)), Appearance::basic(Paint::None, Paint::None, 0.0)); + clip.appearance.effects.push(vectorcraft_doc::Effect { id: "distort.transform".into(), params: serde_json::json!({"moveH": 50}), visible: true }); + let r = clipped(d, Arc::new(clip)); + assert_eq!(r.pixel(25, 50), CLEAR, "the clipping path's own place"); + assert_eq!(r.pixel(75, 50), BLACK, "where its effect moves it"); +} + +#[test] +fn a_view_of_only_the_moved_clip_draws_the_clipped_art() { + // The clipping path covers x 0 to 50 and its Transform effect moves it to x 50 to 100; the + // view shows x 60 to 100, past the clipping path's own shape. + let mut d = Document::new(100.0, 100.0); + let mut clip = Node::path(d.alloc_id(), rect(Rect::new(0.0, 0.0, 50.0, 100.0)), Appearance::basic(Paint::None, Paint::None, 0.0)); + clip.appearance.effects.push(vectorcraft_doc::Effect { id: "distort.transform".into(), params: serde_json::json!({"moveH": 50}), visible: true }); + let art = Node::path(d.alloc_id(), rect(Rect::new(0.0, 0.0, 100.0, 100.0)), Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 0.0)); + let members = vec![Arc::new(clip), Arc::new(art)]; + let g = Node::new(d.alloc_id(), NodeKind::Group { children: members.clone(), clip: true }); + // The same in a sublayer that clips by its first object. + let mut sublayer = (*d.layers[0]).clone(); + sublayer.id = d.alloc_id(); + if let NodeKind::Layer { children, clip, .. } = &mut sublayer.kind { + (*children, *clip) = (members, true); + } + for clipping in [g, sublayer] { + let mut d = d.clone(); + let l = d.layers[0].id; + d.insert(Some(l), 0, clipping).unwrap(); + let r = Renderer::new().render(&d, 40, 100, Affine::translate((-60.0, 0.0)), &RenderOptions::default()); + assert_eq!(r.pixel(20, 50), BLACK, "x 80, inside the moved clip"); + } +} + #[test] fn clip_regions_are_cached_per_clipping_path() { let mut d = Document::new(100.0, 100.0); diff --git a/crates/render/src/tests/container.rs b/crates/render/src/tests/container.rs index 89126cf2a2..dfc8dca91c 100644 --- a/crates/render/src/tests/container.rs +++ b/crates/render/src/tests/container.rs @@ -217,9 +217,9 @@ fn type_in_a_group_keeps_its_transparency_and_visibility_under_the_groups_geomet #[test] fn type_in_a_clipping_path_clips_alike_under_the_groups_geometry_effects() { - // The red square is clipped by type with a Transform of its own, which the clip leaves out, - // then by a group of that type and a small square, with the type shown and hidden. Offset - // Path 0 on the clip group leaves every path as it is. + // The red square is clipped by type with a Transform of its own, then by a group of that type + // and a small square, with the type shown and hidden. Offset Path 0 on the clip group leaves + // every path as it is, so the clip group draws the same with it and without it. let doc = |effect: bool, grouped: bool, hidden: bool| { let mut d = Document::new(100.0, 100.0); let style = CharStyle { size: 40.0, fill: Paint::None, ..Default::default() }; diff --git a/crates/render/src/tests/memory.rs b/crates/render/src/tests/memory.rs index d286fa7e3c..e60114708f 100644 --- a/crates/render/src/tests/memory.rs +++ b/crates/render/src/tests/memory.rs @@ -1667,6 +1667,16 @@ fn objects_with_plugin_effects_follow_the_plugins_installed() { plugin_change_draws_as_new(alone(20.0, vec![drop_shadow()]), ID, small.clone(), big.clone()); let blur = effect("blur.gaussian", serde_json::json!({"radius": 1.0})); plugin_change_draws_as_new(alone(20.0, vec![blur]), ID, small.clone(), big.clone()); + // A clip group whose clipping path, the square, has the plug-in effect: it clips a red + // rectangle over the whole view by the shape the plug-in draws. + let mut d = Document::new(200.0, 100.0); + let mut clip = square(&mut d, 20.0, 30.0, vec![]); + if let NodeKind::Path { clipping, .. } = &mut clip.kind { + *clipping = true; + } + let red = filled(&mut d, rectangle(Rect::new(0.0, 0.0, 200.0, 100.0)), Paint::solid(Color::rgb(1.0, 0.0, 0.0)), vec![]); + let group = Node::new(d.alloc_id(), NodeKind::Group { children: vec![Arc::new(clip), Arc::new(red)], clip: true }); + plugin_change_draws_as_new(with_art(d, vec![group]), ID, small.clone(), big.clone()); // An instance of symbol `Shaped`, a group of the square around the origin. let mut d = Document::new(200.0, 100.0); let art = square(&mut d, -20.0, -20.0, vec![]); diff --git a/crates/svg/tests/it/effects_export.rs b/crates/svg/tests/it/effects_export.rs index 832e72c8f8..c1a19e8d53 100644 --- a/crates/svg/tests/it/effects_export.rs +++ b/crates/svg/tests/it/effects_export.rs @@ -102,6 +102,37 @@ fn a_strokes_own_glow_filters_the_stroke_element_only() { assert!(!export(&doc_with(n), &ExportOptions::default()).contains("<filter ")); } +#[test] +fn a_clipping_paths_transform_effect_moves_the_written_clip_path() { + // A clip group whose clipping path covers x 0 to 50; `effect` moves it 50 pt right. + let clipped = |x0: f64, effect: bool| { + let mut clip = + Node::path(NodeId(0), shapes::rectangle(Rect::new(x0, 0.0, x0 + 50.0, 100.0)), Appearance::basic(Paint::None, Paint::None, 0.0)); + if let NodeKind::Path { clipping, .. } = &mut clip.kind { + *clipping = true; + } + if effect { + clip.appearance.effects.push(Effect { id: "distort.transform".into(), params: json!({"moveH": 50}), visible: true }); + } + let art = Node::path( + NodeId(0), + shapes::rectangle(Rect::new(0.0, 0.0, 100.0, 100.0)), + Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 0.0), + ); + let mut d = Document::new(200.0, 200.0); + let (clip, art) = (Node { id: d.alloc_id(), ..clip }, Node { id: d.alloc_id(), ..art }); + let g = Node::new(d.alloc_id(), NodeKind::Group { children: vec![std::sync::Arc::new(clip), std::sync::Arc::new(art)], clip: true }); + let l = d.layers[0].id; + d.insert(Some(l), 0, g).unwrap(); + let svg = export(&d, &ExportOptions::default()); + let open = svg.find("<clipPath").expect("a clip path"); + let body = &svg[open..open + svg[open..].find("</clipPath>").expect("its end")]; + body[body.find('>').unwrap()..].to_string() + }; + assert_eq!(clipped(0.0, true), clipped(50.0, false), "the clip path is written where the effect moves it"); + assert_ne!(clipped(0.0, true), clipped(0.0, false)); +} + #[test] fn geometry_effects_on_type_export_as_its_reshaped_outlines() { let style = CharStyle { size: 40.0, fill: Paint::solid(Color::BLACK), ..Default::default() }; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ee72f2cbe8..33cad82654 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1552,6 +1552,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Object › Expand Appearance keeps each stroke of a path a stroke (weight, caps, joins, dashes, arrowheads, alignment and width profile) on a copy of the path with the geometry effects baked in, and Object › Expand… is dimmed, with a tooltip, while the selection has appearance attributes, so a stroked line with Zig Zag becomes a stroked zig-zag line and only Expand then outlines it, the two steps the [Expand objects](https://helpx.adobe.com/illustrator/desktop/manage-objects/arrange-objects/expand-objects.html) help page describes (#3089). Brushed strokes still become their brush art; `object.expand` still bakes and outlines in one step for agents. - **Masks and clipping:** opacity-mask controls work while the mask is being edited; transparency commands take ids and work without a selection; clipping sets clip by compound paths, even-odd paths, text and groups on screen and in raster export, matching SVG/PDF. Alt-click shows only the mask; SVG masks keep Clip and Invert; the transparency grid is per-document state; a clipping path's own fill and stroke paint behind and over the clipped art; layers can be clipping masks. - **Masks and clipping:** opacity-mask controls work while the mask is being edited; transparency commands take ids and work without a selection; clipping sets clip by compound paths, even-odd paths, text and groups on screen and in raster export, matching SVG/PDF. Alt-click shows only the mask; SVG masks keep Clip and Invert; the transparency grid is per-document view state saved in native files (#1968); a clipping path's own fill and stroke paint behind and over the clipped art; layers can be clipping masks. + The geometry effects of a clipping path (Roughen, Transform and the other effects that reshape a path), of its fills and strokes, and of the members of a group used as one, shape the area it clips to on the canvas and in raster export, as in SVG and PDF export: a roughened clipping path clips by its roughened outline. They apply before the geometry effects of the clip group or of a group around it, on the canvas and in every export, and type used as a clipping path keeps them when a group's effect outlines it. Raster effects such as Gaussian Blur leave that area as it is. `effects::tests::clipfx` and the renderer's `tests::clip` cover it. - **Transparency:** three-state Knockout Group (on, neutral, off), Opacity & Mask Define Knockout Shape, Page Isolated Blending and Page Knockout Group, on screen and in SVG/PDF. SVG export writes a knockout group of opaque art plainly, without masks, so shapes meeting edge to edge leave no seam; translucent, blended, masked or brushed art knocks out through masks. Blend modes match the standard formulas on screen, in SVG and in PDF, and non-isolated groups blend with the art below. Flatten Transparency with presets, a dialog and a Flattener Preview panel. Flattening for files without transparency (PDF/X-1a, PDF/X-3) in a CMYK document keeps the inks where it rasterizes, as under an image with see-through pixels: the images it makes hold ink amounts, not screen colours the file would separate again, so a C100 M6 Y41 K3 panel stays C100 M6 Y41 K3 there (#2160, `engine/src/cmd/fileio/tests_pdfx.rs`). On the canvas, the renderer no longer draws the picture of the art below back as an image each time it copies the backdrop of a non-isolated group that blends: it keeps that picture and draws the art that follows over it. At 2880 × 1800, 50 translucent groups with Multiply members take 65 ms a frame instead of 299 ms on 8 threads (`vectorcraft-cli bench`), and the frames have the same pixels. Type inside a group, layer, symbol instance, blend or repeat keeps its opacity, blend mode, opacity mask, Opacity & Mask Define Knockout Shape, own effects, perspective and visibility when the effects on the container outline it. Hidden type with a geometry effect of its own is left out of exports. From 541059faf2b31a4ba2f95364d30f4d1ebe2752f6 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:21:11 -0800 Subject: [PATCH 042/108] Path: path.setHandle to the handle's own point leaves a smooth anchor unchanged path.setHandle checked for a no-op by running the handle edit on a copy and comparing the whole anchor. On a smooth anchor the edit recomputes the other handle, so when that handle was not exactly in line, or the recomputed value rounded differently, a request for the handle's own point realigned the other handle and recorded an undo step. The check now compares the requested point with the handle itself, and still lets independent turn a smooth anchor into a corner. --- crates/engine/src/cmd/path.rs | 14 +++++------ crates/engine/src/tests/anchor_edit_work.rs | 28 ++++++++++++++++++++- 2 files changed, 34 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/cmd/path.rs b/crates/engine/src/cmd/path.rs index 33bde936bf..756eb00c26 100644 --- a/crates/engine/src/cmd/path.rs +++ b/crates/engine/src/cmd/path.rs @@ -315,13 +315,13 @@ fn set_handle(s: &mut Session, p: &Value) -> Result<Value> { let pos = Point::new(f64_req(p, "x", "path.setHandle")?, f64_req(p, "y", "path.setHandle")?); let independent = switch_or(p, "independent", false, "path.setHandle")?; // A handle already there, on an anchor already of the kind it would get, changes nothing and - // records no undo step. - if let Some(a) = anchor_of(s, id, si, ai)? { - let mut b = a; - b.set_handle(out, pos, independent); - if b == a { - return ok(); - } + // records no undo step. The handle is compared directly: `set_handle` would recompute the + // other handle of a smooth anchor, which need not give back the same value. + if let Some(a) = anchor_of(s, id, si, ai)? + && (if out { a.h_out } else { a.h_in }) == pos + && !(independent && a.kind != AnchorKind::Corner) + { + return ok(); } s.edit("Reshape", |d, _| { let path = path_mut(d, id)?; diff --git a/crates/engine/src/tests/anchor_edit_work.rs b/crates/engine/src/tests/anchor_edit_work.rs index 7ad50a871d..1055156167 100644 --- a/crates/engine/src/tests/anchor_edit_work.rs +++ b/crates/engine/src/tests/anchor_edit_work.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use serde_json::{Value, json}; use vectorcraft_doc::{Appearance, Document, Node, NodeId}; use vectorcraft_geom::path::measured_segments; -use vectorcraft_geom::{Anchor, PathData, Point, SubPath}; +use vectorcraft_geom::{Anchor, AnchorKind, PathData, Point, SubPath, Vec2}; use crate::*; @@ -109,3 +109,29 @@ fn an_anchor_edit_that_changes_nothing_records_no_undo_step() { s.execute("path.moveAnchor", &json!({"id": id.0, "anchor": 5, "x": a.p.x + 1.0, "y": a.p.y})).unwrap(); assert_eq!(undo_steps(&s), 1); } + +/// `path.setHandle` to where the handle already is, on a smooth anchor whose other handle is not in +/// line with it, leaves both handles as they are and records no undo step. With `independent` it +/// makes the anchor a corner, which records one. +#[test] +fn a_handle_already_in_place_on_a_smooth_anchor_records_no_undo_step() { + let (mut s, id) = long_path(100); + let p = anchor(&s, id, 5).p; + let smooth = Anchor { p, h_in: p + Vec2::new(-3.0, 0.0), h_out: p + Vec2::new(0.0, 4.0), kind: AnchorKind::Smooth }; + let path = Arc::make_mut(&mut s.doc_mut().unwrap().doc).node_mut(id).unwrap().path_data_mut().unwrap(); + path.subpaths[0].anchors[5] = smooth; + for which in ["out", "in"] { + let h = if which == "out" { smooth.h_out } else { smooth.h_in }; + s.execute("path.setHandle", &json!({"id": id.0, "anchor": 5, "which": which, "x": h.x, "y": h.y})).unwrap(); + assert_eq!(undo_steps(&s), 0, "path.setHandle on the {which} handle recorded an undo step"); + assert_eq!(anchor(&s, id, 5), smooth, "path.setHandle on the {which} handle changed the anchor"); + } + s.execute("path.setHandle", &json!({"id": id.0, "anchor": 5, "which": "out", "x": smooth.h_out.x, "y": smooth.h_out.y, "independent": true})) + .unwrap(); + assert_eq!(undo_steps(&s), 1); + assert_eq!(anchor(&s, id, 5).kind, AnchorKind::Corner); + // On a corner, the same independent request changes nothing. + s.execute("path.setHandle", &json!({"id": id.0, "anchor": 5, "which": "out", "x": smooth.h_out.x, "y": smooth.h_out.y, "independent": true})) + .unwrap(); + assert_eq!(undo_steps(&s), 1); +} From fb48216aa28e477dcb578d34a8fd835cc082939f Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:23:00 -0800 Subject: [PATCH 043/108] Image Trace: clean flat art of 10 to 16 evenly spaced levels traces as flat color The continuous-tone check exempts a neutral or single-curve picture when sixteen colors leave at most a fifth of the error of eight, but only applied the exemption below the 0.1 ratio. Clean gray, sepia, single-hue and duotone art of 10 to 16 evenly spaced levels lands above it, so it was smoothed before tracing. The exemption now applies in both branches. At 16 Colors, 12 sepia and 16 gray or sepia levels crossed by 1 px lines keep every region the lines cut, and Automatic traces 16 clean sepia levels in 9 colors instead of 4. Art in several unrelated colors is unaffected. --- crates/trace/src/quantize/cut_edge.rs | 20 ++++++---- crates/trace/src/tests.rs | 53 +++++++++++++++++++++++++++ docs/target-app-parity.md | 1 + 3 files changed, 66 insertions(+), 8 deletions(-) diff --git a/crates/trace/src/quantize/cut_edge.rs b/crates/trace/src/quantize/cut_edge.rs index 99b3c42845..27b7727b38 100644 --- a/crates/trace/src/quantize/cut_edge.rs +++ b/crates/trace/src/quantize/cut_edge.rs @@ -283,11 +283,11 @@ pub(super) fn settled_wide(mut q: Quantized, img: &Raster, own: &[bool], gray: b /// channels within 8 levels of each other) is therefore also continuous tone when eight colors /// stay more than 0.065 as far as a single color does. So is a sepia, single-hue or duotone /// picture whose tones follow one curve through the color cube (19 in 20 of its opaque pixels on -/// it, see [`on_one_curve`]). Neither is when sixteen colors stay at most a fifth as far as eight -/// do. That exception holds for flat art of up to sixteen clean levels, gray or tinted, where -/// sixteen colors come within about a level of every pixel. On gray and tinted photos sixteen -/// colors stay 0.18 to 0.57 as far as eight do, and on most anti-aliased or noisy gray flat art -/// 0.24 to 0.5 as far, so the exception holds for neither. +/// it, see [`on_one_curve`]). Neither is, however far eight colors stay, when sixteen colors stay +/// at most a fifth as far as eight do. That exception holds for flat art of up to sixteen clean +/// levels, gray or tinted, where sixteen colors come within about a level of every pixel. On gray +/// and tinted photos sixteen colors stay 0.18 to 0.57 as far as eight do, and on most anti-aliased +/// or noisy gray flat art 0.24 to 0.5 as far, so the exception holds for neither. pub(crate) fn continuous_tone(img: &Raster) -> bool { let hk = HistKey::new(img); let mut bins = vec![Bin::default(); 1 << 15]; @@ -318,10 +318,14 @@ pub(crate) fn continuous_tone(img: &Raster) -> bool { return false; } let one = unsaid(1); - if eight > 0.1 * one { - return true; + if eight <= 0.065 * one { + return false; } - eight > 0.065 * one && unsaid(16) > 0.2 * eight && (20 * neutral >= 19 * opaque || 20 * on_one_curve(img) >= 19 * opaque) + let one_line = || 20 * neutral >= 19 * opaque || 20 * on_one_curve(img) >= 19 * opaque; + if eight > 0.1 * one { + return !(unsaid(16) <= 0.2 * eight && one_line()); + } + unsaid(16) > 0.2 * eight && one_line() } /// How far (levels) a pixel may lie from the tone curve of its picture and still count as on it, diff --git a/crates/trace/src/tests.rs b/crates/trace/src/tests.rs index 3b4e84989a..2bf9e1e2b6 100644 --- a/crates/trace/src/tests.rs +++ b/crates/trace/src/tests.rs @@ -2206,6 +2206,59 @@ fn tinted_flat_art_stays_flat_art() { } } +/// `levels` clean gray bands 20 px wide, evenly spaced from black to white. +fn even_gray_bands(levels: u32) -> Raster { + Raster::from_fn(levels * 20, 60, |x, _| { + let v = (x / 20 * 255 / (levels - 1)) as u8; + [v, v, v, 255] + }) +} + +#[test] +fn flat_art_of_up_to_sixteen_clean_levels_stays_flat_art() { + // Equal bands: eight colors leave more than a tenth of what a single color leaves. + let tints: [(&str, &[[f64; 3]]); 4] = [("gray", &GRAY_RAMP), ("sepia", &SEPIA), ("blue", &BLUE), ("duotone", &DUOTONE)]; + let mut smoothed = vec![]; + for (name, stops) in tints { + for levels in [10, 12, 14, 16] { + let bands = tinted(&even_gray_bands(levels), stops, 0.0); + if quantize::continuous_tone(&bands) { + smoothed.push(format!("{levels} {name} bands")); + } + if quantize::continuous_tone(&beside_transparent_colors(&bands)) { + smoothed.push(format!("{levels} {name} bands beside transparent colors")); + } + } + } + assert!(smoothed.is_empty(), "continuous tone: {smoothed:?}"); +} + +#[test] +fn thin_lines_on_flat_art_of_up_to_sixteen_clean_levels_are_traced() { + for levels in [12, 16] { + for (name, stops) in [("gray", &GRAY_RAMP[..]), ("sepia", &SEPIA[..])] { + let bands = even_gray_bands(levels); + // A 1 px black line across the bands at y = 30, and a 1 px white line down the second + // band at x = 25. + let lined = Raster::from_fn(bands.width, bands.height, |x, y| { + if y == 30 { + [0, 0, 0, 255] + } else if x == 25 { + [255, 255, 255, 255] + } else { + let i = ((y * bands.width + x) * 4) as usize; + [bands.rgba[i], bands.rgba[i + 1], bands.rgba[i + 2], 255] + } + }); + let res = trace(&tinted(&lined, stops, 0.0), &sixteen_colors()); + assert_eq!(res.palette.len(), levels as usize, "{levels} {name} bands: {:?}", res.palette); + // The black band with the black line; the white band above and below the line; the + // white line above and below it; the second band in four; each other band in two. + assert_eq!(res.paths.len(), 1 + 2 + 2 + 4 + 2 * (levels as usize - 3), "{levels} {name} bands"); + } + } +} + #[test] fn pictures_without_tones_are_not_continuous_tone() { let photo = tinted(&photo_scene(6.0, true), &SEPIA, 2.0); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..60648c37b6 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1391,6 +1391,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Image Trace, curve fitting tolerance:** the outline fitter keeps cutting a run while a point stays farther than the tolerance from its curve, so a run of fewer than six points or one cut 14 times no longer keeps a piece over the tolerance. Pieces already within the tolerance do not change, and noisy art can get more anchors. Tests: `logo::bezier::tests`, `logo::outline::tests`. Scores and hours unchanged. - **Image Trace, gray photos:** Color and Grayscale smooth a gray photo within its tones before choosing its colors, as they do a color photo. A picture with at least 95% of its opaque pixels within 8 levels across their channels counts as continuous tone when 8 colors leave an error of more than 6 levels and more than 0.065 of the error of one color, instead of 0.1, unless 16 colors leave at most a fifth of the error of 8 (VectorCraft's own values). That exception keeps gray flat art of up to 16 clean levels on its old route; anti-aliased or noisy gray flat art can now count as continuous tone too. Most gray photos the change reaches, and very noisy gray scans of flat art, trace with fewer specks and fewer staircase edges. Some 16 Colors and High Fidelity Photo palettes of gray photos grow toward the requested count, with more anchors and regions. Some gray illustrations and sketches get more anchors and staircase edges at 16 Colors and High Fidelity Photo, and some 6 Colors traces get more staircase edges. Tests: `tests::a_gray_photo_is_continuous_tone_as_its_color_original_is`, `tests::a_gray_photo_is_smoothed_before_it_is_traced`. Scores and hours unchanged. - **Image Trace, tinted photos:** Color and Grayscale smooth a sepia, single-hue or duotone photo within its tones before choosing its colors, as they do a gray photo. A picture with at least 95% of its opaque pixels within 6 levels of its tone curve counts as continuous tone under the same 0.065 rule as a neutral picture. The tone curve runs through the median color of each 8-level stretch along the direction in which the picture's colors spread the most, and a pixel on it must also lie within 6 levels of the plane the colors spread along most, so art in several unrelated colors is not counted (VectorCraft's own rule and values). The neutral rule's exception for 16 colors leaving at most a fifth of the error of 8 applies to it too. Clean tinted bands of 2, 3 and 9 levels and tinted scans of flat art with up to 8 levels of noise stay on the flat-art route. On the synthetic tinted photos the 16 Colors trace keeps 12 to 15 colors instead of 6 to 13, with 525 to 708 anchors instead of up to 1,402. A duotone with strong noise on each channel can still miss the curve and stay unsmoothed. Tests: `tests::a_tinted_photo_is_continuous_tone_as_a_gray_photo_is`, `tests::small_accents_of_other_colors_leave_a_tinted_photo_continuous_tone`, `tests::tinted_flat_art_stays_flat_art`, `tests::pictures_without_tones_are_not_continuous_tone`, `tests::a_tinted_photo_is_smoothed_before_it_is_traced`. Scores and hours unchanged. +- **Image Trace, flat art of 10 to 16 levels:** the exception for 16 colors leaving at most a fifth of the error of 8 also applies to a neutral or tinted picture whose 8-color error is more than 0.1 of the error of one color (VectorCraft's own values), so Color and Grayscale trace clean gray, sepia, single-hue and duotone art of 10 to 16 evenly spaced levels as flat art, without smoothing it first. At 16 Colors, 16 gray or sepia levels crossed by two 1 px lines trace as the 35 regions the lines cut them into instead of 33, and Automatic traces 16 clean sepia levels in 9 colors instead of 4. Tests: `tests::flat_art_of_up_to_sixteen_clean_levels_stays_flat_art`, `tests::thin_lines_on_flat_art_of_up_to_sixteen_clean_levels_are_traced`. Scores and hours unchanged. - **Image Trace, JPEG blocks:** Color, Grayscale and Black and White traces smooth the edges of a JPEG's 8 × 8 blocks before tracing, so a dark ground whose tone changes slowly is no longer traced as staircases along the block edges. The block grid is found in the image itself: the mean step between neighboring pixels must peak at one position in eight, across and down. A cropped JPEG and a JPEG saved in another format are smoothed too. A picture of flat 8 × 8 cells is left as it is, and art made of 8 × 8 cells with slight texture inside each cell is smoothed as a JPEG copy would be. A small step at a block edge, with no edge in the eight pixels around it, is spread over those eight pixels, and larger steps are kept, as the deblocking filters of ITU-T H.263 Annex J and MPEG-4 Part 2 Annex F.3.1 do. Black and White smooths only the smallest steps, and traces of more than 16 colors move every row of a stretch of eight by the same amount (VectorCraft's own rule and values). On a 4000 × 3000 photo saved as JPEG, the straight outline segments that lie on the block grid fall from 52% and 51% (across and down) to 24% and 29% at 16 Colors, and from 54% and 51% to 43% and 42% at High Fidelity Photo; staircase runs fall from 83 to 67 (16 Colors), 11 to 1 (6 Colors), 30 to 13 (Black and White Logo) and 428 to 403 (High Fidelity Photo). A 600 px photo saved as a quality-40 JPEG has 4 staircase runs instead of 2 at 16 Colors. Images without a block grid trace as before. Tests: `tests::a_jpegs_blocks_are_not_traced_as_steps`, `deblock::tests`. Scores and hours unchanged. - **Image Trace, Document Library color groups:** with Document Swatches, the panel's Colors menu and `"colorGroup"` trace with one color group's colors instead of every swatch, as the public panel documentation describes Document Library; code-drawn tests in `crates/engine` and the panel. - **Image Trace, Document Library colors:** with Document Swatches, traced fills and strokes use the displayed colors of process, global, spot and tint swatches without links, so editing a swatch leaves the trace unchanged; swatch-library colors are also unlinked; code-drawn tests in `crates/engine`. From f4fdf2755e451947ff92f5a8b0e0228d1bab6e85 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:11:13 -0800 Subject: [PATCH 044/108] i18n: Brazilian Portuguese translates 114 messages that no catalog had The untranslated report listed 167 status and error messages that no complete-message catalog translated. pt-br.tsv now has an @msg row for the 114 of them that no open pull request already translates: messages of the 3D and Revolve effects, the image encoders, color profiles, swatch exchange files, color books and DXF import. Placeholders, parameter names and literal values stay as the English writes them. The other 53 (composite font, SVG filter, read root and graph design messages) are translated by open #7211, #7378 and #7405; adding them here too would make bundled_catalogs_are_consistent fail on a duplicate row once those merge. --- crates/ui-egui/src/i18n/pt-br.tsv | 116 ++++++++++++++++++++++++++++++ docs/localization-parity.md | 2 +- docs/target-app-parity.md | 1 + 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index f6e54552d4..3662e58de6 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -7042,6 +7042,122 @@ breakText Glyphs Glifos @msg save the document with Save As before Save and Close salve o documento com Salvar Como antes de Salvar e fechar @msg no free data set file name in destination folder Não há nome de arquivo livre para o conjunto de dados na pasta de destino +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +@msg 3D effects require finite coordinates within 100 million points Os efeitos 3D exigem coordenadas finitas de até 100 milhões de pontos +@msg 3D effects require one to ten lights Os efeitos 3D exigem de uma a dez luzes +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel Profundidade BMP {_1}: 1, 4, 8, 16, 24 ou 32 bits por pixel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer Falha na codificação BMP: {width} × {height} pixels não cabem no formato ou no buffer de pixels +@msg GIF encoding failed: the palette image is malformed Falha na codificação GIF: a imagem de paleta está malformada +@msg GIF encoding failed: {e} Falha na codificação GIF: {e} +@msg JPEG colour profile: {e} Perfil de cor JPEG: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size Falha na codificação JPEG: o buffer de pixels não corresponde ao tamanho da imagem +@msg JPEG encoding failed: {e} Falha na codificação JPEG: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size Falha na codificação PNG: o buffer de pixels não corresponde ao tamanho da imagem +@msg PNG encoding failed: the palette image is malformed Falha na codificação PNG: a imagem de paleta está malformada +@msg PNG encoding failed: {e} Falha na codificação PNG: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size Falha na codificação PNG: {width} × {height} pixels não é um tamanho de imagem válido +@msg PSD colour profile: {e} Perfil de cor PSD: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size Falha na codificação PSD: o buffer de pixels não corresponde ao tamanho da imagem +@msg Revolve profile contains invalid coordinates O perfil de Revolver contém coordenadas inválidas +@msg Revolve profile is too complex O perfil de Revolver é complexo demais +@msg Revolve projection is not finite A projeção de Revolver não é finita +@msg Revolve requires finite profile coordinates within 100 million points Revolver exige coordenadas de perfil finitas de até 100 milhões de pontos +@msg Revolve surface is too complex; reduce Segments or simplify the profile A superfície de Revolver é complexa demais; reduza Segmentos ou simplifique o perfil +@msg Revolve surface is too complex; simplify the profile A superfície de Revolver é complexa demais; simplifique o perfil +@msg Revolve visibility cannot split the projected boundary A visibilidade de Revolver não consegue dividir o contorno projetado +@msg Revolve visibility creates too many fragments A visibilidade de Revolver cria fragmentos demais +@msg Revolve visibility creates too many vector anchors A visibilidade de Revolver cria pontos de ancoragem vetoriais demais +@msg Revolve visibility exceeds its geometry work limit A visibilidade de Revolver excede seu limite de trabalho geométrico +@msg Revolve visibility exceeds its spatial index limit A visibilidade de Revolver excede seu limite de índice espacial +@msg Revolve visibility has too many boundary crossings A visibilidade de Revolver tem cruzamentos de contorno demais +@msg Revolve visibility has too many input anchors A visibilidade de Revolver tem pontos de ancoragem de entrada demais +@msg Revolve visibility requires convex cap sectors A visibilidade de Revolver exige setores de tampa convexos +@msg Revolve visibility requires finite projected faces A visibilidade de Revolver exige faces projetadas finitas +@msg SVG options: {e} Opções SVG: {e} +@msg Save for Web settings: {e} Configurações de Salvar para a Web: {e} +@msg TIFF colour profile: {e} Perfil de cor TIFF: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size Falha na codificação TIFF: o buffer de pixels não corresponde ao tamanho da imagem +@msg TIFF encoding failed: {e} Falha na codificação TIFF: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Profundidade Targa {_1}: 16, 24 ou 32 bits por pixel +@msg Targa encoding failed: the pixel buffer doesn't match the image size Falha na codificação Targa: o buffer de pixels não corresponde ao tamanho da imagem +@msg The 3D projection is not finite A projeção 3D não é finita +@msg The 3D shadow is too complex; turn Shadows off or simplify the art A sombra 3D é complexa demais; desative Sombras ou simplifique a arte +@msg The shape contains invalid coordinates A forma contém coordenadas inválidas +@msg Too many Revolve faces for visibility evaluation Faces de Revolver demais para avaliar a visibilidade +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} O VectorCraft lê no máximo {ASE_MAX_ENTRIES} cores e grupos de um arquivo de intercâmbio de amostras, e esta biblioteca tem {entries} +@msg WebP encoding failed: {e} Falha na codificação WebP: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` é smallThumb, mediumThumb, largeThumb, smallList ou largeList +@msg a line can't run from a point to itself uma linha não pode ir de um ponto até ele mesmo +@msg a line needs at least two points uma linha precisa de pelo menos dois pontos +@msg a number cannot be read um número não pode ser lido +@msg a swatch exchange block is too long um bloco de intercâmbio de amostras é longo demais +@msg a swatch exchange name is too long um nome de intercâmbio de amostras é longo demais +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels uma imagem de {sw} × {sh} não pode ser redimensionada para {width} × {height} pixels +@msg a {width} × {height} image is too large uma imagem de {width} × {height} é grande demais +@msg a {width} × {height} image: {e} uma imagem de {width} × {height}: {e} +@msg an image could not be written: {e} não foi possível gravar uma imagem: {e} +@msg an image that couldn't be read was left out uma imagem que não pôde ser lida foi omitida +@msg can't open “{name}”: {e} não é possível abrir “{name}”: {e} +@msg cannot align zip entries to {align} bytes não é possível alinhar as entradas do zip a {align} bytes +@msg cannot open the automation {kind} root `{_1}`: {e} não é possível abrir a raiz de {kind} da automação `{_1}`: {e} +@msg cannot read profile: {0} não é possível ler o perfil: {0} +@msg color book version {version} isn't supported (only 1) a versão {version} do livro de cores não tem suporte (somente 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) livros de cores no espaço de cores {other} não têm suporte (somente RGB, CMYK e Lab) +@msg file name too long to zip: {_1} nome de arquivo longo demais para o zip: {_1} +@msg file name too long to zip: {name} nome de arquivo longo demais para o zip: {name} +@msg freeform line {i}: {e} linha {i} de forma livre: {e} +@msg freeform point {i}: {e} ponto {i} de forma livre: {e} +@msg give `{key}` or `{other}`, not both informe `{key}` ou `{other}`, não ambos +@msg grayscale profiles can't be working spaces yet perfis em escala de cinza ainda não podem ser espaços de trabalho de cores +@msg input contains NaN or infinite coordinates a entrada contém coordenadas NaN ou infinitas +@msg input path could not be closed não foi possível fechar o caminho de entrada +@msg invalid ICC profile: {0} perfil ICC inválido: {0} +@msg invalid scale {scale} escala inválida {scale} +@msg its localized names take more than {_1} KB seus nomes localizados ocupam mais de {_1} KB +@msg its objects are nested too deep ({e}) seus objetos estão aninhados profundamente demais ({e}) +@msg its tag table lists the `{_1}` tag more than once sua tabela de tags lista a tag `{_1}` mais de uma vez +@msg not a graphic style library: {e} não é uma biblioteca de estilos gráficos: {e} +@msg not a swatch library (.vcswatches or .gpl) não é uma biblioteca de amostras (.vcswatches ou .gpl) +@msg not a swatch library (format `{_1}`) não é uma biblioteca de amostras (formato `{_1}`) +@msg not a swatch library: {e} não é uma biblioteca de amostras: {e} +@msg not an action set file ({e}) não é um arquivo de conjunto de ações ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray o espaço de cores do perfil, {other}, não é RGB, CMYK ou Cinza +@msg regular expression too large expressão regular grande demais +@msg script file is not UTF-8 text: {value} o arquivo de script não é texto UTF-8: {value} +@msg stop {i}: {e} parada {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) a versão {major}.{minor} de intercâmbio de amostras não tem suporte (somente 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors o livro de cores contém mais de {ASE_MAX_ENTRIES} cores +@msg the color book is cut short o livro de cores está incompleto +@msg the color book's names take more than {_1} MB os nomes do livro de cores ocupam mais de {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution a imagem teria {w} × {h} pixels; as exportações raster são limitadas a {MAX_RASTER_SIDE} pixels por lado e {_1} megapixels: reduza a escala ou a resolução +@msg the optimised image can't be read back: {e} a imagem otimizada não pode ser lida de volta: {e} +@msg the pixel buffer doesn't match the image size o buffer de pixels não corresponde ao tamanho da imagem +@msg the preview: {e} a visualização: {e} +@msg the request may not read the New Document profiles folder a solicitação não tem permissão para ler a pasta de perfis de Novo Documento +@msg the shapes are too degenerate to combine as formas são degeneradas demais para combinar +@msg the shapes cross themselves and each other too often to combine as formas se cruzam consigo mesmas e entre si vezes demais para combinar +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups o arquivo de intercâmbio de amostras contém mais de {ASE_MAX_ENTRIES} cores e grupos +@msg the swatch exchange file is cut short o arquivo de intercâmbio de amostras está incompleto +@msg the {_1} plate can't be read: {e} a chapa {_1} não pode ser lida: {e} +@msg this binary DXF file is damaged or cut short este arquivo DXF binário está danificado ou incompleto +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that este é um desenho DWG, que não pode ser lido: salve-o no aplicativo de CAD como DXF e abra esse arquivo +@msg too many classes classes demais +@msg too many groups grupos demais +@msg too many layers for PSD (at most 32767) camadas demais para PSD (no máximo 32767) +@msg too many swatch exchange blocks blocos de intercâmbio de amostras demais +@msg unknown colour profile: {0} perfil de cor desconhecido: {0} +@msg {_1} clashes with a built-in profile name {_1} coincide com o nome de um perfil integrado +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixels é grande demais para GIF (no máximo 65535 pixels por lado): reduza a resolução +@msg {_1}: no usable transform to/from sRGB {_1}: nenhuma transformação utilizável de/para sRGB +@msg {name} is not a CMYK profile {name} não é um perfil CMYK +@msg {name} is not an RGB profile {name} não é um perfil RGB +@msg {path}: could not be read {path}: não foi possível ler +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pixels é grande demais para JPEG (no máximo 65535 pixels por lado): reduza a resolução +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pixels é grande demais para Targa (no máximo 65535 pixels por lado): reduza a resolução +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixels é grande demais para PSD (no máximo {MAX_SIDE} pixels por lado): reduza a resolução + # Path Precision Tools add-on: Path Effects (Effect › Path Effects). Distance Distância Mode Modo diff --git a/docs/localization-parity.md b/docs/localization-parity.md index 6cbad8f5e3..4055fe74ca 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -32,7 +32,7 @@ Chinese by `imachus`). Only Georgian is recorded as reviewed by a native speaker | Hindi | `hi` | 8,782 rows (2026-11-13): 3,014 `@msg`, 47 `@msgplural`, 41 `@plural`; no gaps in the untranslated report | menus, dialogs, tooltips and scanned messages; contributor-approved loanword terminology; agent wording pass | UI and document text shape with HarfRust; installed desktop Devanagari fallback, or a `Deva` craft-fonts face; web font still needed | contributor terminology review; 2026-11-13 wording pass on messages and longer labels, with a glossary-term test; wider proofread welcome | complete catalog, machine-assisted draft | native review, layout and web font | | Arabic | `ar` | 0 | none | document text: bidi layout and Paragraph Direction; interface: no right-to-left layout, no Arabic shaping in egui | no | none | 25–40 | | French | `fr` | 4,020 / 4,020 (100%) | all | Latin | no | full | — (review) | -| Portuguese | `pt-br` | 9,260 rows, 3,445 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 39 missing messages for it; one/other plurals | all | Latin | contributor is a Brazilian Portuguese speaker; further native review welcome | full | — (review) | +| Portuguese | `pt-br` | 9,378 rows, 3,563 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 55 missing messages for it, which open #7116, #7211, #7330, #7378 and #7405 translate; one/other plurals | all | Latin | contributor is a Brazilian Portuguese speaker; further native review welcome | full | — (review) | | Indonesian | `id` | 5,279 rows, 750 of them `@msg` (counted 2026-10-21): menus and `tl!` literals complete when counted; its messages are partial; one plural form | dialogs and tooltips all; 750 message rows (French has 796) | Latin | no | full | — (review) | | Japanese | `ja` | 4,004 / 4,020 (99.6%) | all | CJK UI font as above; Japanese IME; vertical type partial; Japanese crop marks and composition settings | no | full | — (review) | | German | `de` | 3,952 / 4,020 (98%; menus, literals and messages complete when counted) | all (3,433 `@msg` and 48 `@msgplural` rows, counted 2026-11-13: the untranslated report lists 48 missing messages for it) | Latin | contributor-written, not reviewed | full | — (review) | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..a9141f1a20 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -896,6 +896,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The status bar translates the plug-in host's other errors (manifest, module and run checks, the output an importer, exporter or effect returns, and the approval a plug-in's permissions need) in every language that translates every message. A JSON object or array inside a message stays as written, and a message that wraps another one, such as `plug-in manifest: {0}`, is matched by its own row before a row that starts with a placeholder. The reasons inside these errors (what is wrong with a parameter's spec or dialog keys, the value a parameter needs, what is wrong with an object, stroke, paint or effect in a plug-in's output) are translated with them, and the untranslated-strings report lists the reasons the plug-in host's error helpers take (`plugin_messages_are_translated_in_every_complete_catalog`, `plugin_errors_translate_with_their_values`, `plugin_error_reasons_are_translated_with_the_error`, `message_scan_reads_plugin_helpers`, `templates_that_start_with_text_match_first`). - The status bar translates the errors a script's `File` and `Folder` objects, `vc.run`, `$.evalFile`, the `$` object's properties and functions, `alert`, `confirm` and `prompt`, `vc.document` and `vc.log` raise, the limits a run can pass, and the errors of Drop Script Engine, and the line for a run that fails (a syntax error, a thrown error, a limit, a stop or an internal error, with the script's name, the line and column, the included file it is in and the files left written), in every language that translates every message. The script's name, paths, numbers, command ids and the text a script throws itself are shown as they are. A failure with no line and column, such as an error in code `eval` compiled, is shown with one colon after the script's name (`an_error_without_a_place_names_the_script_and_kind`). A message template that names a value twice matches only when both places hold the same text, so the line for a failed run is not taken for the message inside it (`a_repeated_placeholder_matches_the_same_text`). The untranslated-strings report also lists the messages the script host's `fail`, `value` and `over` helpers take and the errors the script interpreter throws, and a constant's text comes from the file or crate that declares it, so the Scripts menu's headers are not listed as messages (`script_errors_are_translated`, `script_host_errors_are_translated`, `message_scan_reads_script_interpreter_errors`, `message_scan_reads_constants_of_the_file_and_its_crate`, `message_scan_skips_test_modules_with_any_test_cfg`). - Localised UI: menus (in-window and native), panels, dialogs, toolbar and Preferences read from per-language catalogs (`crates/ui-egui/src/i18n`, see `docs/development.md`); Traditional Chinese (Taiwan), Simplified Chinese (mainland), Japanese, Korean, Vietnamese, German, Spanish, French, Italian, Polish, Brazilian Portuguese, Russian, Ukrainian, Georgian and Catalan ship complete, and Czech covers every menu label (and more), with system-locale detection on macOS, Windows, Linux and the web (the browser's languages, or `?lang=`), a Language preference and, on macOS, a VectorCraft ▸ Language menu. Names are never translated (fonts and their styles, layers, artboards, saved presets, user libraries, custom workspaces, recent files, plug-ins). + - The Brazilian Portuguese catalog (`crates/ui-egui/src/i18n/pt-br.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,563 `@msg` rows in all, including the image export, color profile, color book, swatch exchange file, DXF import and Revolve errors. The report lists 55 Brazilian Portuguese messages: the composite font, SVG filter, read root, graph design, justification order and Blob Brush connect end errors that open #7211, #7378, #7405, #7116 and #7330 translate. The counts that Package's status and question, the folder search of Missing Fonts and Find Linked Files, the modified and missing linked file prompts and the CSS Properties panel's notes show use the interface language's plural forms instead of a fixed "(s)" form. Evidence: `the_missing_links_note_uses_each_count_form` in `crates/ui-egui/src/dialogs/tests_package.rs`, `the_modified_links_question_uses_each_count_form` in `crates/ui-egui/src/dialogs/missing_links.rs`, `search_counts_use_each_count_form` in `crates/ui-egui/src/dialogs/missing_fonts/tests.rs` and `the_unnamed_objects_note_uses_each_count_form` in `crates/ui-egui/src/panels/tests_css_properties.rs`. The status bar's messages for relinked, replaced, updated and embedded images, broken links, linked files that can't be read or changed on disk, images that can't be decoded, added and unavailable fonts, copied CSS, downloads and exports with their notes name one item in the singular and more in the plural, in English and in each language's plural forms (`counted_status_messages_take_the_plural_form` in `crates/ui-egui/src/i18n/tests.rs`). The status bar's messages for documents opened or saved with notes and for discarded or restored recovered documents, and the Global Edit options' Results line, do the same (`open_save_and_recovery_messages_take_the_plural_form` in `crates/ui-egui/src/i18n/tests.rs`); the warnings for linked images and placed documents output as their previews and the errors for a page past a placed file's last page or artboard name their counts in the singular or the plural in English. From d57cc3896f3b370b9e451543066b0b4046c0439e Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:28:53 -0800 Subject: [PATCH 045/108] Docs: the complete-message language lists match COMPLETE_MESSAGES The development guide and the progress doc now name all 23 languages in COMPLETE_MESSAGES: Hindi was missing from the first, and Georgian, Hindi, Turkish and Catalan from the second. The localization summary adds Bosnian to the languages marked full that are not in the list. --- docs/development.md | 2 +- docs/localization-parity.md | 2 +- docs/target-app-parity.md | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/docs/development.md b/docs/development.md index 82ffbd4a5a..5c4f16a85d 100644 --- a/docs/development.md +++ b/docs/development.md @@ -294,7 +294,7 @@ other `sv-*` locale resolve to it), Georgian (`ka`, complete; `ka-GE` and `ka_GE control channel, MCP and tests read them) and are translated only where the status bar draws them (`i18n::msg`). `@msg` catalog rows hold a whole message or a template such as `Couldn't open {name}: {e}`; `{_1}`, `{_2}` … stand for the format string's `{}`, and the values in the - placeholders are translated in turn (the reason after `: {e}` is often a message too). Czech, German, Greek, Spanish, French, Georgian, Hungarian, Italian, Japanese, Korean, Polish, Brazilian Portuguese, Russian, Simplified Chinese, Traditional Chinese, Swedish, Ukrainian, Vietnamese, Finnish, Turkish, Catalan and Dutch + placeholders are translated in turn (the reason after `: {e}` is often a message too). Czech, German, Greek, Spanish, French, Georgian, Hindi, Hungarian, Italian, Japanese, Korean, Polish, Brazilian Portuguese, Russian, Simplified Chinese, Traditional Chinese, Swedish, Ukrainian, Vietnamese, Finnish, Turkish, Catalan and Dutch translate status and error messages (`COMPLETE_MESSAGES` in `i18n::tests`); the untranslated report lists the message literals the scan finds, and the phrases a parameter schema's error builds at run time (`SCHEMA_PHRASES`), that one of them has no row for. The scan covers the crates in `MESSAGE_CRATES`, the diff --git a/docs/localization-parity.md b/docs/localization-parity.md index 6cbad8f5e3..332963bb83 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -15,7 +15,7 @@ translation never fails a test or a build: the interface shows the English text `cargo xtask ci` prints the untranslated report (`cargo xtask i18n-report` alone), which lists per language the strings missing from each catalog with the `complete_menus` flag and the messages missing from each language in the `COMPLETE_MESSAGES` list. Every non-English language marked "full" has the flag, and all of them except -Bulgarian, Danish and Indonesian are in the list. No language has help content: there is no translated (or +Bosnian, Bulgarian, Danish and Indonesian are in the list. No language has help content: there is no translated (or English) in-app help, and the docs are English. **Native review:** every catalog was written clean-room from the English meaning, most of it by agents diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..be80b40424 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1373,7 +1373,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur When a drag on the Tabs panel's ruler or a value typed in its X field moves a tab stop past another stop, the moved stop stays selected. With the Selection tool, the Tabs panel shows the ruler and stops of the first paragraph of the first selected text object, also when the text is inside a selected group or a shape is selected before it; a selection without text shows "No text selected". A stop set on that ruler is set on every selected text object and the text in selected groups, and other objects are left as they were. This is VectorCraft's own rule. Tests `panels::tabs::tests::the_ruler_shows_text_selected_after_an_object_that_is_not_text`, `the_ruler_shows_text_inside_a_selected_group`, `a_stop_added_on_a_mixed_selection_sets_every_selected_text` and `a_selection_without_text_shows_no_ruler`. The Tabs panel menu's Clear All Tabs (`text.tabs.clear`), Delete Tab and Repeat Tab (`text.tabs.set`) can be chosen while the panel's ruler shows tab stops. Delete Tab removes the stop selected on the ruler. Repeat Tab replaces the stops after the selected stop with up to 20 copies of it. The copies are spaced by the selected stop's distance from the stop before it, or from the paragraph's left indent (18 pt further in for each list level past the first) when it is the first stop, and no copy is placed at 2,000 pt or beyond. Clear All Tabs removes every stop, so the default stops every ½ inch apply again. -- **Interface languages, vertical type:** Preferences ▸ User Interface (or VectorCraft ▸ Language on macOS) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese, German (every `de-*` locale), Spanish (neutral international Spanish, for every `es-*` locale), French (every `fr-*` locale), Italian (every `it-*` locale), Russian (every `ru-*` locale) and Ukrainian (every `uk-*` locale), Catalan (every `ca-*` locale) and Polish (every `pl-*` locale; AI-drafted, native review pending) cover the whole interface, Czech every menu label; Czech, German, Greek, Spanish, French, Hungarian, Italian, Japanese, Korean, Vietnamese, Polish, Brazilian Portuguese, Russian, Simplified Chinese, Traditional Chinese, Swedish, Ukrainian, Finnish and Dutch also translate status-bar and error messages as they are shown (`@msg` templates, every message literal tested; the messages themselves stay English for agents); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech, German, Spanish, French, Italian, Russian and Ukrainian ones from the bundled UI fonts. The web app follows the browser's languages (or `?lang=`). The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line; on a vertical path, upright glyphs and tate-chu-yoko blocks face the path's start, and letters on their side are a quarter turn clockwise from them (with Skew, 3D Ribbon and Stair Step only on a path that runs to the right), in one column that Align to Path Baseline or Center centers on the path and that the caret and selection span); kinsoku applies to horizontal and vertical Japanese (Paragraph panel › Kinsoku Set, `text.setFormat {kinsoku}`: Hard, the default, keeps closing marks, iteration marks, the prolonged sound mark and small kana off the line start and opening brackets off its end; Soft lets 々, ー and small kana start a line as JLREQ's level 3 rules do; None turns it off), and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width and an opening bracket starting a line flush with its start (a paragraph's first line at its first-line indent, JIS X 4051's principle in JLREQ 3.1.5), and puts a quarter em between Japanese and Latin letters or digits; Paragraph panel menu › Top-to-Top / Bottom-to-Bottom Leading measures leading from em box top to top (area type's first line touches the frame) or from baseline to baseline (new type in a Japanese interface starts top to top, with em box centre character alignment, #432); Paragraph panel menu › Burasagari None / Regular / Force (`text.setFormat {burasagari: "none"|"standard"|"forced"}`) hangs an East Asian comma or full stop (、。,.、。) ending an area type line outside it, Regular (new type's default) when it doesn't fit and Force always (the rest of the line then fills the measure; closing brackets and Latin punctuation don't hang); Character panel menu › Character Alignment (with the East Asian options; `text.setFormat` or `text.setRangeStyle {charAlign}`) lines characters smaller than the largest on their line up on the Roman baseline, the em box top/right, centre or bottom/left, or the ICF (ideographic character face) top/right or bottom/left, from the font's BASE table or, without one, the average ink box of some ideographs and kana; Proportional Metrics (the same menu; `{proportionalMetrics}`) sets full-width glyphs on the font's proportional widths (OpenType `palt`) in horizontal type and upright glyphs on its proportional heights (`vpal`, shaped top to bottom; fonts without vertical metrics keep their cells) in vertical type, and Line-end Punctuation Half Width takes nothing more off the punctuation they re-spaced; Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines. The interface is available in Polish (`pl`): menus, panels, dialogs and messages, with one/few/many plurals; AI-drafted, native review pending (#1498). +- **Interface languages, vertical type:** Preferences ▸ User Interface (or VectorCraft ▸ Language on macOS) picks Automatic (the system locale) or a registered language, persisted as `interfaceLanguage`. Translations come from per-language catalogs (`i18n/*.tsv`): Traditional and Simplified Chinese, Japanese, German (every `de-*` locale), Spanish (neutral international Spanish, for every `es-*` locale), French (every `fr-*` locale), Italian (every `it-*` locale), Russian (every `ru-*` locale) and Ukrainian (every `uk-*` locale), Catalan (every `ca-*` locale) and Polish (every `pl-*` locale; AI-drafted, native review pending) cover the whole interface, Czech every menu label; Czech, German, Greek, Spanish, French, Georgian, Hindi, Hungarian, Italian, Japanese, Korean, Vietnamese, Polish, Brazilian Portuguese, Russian, Simplified Chinese, Traditional Chinese, Swedish, Ukrainian, Finnish, Turkish, Catalan and Dutch also translate status-bar and error messages as they are shown (`@msg` templates, every message literal tested; the messages themselves stay English for agents); untranslated text stays English. Japanese and Chinese glyphs come from the craft-fonts build input (release builds) or the installed fonts, Czech, German, Spanish, French, Italian, Russian and Ukrainian ones from the bundled UI fonts. The web app follows the browser's languages (or `?lang=`). The Basic toolbar's Type button holds Vertical Type in its flyout. Vertical Type, Vertical Area Type and Vertical Type on a Path create vertical text (columns right to left, upright CJK glyphs and marks with `vert` alternates, Latin and longer numbers on their side, two- and three-digit numbers set as tate-chu-yoko in one em of the column (kept whole when justified), upright glyphs centred on the column (tracked or justified too), point type's anchor on the first column's centre line; on a vertical path, upright glyphs and tate-chu-yoko blocks face the path's start, and letters on their side are a quarter turn clockwise from them (with Skew, 3D Ribbon and Stair Step only on a path that runs to the right), in one column that Align to Path Baseline or Center centers on the path and that the caret and selection span); kinsoku applies to horizontal and vertical Japanese (Paragraph panel › Kinsoku Set, `text.setFormat {kinsoku}`: Hard, the default, keeps closing marks, iteration marks, the prolonged sound mark and small kana off the line start and opening brackets off its end; Soft lets 々, ー and small kana start a line as JLREQ's level 3 rules do; None turns it off), and justified Japanese lines spread their room between characters (not inside Latin words); Paragraph panel › Mojikumi Set (shown with Preferences › Type › Show East Asian Options, `text.setFormat {mojikumi}`): None or Line-end Punctuation Half Width (new type's default, as in Illustrator; older documents and imported text keep None) shares one half-em space between consecutive punctuation, sets a closing mark ending a line half width and an opening bracket starting a line flush with its start (a paragraph's first line at its first-line indent, JIS X 4051's principle in JLREQ 3.1.5), and puts a quarter em between Japanese and Latin letters or digits; Paragraph panel menu › Top-to-Top / Bottom-to-Bottom Leading measures leading from em box top to top (area type's first line touches the frame) or from baseline to baseline (new type in a Japanese interface starts top to top, with em box centre character alignment, #432); Paragraph panel menu › Burasagari None / Regular / Force (`text.setFormat {burasagari: "none"|"standard"|"forced"}`) hangs an East Asian comma or full stop (、。,.、。) ending an area type line outside it, Regular (new type's default) when it doesn't fit and Force always (the rest of the line then fills the measure; closing brackets and Latin punctuation don't hang); Character panel menu › Character Alignment (with the East Asian options; `text.setFormat` or `text.setRangeStyle {charAlign}`) lines characters smaller than the largest on their line up on the Roman baseline, the em box top/right, centre or bottom/left, or the ICF (ideographic character face) top/right or bottom/left, from the font's BASE table or, without one, the average ink box of some ideographs and kana; Proportional Metrics (the same menu; `{proportionalMetrics}`) sets full-width glyphs on the font's proportional widths (OpenType `palt`) in horizontal type and upright glyphs on its proportional heights (`vpal`, shaped top to bottom; fonts without vertical metrics keep their cells) in vertical type, and Line-end Punctuation Half Width takes nothing more off the punctuation they re-spaced; Type ▸ Type Orientation switches existing text; caret, selection, hit testing and arrow keys follow the writing direction. Vertical text exports to PDF as real text and to SVG as outlines. The interface is available in Polish (`pl`): menus, panels, dialogs and messages, with one/few/many plurals; AI-drafted, native review pending (#1498). With Line-end Punctuation Half Width, both composers measure a line with its last character set as narrow as Mojikumi sets it ([the help page](https://helpx.adobe.com/illustrator/desktop/design-with-text/edit-format-text/use-mojikumi-for-japanese-text-composition.html)): a closing bracket, comma or full stop that fits at half width ends the line, and the character before it no longer goes to the next line with it. A mark that already lost its half to the punctuation after it and a line that ends in a hyphen take nothing more off, and the quarter em between Japanese and Latin text counts only where the line ends there. Kinsoku Shori Type and Burasagari Regular measure lines the same way; right-to-left lines and Mojikumi None break as before. In a frame that is not a rectangle, or with text wrap, a line's first word is measured as it is set (an opening bracket at its start flush, its last character narrowed) when layout looks for a line wide enough for it, and it ends only where the line may break, so kinsoku keeps an opening bracket with the character after it and a No Break run counts whole (`crates/text/src/layout/wrapping_tests.rs`, `crates/text/src/tests/vertical.rs`). Scores and estimates are unchanged. The Paragraph panel's Mojikumi Set lists the five predefined sets the help page names (None, YakumonoHankaku, GyomatsuYakumonoHankaku, GyomatsuYakumonoZenkaku and YakumonoZenkaku), then Line-end Punctuation Half Width, and `text.setFormat {mojikumi}` takes each of them. YakumonoHankaku sets every bracket, comma and full stop half width and takes a quarter em off each side of a middle dot; GyomatsuYakumonoHankaku keeps punctuation full width inside a line, sets an opening bracket flush at a line's start and a closing mark half width at its end, and takes the quarter em after a middle dot off at a line's end; GyomatsuYakumonoZenkaku keeps punctuation full width and adds a quarter em between Japanese and Latin text; YakumonoZenkaku sets characters as None does. These widths are VectorCraft's own rules, from the help page's one-line description of each set. Both composers and vertical type measure each line as it is set, the sets save with the document and paragraph styles, and a `.ai` save reports the new sets as left out (`crates/text/src/tests/vertical.rs`, `crates/ui-egui/src/panels/paragraph/tests.rs`). Scores and estimates are unchanged. Interface text in characters the interface's fonts lack, drawn in a bundled Japanese, Georgian or Devanagari face or in an installed font that covers them, sits on the baseline of the Latin text beside it, monospace text included (#5816; `crates/ui-egui/src/ui_fonts.rs`, `crates/ui-egui/src/theme.rs`). From ed0a4e0abe6a13f21e69feef5ae41d227eed6b49 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:30:13 -0800 Subject: [PATCH 046/108] .ai save: a clipping path cut away outside keeps its text wrap options A clipping path inside art cut to another clipping object is written as its fills and its strokes. Its text wrap options went with the fills, so when the outer region left nothing of the fills, the strokes were written without them. The strokes now keep them unless a fill object was written. A symbol definition that had no room left for its group under the object limit returned without restoring the writer's drawn-art depth. Asked for from art drawn for an object (a stained instance's art), the depth then dropped below zero on the way out, which panics in debug builds. That path now restores it as the others do. --- crates/eps/src/ai_editing/tests.rs | 31 ++++++++++++++++++--- crates/eps/src/ai_editing/writer.rs | 15 ++++++---- crates/eps/src/ai_editing/writer/symbols.rs | 1 + 3 files changed, 37 insertions(+), 10 deletions(-) diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 967c982ad4..72f20a610d 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -1187,6 +1187,28 @@ fn a_symbol_definition_is_written_only_with_room_for_its_instance() { } } +/// A symbol definition without room for its group, asked for by an instance in art drawn for an +/// object (a stained instance's art), is left out and leaves the writing of that art as it was. +#[test] +fn a_symbol_definition_without_room_in_drawn_art_is_left_out() { + let mut doc = Document::new(200.0, 100.0); + let layer = doc.layers[0].id; + let dot = square(&mut doc, Rect::new(0.0, 0.0, 10.0, 10.0), Color::gray(0.5)); + doc.symbols.push(Symbol { dynamic: false, name: "Dot".into(), art: Arc::new(dot) }); + let inner = instance(&mut doc, "Dot", Affine::IDENTITY); + doc.symbols.push(Symbol { dynamic: false, name: "Badge".into(), art: Arc::new(inner) }); + let mut stained = instance(&mut doc, "Badge", Affine::translate((50.0, 10.0))); + stained.appearance = Appearance::basic(solid(Color::rgb(1.0, 0.0, 0.0)), Paint::None, 0.0).into(); + doc.insert(Some(layer), usize::MAX, stained).unwrap(); + let read = crate::import::objects_read(&export_ai_editing(&doc, &opts()).unwrap().program).unwrap(); + for max in 0..read { + let out = export_within(&doc, &opts(), max).unwrap(); + assert!(out.warnings.iter().any(|w| w == writer::OBJECT_LIMIT), "room for {max} of {read}"); + let objects = crate::import::objects_read(&out.program).unwrap(); + assert!(objects <= max, "{objects} objects read with room for {max}"); + } +} + /// The writer's limit is the reader's, which its warning names. #[test] fn the_object_limit_is_the_readers() { @@ -10017,14 +10039,15 @@ fn text_wrap_options_of_type_and_envelopes_are_read_back() { } /// A clipping path inside art cut to a clipping object is written as its fills and its strokes, -/// two objects: its text wrap options are written once, whether it has both or only strokes. +/// two objects: its text wrap options are written once, whether it has both or only strokes, and +/// with its strokes when the region outside leaves nothing of its fills. #[test] fn a_clipping_path_written_as_its_paint_keeps_one_text_wrap() { - for fill in [solid(Color::gray(0.5)), Paint::None] { + for (fill, left, width) in [(solid(Color::gray(0.5)), 20.0, 2.0), (Paint::None, 20.0, 2.0), (solid(Color::gray(0.5)), 101.0, 4.0)] { let mut doc = Document::new(200.0, 100.0); let layer = doc.layers[0].id; - let mut cutter = clipping(&mut doc, shapes::rectangle(Rect::new(20.0, 20.0, 80.0, 80.0))); - cutter.appearance = Appearance::basic(fill, solid(Color::BLACK), 2.0).into(); + let mut cutter = clipping(&mut doc, shapes::rectangle(Rect::new(left, 20.0, left + 60.0, 80.0))); + cutter.appearance = Appearance::basic(fill, solid(Color::BLACK), width).into(); let cutter = wrapped(cutter, 5.0, true); let member = square(&mut doc, Rect::new(30.0, 30.0, 120.0, 60.0), Color::rgb(1.0, 0.0, 0.0)); let inner = group(&mut doc, vec![cutter, member], true); diff --git a/crates/eps/src/ai_editing/writer.rs b/crates/eps/src/ai_editing/writer.rs index 879eb9d9f5..cc2bbca8b4 100644 --- a/crates/eps/src/ai_editing/writer.rs +++ b/crates/eps/src/ai_editing/writer.rs @@ -1037,22 +1037,25 @@ impl<'a> Writer<'a> { /// A container's members, the first one's outline cutting the others: its fills painted /// behind them (cut to the region outside too), its strokes over them, not cut by it. Its text - /// wrap options are written once: with its fills, or without fills with its strokes. + /// wrap options are written once: with its fills, or with its strokes when no fill object is + /// written (it has no fills, or the region outside leaves nothing of them). fn clip_contents(&mut self, children: &[Arc<Node>]) { let Some((first, rest)) = children.split_first() else { return }; // Nothing to clip by hides the clipped art. let Some((outline, rule)) = vectorcraft_effects::clip_outline(first) else { return }; let mut paint = first.clip_paint(); - if let (Some(_), Some(stroke)) = (&paint.fill, &mut paint.stroke) - && stroke.extras().wrap.is_some() - { - stroke.extras_mut().wrap = None; - } let outer = self.clip.clone(); let region = self.cut(&PathData::from_bezpath(&outline), rule); self.clip = Some(region); if let Some(fill) = &paint.fill { + let objects = self.objects; self.node(fill); + if self.objects > objects + && let Some(stroke) = &mut paint.stroke + && stroke.extras().wrap.is_some() + { + stroke.extras_mut().wrap = None; + } } for c in rest { self.node(c); diff --git a/crates/eps/src/ai_editing/writer/symbols.rs b/crates/eps/src/ai_editing/writer/symbols.rs index 86d7c4694d..a96b4d1831 100644 --- a/crates/eps/src/ai_editing/writer/symbols.rs +++ b/crates/eps/src/ai_editing/writer/symbols.rs @@ -233,6 +233,7 @@ impl Writer<'_> { if !self.take_objects(1) { self.defining_symbols.pop(); self.keep_since(before); + (self.in_look, self.drawn) = (in_look, drawn); return false; } // The art is written in the symbol's space, from the state `0 A` and `0 Xw` set, from the From 81b79ae67ddf93d9f716faaea950d6c6331c12e5 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 21:30:14 -0800 Subject: [PATCH 047/108] Swatches: a gradient stop unlinked from its spot swatch also drops its plates A gradient stop that loses its link to a spot swatch kept the process plates it printed with that ink, so it carried a DeviceN mix with no ink. Paint::map_links, which deleting a swatch, recoloring and color adjustments go through, now clears a stop's plates whenever it leaves the stop without a link, as GradientStop::set_color(color, None) already does. Library gradients and library character styles linked to a swatch the document lacks unlink their stops the same way. Docs: docs/target-app-parity.md. --- crates/color/src/lib.rs | 41 ++++++++++++++++++++++--- crates/engine/src/cmd/library.rs | 30 +++++------------- crates/engine/src/tests/library.rs | 32 +++++++++++++++++++ crates/engine/src/tests/linked_stops.rs | 18 +++++++++++ docs/target-app-parity.md | 1 + 5 files changed, 96 insertions(+), 26 deletions(-) diff --git a/crates/color/src/lib.rs b/crates/color/src/lib.rs index 3afca8063c..fa8cd564f2 100644 --- a/crates/color/src/lib.rs +++ b/crates/color/src/lib.rs @@ -435,9 +435,10 @@ impl Paint { } /// Apply `f` to the colours of this paint that can link to a swatch (a solid colour, each /// gradient stop) with their link and tint; `f` returns true when it changed them. A colour - /// left without a link gets tint 1. A freeform gradient's points, which it draws from, go - /// through `f` too, as unlinked colours (a link `f` gives them is dropped). Returns whether - /// anything changed. + /// left without a link gets tint 1, and a stop left without one also loses its process plates + /// ([`GradientStop::plates`], which print with a linked spot tint). A freeform gradient's + /// points, which it draws from, go through `f` too, as unlinked colours (a link `f` gives them + /// is dropped). Returns whether anything changed. pub fn map_links(&mut self, f: &mut dyn FnMut(&mut Color, &mut Option<String>, &mut f32) -> bool) -> bool { let mut one = |c: &mut Color, link: &mut Option<String>, tint: &mut f32| { let changed = f(c, link, tint); @@ -449,7 +450,11 @@ impl Paint { match self { Paint::Solid { color, swatch, tint } => one(color, swatch, tint), Paint::Gradient(g) => { - let stops = g.gradient.stops.iter_mut().fold(false, |ch, s| one(&mut s.color, &mut s.swatch, &mut s.tint) | ch); + let stops = g.gradient.stops.iter_mut().fold(false, |ch, s| { + let changed = one(&mut s.color, &mut s.swatch, &mut s.tint); + let unplated = s.swatch.is_none() && s.plates.take().is_some(); + changed | unplated | ch + }); let points = g.freeform.iter_mut().flat_map(|ff| ff.points.iter_mut()).fold(false, |ch, p| one(&mut p.color, &mut None, &mut 1.0) | ch); stops | points @@ -593,6 +598,34 @@ mod tests { assert!(g.gradient.stops.iter().all(|s| s.swatch.as_deref() == Some("Ink") && s.tint == 0.5)); } + #[test] + fn mapping_links_drops_the_process_plates_of_unlinked_stops() { + let mut gradient = Gradient::default(); + let ink = Color::cmyk(0.0, 0.4, 0.0, 0.0); + gradient.stops[0].swatch = Some("Ink".into()); + (gradient.stops[0].color, gradient.stops[0].tint, gradient.stops[0].plates) = (ink, 0.4, Some([0.3, 0.0, 0.0, 0.0])); + let mut g = Paint::Gradient(Box::new(GradientPaint::new(gradient))); + // Unlinking the stop takes its plates with its tint and keeps the colour it shows. + assert!(g.map_links(&mut |_, l, _| l.take().is_some())); + let Paint::Gradient(gp) = &g else { panic!("a gradient") }; + let st = &gp.gradient.stops[0]; + assert_eq!((st.color, st.swatch.as_deref(), st.tint, st.plates), (ink, None, 1.0, None)); + // A linked stop keeps its plates. + let mut linked = Gradient::default(); + (linked.stops[0].swatch, linked.stops[0].plates) = (Some("Ink".into()), Some([0.3, 0.0, 0.0, 0.0])); + let mut l = Paint::Gradient(Box::new(GradientPaint::new(linked))); + assert!(!l.map_links(&mut |_, _, _| false)); + let Paint::Gradient(lp) = &l else { panic!("a gradient") }; + assert_eq!(lp.gradient.stops[0].plates, Some([0.3, 0.0, 0.0, 0.0])); + // An unlinked stop that still has plates loses them, and that counts as a change. + let mut stale = Gradient::default(); + stale.stops[1].plates = Some([0.0, 0.0, 0.2, 0.0]); + let mut p = Paint::Gradient(Box::new(GradientPaint::new(stale))); + assert!(p.map_links(&mut |_, _, _| false)); + let Paint::Gradient(pp) = &p else { panic!("a gradient") }; + assert!(pp.gradient.stops.iter().all(|s| s.plates.is_none())); + } + #[test] fn lab_colours_serialize_with_their_tag_and_keep_their_model() { let c = Color::lab(52.5, 70.0, -30.0); diff --git a/crates/engine/src/cmd/library.rs b/crates/engine/src/cmd/library.rs index ae8a7ef6b2..b2b8f8acdf 100644 --- a/crates/engine/src/cmd/library.rs +++ b/crates/engine/src/cmd/library.rs @@ -470,8 +470,8 @@ impl Library { } } -/// Make `g` a library gradient: no placement, freeform points or swatch links (a linked stop keeps -/// the color it shows), the angle its placement showed (a finite one), and stops in order with +/// Make `g` a library gradient: no placement, freeform points, swatch links or process plates (a +/// linked stop keeps the color it shows), the angle its placement showed (a finite one), and stops in order with /// offsets, opacities and midpoints in range. False when it has fewer than 2 or more than /// [`MAX_STOPS`] stops. fn clean_gradient(g: &mut GradientPaint) -> bool { @@ -490,8 +490,8 @@ fn clean_gradient(g: &mut GradientPaint) -> bool { st.offset = within(st.offset, 0.0, 1.0, 0.0); st.opacity = within(st.opacity, 0.0, 1.0, 1.0); st.midpoint = within(st.midpoint, 0.13, 0.87, 0.5); - st.swatch = None; - st.tint = 1.0; + let color = st.color; + st.set_color(color, None); } g.gradient.stops.sort_by(|a, b| a.offset.total_cmp(&b.offset)); true @@ -1488,29 +1488,15 @@ fn add_to_char_styles(s: &mut Session, p: &Value) -> Result<Value> { /// Unlink a library character style's `fill` and `stroke` colors (solid, and each gradient stop) /// from swatches that are not global or spot swatches of `doc`: an unlinked color keeps the color -/// it shows at full tint, as [`clean_gradient`] keeps a library gradient's stops. A link to a +/// it shows at full tint, and an unlinked stop has no process plates, as [`clean_gradient`] keeps +/// a library gradient's stops. A link to a /// global or spot swatch `doc` has stays, and takes that swatch's color. fn unlink_missing_swatches(doc: &vectorcraft_doc::Document, attrs: &mut Map<String, Value>) { let keep = |name: &str| doc.global_color(name).is_some(); for key in ["fill", "stroke"] { let Some(mut paint) = attrs.get(key).and_then(|v| serde_json::from_value::<Paint>(v.clone()).ok()) else { continue }; - let mut changed = false; - let mut unlink = |swatch: &mut Option<String>, tint: &mut f32| { - if swatch.as_deref().is_some_and(|n| !keep(n)) { - *swatch = None; - *tint = 1.0; - changed = true; - } - }; - match &mut paint { - Paint::Solid { swatch, tint, .. } => unlink(swatch, tint), - Paint::Gradient(g) => { - for st in &mut g.gradient.stops { - unlink(&mut st.swatch, &mut st.tint); - } - } - _ => {} - } + // `map_links` gives an unlinked color full tint, and an unlinked stop no process plates. + let changed = paint.map_links(&mut |_, swatch, _| swatch.take_if(|n| !keep(n.as_str())).is_some()); if changed && let Ok(v) = serde_json::to_value(&paint) { attrs.insert(key.to_string(), v); } diff --git a/crates/engine/src/tests/library.rs b/crates/engine/src/tests/library.rs index c2dccc7bb5..a75bc532bf 100644 --- a/crates/engine/src/tests/library.rs +++ b/crates/engine/src/tests/library.rs @@ -733,6 +733,38 @@ fn a_library_character_style_linked_to_a_missing_swatch_is_added_unlinked() { assert_eq!((r["style"].as_str(), r["existing"].as_bool()), (Some("Accent"), Some(true))); } +/// A gradient stop linked to a spot swatch with process plates, as a library file can hold one. +fn plated_stops() -> Value { + let ink = vectorcraft_color::Color::cmyk(0.0, 0.5, 0.0, 0.0); + json!([ + {"offset": 0, "color": vectorcraft_color::Color::WHITE}, + {"offset": 1, "color": ink, "swatch": "Brand", "tint": 0.5, "plates": [0.3, 0, 0, 0]} + ]) +} + +/// Library gradients and the gradient stops of library character styles lose their links to +/// swatches the document does not have together with the process plates those links print with. +#[test] +fn library_stops_unlinked_from_their_swatch_keep_no_process_plates() { + let data = json!({ + "name": "Plated", + "gradients": [{"name": "Glow", "gradient": {"gradient": {"kind": "Linear", "stops": plated_stops()}, "angle": 0}}], + "charStyles": [{"name": "Accent", "attrs": {"fill": {"type": "gradient", "gradient": {"kind": "Linear", "stops": plated_stops()}}}}] + }); + let mut s = session(); + let lib = run(&mut s, "library.import", json!({"data": data.to_string()}))["id"].as_str().unwrap().to_string(); + let a = run(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 40, "height": 20}))["id"].clone(); + run(&mut s, "select.set", json!({"ids": [a]})); + run(&mut s, "library.use", json!({"library": lib, "kind": "fillGradient", "item": "Glow"})); + let st = gradient(&paint_of(&s, &a, false)).gradient.stops[1].clone(); + assert_eq!((st.swatch.as_deref(), st.tint, st.plates), (None, 1.0, None), "{st:?}"); + run(&mut s, "library.addToCharacterStyles", json!({"library": lib, "item": "Accent"})); + let style = s.doc().unwrap().doc.char_styles.iter().find(|c| c.name == "Accent").map(|c| c.attrs["fill"].clone()).unwrap(); + let fill = serde_json::from_value::<vectorcraft_color::Paint>(style).unwrap(); + let st = gradient(&fill).gradient.stops[1].clone(); + assert_eq!((st.swatch.as_deref(), st.tint, st.plates), (None, 1.0, None), "{st:?}"); +} + /// A library style is compared with the document's in the form the document stores it in, so a /// style whose file writes a size as a whole number is reused, by Add to Character Styles and by a /// click alike. diff --git a/crates/engine/src/tests/linked_stops.rs b/crates/engine/src/tests/linked_stops.rs index 9ed3db2724..62955e6065 100644 --- a/crates/engine/src/tests/linked_stops.rs +++ b/crates/engine/src/tests/linked_stops.rs @@ -213,6 +213,24 @@ fn spot_stops_with_process_plates_export_both_in_device_n_shadings() { assert_eq!(gradient(&s, id).gradient.stops[1].plates, None); } +#[test] +fn deleting_a_spot_swatch_takes_the_process_plates_of_the_stops_it_unlinks() { + let (mut s, id) = setup(); + let plated = json!({"stops": [{"offset": 0, "color": "#ffffff"}, {"offset": 1, "swatch": "Ink", "tint": 50, "plates": [0.3, 0, 0, 0]}]}); + run(&mut s, "paint.editGradient", plated.clone()); + run(&mut s, "swatch.new", json!({"name": "Glow", "gradient": plated})); + let linked = gradient(&s, id).gradient.stops[1].clone(); + assert_eq!((linked.swatch.as_deref(), linked.plates), (Some("Ink"), Some([0.3, 0.0, 0.0, 0.0]))); + run(&mut s, "swatch.delete", json!({"name": "Ink"})); + // The art's stop and the gradient swatch's stop keep the color they show, unlinked and without plates. + let Paint::Gradient(sw) = doc(&s).swatch("Glow").unwrap().paint.clone() else { panic!("a gradient swatch") }; + for st in [&gradient(&s, id).gradient.stops[1], &sw.gradient.stops[1]] { + assert_eq!((st.color, st.swatch.as_deref(), st.tint, st.plates), (linked.color, None, 1.0, None), "{st:?}"); + } + run(&mut s, "edit.undo", json!({})); + assert_eq!(gradient(&s, id).gradient.stops[1], linked, "undo brings back the link and the plates"); +} + #[test] fn radial_spot_gradients_mixed_with_other_inks_export_as_device_n_shadings() { let (mut s, _) = setup(); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..97f285293b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1507,6 +1507,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Sample Color from Screen:** an eyedropper button in the Color Picker and `ui.sampleScreenColor` (which can be given a key in Keyboard Shortcuts) pick a color anywhere on the screen with the system's sampler: `NSColorSampler` on macOS, the XDG desktop portal's [PickColor](https://flatpak.github.io/xdg-desktop-portal/docs/doc-org.freedesktop.portal.Screenshot.html) on Linux, and the EyeDropper API in browsers that have it. The color becomes the fill or the stroke as one undo step, or the Color Picker's color, converted from display sRGB into the working RGB space. On Linux, a session without a portal that has PickColor, a portal that does not return from the call within 25 seconds (VectorCraft's own limit) or leaves the bus before it answers, and a portal that ends the request another way each show a status message and end the wait. Windows, the BSDs and other browsers have no sampler yet; the button is gray there. - **Stroke visibility (#1253):** adding paint to a previously unpainted zero-width stroke restores the existing 1 pt default (`PaintDefaults::default`, `Appearance::set_stroke`), for the selected appearance item, the new-art defaults and Swap Fill/Stroke. Positive widths are kept; recoloring a painted zero-width stroke keeps its explicit zero. A real Eyedropper-to-new-shape sequence reproduces the zero-width inheritance. Five engine regressions cover creation, defaults, targeted items, preserved widths and one-step Undo/Redo (`crates/engine/tests/it/stroke_visibility.rs`). - **Gradients:** lossless, validated gradient params; gradients follow rotate, reflect, shear, non-uniform scale and distortions; the Gradient tool edits the fill or stroke of the active proxy, type included; an interactive on-canvas annotator (move, length/angle, rotate, add/move/delete/duplicate stops, midpoints, a stop popover, Delete and arrow keys). The Gradient panel has the Fill/Stroke proxy, a gradient-swatch dropdown with Save to Swatches, midpoint locations, Alt-drag to copy or swap stops, swatch drops on the ramp and a stop eyedropper; copied appearances and graphic styles place gradients on each target's own bounds; gradient handles snap and honour Constrain Angle. Gradient stops stay linked to global and spot swatches. Freeform gradients (points and lines) are edited on the canvas; radial gradients have an extent ellipse, an aspect handle and an off-centre focal point (SVG `fx`/`fy`, PDF two-point radials). A stroke's gradient runs within, along or across it. Object ▸ Expand turns gradients into N objects or a gradient mesh. + A gradient stop that loses its link to a spot swatch (the swatch deleted, a recolor or adjustment that unlinks it, a library gradient, or a library character style linked to a swatch the document lacks) keeps the color it shows at full tint and drops the process plates it printed with that ink, as a stop given a plain color does; this is VectorCraft's own rule. Evidence: `tests::mapping_links_drops_the_process_plates_of_unlinked_stops` in `crates/color`, `tests::linked_stops::deleting_a_spot_swatch_takes_the_process_plates_of_the_stops_it_unlinks` and `tests::library::library_stops_unlinked_from_their_swatch_keep_no_process_plates` in `crates/engine`. - The Gradient panel's Delete Stop sits at the right end of the ramp, level with it, so a panel too short to show the stop fields still shows it; it deletes the selected stop (never below two), as dragging a stop down off the ramp does (#5403). - Conic gradients, VectorCraft's own gradient type: the stops sweep once around the center from the vector, clockwise on the page (a negative aspect, or a reflection, turns the sweep the other way), with a Conic button in the Gradient panel's Type row and the Gradient tool's extent ellipse and aspect handle; they follow transforms, Expand into wedges or a mesh, open from `.af` files, and export to PDF as a function-based shading that PDF import reads back as a conic gradient; SVG, EPS and legacy `.ai` files get solid wedges, and CSS a `conic-gradient`. - Diamond gradients, VectorCraft's own gradient type: the stops run from the center out to a square with a corner at the end of the vector (the aspect stretches it into a rhombus), with a Diamond button in the Gradient panel's Type row and the Gradient tool's square and aspect handle; they follow transforms, Expand into nested squares or a mesh, and export to PDF, SVG, EPS and legacy `.ai` as four linear gradients, one for each quarter of the square (an image in PDF and SVG for translucent stops, a dithered fill, the Perceptual method other than spot color shadings in PDF, or a square with no area), and on type characters in SVG as a radial gradient; PDF import reads a function-based shading whose color is the same along each square about its origin as a diamond gradient. From a5a67f8c4d7041a594d33f71c29e2a61b077f915 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:17:24 -0800 Subject: [PATCH 048/108] EPS: a test covers type taken back with its color bitmap glyph images Type whose color bitmap glyphs fit under the page limit, but whose run fill passes it, is left out together with the image placements of its glyphs. The new test builds the color font in memory and checks that the page then equals the page without that type: no reference or shared resource is left for the glyph image, a glyph drawn once elsewhere is written inline again, and an image drawn twice keeps its shared samples. --- crates/eps/src/tests.rs | 73 +++++++++++++++++++++++++++++++++++++++++ docs/type-parity.md | 2 +- 2 files changed, 74 insertions(+), 1 deletion(-) diff --git a/crates/eps/src/tests.rs b/crates/eps/src/tests.rs index c98cb9689a..d341636c13 100644 --- a/crates/eps/src/tests.rs +++ b/crates/eps/src/tests.rs @@ -1264,6 +1264,79 @@ fn the_page_limit_counts_a_repeated_images_samples_once() { assert!(page.body.len() + page.setup.len() <= inline + 1000 + 400, "{}", page.body.len()); } +/// Type whose color bitmap glyphs fit under the page limit but whose run fill passes it is left +/// out with its glyph image placements: the page is the page without that type. A glyph image +/// that other art draws once more is written inline there again, and an image that other art +/// draws twice keeps its shared samples. +#[test] +fn type_taken_back_for_the_page_limit_takes_its_glyph_images_with_it() { + use vectorcraft_doc::{CharStyle, TextObject}; + use vectorcraft_text::test_fonts::{COLOUR_CHAR, colour_bitmap_family, colour_bitmap_font}; + vectorcraft_text::FontDb::global().add_font(colour_bitmap_font(false).unwrap()); + let black = Paint::solid(Color::rgb(0.0, 0.0, 0.0)); + let type_node = |d: &mut Document, at: Point, text: &str, fill: Paint| { + let st = CharStyle { font_family: colour_bitmap_family(false).into(), size: 32.0, fill, ..CharStyle::default() }; + Node::new(d.alloc_id(), NodeKind::Text(Box::new(TextObject::point(at, text, st)))) + }; + // Six glyph images, then outlines enough for the fill to pass the limit. + let target = format!("{}{}", COLOUR_CHAR.to_string().repeat(6), "W".repeat(40)); + // `shared`: an image drawn twice comes first; `before`: one glyph drawn with the type's image; + // `fill`: the type's run fill (`None`: no type). A red rectangle comes last. + let build = |shared: bool, before: bool, fill: Option<Paint>| { + let mut d = if shared { + let mut d = image_doc(&noise(8, 8), 1.0); + place_again(&mut d, 0, Affine::translate((40.0, 0.0))); + d + } else { + Document::new(200.0, 200.0) + }; + let mut nodes = vec![]; + if before { + nodes.push(type_node(&mut d, Point::new(20.0, 40.0), &COLOUR_CHAR.to_string(), black.clone())); + } + if let Some(fill) = fill { + nodes.push(type_node(&mut d, Point::new(20.0, 100.0), &target, fill)); + } + nodes.push(red_rect(&mut d)); + for n in nodes { + d.insert(d.default_layer(), usize::MAX, n).unwrap(); + } + d + }; + for shared in [false, true] { + for before in [false, true] { + let case = format!("shared {shared}, before {before}"); + let (without, unfilled, filled) = + (build(shared, before, None), build(shared, before, Some(Paint::None)), build(shared, before, Some(black.clone()))); + let o = opts(&filled); + let glyph = usize::from(shared); + let fits = crate::scene::Scene::new(&unfilled, &o).run(); + let full = crate::scene::Scene::new(&filled, &o).run(); + assert!(fits.warnings.is_empty() && full.warnings.is_empty(), "{case}: {:?} {:?}", fits.warnings, full.warnings); + assert_eq!(reuses(&fits.body, glyph, o.level), 6 + usize::from(before), "{case}: {}", fits.body); + assert_eq!(reuses(&full.body, glyph, o.level), 6 + usize::from(before), "{case}: {}", full.body); + let (fits_len, full_len) = (fits.body.len() + fits.setup.len(), full.body.len() + full.setup.len()); + assert!(full_len > fits_len + 2000, "{case}: {fits_len} {full_len}"); + let limit = (fits_len + full_len) / 2; + // Without its fill the type fits, every glyph image with it. + let page = crate::scene::Scene::new(&unfilled, &o).with_max_body(limit).run(); + assert!(page.warnings.is_empty(), "{case}: {:?}", page.warnings); + assert_eq!((page.setup, page.body), (fits.setup, fits.body), "{case}"); + // With it the type is taken back after its glyph images were placed. + let page = crate::scene::Scene::new(&filled, &o).with_max_body(limit).run(); + assert!(page.warnings.iter().any(|w| w.contains("too large")), "{case}: {:?}", page.warnings); + let alone = crate::scene::Scene::new(&without, &o).run(); + assert!(alone.warnings.is_empty(), "{case}: {:?}", alone.warnings); + assert_eq!(reuses(&page.body, glyph, o.level), 0, "{case}: {}", page.body); + assert!(!page.setup.contains(&format!("/VCim{glyph} ")), "{case}: {}", page.setup); + assert_eq!(page.body.matches("/Width 16 /Height 16").count(), usize::from(before), "{case}: {}", page.body); + assert_eq!(reuses(&page.body, 0, o.level), if shared { 2 } else { 0 }, "{case}: {}", page.body); + assert_eq!((&page.setup, &page.body), (&alone.setup, &alone.body), "{case}"); + checked_page(&page.body); + } + } +} + #[test] fn run_length_and_ascii85_round_trip() { let cycle: Vec<u8> = (0..=255u8).cycle().take(1000).collect(); diff --git a/docs/type-parity.md b/docs/type-parity.md index 308a395670..baee56b877 100644 --- a/docs/type-parity.md +++ b/docs/type-parity.md @@ -39,7 +39,7 @@ against Illustrator's public documentation; **estimated** unless noted. | Full font-name matching (OpenType name ID 4) | done | #1258: loaded/cataloged faces and Missing Fonts searches; localized names and variable default faces; Windows font-service QA pending | | Variable fonts | done | named instances as styles; Character panel › Variable Font sets each axis (`fontAxes`); the font menu's Font Technology › Variable lists only variable font families, with the script, kind and ★ filters ([Find, apply, and adjust variable fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/find-apply-and-adjust-variable-fonts.html)); a family with a variable file beside static ones counts as variable. Evidence: `font_menu::tests::the_variable_filter_lists_only_variable_families`, `tests_axes::a_family_with_variation_axes_is_variable`, `tests_sysfonts::a_family_with_a_variable_file_beside_static_ones_is_variable` | | Fallback glyphs keep the text's weight and slant | done | #2491: a character from a fallback face is set in that family's face nearest the run's weight and slant; Bold Italic of a missing family is drawn Bold (Source Sans 3 has no Bold Italic) rather than Italic; a letter and its combining marks (a grapheme cluster) are drawn in one face, the first that has all of them, so marks the text's font lacks attach to their letter instead of drawing as missing glyphs (#4491). Vietnamese letters with two marks (Ể, Ứ, Ự) sit on their letter whether typed precomposed, decomposed or as a vowel plus a tone mark, built from GPOS mark-to-mark in fonts without the precomposed letters. Evidence: `tests::vietnamese` | -| Colour fonts (bitmap, COLR, OpenType SVG) | partial | bitmap glyphs (`sbix`, `CBDT`) done: the largest strike's PNG, transformed with the type, fill and stroke ignored; PDF Type 3 glyphs or images, SVG images with outlined text (live text leaves emoji to the viewer, their fonts not embedded), EPS and legacy `.ai` images, Create Outlines images; not `sbix` duplicate, flipped, JPEG or TIFF glyphs, or `CBDT` BGRA or mask data, or ruby; in envelopes they warp as images do, and a Warp effect moves them without bending them. COLR (v0 and v1) done: a glyph's layers as vector art (solid colours, linear and radial gradients, clip glyphs and boxes, blend modes, transforms, palette 0, the foreground colour from the run's fill, variable fonts at the face's instance), transformed with the type; drawn on the canvas, written as paths in SVG, EPS, legacy `.ai` and PDF with outlined text, as text in PDF (Type 3 glyphs), and Create Outlines makes groups of editable paths. Paints documents have no form for draw the glyph as an image (256 px per em): sweep gradients, Porter-Duff compositing, radial gradients from a circle that isn't the centre, repeating or reflecting gradients. Not ruby. COLR and SVG glyphs also go with type that geometry effects reshape (on the canvas and in exports), into Expand Appearance and EMF/WMF export, as their art, and bitmap glyphs as images. OpenType SVG done: a glyph's SVG document (its element `glyph<gid>`) is read by the SVG importer into vector art in font units, `currentColor` in the run's fill (and the legacy `context-fill` and `context-stroke` in its fill and stroke), a `viewBox` mapped onto the em square, and then drawn, exported and outlined as COLR glyphs are; in PDF real text such glyphs are text that draws nothing, with their art drawn where they sit. Images in glyph documents are in the art, holding their pixels until a document takes them in; text, scripts and embedded content are left out, as the table rules them out. Not CPAL palette variables. Evidence: `tests_svg_glyphs`, `svg/tests/it/svg_glyphs.rs`, `tests_colourfonts::svg_glyph_images_draw_and_outline`, `tests_colourfonts::create_outlines_turns_svg_glyphs_into_groups`, `tests_colourfonts::pdf_real_text_draws_svg_glyphs_as_art_and_keeps_their_characters`, `tests_colourfonts::expand_appearance_keeps_the_colour_glyphs_of_type_with_effects`, `render::tests_colrglyphs::colour_glyphs_go_with_type_that_a_geometry_effect_reshapes`, `tests_bitmaps`, `tests_colr`, `render::tests_bitmapglyphs`, `render::tests_colrglyphs`, `pdf::tests::colour_bitmap_glyphs_export_as_images`, `pdf::tests::colr_glyphs_export_as_vector_art`, `svg/tests/it/colour_glyphs.rs`, `eps` `colour_bitmap_glyphs_*` and `colr_glyphs_*`, `tests_pathops::create_outlines_turns_bitmap_glyphs_into_images`, `tests_pathops::create_outlines_turns_colr_glyphs_into_layer_groups` | +| Colour fonts (bitmap, COLR, OpenType SVG) | partial | bitmap glyphs (`sbix`, `CBDT`) done: the largest strike's PNG, transformed with the type, fill and stroke ignored; PDF Type 3 glyphs or images, SVG images with outlined text (live text leaves emoji to the viewer, their fonts not embedded), EPS and legacy `.ai` images, Create Outlines images; not `sbix` duplicate, flipped, JPEG or TIFF glyphs, or `CBDT` BGRA or mask data, or ruby; in envelopes they warp as images do, and a Warp effect moves them without bending them. COLR (v0 and v1) done: a glyph's layers as vector art (solid colours, linear and radial gradients, clip glyphs and boxes, blend modes, transforms, palette 0, the foreground colour from the run's fill, variable fonts at the face's instance), transformed with the type; drawn on the canvas, written as paths in SVG, EPS, legacy `.ai` and PDF with outlined text, as text in PDF (Type 3 glyphs), and Create Outlines makes groups of editable paths. Paints documents have no form for draw the glyph as an image (256 px per em): sweep gradients, Porter-Duff compositing, radial gradients from a circle that isn't the centre, repeating or reflecting gradients. Not ruby. COLR and SVG glyphs also go with type that geometry effects reshape (on the canvas and in exports), into Expand Appearance and EMF/WMF export, as their art, and bitmap glyphs as images. OpenType SVG done: a glyph's SVG document (its element `glyph<gid>`) is read by the SVG importer into vector art in font units, `currentColor` in the run's fill (and the legacy `context-fill` and `context-stroke` in its fill and stroke), a `viewBox` mapped onto the em square, and then drawn, exported and outlined as COLR glyphs are; in PDF real text such glyphs are text that draws nothing, with their art drawn where they sit. Images in glyph documents are in the art, holding their pixels until a document takes them in; text, scripts and embedded content are left out, as the table rules them out. Not CPAL palette variables. Evidence: `tests_svg_glyphs`, `svg/tests/it/svg_glyphs.rs`, `tests_colourfonts::svg_glyph_images_draw_and_outline`, `tests_colourfonts::create_outlines_turns_svg_glyphs_into_groups`, `tests_colourfonts::pdf_real_text_draws_svg_glyphs_as_art_and_keeps_their_characters`, `tests_colourfonts::expand_appearance_keeps_the_colour_glyphs_of_type_with_effects`, `render::tests_colrglyphs::colour_glyphs_go_with_type_that_a_geometry_effect_reshapes`, `tests_bitmaps`, `tests_colr`, `render::tests_bitmapglyphs`, `render::tests_colrglyphs`, `pdf::tests::colour_bitmap_glyphs_export_as_images`, `pdf::tests::colr_glyphs_export_as_vector_art`, `svg/tests/it/colour_glyphs.rs`, `eps` `colour_bitmap_glyphs_*`, `colr_glyphs_*` and `type_taken_back_for_the_page_limit_takes_its_glyph_images_with_it`, `tests_pathops::create_outlines_turns_bitmap_glyphs_into_images`, `tests_pathops::create_outlines_turns_colr_glyphs_into_layer_groups` | | Every-line and Single-line composers | done | tuned by eye, never compared side by side | | Optical Margin Alignment | done | Type › Optical Margin Alignment, `type.opticalMarginAlignment`: per type object, with one setting for all the frames of a thread, in point and area type of left-to-right paragraphs, and at the brackets of type on a path whose first paragraph runs left to right; right-to-left paragraphs of point and area type, and type on a path whose first paragraph runs right to left, do not hang | | System Layout | done | Character panel menu › System Layout, `type.systemLayout`: the whole document, off by default and for documents from before it, saved only when on. On, every text object advances by whole points (at least one when a character takes space). New point, area and path type, threaded frames, placed text, graph and dimension labels and pasted plain text inherit it. Evidence: `tests::system_layout_rounds_positive_advances_to_whole_points`, `typecmd::area_tests::system_layout_sets_the_document_and_every_text_object`, `panels::character::tests::system_layout_menu_item_toggles_the_document` | From c91fba986e879da025ec05485c18be09c1141e58 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:23:17 -0800 Subject: [PATCH 049/108] i18n: Traditional Chinese translates 114 status and error messages that no catalog had untranslated_report lists 167 messages under "messages, all 23 languages checked". zh-hant.tsv gains an @msg row for 114 of them, in one block at the end of the file: image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, 3D and Revolve limits, and script, zip, line and file errors. Placeholders, parameter names and literal values stay as the English writes them. The other 53 are left to the open pull requests that translate them (composite fonts, SVG filters, read roots and graph design). --- crates/ui-egui/src/i18n/zh-hant.tsv | 116 ++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index a0d987fe69..ff5ff8d354 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -7138,3 +7138,119 @@ breakText Glyphs 字符 Grommets 扣眼 Grommet Inset 扣眼邊距 Diameter 直徑 + +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +@msg 3D effects require finite coordinates within 100 million points 3D 效果需要位於 1 億點以內的有限座標 +@msg 3D effects require one to ten lights 3D 效果需要 1 到 10 個光源 +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP 色彩深度 {_1}:須為每像素 1、4、8、16、24 或 32 位元 +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP 編碼失敗:{width} × {height} 像素不符合格式或像素緩衝區 +@msg GIF encoding failed: the palette image is malformed GIF 編碼失敗:調色盤影像格式錯誤 +@msg GIF encoding failed: {e} GIF 編碼失敗:{e} +@msg JPEG colour profile: {e} JPEG 色彩描述檔:{e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG 編碼失敗:像素緩衝區與影像尺寸不符 +@msg JPEG encoding failed: {e} JPEG 編碼失敗:{e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG 編碼失敗:像素緩衝區與影像尺寸不符 +@msg PNG encoding failed: the palette image is malformed PNG 編碼失敗:調色盤影像格式錯誤 +@msg PNG encoding failed: {e} PNG 編碼失敗:{e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG 編碼失敗:{width} × {height} 像素不是有效的影像尺寸 +@msg PSD colour profile: {e} PSD 色彩描述檔:{e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD 編碼失敗:像素緩衝區與影像尺寸不符 +@msg Revolve profile contains invalid coordinates 迴轉的輪廓包含無效的座標 +@msg Revolve profile is too complex 迴轉的輪廓過於複雜 +@msg Revolve projection is not finite 迴轉的投影不是有限值 +@msg Revolve requires finite profile coordinates within 100 million points 迴轉需要位於 1 億點以內的有限輪廓座標 +@msg Revolve surface is too complex; reduce Segments or simplify the profile 迴轉曲面過於複雜;請減少「分段數」或簡化輪廓 +@msg Revolve surface is too complex; simplify the profile 迴轉曲面過於複雜;請簡化輪廓 +@msg Revolve visibility cannot split the projected boundary 迴轉的可見性計算無法分割投影邊界 +@msg Revolve visibility creates too many fragments 迴轉的可見性計算產生過多片段 +@msg Revolve visibility creates too many vector anchors 迴轉的可見性計算產生過多向量錨點 +@msg Revolve visibility exceeds its geometry work limit 迴轉的可見性計算超出幾何運算量上限 +@msg Revolve visibility exceeds its spatial index limit 迴轉的可見性計算超出空間索引上限 +@msg Revolve visibility has too many boundary crossings 迴轉的可見性計算有過多邊界交叉 +@msg Revolve visibility has too many input anchors 迴轉的可見性計算有過多輸入錨點 +@msg Revolve visibility requires convex cap sectors 迴轉的可見性計算需要凸形的端蓋扇區 +@msg Revolve visibility requires finite projected faces 迴轉的可見性計算需要有限的投影面 +@msg SVG options: {e} SVG 選項:{e} +@msg Save for Web settings: {e} 儲存為網頁用設定:{e} +@msg TIFF colour profile: {e} TIFF 色彩描述檔:{e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF 編碼失敗:像素緩衝區與影像尺寸不符 +@msg TIFF encoding failed: {e} TIFF 編碼失敗:{e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa 色彩深度 {_1}:須為每像素 16、24 或 32 位元 +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa 編碼失敗:像素緩衝區與影像尺寸不符 +@msg The 3D projection is not finite 3D 投影不是有限值 +@msg The 3D shadow is too complex; turn Shadows off or simplify the art 3D 陰影過於複雜;請關閉「陰影」或簡化圖稿 +@msg The shape contains invalid coordinates 形狀包含無效的座標 +@msg Too many Revolve faces for visibility evaluation 迴轉的面過多,無法計算可見性 +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft 從色票交換檔案最多讀取 {ASE_MAX_ENTRIES} 個顏色和群組,而此資料庫有 {entries} 個 +@msg WebP encoding failed: {e} WebP 編碼失敗:{e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`:{why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` 必須是 smallThumb、mediumThumb、largeThumb、smallList 或 largeList +@msg a line can't run from a point to itself 線條不能從一個點連到同一個點 +@msg a line needs at least two points 線條至少需要兩個點 +@msg a number cannot be read 無法讀取數字 +@msg a swatch exchange block is too long 色票交換區塊過長 +@msg a swatch exchange name is too long 色票交換名稱過長 +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels {sw} × {sh} 的影像無法調整為 {width} × {height} 像素 +@msg a {width} × {height} image is too large {width} × {height} 的影像過大 +@msg a {width} × {height} image: {e} {width} × {height} 的影像:{e} +@msg an image could not be written: {e} 無法寫入影像:{e} +@msg an image that couldn't be read was left out 已略過無法讀取的影像 +@msg can't open “{name}”: {e} 無法開啟「{name}」:{e} +@msg cannot align zip entries to {align} bytes 無法將 ZIP 項目對齊至 {align} 位元組 +@msg cannot open the automation {kind} root `{_1}`: {e} 無法開啟自動化 {kind} 根目錄 `{_1}`:{e} +@msg cannot read profile: {0} 無法讀取描述檔:{0} +@msg color book version {version} isn't supported (only 1) 不支援色票簿版本 {version} (僅支援 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) 不支援色彩空間為 {other} 的色票簿 (僅支援 RGB、CMYK 和 Lab) +@msg file name too long to zip: {_1} 檔案名稱過長,無法壓縮為 ZIP:{_1} +@msg file name too long to zip: {name} 檔案名稱過長,無法壓縮為 ZIP:{name} +@msg freeform line {i}: {e} 任意形狀線條 {i}:{e} +@msg freeform point {i}: {e} 任意形狀點 {i}:{e} +@msg give `{key}` or `{other}`, not both 請提供 `{key}` 或 `{other}`,不能同時提供兩者 +@msg grayscale profiles can't be working spaces yet 灰階描述檔目前還不能作為工作空間 +@msg input contains NaN or infinite coordinates 輸入包含 NaN 或無限大的座標 +@msg input path could not be closed 無法封閉輸入路徑 +@msg invalid ICC profile: {0} 無效的 ICC 描述檔:{0} +@msg invalid scale {scale} 無效的縮放比例 {scale} +@msg its localized names take more than {_1} KB 其本地化名稱超過 {_1} KB +@msg its objects are nested too deep ({e}) 其物件巢狀層級過深 ({e}) +@msg its tag table lists the `{_1}` tag more than once 其標記表多次列出 `{_1}` 標記 +@msg not a graphic style library: {e} 不是繪圖樣式資料庫:{e} +@msg not a swatch library (.vcswatches or .gpl) 不是色票資料庫 (.vcswatches 或 .gpl) +@msg not a swatch library (format `{_1}`) 不是色票資料庫 (格式為 `{_1}`) +@msg not a swatch library: {e} 不是色票資料庫:{e} +@msg not an action set file ({e}) 不是動作組檔案 ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray 描述檔的色彩空間 {other} 不是 RGB、CMYK 或灰階 +@msg regular expression too large 規則運算式過大 +@msg script file is not UTF-8 text: {value} 指令碼檔案不是 UTF-8 文字:{value} +@msg stop {i}: {e} 色標 {i}:{e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) 不支援色票交換版本 {major}.{minor} (僅支援 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors 色票簿包含超過 {ASE_MAX_ENTRIES} 個顏色 +@msg the color book is cut short 色票簿不完整 +@msg the color book's names take more than {_1} MB 色票簿的名稱超過 {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution 影像會是 {w} × {h} 像素;點陣圖匯出的上限為每邊 {MAX_RASTER_SIDE} 像素及 {_1} 百萬像素:請降低縮放比例或解析度 +@msg the optimised image can't be read back: {e} 無法讀回最佳化後的影像:{e} +@msg the pixel buffer doesn't match the image size 像素緩衝區與影像尺寸不符 +@msg the preview: {e} 預覽:{e} +@msg the request may not read the New Document profiles folder 此要求不得讀取新增文件描述檔資料夾 +@msg the shapes are too degenerate to combine 形狀過度退化,無法合併 +@msg the shapes cross themselves and each other too often to combine 形狀自身及彼此之間交叉過多,無法合併 +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups 色票交換檔案包含超過 {ASE_MAX_ENTRIES} 個顏色和群組 +@msg the swatch exchange file is cut short 色票交換檔案不完整 +@msg the {_1} plate can't be read: {e} 無法讀取 {_1} 色版:{e} +@msg this binary DXF file is damaged or cut short 此二進位 DXF 檔案已損毀或不完整 +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that 這是 DWG 圖面,無法讀取:請在 CAD 應用程式中將其儲存為 DXF,再開啟該檔案 +@msg too many classes 字元類別過多 +@msg too many groups 群組過多 +@msg too many layers for PSD (at most 32767) PSD 的圖層過多 (最多 32767 個) +@msg too many swatch exchange blocks 色票交換區塊過多 +@msg unknown colour profile: {0} 未知的色彩描述檔:{0} +@msg {_1} clashes with a built-in profile name {_1} 與內建描述檔名稱衝突 +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} 像素對 GIF 來說過大 (每邊最多 65535 像素):請降低解析度 +@msg {_1}: no usable transform to/from sRGB {_1}:沒有可與 sRGB 互相轉換的可用轉換 +@msg {name} is not a CMYK profile {name} 不是 CMYK 描述檔 +@msg {name} is not an RGB profile {name} 不是 RGB 描述檔 +@msg {path}: could not be read {path}:無法讀取 +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} 像素對 JPEG 來說過大 (每邊最多 65535 像素):請降低解析度 +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} 像素對 Targa 來說過大 (每邊最多 65535 像素):請降低解析度 +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} 像素對 PSD 來說過大 (每邊最多 {MAX_SIDE} 像素):請降低解析度 From 019f604e91f769bd7ba7022157bbf3331adf6b90 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:38:38 -0800 Subject: [PATCH 050/108] Artwork Cleanup: text tools act on the locked or hidden type ids name Remove Breaks, Break Text, Combine Point Text, Join Point Text, Set Alignment, Keep Position and Reset Text Transform skipped locked and hidden type even when `ids` named it, or named the group or layer holding it, while other commands such as text.convertListToText act on named locked or hidden objects. - With `ids`, the type they name is taken locked or hidden too (not type on a locked artboard); from the selection, only type that can be edited, as before. - Remove Breaks reads a named threaded story with a locked frame as one text. - Objects made from locked or hidden type are not selected. Docs: docs/mcp.md (Text tools), docs/target-app-parity.md. --- crates/engine/src/cmd/addons/cleanup/text.rs | 70 ++++++----- .../src/cmd/addons/cleanup/text/tests.rs | 115 ++++++++++++++++++ docs/mcp.md | 4 +- docs/target-app-parity.md | 4 + 4 files changed, 164 insertions(+), 29 deletions(-) diff --git a/crates/engine/src/cmd/addons/cleanup/text.rs b/crates/engine/src/cmd/addons/cleanup/text.rs index 052ba901ed..0f22b184f3 100644 --- a/crates/engine/src/cmd/addons/cleanup/text.rs +++ b/crates/engine/src/cmd/addons/cleanup/text.rs @@ -45,7 +45,7 @@ pub fn specs() -> Vec<CommandSpec> { "Break Text", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{by?: \"lines\"|\"paragraphs\"|\"words\"|\"glyphs\" (lines), ids?: [id…] (default: the selection)} each horizontal point or area type object becomes point type objects, one per line, paragraph, word or glyph, each where its characters were and with their character styles, as one undo step; spaces between pieces go, a paragraph's lines stay lines (a wrapped line ends in a line break), justified lines close up, and a paragraph broken out whole keeps its bullet (not its number; other pieces have no list markers). Type on a path, vertical type, threaded type and area type whose text doesn't fit stay as they are → {ids (the pieces, selected), skipped}", + "{by?: \"lines\"|\"paragraphs\"|\"words\"|\"glyphs\" (lines), ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} each horizontal point or area type object becomes point type objects, one per line, paragraph, word or glyph, each where its characters were and with their character styles, as one undo step; spaces between pieces go, a paragraph's lines stay lines (a wrapped line ends in a line break), justified lines close up, and a paragraph broken out whole keeps its bullet (not its number; other pieces have no list markers). Type on a path, vertical type, threaded type and area type whose text doesn't fit stay as they are → {ids (the pieces, selected), skipped}", has_selection, break_text ), @@ -54,7 +54,7 @@ pub fn specs() -> Vec<CommandSpec> { "Combine Point Text", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{ids?: [id…] (default: the selection)} merge one-line horizontal point type into as few objects as it can, every glyph staying where it was: pieces turned and sheared alike whose baselines line up (within 0.4 em; the difference becomes baseline shift) join left to right, a space goes between pieces at least half a space apart, and tracking on the character before each piece keeps the spacing; each object keeps its character styles, and the leftmost piece of each run its place and paint, as one undo step → {ids (the objects made, selected), combined (pieces merged into them)}", + "{ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} merge one-line horizontal point type into as few objects as it can, every glyph staying where it was: pieces turned and sheared alike whose baselines line up (within 0.4 em; the difference becomes baseline shift) join left to right, a space goes between pieces at least half a space apart, and tracking on the character before each piece keeps the spacing; each object keeps its character styles, and the leftmost piece of each run its place and paint, as one undo step → {ids (the objects made, selected), combined (pieces merged into them)}", has_selection, combine_text ), @@ -63,7 +63,7 @@ pub fn specs() -> Vec<CommandSpec> { "Join Point Text", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{ids?: [id…] (default: the selection)} join one-line horizontal point type into one point type object, as one undo step: pieces turned and sheared like the top-left one are read as lines (baselines within 0.4 em of each other), top to bottom, each line's pieces left to right with a space between them; each line becomes a paragraph, left aligned, and keeps the distance between baselines as its leading. The text keeps its character styles; the object takes the top-left piece's place and paint, and the other pieces go → {id (selected), joined (pieces merged into it), lines}", + "{ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} join one-line horizontal point type into one point type object, as one undo step: pieces turned and sheared like the top-left one are read as lines (baselines within 0.4 em of each other), top to bottom, each line's pieces left to right with a space between them; each line becomes a paragraph, left aligned, and keeps the distance between baselines as its leading. The text keeps its character styles; the object takes the top-left piece's place and paint, and the other pieces go → {id (selected), joined (pieces merged into it), lines}", has_selection, join_text ), @@ -72,7 +72,7 @@ pub fn specs() -> Vec<CommandSpec> { "Remove Breaks", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{kind: \"line\"|\"paragraph\", ids?: [id…]} remove the forced line breaks (line) or paragraph returns (paragraph) in the characters selected with a Type tool (after Select All in a frame of threaded text, in the text of every frame of the story), else in all the text of the selected type, as one undo step; a break between two words becomes a space, the frames of a threaded story selected all together being read as one text → {ids, removed}", + "{kind: \"line\"|\"paragraph\", ids?: [id…] (the type they name is taken locked or hidden too)} remove the forced line breaks (line) or paragraph returns (paragraph) in the characters selected with a Type tool (after Select All in a frame of threaded text, in the text of every frame of the story), else in all the text of the selected type, as one undo step; a break between two words becomes a space, the frames of a threaded story selected all together being read as one text → {ids, removed}", has_selection, remove_breaks ), @@ -90,7 +90,7 @@ pub fn specs() -> Vec<CommandSpec> { "Set Alignment, Keep Position", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{align: \"left\"|\"center\"|\"right\", ids?: [id…] (default: the selection)} align every paragraph of each horizontal point type object so, moving the object so its longest line stays where it is (one line: the text doesn't move), as one undo step → {ids (the objects changed)}", + "{align: \"left\"|\"center\"|\"right\", ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} align every paragraph of each horizontal point type object so, moving the object so its longest line stays where it is (one line: the text doesn't move), as one undo step → {ids (the objects changed)}", has_selection, align_in_place ), @@ -99,7 +99,7 @@ pub fn specs() -> Vec<CommandSpec> { "Reset Text Transform", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{scale?: bool (false: the horizontal scale stays; true: it goes too, the object's and every character's), ids?: [id…] (default: the selection)} take the rotation, shear and reflection off each point type object, its size and the centre of its text staying, as one undo step → {ids (the objects changed)}", + "{scale?: bool (false: the horizontal scale stays; true: it goes too, the object's and every character's), ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} take the rotation, shear and reflection off each point type object, its size and the centre of its text staying, as one undo step → {ids (the objects changed)}", has_selection, reset_transform ), @@ -123,8 +123,17 @@ fn editing_text(s: &Session) -> std::result::Result<(), String> { } } -/// The type objects under `roots` (inside groups and layers, not live art) that can be edited. -fn texts_under(d: &Document, roots: &[NodeId]) -> Result<Vec<NodeId>> { +/// The type objects a command acts on: those under the objects `ids` names, locked and hidden ones +/// included, else those under the selection that can be edited ([`texts_under`]). +fn target_texts(s: &Session, p: &Value, command: &str) -> Result<Vec<NodeId>> { + let named = p.get("ids").is_some_and(|v| !v.is_null()); + texts_under(&s.doc()?.doc, &checked_ids_or_selection(s, p, command)?, named) +} + +/// The type objects under `roots` (inside groups and layers, not live art). When `named`, every one +/// not on a locked artboard, locked and hidden ones (and ones in a locked or hidden group or layer) +/// included; else only those that can be edited. +fn texts_under(d: &Document, roots: &[NodeId], named: bool) -> Result<Vec<NodeId>> { fn visit(n: &Node, out: &mut Vec<NodeId>) { match &n.kind { NodeKind::Text(_) => out.push(n.id), @@ -134,8 +143,13 @@ fn texts_under(d: &Document, roots: &[NodeId]) -> Result<Vec<NodeId>> { } let mut out = vec![]; roots.iter().filter_map(|id| d.node(*id)).for_each(|n| visit(n, &mut out)); - let editable = d.editable(); - out.retain(|id| editable(*id)); + if named { + let locks = d.locked_artboards(); + out.retain(|id| !locks.holds_id(*id)); + } else { + let editable = d.editable(); + out.retain(|id| editable(*id)); + } out.dedup(); if out.len() > MAX_TEXTS { return Err(EngineError::Other("Too many type objects to change at once".into())); @@ -376,7 +390,9 @@ fn replace_with_pieces(s: &mut Session, label: &str, items: Vec<(NodeId, Node, V places.push((id, nodes)); } d.insert_beside(places, true)?; - sel.set(made.iter().copied()); + // Pieces of locked or hidden type stay unselected. + let editable = d.editable(); + sel.set(made.iter().copied().filter(|id| editable(*id))); Ok(made.iter().map(|i| i.0).collect()) }) } @@ -396,7 +412,7 @@ fn break_text(s: &mut Session, p: &Value) -> Result<Value> { }; let d = &s.doc()?.doc; let (mut items, mut skipped, mut count) = (vec![], vec![], 0); - let ids = texts_under(d, &checked_ids_or_selection(s, p, C)?)?; + let ids = target_texts(s, p, C)?; let threads = thread_index(d); for id in ids { let (Some(src), Some(node)) = (Source::of(d, id, threads.contains_key(&id)), d.node(id)) else { @@ -595,8 +611,7 @@ fn merge(chain: &[&Piece]) -> std::result::Result<TextObject, usize> { fn combine_text(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "addon.cleanup.combineText"; let d = &s.doc()?.doc; - let mut pieces: Vec<(Piece, &Node)> = - texts_under(d, &checked_ids_or_selection(s, p, C)?)?.into_iter().filter_map(|id| Piece::of(d, id)).collect(); + let mut pieces: Vec<(Piece, &Node)> = target_texts(s, p, C)?.into_iter().filter_map(|id| Piece::of(d, id)).collect(); // Lines: pieces turned alike and looking alike, by baseline, then left to right. pieces.sort_by(|x, y| x.0.at.y.total_cmp(&y.0.at.y).then(x.0.at.x.total_cmp(&y.0.at.x))); let mut lines: Vec<Vec<(&Piece, &Node)>> = vec![]; @@ -672,7 +687,8 @@ fn combine_text(s: &mut Session, p: &Value) -> Result<Value> { gone.extend(others); } d.remove_many(&gone)?; - sel.set(ids.iter().map(|i| NodeId(*i))); + let editable = d.editable(); + sel.set(ids.iter().map(|i| NodeId(*i)).filter(|id| editable(*id))); Ok(()) })?; Ok(json!({ "ids": ids, "combined": combined })) @@ -681,8 +697,7 @@ fn combine_text(s: &mut Session, p: &Value) -> Result<Value> { fn join_text(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "addon.cleanup.joinText"; let d = &s.doc()?.doc; - let pieces: Vec<Piece> = - texts_under(d, &checked_ids_or_selection(s, p, C)?)?.into_iter().filter_map(|id| Piece::of(d, id).map(|p| p.0)).collect(); + let pieces: Vec<Piece> = target_texts(s, p, C)?.into_iter().filter_map(|id| Piece::of(d, id).map(|p| p.0)).collect(); // The piece top-left on the page sets the turn; the others turned like it are read in that frame. let on_page = |p: &Piece| Affine::new([p.turn[0], p.turn[1], p.turn[2], p.turn[3], 0.0, 0.0]) * p.at; let first = pieces.iter().min_by(|x, y| { @@ -751,7 +766,7 @@ fn join_text(s: &mut Session, p: &Value) -> Result<Value> { n.kind = NodeKind::Text(Box::new(m)); } d.remove_many(&gone)?; - sel.set([id]); + sel.set([id].into_iter().filter(|id| d.is_editable(*id))); Ok(()) })?; Ok(json!({ "id": id.0, "joined": joined, "lines": count })) @@ -797,8 +812,8 @@ fn apply_cuts(t: &mut TextObject, cuts: &[(usize, bool)], brk: char) -> usize { /// The breaks `brk` in the text of the frames of `story`, read as one text: a break at the end or /// start of a frame between words of the frames on either side becomes a space. Each editable frame -/// comes with its own breaks, at its own bytes. -fn story_cuts(d: &Document, story: &[NodeId], brk: char) -> Vec<(NodeId, Vec<(usize, bool)>)> { +/// (each frame when `all`) comes with its own breaks, at its own bytes. +fn story_cuts(d: &Document, story: &[NodeId], brk: char, all: bool) -> Vec<(NodeId, Vec<(usize, bool)>)> { let texts: Vec<(NodeId, String)> = story.iter().filter_map(|id| Some((*id, text_of(d, *id)?.plain_text()))).collect(); let joined: String = texts.iter().map(|(_, t)| t.as_str()).collect(); // The breaks in story order, handed to the frames in one pass. @@ -811,7 +826,7 @@ fn story_cuts(d: &Document, story: &[NodeId], brk: char) -> Vec<(NodeId, Vec<(us while let Some((at, space)) = cuts.next_if(|(at, _)| *at < end) { own.push((at - start, space)); } - if d.is_editable(id) { + if all || d.is_editable(id) { out.push((id, own)); } start = end; @@ -834,14 +849,14 @@ fn remove_breaks(s: &mut Session, p: &Value) -> Result<Value> { let d = &s.doc()?.doc; // Each type object with the breaks that go from it. let targets: Vec<(NodeId, Vec<(usize, bool)>)> = match editing { - Some(_) if !story.is_empty() => story_cuts(d, &story, brk), + Some(_) if !story.is_empty() => story_cuts(d, &story, brk, false), Some((id, a, b)) => vec![(id, a.min(b), a.max(b))] .into_iter() .filter(|(id, ..)| d.is_editable(*id)) .filter_map(|(id, a, b)| Some((id, break_cuts(&text_of(d, id)?.plain_text(), a, b, brk)))) .collect(), None => { - let ids = texts_under(d, &checked_ids_or_selection(s, p, C)?)?; + let ids = target_texts(s, p, C)?; // A threaded story whose frames are all among them is read as one text, once. let named: std::collections::HashSet<NodeId> = ids.iter().copied().collect(); let threads = thread_index(d); @@ -857,7 +872,8 @@ fn remove_breaks(s: &mut Session, p: &Value) -> Result<Value> { }; if !story.is_empty() && story.iter().all(|f| named.contains(f)) { done.extend(story.iter().copied()); - out.extend(story_cuts(d, &story, brk)); + // Every frame is among them, so each one keeps its breaks. + out.extend(story_cuts(d, &story, brk, true)); } else if let Some(t) = text_of(d, id) { out.push((id, break_cuts(&t.plain_text(), 0, usize::MAX, brk))); } @@ -891,10 +907,8 @@ fn remove_breaks(s: &mut Session, p: &Value) -> Result<Value> { /// Horizontal point type among the objects `p` names. fn point_texts(s: &Session, p: &Value, cmd: &str) -> Result<Vec<NodeId>> { let d = &s.doc()?.doc; - let ids: Vec<NodeId> = texts_under(d, &checked_ids_or_selection(s, p, cmd)?)? - .into_iter() - .filter(|id| text_of(d, *id).is_some_and(|t| matches!(t.kind, TextKind::Point))) - .collect(); + let ids: Vec<NodeId> = + target_texts(s, p, cmd)?.into_iter().filter(|id| text_of(d, *id).is_some_and(|t| matches!(t.kind, TextKind::Point))).collect(); if ids.is_empty() { return Err(EngineError::Other("Select point type".into())); } diff --git a/crates/engine/src/cmd/addons/cleanup/text/tests.rs b/crates/engine/src/cmd/addons/cleanup/text/tests.rs index cfa78a5ce5..cf5f95a667 100644 --- a/crates/engine/src/cmd/addons/cleanup/text/tests.rs +++ b/crates/engine/src/cmd/addons/cleanup/text/tests.rs @@ -379,6 +379,121 @@ fn remove_breaks_reads_the_threads_once() { } } +/// Lock `id` (`locked`), else hide it, as an undo step of its own. +fn lock_or_hide(s: &mut Session, id: NodeId, locked: bool) { + s.edit("Lock or Hide", |d, _| { + let n = d.node_mut(id).unwrap(); + if locked { + n.locked = true; + } else { + n.visible = false; + } + Ok(()) + }) + .unwrap(); +} + +/// Remove Breaks takes the locked and hidden type that `ids` names, and the locked member of a +/// group it names, as one undo step; from the selection it takes only type that can be edited, and +/// nothing changed makes no undo step. +#[test] +fn remove_breaks_named_locked_and_hidden_type() { + let mut s = session(); + let locked = text(&mut s, json!({"x": 40, "y": 60, "text": "a\nb", "size": 12})); + let hidden = text(&mut s, json!({"x": 40, "y": 120, "text": "c\nd", "size": 12})); + let grouped = text(&mut s, json!({"x": 40, "y": 180, "text": "e\nf", "size": 12})); + let free = text(&mut s, json!({"x": 40, "y": 240, "text": "g\nh", "size": 12})); + select(&mut s, &[grouped, free]); + let group = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + lock_or_hide(&mut s, locked, true); + lock_or_hide(&mut s, hidden, false); + lock_or_hide(&mut s, grouped, true); + select(&mut s, &[locked, hidden]); + let steps = undo_steps(&s); + assert_eq!(other(s.execute("addon.cleanup.removeBreaks", &json!({"kind": "paragraph"}))), "No paragraph breaks to remove"); + assert_eq!(undo_steps(&s), steps, "the selected locked and hidden type stays as it is"); + let r = s.execute("addon.cleanup.removeBreaks", &json!({"kind": "paragraph", "ids": [locked.0, hidden.0, group.0]})).unwrap(); + assert_eq!(undo_steps(&s), steps + 1); + assert_eq!(r["removed"], 4); + for (id, now) in [(locked, "a b"), (hidden, "c d"), (grouped, "e f"), (free, "g h")] { + assert_eq!(obj(&s, id).plain_text(), now); + } + assert_eq!(other(s.execute("addon.cleanup.removeBreaks", &json!({"kind": "paragraph", "ids": [locked.0]}))), "No paragraph breaks to remove"); + assert_eq!(undo_steps(&s), steps + 1, "nothing changed, no undo step"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(obj(&s, locked).plain_text(), "a\nb"); +} + +/// A threaded story whose frames `ids` all names is read as one text even when a frame is locked. +#[test] +fn remove_breaks_named_story_with_a_locked_frame() { + let mut s = session(); + let (a, b) = threaded(&mut s, "one\ntwo"); + lock_or_hide(&mut s, a, true); + let r = s.execute("addon.cleanup.removeBreaks", &json!({"kind": "paragraph", "ids": [a.0, b.0]})).unwrap(); + assert_eq!(r["removed"], 1); + assert_eq!(obj(&s, a).plain_text(), "one two"); +} + +/// Break Text, Combine and Join Point Text, Set Alignment, Keep Position and Reset Text Transform +/// act on the locked and hidden type that `ids` names (type in a locked layer included), each as +/// one undo step, and leave it as it is when it is only selected. +#[test] +fn named_locked_and_hidden_type() { + let mut s = session(); + let words = text(&mut s, json!({"x": 40, "y": 100, "text": "Two words", "size": 14})); + lock_or_hide(&mut s, words, true); + select(&mut s, &[words]); + assert!(s.execute("addon.cleanup.breakText", &json!({"by": "words"})).is_err()); + let steps = undo_steps(&s); + let r = s.execute("addon.cleanup.breakText", &json!({"by": "words", "ids": [words.0]})).unwrap(); + assert_eq!((ids(&r).len(), undo_steps(&s)), (2, steps + 1)); + assert!(s.doc().unwrap().selection.objects.is_empty(), "the locked pieces stay unselected"); + + let mut s = session(); + let a = text(&mut s, json!({"x": 50, "y": 100, "text": "Left", "size": 20})); + let b = text(&mut s, json!({"x": 110, "y": 100, "text": "Right", "size": 20})); + lock_or_hide(&mut s, a, false); + lock_or_hide(&mut s, b, false); + select(&mut s, &[a, b]); + assert!(s.execute("addon.cleanup.combineText", &json!({})).is_err()); + let r = s.execute("addon.cleanup.combineText", &json!({"ids": [a.0, b.0]})).unwrap(); + assert_eq!(ids(&r), [a]); + assert_eq!(obj(&s, a).plain_text(), "Left Right"); + assert!(s.doc().unwrap().selection.objects.is_empty(), "the hidden object stays unselected"); + + let mut s = session(); + let first = text(&mut s, json!({"x": 50, "y": 100, "text": "First", "size": 20})); + let second = text(&mut s, json!({"x": 50, "y": 130, "text": "Second", "size": 20})); + let layer = s.doc().unwrap().doc.layers[0].id; + lock_or_hide(&mut s, layer, true); + select(&mut s, &[first, second]); + assert!(s.execute("addon.cleanup.joinText", &json!({})).is_err()); + let r = s.execute("addon.cleanup.joinText", &json!({"ids": [first.0, second.0]})).unwrap(); + assert_eq!(r["id"].as_u64(), Some(first.0)); + assert_eq!(obj(&s, first).plain_text(), "First\nSecond"); + assert!(s.doc().unwrap().selection.objects.is_empty(), "the object in the locked layer stays unselected"); + + let mut s = session(); + let lines = text(&mut s, json!({"x": 50, "y": 100, "text": "a\nlonger line", "size": 20})); + lock_or_hide(&mut s, lines, false); + select(&mut s, &[lines]); + assert!(s.execute("addon.cleanup.alignInPlace", &json!({"align": "center"})).is_err()); + s.execute("addon.cleanup.alignInPlace", &json!({"align": "center", "ids": [lines.0]})).unwrap(); + assert!(obj(&s, lines).para_styles().all(|p| p.justify == Justify::Center)); + + let mut s = session(); + let turned = text(&mut s, json!({"x": 300, "y": 200, "text": "Turned", "size": 18, "rotation": 30})); + lock_or_hide(&mut s, turned, true); + select(&mut s, &[turned]); + assert!(s.execute("addon.cleanup.resetTextTransform", &json!({})).is_err()); + let steps = undo_steps(&s); + s.execute("addon.cleanup.resetTextTransform", &json!({"ids": [turned.0]})).unwrap(); + assert_eq!(undo_steps(&s), steps + 1); + let [_, b, c, _, _, _] = obj(&s, turned).xf.as_coeffs(); + assert!(b.abs() < 1e-9 && c.abs() < 1e-9, "the rotation is gone"); +} + #[test] fn split_at_the_cursor_and_around_a_selection() { for (anchor, caret, want) in [(6, 6, &["Split", "here please"][..]), (6, 10, &["Split", "here", "please"][..])] { diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..a9b621b298 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10642,7 +10642,9 @@ topmost piece. ### Text tools The add-on's text tools act on the selected type (or `ids`), each as one undo step, and refuse with an error when there -is nothing for them to do. The pieces they make are point type that keeps its characters' styles, each placed so the +is nothing for them to do. From the selection they take only type that can be edited; the type that `ids` names, or +that is inside a group or layer it names, is taken even when it, its group or its layer is locked or hidden (not type +on a locked artboard). The objects they make from locked or hidden type are not selected. The pieces they make are point type that keeps its characters' styles, each placed so the glyph of its first character lands where it was drawn. - `addon.cleanup.breakText {by?, ids?}` turns each horizontal point or area type object into point type objects, one diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..a5953d677e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2048,6 +2048,10 @@ Line / Paragraph Breaks, Set Alignment, Keep Position, Reset Text Transform and refusals), `addons::cleanup::tests` in `vectorcraft-ui-egui` (the submenu and the panel's Text row run them) and `cleanup_text_tools_with_junk_editing_ranges` in the command sweep. +With `ids`, the text tools act on the type the ids name even when it, or its group or layer, is locked or hidden, as +`text.convertListToText` does; from the selection they still take only type that can be edited (VectorCraft's own +rule). Tests: `named_locked_and_hidden_type` and the other `named_` tests in `cmd::addons::cleanup::text::tests`. + ## Path Precision Tools add-on (2026-10-30) A VectorCraft addition, not a feature of the reference app, so no area score moves. Object › Plug-ins › Path Precision Tools, From 8887806cb20b2aaf11fb95bb2dd13d54cd23e0f4 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:16:15 -0800 Subject: [PATCH 051/108] Undo: no step when Randomize Opacity or a type setting changes nothing - addon.arrange.randomizeOpacity, type.orientation.vertical and .horizontal, type.opticalMarginAlignment, type.systemLayout and type.fractionalWidths run through edit_if_changed (the Edit Colors helper) and record an undo step only when an opacity, a direction or a setting changes. - A test for each command; the params text says so, and docs/mcp.md for the commands it describes. --- crates/engine/src/cmd/addons/arrange.rs | 8 ++- crates/engine/src/cmd/addons/arrange/tests.rs | 19 +++++ crates/engine/src/cmd/typecmd.rs | 69 ++++++++++++------- crates/engine/src/cmd/typecmd/area_tests.rs | 20 ++++++ docs/mcp.md | 6 +- 5 files changed, 93 insertions(+), 29 deletions(-) diff --git a/crates/engine/src/cmd/addons/arrange.rs b/crates/engine/src/cmd/addons/arrange.rs index d7cae868ed..3dd2e0e43b 100644 --- a/crates/engine/src/cmd/addons/arrange.rs +++ b/crates/engine/src/cmd/addons/arrange.rs @@ -21,6 +21,7 @@ use vectorcraft_geom::{Affine, Point, Rect}; use vectorcraft_render::effects; use super::super::appearance::series_children_in_paint_order; +use super::super::colorcmds::edit_if_changed; use super::super::edit::selected_roots; use super::super::graph::capture_series_object_opacity; use super::super::menucmds::whole_or; @@ -92,7 +93,7 @@ pub fn specs() -> Vec<CommandSpec> { "Randomize Opacity", ["Object", "Plug-ins", "Arrange Tools"], None, - "{min?: % 0..100 (30), max?: % 0..100 (100; not less than min), seed?: whole number (0; the same seed, objects and range give the same opacities), ids?: [id…] (default: the selection)} give each selected object (the top-level ones) its own opacity, picked at random and evenly from min to max, as one undo step; it is the object's opacity, as the Transparency panel sets it. On paths directly in a graph series whose opacity changes, the graph stores the opacity and blend mode of the frontmost of them for its next redraw (docs/mcp.md) → {count}", + "{min?: % 0..100 (30), max?: % 0..100 (100; not less than min), seed?: whole number (0; the same seed, objects and range give the same opacities), ids?: [id…] (default: the selection)} give each selected object (the top-level ones) its own opacity, picked at random and evenly from min to max, as one undo step (none when no opacity changes); it is the object's opacity, as the Transparency panel sets it. On paths directly in a graph series whose opacity changes, the graph stores the opacity and blend mode of the frontmost of them for its next redraw (docs/mcp.md) → {count}", has_selection, randomize_opacity ), @@ -397,7 +398,8 @@ fn randomize_opacity(s: &mut Session, p: &Value) -> Result<Value> { return Ok(json!({ "count": 0 })); } let (lo, hi) = ((min / 100.0) as f32, (max / 100.0) as f32); - s.edit("Randomize Opacity", |d, _| { + // A run that gives every object the opacity it has records no undo step. + edit_if_changed(s, "Randomize Opacity", |_, d| { let mut changed = vec![]; for id in &ids { let o = rng.range(lo, hi); @@ -409,7 +411,7 @@ fn randomize_opacity(s: &mut Session, p: &Value) -> Result<Value> { } } keep_series_opacity(d, &changed); - Ok(()) + Ok(((), !changed.is_empty())) })?; Ok(json!({ "count": ids.len() })) } diff --git a/crates/engine/src/cmd/addons/arrange/tests.rs b/crates/engine/src/cmd/addons/arrange/tests.rs index 85191935b2..759f6f321e 100644 --- a/crates/engine/src/cmd/addons/arrange/tests.rs +++ b/crates/engine/src/cmd/addons/arrange/tests.rs @@ -393,6 +393,25 @@ fn randomize_opacity_takes_ids_and_leaves_the_rest() { assert_eq!((opacity(&s, g), opacity(&s, a), opacity(&s, b)), (0.2, 1.0, 1.0)); } +#[test] +fn randomize_opacity_records_no_undo_step_when_no_opacity_changes() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 5.0, 5.0); + let b = rect(&mut s, 10.0, 0.0, 5.0, 5.0); + select(&mut s, &[a, b]); + let n = steps(&s); + // Every object already has the one opacity the range allows. + let r = s.execute("addon.arrange.randomizeOpacity", &json!({"min": 100, "max": 100})).unwrap(); + assert_eq!(r["count"], json!(2)); + assert_eq!(steps(&s), n); + assert_eq!((opacity(&s, a), opacity(&s, b)), (1.0, 1.0)); + s.execute("addon.arrange.randomizeOpacity", &json!({"min": 40, "max": 40})).unwrap(); + assert_eq!(steps(&s), n + 1); + s.execute("addon.arrange.randomizeOpacity", &json!({"min": 40, "max": 40})).unwrap(); + assert_eq!(steps(&s), n + 1, "the same opacities again"); + assert_eq!((opacity(&s, a), opacity(&s, b)), (0.4, 0.4)); +} + #[test] fn randomize_opacity_refuses_bad_params() { let mut s = session(); diff --git a/crates/engine/src/cmd/typecmd.rs b/crates/engine/src/cmd/typecmd.rs index 6b14c98916..ffb6655507 100644 --- a/crates/engine/src/cmd/typecmd.rs +++ b/crates/engine/src/cmd/typecmd.rs @@ -23,7 +23,7 @@ pub fn specs() -> Vec<CommandSpec> { "Vertical", ["Type", "Orientation"], None, - "{ids?|id?} set vertical writing for the selected type and every frame of its threads → {vertical, ids}", + "{ids?|id?} set vertical writing for the selected type and every frame of its threads; no undo step when every object is already vertical → {vertical, ids}", has_selection, |s, p| orientation(s, p, true) ), @@ -32,7 +32,7 @@ pub fn specs() -> Vec<CommandSpec> { "Horizontal", ["Type", "Orientation"], None, - "{ids?|id?} set horizontal writing for the selected type and every frame of its threads → {vertical, ids}", + "{ids?|id?} set horizontal writing for the selected type and every frame of its threads; no undo step when every object is already horizontal → {vertical, ids}", has_selection, |s, p| orientation(s, p, false) ), @@ -59,7 +59,7 @@ pub fn specs() -> Vec<CommandSpec> { "Optical Margin Alignment", ["Type"], None, - "{ids?|id?, on?: bool} turn Optical Margin Alignment on or off for the selected type and every frame of its threads (on omitted: the opposite of the first object's setting): in every paragraph of point and area type, quotation marks, hyphens, full stops and commas at a line's start or end hang wholly outside the margin there; asterisks, tildes, ellipses, en and em dashes, colons and semicolons hang by half; and A, V, W, Y, v, w and y hang by a tenth of their advance; a left-aligned line hangs at its left margin, a right-aligned line hangs at its right margin, and centered and justified lines hang at both; Auto aligns a right-to-left line at its right; type on a path hangs at the start bracket when its line is placed there, hangs at the end bracket when the line is placed there, and hangs at both when it is centered → {on, ids}", + "{ids?|id?, on?: bool} turn Optical Margin Alignment on or off for the selected type and every frame of its threads (on omitted: the opposite of the first object's setting): in every paragraph of point and area type, quotation marks, hyphens, full stops and commas at a line's start or end hang wholly outside the margin there; asterisks, tildes, ellipses, en and em dashes, colons and semicolons hang by half; and A, V, W, Y, v, w and y hang by a tenth of their advance; a left-aligned line hangs at its left margin, a right-aligned line hangs at its right margin, and centered and justified lines hang at both; Auto aligns a right-to-left line at its right; type on a path hangs at the start bracket when its line is placed there, hangs at the end bracket when the line is placed there, and hangs at both when it is centered; no undo step when every object already has the setting → {on, ids}", has_selection, optical_margin_alignment ), @@ -68,7 +68,7 @@ pub fn specs() -> Vec<CommandSpec> { "System Layout", [], None, - "{on?: bool} turn System Layout on or off for the document (on omitted: the opposite of the document's setting) and every text object in it. On, each character that takes any space advances by a whole number of points, at least one, so small type does not run together; a character with no width stays at none. Off (the default, and what a document from before it reads as), spacing uses fractions of a point. New point, area and path type inherits the document's setting → {on}", + "{on?: bool} turn System Layout on or off for the document (on omitted: the opposite of the document's setting) and every text object in it. On, each character that takes any space advances by a whole number of points, at least one, so small type does not run together; a character with no width stays at none. Off (the default, and what a document from before it reads as), spacing uses fractions of a point. New point, area and path type inherits the document's setting. No undo step when the document and every text object already have the setting → {on}", has_doc, system_layout ), @@ -77,7 +77,7 @@ pub fn specs() -> Vec<CommandSpec> { "Fractional Widths", [], None, - "{ids?|id?, on?: bool} turn Fractional Widths on or off for the selected type and every frame of its threads (on omitted: the opposite of the first object's setting). On (the default, and what a document from before it reads as), spacing between characters uses fractions of a point. Off, each character that takes any space advances by a whole number of points, at least one, so small type does not run together; a character with no width stays at none. The setting is the whole type object, not a range of characters → {on, ids}", + "{ids?|id?, on?: bool} turn Fractional Widths on or off for the selected type and every frame of its threads (on omitted: the opposite of the first object's setting). On (the default, and what a document from before it reads as), spacing between characters uses fractions of a point. Off, each character that takes any space advances by a whole number of points, at least one, so small type does not run together; a character with no width stays at none. The setting is the whole type object, not a range of characters. No undo step when every object already has the setting → {on, ids}", has_selection, fractional_widths ), @@ -157,24 +157,30 @@ pub fn specs() -> Vec<CommandSpec> { } /// Type › Type Orientation: set vertical or horizontal writing on every selected text object and -/// every frame of their threads, in one undo step. +/// every frame of their threads, in one undo step (none when nothing changes). fn orientation(s: &mut Session, p: &Value, vertical: bool) -> Result<Value> { let ids = super::threads::with_threads(&s.doc()?.doc, &text_targets(s, p, "Text Orientation")?); - s.edit("Text Orientation", |d, _| { + // When every object already has the orientation, the document and its undo history stay as they are. + super::colorcmds::edit_if_changed(s, "Text Orientation", |_, d| { + let mut changed = false; for id in &ids { let Some(NodeKind::Text(t)) = d.node_mut(*id).map(|n| &mut n.kind) else { return Err(EngineError::NoNode(*id)); }; - t.vertical = vertical; - refresh_bounds(t); + if t.vertical != vertical { + t.vertical = vertical; + refresh_bounds(t); + changed = true; + } } - Ok(()) + Ok(((), changed)) })?; Ok(json!({"vertical": vertical, "ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()})) } /// Type › Optical Margin Alignment: set `on` (without it, the opposite of the first object's -/// setting) on every selected text object and every frame of their threads, in one undo step. +/// setting) on every selected text object and every frame of their threads, in one undo step +/// (none when nothing changes). fn optical_margin_alignment(s: &mut Session, p: &Value) -> Result<Value> { let ids = super::threads::with_threads(&s.doc()?.doc, &text_targets(s, p, "Optical Margin Alignment")?); let first = ids.first().and_then(|id| match s.doc().ok()?.doc.node(*id).map(|n| &n.kind) { @@ -182,29 +188,38 @@ fn optical_margin_alignment(s: &mut Session, p: &Value) -> Result<Value> { _ => None, }); let on = switch_or(p, "on", !first.unwrap_or(false), "type.opticalMarginAlignment")?; - s.edit("Optical Margin Alignment", |d, _| { + // When every object already has the setting, the document and its undo history stay as they are. + super::colorcmds::edit_if_changed(s, "Optical Margin Alignment", |_, d| { + let mut changed = false; for id in &ids { let Some(NodeKind::Text(t)) = d.node_mut(*id).map(|n| &mut n.kind) else { return Err(EngineError::NoNode(*id)); }; - t.optical_margin = on; - refresh_bounds(t); + if t.optical_margin != on { + t.optical_margin = on; + refresh_bounds(t); + changed = true; + } } - Ok(()) + Ok(((), changed)) })?; Ok(json!({"on": on, "ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()})) } /// Character panel menu › System Layout: set `on` (without it, the opposite of the document's -/// setting) on the document and every text object, in one undo step. Off is the default. +/// setting) on the document and every text object, in one undo step (none when nothing changes). +/// Off is the default. fn system_layout(s: &mut Session, p: &Value) -> Result<Value> { let current = s.doc()?.doc.setup.system_layout; let on = switch_or(p, "on", !current, "type.systemLayout")?; - s.edit("System Layout", |d, _| { + // When the document and every text object already have the setting, the document and its undo + // history stay as they are. + super::colorcmds::edit_if_changed(s, "System Layout", |_, d| { + let mut changed = d.setup.system_layout != on; d.setup.system_layout = on; let mut ids = vec![]; d.walk(|n| { - if matches!(n.kind, NodeKind::Text(_)) { + if matches!(&n.kind, NodeKind::Text(t) if t.system_layout != on) { ids.push(n.id); } }); @@ -214,15 +229,16 @@ fn system_layout(s: &mut Session, p: &Value) -> Result<Value> { }; t.system_layout = on; refresh_bounds(t); + changed = true; } - Ok(()) + Ok(((), changed)) })?; Ok(json!({ "on": on })) } /// Character panel menu › Fractional Widths: set `on` (without it, the opposite of the first /// object's setting) on every selected text object and every frame of their threads, in one undo -/// step. On is the default. +/// step (none when nothing changes). On is the default. fn fractional_widths(s: &mut Session, p: &Value) -> Result<Value> { let ids = super::threads::with_threads(&s.doc()?.doc, &text_targets(s, p, "Fractional Widths")?); let first = ids.first().and_then(|id| match s.doc().ok()?.doc.node(*id).map(|n| &n.kind) { @@ -230,15 +246,20 @@ fn fractional_widths(s: &mut Session, p: &Value) -> Result<Value> { _ => None, }); let on = switch_or(p, "on", !first.unwrap_or(true), "type.fractionalWidths")?; - s.edit("Fractional Widths", |d, _| { + // When every object already has the setting, the document and its undo history stay as they are. + super::colorcmds::edit_if_changed(s, "Fractional Widths", |_, d| { + let mut changed = false; for id in &ids { let Some(NodeKind::Text(t)) = d.node_mut(*id).map(|n| &mut n.kind) else { return Err(EngineError::NoNode(*id)); }; - t.fractional_widths = on; - refresh_bounds(t); + if t.fractional_widths != on { + t.fractional_widths = on; + refresh_bounds(t); + changed = true; + } } - Ok(()) + Ok(((), changed)) })?; Ok(json!({"on": on, "ids": ids.iter().map(|id| id.0).collect::<Vec<_>>()})) } diff --git a/crates/engine/src/cmd/typecmd/area_tests.rs b/crates/engine/src/cmd/typecmd/area_tests.rs index c68334e2c0..52c609fa9f 100644 --- a/crates/engine/src/cmd/typecmd/area_tests.rs +++ b/crates/engine/src/cmd/typecmd/area_tests.rs @@ -199,8 +199,11 @@ fn optical_margin_alignment_is_set_per_object_and_saved_only_when_on() { assert!(left(&s) < inside - 5.0, "{} {inside}", left(&s)); assert_eq!(serde_json::to_value(text(&s)).unwrap()["opticalMarginAlignment"], true); // `on` sets it; without `on` it toggles. + // Setting the value the type already has: no undo step. + let n = s.doc().unwrap().history.undo.len(); assert_eq!(s.execute("type.opticalMarginAlignment", &json!({"on": true})).unwrap()["on"], true); assert!(text(&s).optical_margin); + assert_eq!(s.doc().unwrap().history.undo.len(), n); assert_eq!(s.execute("type.opticalMarginAlignment", &json!({})).unwrap()["on"], false); assert!(!text(&s).optical_margin); assert_eq!(left(&s), inside); @@ -247,6 +250,10 @@ fn system_layout_sets_the_document_and_every_text_object() { assert!(fractional.iter().zip(&whole).any(|(a, b)| (a - b).abs() > 0.05), "{fractional:?} {whole:?}"); assert_eq!(serde_json::to_value(setup(&s)).unwrap()["systemLayout"], true); assert_eq!(serde_json::to_value(text(&s, id)).unwrap()["systemLayout"], true); + // Setting the value the document and its type already have: no undo step. + let n = s.doc().unwrap().history.undo.len(); + assert_eq!(s.execute("type.systemLayout", &json!({"on": true})).unwrap()["on"], true); + assert_eq!(s.doc().unwrap().history.undo.len(), n); // New type inherits the document's setting. let made = s.execute("text.create", &json!({"x": 10, "y": 120, "text": "Z"})).unwrap()["id"].as_u64().unwrap(); assert!(text(&s, made).system_layout); @@ -305,6 +312,10 @@ fn fractional_widths_is_set_per_object_and_saved_only_when_off() { assert!(text(&s).fractional_widths); assert_eq!(s.execute("type.fractionalWidths", &json!({"on": false})).unwrap()["on"], false); assert!(!text(&s).fractional_widths); + // Setting the value the type already has: no undo step. + let n = s.doc().unwrap().history.undo.len(); + assert_eq!(s.execute("type.fractionalWidths", &json!({"on": false})).unwrap()["on"], false); + assert_eq!(s.doc().unwrap().history.undo.len(), n); // One undo step. s.execute("edit.undo", &json!({})).unwrap(); assert!(text(&s).fractional_widths); @@ -2277,8 +2288,17 @@ fn vertical_point_type_keeps_its_anchor_on_the_column_centre_line() { let tall = bounds(&s); assert!(tall.height() > tall.width(), "{tall:?}"); assert!((tall.center().x - 100.0).abs() < 6.0, "the anchor stays on the column's centre line: {tall:?}"); + // Vertical type set vertical again: no undo step. + let n = s.doc().unwrap().history.undo.len(); + s.execute("type.orientation.vertical", &json!({})).unwrap(); + assert_eq!(s.doc().unwrap().history.undo.len(), n); + assert_eq!(bounds(&s), tall); s.execute("edit.undo", &json!({})).unwrap(); assert_eq!(bounds(&s), wide); + // Horizontal type set horizontal: no undo step either. + let n = s.doc().unwrap().history.undo.len(); + s.execute("type.orientation.horizontal", &json!({})).unwrap(); + assert_eq!(s.doc().unwrap().history.undo.len(), n); } #[test] diff --git a/docs/mcp.md b/docs/mcp.md index f756bc8c97..686da1d88f 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -672,7 +672,8 @@ CJK composition. (the selection, or `ids`) and reply `{vertical, ids}`. The writing direction is a setting of the whole thread: the commands set every frame of a selected frame's thread, and `ids` lists them all. Threading frames gives the thread its first frame's direction, frames taken out of a thread keep theirs, and a file whose frames of one thread differ opens -with the first frame's direction in all of them. +with the first frame's direction in all of them. When every frame already has the direction, the command records no +undo step. For SVG/SVGZ, `export`'s top-level `outlineText: true` writes text as paths; DXF takes it too (its type is outlined anyway unless `preserve: editability`). PDF instead uses `options: {"advanced": {"outlineText": true}}`; its default is false (live text). @@ -8802,6 +8803,7 @@ for the selected type objects (or `ids`); without `on` it sets the opposite of t on. Optical Margin Alignment is a setting of the whole thread: the command sets every frame of a selected frame's thread, and `ids` lists them all. Threading frames gives the thread its first frame's setting, frames taken out of a thread keep it, and a file whose frames of one thread differ opens with the first frame's setting in all of them. +When every frame already has the setting, the command records no undo step. In every paragraph of point and area type, these characters hang outside the margin when they start or end a line: quotation marks, hyphens (a hyphenated line's hyphen too), full stops and commas hang wholly; asterisks, tildes, ellipses, en and em dashes, colons and semicolons hang by half their width; and A, V, W, Y, v, w @@ -11341,7 +11343,7 @@ as `object.setBounds` measures them (Use Preview Bounds), except Arrange in Grid | `addon.arrange.replace` | `fit`: `keep`, `bounds` (the replaced object's width and height), `proportional` (fits inside them) (`keep`); `scaleStrokes`; `keep` (false) | Puts a copy of the topmost selected object centred on each of the other selected objects, in that object's place in the stacking order; the replaced objects are deleted unless `keep` (the copy then goes right above each). Needs two objects or more; the copies are selected. → `{ids}` | | `addon.arrange.size` | `width`, `height` pt, 0.001…1000000 (at least one); `proportional` (false: a side not given stays; true: it follows the given one in proportion); `reference` 0…8 (4, the centre); `scaleStrokes` | Gives every selected object that width and height, keeping its reference point in place (the 9-point grid row by row from the top-left). | | `addon.arrange.groupOverlapping` | none | Groups the selected objects (at most 20000) wherever their visual bounds overlap or touch, chains included: when A overlaps B and B overlaps C, all three go in one group. Only objects in the same layer or group are grouped together; objects that overlap nothing stay as they are. Each new group goes where its frontmost member was in the stacking order, and the groups and the objects left alone stay selected; with nothing overlapping it makes no step. Needs two objects or more. → `{groups: [id…], grouped}` (how many objects went into groups) | -| `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. → `{count}` | +| `addon.arrange.randomizeOpacity` | `min`, `max` % 0…100 (30, 100; `min` not more than `max`); `seed` whole number (0); `ids` (the selection) | Gives each selected object its own opacity (the object opacity the Transparency panel sets), picked at random and evenly from `min` to `max`; the same seed, objects and range give the same opacities. Groups take one opacity of their own; the objects inside keep theirs. A run that changes no opacity, such as `min` and `max` both at the opacity every object has, records no undo step. → `{count}` | | `addon.arrange.sort` | `by`, `apply`: `width`, `height`, `area` (width × height), `x` (left edge), `y` (top edge), `opacity` (%), `stacking` (stacking order from the back) (`area`, `stacking`); `order`: `ascending` (small to large), `descending` (large to small), `random` (`ascending`); `distribute` (false); `seed` whole number (0, for `random`); `scaleStrokes`; `ids` (the selection) | Sorts the selected objects (at most 20000) by `by` and gives them the values of `apply` in that order: the first gets the smallest value. Without `distribute` the objects trade the values they have; with it the values step evenly from the smallest to the largest. A width, height or area changes about each object's centre (an area in proportion), a place moves the top-left corner. Stacking order always trades places, and only among objects in the same layer or group. Needs two objects or more. → `{count}` | Zoom to Selection is the UI command `addon.arrange.zoomSelection {}` (remote mode only): it zooms and centres the From dcba7a76b8731ca370f63cc427ac701863e40477 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:41:37 -0800 Subject: [PATCH 052/108] i18n: Polish translates 114 status and error messages that no catalog had untranslated_report lists 167 status and error messages under "messages, all 23 languages checked". pl.tsv gains @msg rows for 114 of them, in one commented block at the end of the file: image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, 3D and Revolve limits, and script, zip, line and file errors. Placeholders, parameter names, command ids and literal values stay as the English writes them. The other 53 are translated by #7211, #7378 and #7405 and are left out. --- crates/ui-egui/src/i18n/pl.tsv | 116 +++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 48f2671c2d..d899112ee2 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -9159,3 +9159,119 @@ breakText Glyphs Glify @msg {what} can't be intertwined {what} nie można przeplatać @msg {what} doesn't fit the paper with its bleed and marks {what} nie mieści się na papierze wraz ze spadem i znacznikami @msg {what} would print on more than {MAX_TILES} tiles: scale it down {what}: wydruk zająłby ponad {MAX_TILES} kafelków: zmniejsz skalę + +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +@msg 3D effects require finite coordinates within 100 million points Efekty 3D wymagają skończonych współrzędnych w zakresie 100 milionów punktów +@msg 3D effects require one to ten lights Efekty 3D wymagają od jednego do dziesięciu świateł +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel Głębia BMP {_1}: 1, 4, 8, 16, 24 lub 32 bity na piksel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer Kodowanie BMP nie powiodło się: {width} × {height} pikseli nie mieści się w formacie ani w buforze pikseli +@msg GIF encoding failed: the palette image is malformed Kodowanie GIF nie powiodło się: obraz z paletą jest nieprawidłowy +@msg GIF encoding failed: {e} Kodowanie GIF nie powiodło się: {e} +@msg JPEG colour profile: {e} Profil kolorów JPEG: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size Kodowanie JPEG nie powiodło się: bufor pikseli nie odpowiada rozmiarowi obrazu +@msg JPEG encoding failed: {e} Kodowanie JPEG nie powiodło się: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size Kodowanie PNG nie powiodło się: bufor pikseli nie odpowiada rozmiarowi obrazu +@msg PNG encoding failed: the palette image is malformed Kodowanie PNG nie powiodło się: obraz z paletą jest nieprawidłowy +@msg PNG encoding failed: {e} Kodowanie PNG nie powiodło się: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size Kodowanie PNG nie powiodło się: {width} × {height} pikseli to nieprawidłowy rozmiar obrazu +@msg PSD colour profile: {e} Profil kolorów PSD: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size Kodowanie PSD nie powiodło się: bufor pikseli nie odpowiada rozmiarowi obrazu +@msg Revolve profile contains invalid coordinates Profil efektu Obrót zawiera nieprawidłowe współrzędne +@msg Revolve profile is too complex Profil efektu Obrót jest zbyt złożony +@msg Revolve projection is not finite Rzut efektu Obrót nie jest skończony +@msg Revolve requires finite profile coordinates within 100 million points Efekt Obrót wymaga skończonych współrzędnych profilu w zakresie 100 milionów punktów +@msg Revolve surface is too complex; reduce Segments or simplify the profile Powierzchnia efektu Obrót jest zbyt złożona; zmniejsz Segmenty lub uprość profil +@msg Revolve surface is too complex; simplify the profile Powierzchnia efektu Obrót jest zbyt złożona; uprość profil +@msg Revolve visibility cannot split the projected boundary Obliczanie widoczności efektu Obrót nie może podzielić rzutowanej granicy +@msg Revolve visibility creates too many fragments Obliczanie widoczności efektu Obrót tworzy zbyt wiele fragmentów +@msg Revolve visibility creates too many vector anchors Obliczanie widoczności efektu Obrót tworzy zbyt wiele wektorowych punktów kontrolnych +@msg Revolve visibility exceeds its geometry work limit Obliczanie widoczności efektu Obrót przekracza swój limit obliczeń geometrycznych +@msg Revolve visibility exceeds its spatial index limit Obliczanie widoczności efektu Obrót przekracza swój limit indeksu przestrzennego +@msg Revolve visibility has too many boundary crossings Obliczanie widoczności efektu Obrót napotyka zbyt wiele przecięć granicy +@msg Revolve visibility has too many input anchors Obliczanie widoczności efektu Obrót otrzymuje zbyt wiele wejściowych punktów kontrolnych +@msg Revolve visibility requires convex cap sectors Obliczanie widoczności efektu Obrót wymaga wypukłych sektorów zakończenia +@msg Revolve visibility requires finite projected faces Obliczanie widoczności efektu Obrót wymaga skończonych rzutowanych ścian +@msg SVG options: {e} Opcje SVG: {e} +@msg Save for Web settings: {e} Ustawienia Zapisz dla Internetu: {e} +@msg TIFF colour profile: {e} Profil kolorów TIFF: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size Kodowanie TIFF nie powiodło się: bufor pikseli nie odpowiada rozmiarowi obrazu +@msg TIFF encoding failed: {e} Kodowanie TIFF nie powiodło się: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Głębia Targa {_1}: 16, 24 lub 32 bity na piksel +@msg Targa encoding failed: the pixel buffer doesn't match the image size Kodowanie Targa nie powiodło się: bufor pikseli nie odpowiada rozmiarowi obrazu +@msg The 3D projection is not finite Rzut 3D nie jest skończony +@msg The 3D shadow is too complex; turn Shadows off or simplify the art Cień 3D jest zbyt złożony; wyłącz Cienie lub uprość grafikę +@msg The shape contains invalid coordinates Kształt zawiera nieprawidłowe współrzędne +@msg Too many Revolve faces for visibility evaluation Zbyt wiele ścian efektu Obrót do obliczenia widoczności +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft odczytuje z pliku wymiany próbek najwyżej {ASE_MAX_ENTRIES} kolorów i grup, a ta biblioteka ma ich {entries} +@msg WebP encoding failed: {e} Kodowanie WebP nie powiodło się: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` ma wartość smallThumb, mediumThumb, largeThumb, smallList lub largeList +@msg a line can't run from a point to itself linia nie może prowadzić od punktu do niego samego +@msg a line needs at least two points linia wymaga co najmniej dwóch punktów +@msg a number cannot be read nie można odczytać liczby +@msg a swatch exchange block is too long blok pliku wymiany próbek jest zbyt długi +@msg a swatch exchange name is too long nazwa w pliku wymiany próbek jest zbyt długa +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels nie można zmienić rozmiaru obrazu {sw} × {sh} na {width} × {height} pikseli +@msg a {width} × {height} image is too large obraz {width} × {height} jest zbyt duży +@msg a {width} × {height} image: {e} obraz {width} × {height}: {e} +@msg an image could not be written: {e} nie udało się zapisać obrazu: {e} +@msg an image that couldn't be read was left out pominięto obraz, którego nie udało się odczytać +@msg can't open “{name}”: {e} nie można otworzyć „{name}”: {e} +@msg cannot align zip entries to {align} bytes nie można wyrównać wpisów zip do {align} bajtów +@msg cannot open the automation {kind} root `{_1}`: {e} nie można otworzyć katalogu głównego automatyzacji ({kind}) `{_1}`: {e} +@msg cannot read profile: {0} nie można odczytać profilu: {0} +@msg color book version {version} isn't supported (only 1) wersja księgi kolorów {version} nie jest obsługiwana (tylko 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) księgi kolorów w przestrzeni kolorów {other} nie są obsługiwane (tylko RGB, CMYK i Lab) +@msg file name too long to zip: {_1} nazwa pliku jest zbyt długa dla archiwum zip: {_1} +@msg file name too long to zip: {name} nazwa pliku jest zbyt długa dla archiwum zip: {name} +@msg freeform line {i}: {e} dowolna linia {i}: {e} +@msg freeform point {i}: {e} dowolny punkt {i}: {e} +@msg give `{key}` or `{other}`, not both podaj `{key}` lub `{other}`, nie oba naraz +@msg grayscale profiles can't be working spaces yet profile w skali szarości nie mogą jeszcze być przestrzeniami roboczymi +@msg input contains NaN or infinite coordinates dane wejściowe zawierają współrzędne NaN lub nieskończone +@msg input path could not be closed nie udało się zamknąć ścieżki wejściowej +@msg invalid ICC profile: {0} nieprawidłowy profil ICC: {0} +@msg invalid scale {scale} nieprawidłowa skala {scale} +@msg its localized names take more than {_1} KB jego zlokalizowane nazwy zajmują ponad {_1} KB +@msg its objects are nested too deep ({e}) jego obiekty są zagnieżdżone zbyt głęboko ({e}) +@msg its tag table lists the `{_1}` tag more than once jego tablica znaczników wymienia znacznik `{_1}` więcej niż raz +@msg not a graphic style library: {e} to nie jest biblioteka stylów graficznych: {e} +@msg not a swatch library (.vcswatches or .gpl) to nie jest biblioteka próbek (.vcswatches lub .gpl) +@msg not a swatch library (format `{_1}`) to nie jest biblioteka próbek (format `{_1}`) +@msg not a swatch library: {e} to nie jest biblioteka próbek: {e} +@msg not an action set file ({e}) to nie jest plik zestawu operacji ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray przestrzeń kolorów profilu {other} nie jest RGB, CMYK ani skalą szarości +@msg regular expression too large wyrażenie regularne jest zbyt duże +@msg script file is not UTF-8 text: {value} plik skryptu nie jest tekstem UTF-8: {value} +@msg stop {i}: {e} punkt koloru {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) wersja pliku wymiany próbek {major}.{minor} nie jest obsługiwana (tylko 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors księga kolorów zawiera ponad {ASE_MAX_ENTRIES} kolorów +@msg the color book is cut short księga kolorów jest ucięta +@msg the color book's names take more than {_1} MB nazwy w księdze kolorów zajmują ponad {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution obraz miałby {w} × {h} pikseli; eksport rastrowy jest ograniczony do {MAX_RASTER_SIDE} pikseli na bok i {_1} megapikseli: zmniejsz skalę lub rozdzielczość +@msg the optimised image can't be read back: {e} nie można ponownie odczytać zoptymalizowanego obrazu: {e} +@msg the pixel buffer doesn't match the image size bufor pikseli nie odpowiada rozmiarowi obrazu +@msg the preview: {e} podgląd: {e} +@msg the request may not read the New Document profiles folder żądanie nie ma uprawnień do odczytu folderu profili nowego dokumentu +@msg the shapes are too degenerate to combine kształty są zbyt zdegenerowane, aby je połączyć +@msg the shapes cross themselves and each other too often to combine kształty zbyt często przecinają same siebie i siebie nawzajem, aby je połączyć +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups plik wymiany próbek zawiera ponad {ASE_MAX_ENTRIES} kolorów i grup +@msg the swatch exchange file is cut short plik wymiany próbek jest ucięty +@msg the {_1} plate can't be read: {e} nie można odczytać płyty {_1}: {e} +@msg this binary DXF file is damaged or cut short ten binarny plik DXF jest uszkodzony lub ucięty +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that to rysunek DWG, którego nie można odczytać: zapisz go w programie CAD jako DXF i otwórz ten plik +@msg too many classes zbyt wiele klas +@msg too many groups zbyt wiele grup +@msg too many layers for PSD (at most 32767) zbyt wiele warstw dla formatu PSD (najwyżej 32767) +@msg too many swatch exchange blocks zbyt wiele bloków pliku wymiany próbek +@msg unknown colour profile: {0} nieznany profil kolorów: {0} +@msg {_1} clashes with a built-in profile name {_1} koliduje z nazwą wbudowanego profilu +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pikseli to za dużo dla formatu GIF (najwyżej 65535 pikseli na bok): zmniejsz rozdzielczość +@msg {_1}: no usable transform to/from sRGB {_1}: brak użytecznej transformacji do lub z sRGB +@msg {name} is not a CMYK profile {name} nie jest profilem CMYK +@msg {name} is not an RGB profile {name} nie jest profilem RGB +@msg {path}: could not be read {path}: nie udało się odczytać +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pikseli to za dużo dla formatu JPEG (najwyżej 65535 pikseli na bok): zmniejsz rozdzielczość +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pikseli to za dużo dla formatu Targa (najwyżej 65535 pikseli na bok): zmniejsz rozdzielczość +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pikseli to za dużo dla formatu PSD (najwyżej {MAX_SIDE} pikseli na bok): zmniejsz rozdzielczość From 8add55c85626247a38890bb6cae05e53c7593d2d Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:47:51 -0800 Subject: [PATCH 053/108] i18n: Korean translates 114 status and error messages that no catalog had The untranslated report listed 167 messages that no complete-message catalog had a row for. ko.tsv gains a row for the 114 of them that no open pull request translates: the 3D and Revolve limits, image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, path operations, graphic style, swatch and action set libraries, and script, zip and regular expression errors. Placeholders, backticked names and listed values stay as the English writes them. The Korean row of docs/localization-parity.md and a line in docs/target-app-parity.md give the new counts: 1,743 `@msg` rows, and 1,867 Korean messages the report still lists. --- crates/ui-egui/src/i18n/ko.tsv | 117 +++++++++++++++++++++++++++++++++ docs/localization-parity.md | 2 +- docs/target-app-parity.md | 1 + 3 files changed, 119 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 4715a413f4..848f7022c7 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -7083,3 +7083,120 @@ breakText Glyphs 글리프 Grommets 아일렛 Grommet Inset 가장자리에서 아일렛까지 거리 Diameter 지름 + +# Messages of the 3D effects, image export, color profiles, swatch exchange files, color books, DXF import, +# path operations, libraries, scripts and zip files. +@msg 3D effects require finite coordinates within 100 million points 3D 효과에는 1억 포인트 이내의 유한한 좌표가 필요합니다 +@msg 3D effects require one to ten lights 3D 효과에는 광원이 1개에서 10개까지 필요합니다 +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP 비트 심도 {_1}: 픽셀당 1, 4, 8, 16, 24 또는 32비트여야 합니다 +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP 인코딩 실패: {width} × {height}픽셀이 형식이나 픽셀 버퍼에 맞지 않습니다 +@msg GIF encoding failed: the palette image is malformed GIF 인코딩 실패: 팔레트 이미지의 형식이 잘못되었습니다 +@msg GIF encoding failed: {e} GIF 인코딩 실패: {e} +@msg JPEG colour profile: {e} JPEG 색상 프로파일: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG 인코딩 실패: 픽셀 버퍼가 이미지 크기와 맞지 않습니다 +@msg JPEG encoding failed: {e} JPEG 인코딩 실패: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG 인코딩 실패: 픽셀 버퍼가 이미지 크기와 맞지 않습니다 +@msg PNG encoding failed: the palette image is malformed PNG 인코딩 실패: 팔레트 이미지의 형식이 잘못되었습니다 +@msg PNG encoding failed: {e} PNG 인코딩 실패: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG 인코딩 실패: {width} × {height}픽셀은 올바른 이미지 크기가 아닙니다 +@msg PSD colour profile: {e} PSD 색상 프로파일: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD 인코딩 실패: 픽셀 버퍼가 이미지 크기와 맞지 않습니다 +@msg Revolve profile contains invalid coordinates 회전체 프로파일에 잘못된 좌표가 있습니다 +@msg Revolve profile is too complex 회전체 프로파일이 너무 복잡합니다 +@msg Revolve projection is not finite 회전체 투영이 유한하지 않습니다 +@msg Revolve requires finite profile coordinates within 100 million points 회전체에는 1억 포인트 이내의 유한한 프로파일 좌표가 필요합니다 +@msg Revolve surface is too complex; reduce Segments or simplify the profile 회전체 표면이 너무 복잡합니다. 세그먼트를 줄이거나 프로파일을 단순화하십시오 +@msg Revolve surface is too complex; simplify the profile 회전체 표면이 너무 복잡합니다. 프로파일을 단순화하십시오 +@msg Revolve visibility cannot split the projected boundary 회전체 가시성 계산에서 투영된 경계를 분할할 수 없습니다 +@msg Revolve visibility creates too many fragments 회전체 가시성 계산에서 조각이 너무 많이 생깁니다 +@msg Revolve visibility creates too many vector anchors 회전체 가시성 계산에서 벡터 고정점이 너무 많이 생깁니다 +@msg Revolve visibility exceeds its geometry work limit 회전체 가시성 계산이 기하 연산 한도를 넘습니다 +@msg Revolve visibility exceeds its spatial index limit 회전체 가시성 계산이 공간 인덱스 한도를 넘습니다 +@msg Revolve visibility has too many boundary crossings 회전체 가시성 계산에 경계 교차가 너무 많습니다 +@msg Revolve visibility has too many input anchors 회전체 가시성 계산의 입력 고정점이 너무 많습니다 +@msg Revolve visibility requires convex cap sectors 회전체 가시성 계산에는 볼록한 캡 부채꼴이 필요합니다 +@msg Revolve visibility requires finite projected faces 회전체 가시성 계산에는 유한한 투영 면이 필요합니다 +@msg SVG options: {e} SVG 옵션: {e} +@msg Save for Web settings: {e} 웹용 저장 설정: {e} +@msg TIFF colour profile: {e} TIFF 색상 프로파일: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF 인코딩 실패: 픽셀 버퍼가 이미지 크기와 맞지 않습니다 +@msg TIFF encoding failed: {e} TIFF 인코딩 실패: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa 비트 심도 {_1}: 픽셀당 16, 24 또는 32비트여야 합니다 +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa 인코딩 실패: 픽셀 버퍼가 이미지 크기와 맞지 않습니다 +@msg The 3D projection is not finite 3D 투영이 유한하지 않습니다 +@msg The 3D shadow is too complex; turn Shadows off or simplify the art 3D 그림자가 너무 복잡합니다. 그림자를 끄거나 아트를 단순화하십시오 +@msg The shape contains invalid coordinates 모양에 잘못된 좌표가 있습니다 +@msg Too many Revolve faces for visibility evaluation 회전체의 면이 너무 많아 가시성을 계산할 수 없습니다 +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft는 견본 교환 파일에서 색상과 그룹을 최대 {ASE_MAX_ENTRIES}개까지 읽는데, 이 라이브러리에는 {entries}개가 있습니다 +@msg WebP encoding failed: {e} WebP 인코딩 실패: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view`는 smallThumb, mediumThumb, largeThumb, smallList 또는 largeList여야 합니다 +@msg a line can't run from a point to itself 선은 한 점에서 같은 점으로 이어질 수 없습니다 +@msg a line needs at least two points 선에는 점이 두 개 이상 필요합니다 +@msg a number cannot be read 숫자를 읽을 수 없습니다 +@msg a swatch exchange block is too long 견본 교환 블록이 너무 깁니다 +@msg a swatch exchange name is too long 견본 교환 이름이 너무 깁니다 +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels {sw} × {sh} 이미지를 {width} × {height}픽셀로 크기 조정할 수 없습니다 +@msg a {width} × {height} image is too large {width} × {height} 이미지가 너무 큽니다 +@msg a {width} × {height} image: {e} {width} × {height} 이미지: {e} +@msg an image could not be written: {e} 이미지를 기록할 수 없습니다: {e} +@msg an image that couldn't be read was left out 읽을 수 없는 이미지를 제외했습니다 +@msg can't open “{name}”: {e} “{name}”을(를) 열 수 없습니다: {e} +@msg cannot align zip entries to {align} bytes zip 항목을 {align}바이트 단위로 정렬할 수 없습니다 +@msg cannot open the automation {kind} root `{_1}`: {e} 자동화 {kind} 루트 `{_1}`을(를) 열 수 없습니다: {e} +@msg cannot read profile: {0} 프로파일을 읽을 수 없습니다: {0} +@msg color book version {version} isn't supported (only 1) 색상 견본집 버전 {version}은(는) 지원되지 않습니다(1만 지원) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) 색상 공간이 {other}인 색상 견본집은 지원되지 않습니다(RGB, CMYK, Lab만 지원) +@msg file name too long to zip: {_1} 파일 이름이 너무 길어 zip에 넣을 수 없습니다: {_1} +@msg file name too long to zip: {name} 파일 이름이 너무 길어 zip에 넣을 수 없습니다: {name} +@msg freeform line {i}: {e} 자유형 선 {i}: {e} +@msg freeform point {i}: {e} 자유형 점 {i}: {e} +@msg give `{key}` or `{other}`, not both `{key}`와 `{other}` 중 하나만 지정하세요 +@msg grayscale profiles can't be working spaces yet 그레이스케일 프로파일은 아직 작업 공간으로 사용할 수 없습니다 +@msg input contains NaN or infinite coordinates 입력에 NaN 또는 무한대 좌표가 있습니다 +@msg input path could not be closed 입력 패스를 닫을 수 없습니다 +@msg invalid ICC profile: {0} 잘못된 ICC 프로파일: {0} +@msg invalid scale {scale} 잘못된 비율 {scale} +@msg its localized names take more than {_1} KB 지역화된 이름이 {_1} KB를 넘습니다 +@msg its objects are nested too deep ({e}) 개체가 너무 깊이 중첩되어 있습니다({e}) +@msg its tag table lists the `{_1}` tag more than once 태그 표에 `{_1}` 태그가 두 번 이상 나열되어 있습니다 +@msg not a graphic style library: {e} 그래픽 스타일 라이브러리가 아닙니다: {e} +@msg not a swatch library (.vcswatches or .gpl) 견본 라이브러리가 아닙니다(.vcswatches 또는 .gpl) +@msg not a swatch library (format `{_1}`) 견본 라이브러리가 아닙니다(형식 `{_1}`) +@msg not a swatch library: {e} 견본 라이브러리가 아닙니다: {e} +@msg not an action set file ({e}) 액션 세트 파일이 아닙니다({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray 프로파일의 색상 공간 {other}은(는) RGB, CMYK 또는 Gray가 아닙니다 +@msg regular expression too large 정규식이 너무 큽니다 +@msg script file is not UTF-8 text: {value} 스크립트 파일이 UTF-8 텍스트가 아닙니다: {value} +@msg stop {i}: {e} 정지점 {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) 견본 교환 버전 {major}.{minor}은(는) 지원되지 않습니다(1.x만 지원) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors 색상 견본집의 색상이 {ASE_MAX_ENTRIES}개를 넘습니다 +@msg the color book is cut short 색상 견본집이 중간에 잘려 있습니다 +@msg the color book's names take more than {_1} MB 색상 견본집의 이름이 {_1} MB를 넘습니다 +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution 이미지가 {w} × {h}픽셀이 됩니다. 래스터 내보내기는 한 변에 {MAX_RASTER_SIDE}픽셀, {_1}메가픽셀로 제한됩니다. 비율이나 해상도를 낮추세요 +@msg the optimised image can't be read back: {e} 최적화된 이미지를 다시 읽을 수 없습니다: {e} +@msg the pixel buffer doesn't match the image size 픽셀 버퍼가 이미지 크기와 맞지 않습니다 +@msg the preview: {e} 미리 보기: {e} +@msg the request may not read the New Document profiles folder 이 요청은 새 문서 프로파일 폴더를 읽을 수 없습니다 +@msg the shapes are too degenerate to combine 모양이 너무 퇴화되어 결합할 수 없습니다 +@msg the shapes cross themselves and each other too often to combine 모양이 자기 자신 및 서로와 너무 자주 교차하여 결합할 수 없습니다 +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups 견본 교환 파일의 색상과 그룹이 {ASE_MAX_ENTRIES}개를 넘습니다 +@msg the swatch exchange file is cut short 견본 교환 파일이 중간에 잘려 있습니다 +@msg the {_1} plate can't be read: {e} {_1} 분판을 읽을 수 없습니다: {e} +@msg this binary DXF file is damaged or cut short 이 바이너리 DXF 파일이 손상되었거나 중간에 잘려 있습니다 +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that DWG 도면은 읽을 수 없습니다. CAD 앱에서 DXF로 저장한 후 여세요 +@msg too many classes 문자 클래스가 너무 많습니다 +@msg too many groups 그룹이 너무 많습니다 +@msg too many layers for PSD (at most 32767) PSD에 비해 레이어가 너무 많습니다(최대 32767개) +@msg too many swatch exchange blocks 견본 교환 블록이 너무 많습니다 +@msg unknown colour profile: {0} 알 수 없는 색상 프로파일: {0} +@msg {_1} clashes with a built-in profile name {_1}이(가) 기본 제공 프로파일 이름과 겹칩니다 +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2}픽셀은 GIF에 비해 너무 큽니다(한 변 최대 65535픽셀). 해상도를 낮추세요 +@msg {_1}: no usable transform to/from sRGB {_1}: sRGB와 주고받을 수 있는 변환이 없습니다 +@msg {name} is not a CMYK profile {name}은(는) CMYK 프로파일이 아닙니다 +@msg {name} is not an RGB profile {name}은(는) RGB 프로파일이 아닙니다 +@msg {path}: could not be read {path}: 읽을 수 없습니다 +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height}픽셀은 JPEG에 비해 너무 큽니다(한 변 최대 65535픽셀). 해상도를 낮추세요 +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height}픽셀은 Targa에 비해 너무 큽니다(한 변 최대 65535픽셀). 해상도를 낮추세요 +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h}픽셀은 PSD에 비해 너무 큽니다(한 변 최대 {MAX_SIDE}픽셀). 해상도를 낮추세요 diff --git a/docs/localization-parity.md b/docs/localization-parity.md index 6cbad8f5e3..2c7977e1a1 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -36,7 +36,7 @@ Chinese by `imachus`). Only Georgian is recorded as reviewed by a native speaker | Indonesian | `id` | 5,279 rows, 750 of them `@msg` (counted 2026-10-21): menus and `tl!` literals complete when counted; its messages are partial; one plural form | dialogs and tooltips all; 750 message rows (French has 796) | Latin | no | full | — (review) | | Japanese | `ja` | 4,004 / 4,020 (99.6%) | all | CJK UI font as above; Japanese IME; vertical type partial; Japanese crop marks and composition settings | no | full | — (review) | | German | `de` | 3,952 / 4,020 (98%; menus, literals and messages complete when counted) | all (3,433 `@msg` and 48 `@msgplural` rows, counted 2026-11-13: the untranslated report lists 48 missing messages for it) | Latin | contributor-written, not reviewed | full | — (review) | -| Korean | `ko` | 4,870 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form | all | Hangul from an installed system font on the desktop (Apple SD Gothic Neo, Malgun Gothic, Noto Sans CJK KR…); the web build has no Korean UI font yet (craft-fonts); IME path exists | no (AI-drafted) | full | — (review; web font) | +| Korean | `ko` | 4,870 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form | dialogs and tooltips all; 1,743 `@msg` and 48 `@msgplural` rows (counted 2026-11-13): the untranslated report lists 1,867 missing messages for it | Hangul from an installed system font on the desktop (Apple SD Gothic Neo, Malgun Gothic, Noto Sans CJK KR…); the web build has no Korean UI font yet (craft-fonts); IME path exists | no (AI-drafted) | full | — (review; web font) | | Vietnamese | `vi` | 4,886 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form; 4,046 plain + 18 `@plural` + 28 contextual + 794 `@msg` | all | Latin with Vietnamese diacritics (stacked marks attach in precomposed, decomposed and keyboard forms, #4491; glyph tests pass) | contributor is a Vietnamese speaker; AI-assisted draft, further native review welcome | full | — (review) | **Historical 12-language score: ~82%** (equal weights: 100 + 85 + 100 + 0 + 0 + 100 + 100 + 100 + 100 + 98 + 100 + 100, over 12). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..7ca14d9e61 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -903,6 +903,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Edit › Undo and Edit › Redo, in the in-window and native menus, name the step in the interface language as the History panel lists it (`panels::history::step_name`), so when the catalog has no plain row for a step named after an effect, such as Feather, the menu shows the translation of the effect's menu row without its ellipsis (`undo_and_redo_name_the_step_as_the_history_panel_does`). - The History panel translates the undo step names the engine, the tools and the shell write as literals: the untranslated report (`untranslated_report`) lists any a complete catalog lacks, and a step whose catalog row exists only with an ellipsis (such as an effect's menu name) shows that row without the ellipsis. - The German catalog (`crates/ui-egui/src/i18n/de.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,433 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins. The report lists 48 German messages; 38 of them are the composite font, select-a-path and justification order errors that open #7211, #7214 and #7116 translate. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. + - The Korean catalog (`crates/ui-egui/src/i18n/ko.tsv`) has 1,743 `@msg` rows, among them the 3D and Revolve limits, image export and encoding errors, color profile, color book and swatch exchange file errors, binary DXF and DWG import, path operation errors, the graphic style, swatch and action set library errors and the script, zip and regular expression errors. The untranslated report (`untranslated_report`) still lists 1,867 Korean messages, which are shown in English. - The History panel menu has Step Backward and Step Forward, which run Edit › Undo and Edit › Redo and are disabled when there is no step to undo or redo, and Set History Limit…, which opens Preferences at Performance, where History States is set. - The History panel menu's Clear History (`edit.clearHistory`) removes every step to undo and to redo and leaves the document as it is; it is not an undo step itself, and it is disabled when there is no step to clear. - The New Document from State button at the bottom of the History panel (`edit.newDocumentFromState`) makes a new document, which becomes active, from the state the panel has selected ([public source](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/undo-edits-and-manage-design-history.html)). VectorCraft's own rules: the new document takes the next Untitled-N name, is marked unsaved, has nothing selected and has no steps to undo or redo, and the source document and its steps stay as they are. From dacb5a250d2f335300cdfac06daeebecdacb03e2 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:51:51 -0800 Subject: [PATCH 054/108] i18n: Turkish translates 114 status and error messages that no catalog had untranslated_report lists 167 messages under "messages, all 23 languages checked". tr.tsv gains an @msg row for 114 of them, each next to the closest existing message group: image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, 3D and Revolve limits, and script, zip, line and file errors. Placeholders, parameter names and literal values stay as the English writes them. The other 53 are left to the open pull requests that translate them. --- crates/ui-egui/src/i18n/tr.tsv | 116 +++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 2b3e843ba3..85cfed4bd6 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4046,6 +4046,14 @@ axis Both Her İkisi @msg a script is running: stop it or wait for it to finish bir betik çalışıyor: durdurun veya bitmesini bekleyin @msg this is a compiled script, which cannot be run; use its source text bu derlenmiş bir betik, çalıştırılamaz; kaynak metnini kullanın @msg the script is not UTF-8 text betik UTF-8 metni değil +@msg script file is not UTF-8 text: {value} betik dosyası UTF-8 metni değil: {value} +@msg a number cannot be read bir sayı okunamıyor +@msg regular expression too large düzenli ifade çok büyük +@msg too many classes çok fazla karakter sınıfı +@msg too many groups çok fazla grup +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` smallThumb, mediumThumb, largeThumb, smallList veya largeList olmalıdır @msg the script is too large to run betik çalıştırılamayacak kadar büyük @msg a drag or an undo group is open; finish it before running a script bir sürükleme veya geri alma grubu açık; betiği çalıştırmadan önce tamamlayın @msg the script left a document that cannot be kept betik, saklanamayan bir belge bıraktı @@ -4351,6 +4359,12 @@ axis Both Her İkisi @msg file version {0} is newer than this VectorCraft supports ({VERSION}) dosya sürümü {0}, VectorCraft'ın desteklediğinden daha yenidir ({VERSION}) @msg freeform point {i} needs `at` [x, y] and a valid `color` serbest biçimli nokta {i} için `at` [x, y] ve geçerli bir `color` gerekir @msg freeform line {i} must be an array of point indices Serbest biçimli çizgi {i}, bir nokta indeks dizisi olmalıdır +@msg freeform line {i}: {e} serbest biçimli çizgi {i}: {e} +@msg freeform point {i}: {e} serbest biçimli nokta {i}: {e} +@msg a line can't run from a point to itself bir çizgi bir noktadan aynı noktaya uzanamaz +@msg a line needs at least two points bir çizgi en az iki nokta gerektirir +@msg stop {i}: {e} durak {i}: {e} +@msg give `{key}` or `{other}`, not both `{key}` veya `{other}` verin, ikisini birden değil @msg give both `start` and `end` [x, y] (or neither) hem `start` hem de `end` [x, y] verin (ya da hiçbirini) @msg give corners of the path: anchors where its sides meet at an angle yolun köşelerini verin: kenarlarının belli bir açıyla buluştuğu noktalara sabitleyin @msg give horizontal or vertical yatay veya dikey ver @@ -4476,6 +4490,7 @@ axis Both Her İkisi @msg the action set file can't be read in full eylem seti dosyası tamamen okunamıyor @msgplural Loaded “{name}”: {n} step was left out|Loaded “{name}”: {n} steps were left out “{name}” yüklendi: {n} adım atlandı @msg not an action set file bir eylem seti dosyası değil +@msg not an action set file ({e}) bir eylem seti dosyası değil ({e}) @msg the action set file is larger than 8 MiB eylem seti dosyası 8 MiB'den büyük @msg `{ID}`: the reference would be larger than {MAX_BYTES} bytes `{ID}`: başvuru {MAX_BYTES} bayttan büyük olur @msg the action set file holds more than 1,000 actions eylem seti dosyası 1.000'den fazla eylem içeriyor @@ -4509,6 +4524,34 @@ axis Both Her İkisi @msg not a VectorCraft file: {0} bir VectorCraft dosyası değil: {0} @msg not a VectorCraft shortcut set (missing `overrides`) VectorCraft kısayol seti değil (`overrides` eksik) @msg not a graphic style library (format `{_1}`) grafik stili kitaplığı değil (`{_1}` biçimi) +@msg not a graphic style library: {e} grafik stili kitaplığı değil: {e} +@msg not a swatch library (.vcswatches or .gpl) renk örneği kitaplığı değil (.vcswatches veya .gpl) +@msg not a swatch library (format `{_1}`) renk örneği kitaplığı değil (`{_1}` biçimi) +@msg not a swatch library: {e} renk örneği kitaplığı değil: {e} +# Swatch exchange files, color books and color profiles. +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft bir renk örneği değişim dosyasından en fazla {ASE_MAX_ENTRIES} renk ve grup okur; bu kitaplıkta {entries} tane var +@msg a swatch exchange block is too long bir renk örneği değişim bloğu çok uzun +@msg a swatch exchange name is too long bir renk örneği değişim adı çok uzun +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) renk örneği değişim sürümü {major}.{minor} desteklenmiyor (yalnızca 1.x) +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups renk örneği değişim dosyası {ASE_MAX_ENTRIES} renk ve gruptan fazlasını içeriyor +@msg the swatch exchange file is cut short renk örneği değişim dosyası kısa kesildi +@msg too many swatch exchange blocks çok fazla renk örneği değişim bloğu +@msg color book version {version} isn't supported (only 1) renk kitabı sürümü {version} desteklenmiyor (yalnızca 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) {other} renk alanındaki renk kitapları desteklenmiyor (yalnızca RGB, CMYK ve Lab) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors renk kitabı {ASE_MAX_ENTRIES} renkten fazlasını içeriyor +@msg the color book is cut short renk kitabı kısa kesildi +@msg the color book's names take more than {_1} MB renk kitabının adları {_1} MB'tan fazla yer kaplıyor +@msg cannot read profile: {0} profil okunamıyor: {0} +@msg invalid ICC profile: {0} geçersiz ICC profili: {0} +@msg unknown colour profile: {0} bilinmeyen renk profili: {0} +@msg its localized names take more than {_1} KB yerelleştirilmiş adları {_1} KB'tan fazla yer kaplıyor +@msg its tag table lists the `{_1}` tag more than once etiket tablosu `{_1}` etiketini birden fazla kez listeliyor +@msg profile colour space {other} is not RGB, CMYK or Gray profil renk alanı {other}; RGB, CMYK veya Gray değil +@msg grayscale profiles can't be working spaces yet gri tonlamalı profiller henüz çalışma alanı olarak kullanılamaz +@msg {_1} clashes with a built-in profile name {_1}, yerleşik bir profil adıyla çakışıyor +@msg {_1}: no usable transform to/from sRGB {_1}: sRGB'ye veya sRGB'den kullanılabilir bir dönüşüm yok +@msg {name} is not a CMYK profile {name} bir CMYK profili değil +@msg {name} is not an RGB profile {name} bir RGB profili değil @msg not a shortcut set: the text doesn't start with a slash name and an opening brace bir kısayol seti değil: metin eğik çizgi adı ve açılış paranteziyle başlamıyor @msg not a stored central record saklanan merkezi bir kayıt değil @msg not a valid plug-in module: {0} geçerli bir eklenti modülü değil: {0} @@ -4693,6 +4736,8 @@ axis Both Her İkisi @msg this file's PostScript couldn't be read ({why}): {what} bu dosyanın PostScript'i okunamadı ({why}): {what} @msg this format holds one artboard: export several as PDF or with document.exportForScreens bu formatta bir çalışma yüzeyi bulunur: birkaçını PDF olarak veya document.exportForScreens ile dışa aktarın @msg this is a DWG drawing, which can't be read: save it from the CAD app as an ASCII DXF and open that bu okunamayan bir DWG çizimidir: CAD uygulamasından ASCII DXF olarak kaydedin ve açın. +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that bu okunamayan bir DWG çizimidir: CAD uygulamasından DXF olarak kaydedin ve onu açın +@msg this binary DXF file is damaged or cut short bu ikili DXF dosyası hasarlı veya kısa kesilmiş @msg this is a PostScript file (an .ai saved in an older format or without PDF compatibility, or an EPS file), not a PDF: File › Open and File › Place read it as EPS bu bir PostScript dosyasıdır (eski bir formatta kaydedilmiş veya PDF uyumluluğu olmayan bir .ai veya bir EPS dosyası), PDF değil: Dosya › Aç ve Dosya › Yerleştir, EPS olarak oku @msg this is not a PostScript file bu bir PostScript dosyası değil @msg tool shortcuts must be a single key (optionally with Shift) araç kısayolları tek tuş olmalıdır (isteğe bağlı olarak Shift ile) @@ -4948,6 +4993,16 @@ axis Both Her İkisi @msg automation path rejected: cannot resolve {path}: {e} otomasyon yolu reddedildi: {path} çözülemiyor: {e} @msg automation path rejected: parent traversal below a folder that doesn't exist: {path} otomasyon yolu reddedildi: var olmayan bir klasörün altında üst öğe geçişi: {path} @msg automation path rejected: reserved device names are not allowed: {path} otomasyon yolu reddedildi: ayrılmış cihaz adlarına izin verilmiyor: {path} +@msg cannot open the automation {kind} root `{_1}`: {e} otomasyon {kind} kökü `{_1}` açılamıyor: {e} +@msg cannot align zip entries to {align} bytes zip girdileri {align} bayta hizalanamıyor +@msg file name too long to zip: {_1} dosya adı zip için çok uzun: {_1} +@msg file name too long to zip: {name} dosya adı zip için çok uzun: {name} +@msg can't open “{name}”: {e} “{name}” açılamıyor: {e} +@msg {path}: could not be read {path}: okunamadı +@msg the request may not read the New Document profiles folder isteğin Yeni Belge profilleri klasörünü okuma izni yok +@msg its objects are nested too deep ({e}) nesneleri çok derin iç içe geçmiş ({e}) +@msg an image that couldn't be read was left out okunamayan bir görüntü dışarıda bırakıldı +@msg the {_1} plate can't be read: {e} {_1} baskı plakası okunamıyor: {e} @msg Multichannel PSD files can't be read: save it in RGB, CMYK or Grayscale mode Çok kanallı PSD dosyaları okunamıyor: RGB, CMYK veya Gri Tonlama modunda kaydedin @msg not a PSD file PSD dosyası değil @msg the PSD file has an unknown colour mode ({m}) PSD dosyasında bilinmeyen bir renk modu var ({m}) @@ -4979,6 +5034,42 @@ axis Both Her İkisi @msg the JPEG XL container is too large to read JPEG XL kapsayıcısı okunamayacak kadar büyük @msg CMYK JPEG XL images can't be read CMYK JPEG XL görüntüleri okunamıyor @msg the JPEG XL file can't be read: {e} JPEG XL dosyası okunamıyor: {e} +# Image export: encoders, sizes and options. +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP derinliği {_1}: piksel başına 1, 4, 8, 16, 24 veya 32 bit olmalıdır +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP kodlaması başarısız oldu: {width} × {height} piksel biçime veya piksel arabelleğine sığmıyor +@msg GIF encoding failed: the palette image is malformed GIF kodlaması başarısız oldu: palet görüntüsü bozuk biçimli +@msg GIF encoding failed: {e} GIF kodlaması başarısız oldu: {e} +@msg JPEG colour profile: {e} JPEG renk profili: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG kodlaması başarısız oldu: piksel arabelleği görüntü boyutuyla eşleşmiyor +@msg JPEG encoding failed: {e} JPEG kodlaması başarısız oldu: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG kodlaması başarısız oldu: piksel arabelleği görüntü boyutuyla eşleşmiyor +@msg PNG encoding failed: the palette image is malformed PNG kodlaması başarısız oldu: palet görüntüsü bozuk biçimli +@msg PNG encoding failed: {e} PNG kodlaması başarısız oldu: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG kodlaması başarısız oldu: {width} × {height} piksel geçerli bir görüntü boyutu değil +@msg PSD colour profile: {e} PSD renk profili: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD kodlaması başarısız oldu: piksel arabelleği görüntü boyutuyla eşleşmiyor +@msg TIFF colour profile: {e} TIFF renk profili: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF kodlaması başarısız oldu: piksel arabelleği görüntü boyutuyla eşleşmiyor +@msg TIFF encoding failed: {e} TIFF kodlaması başarısız oldu: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa derinliği {_1}: piksel başına 16, 24 veya 32 bit olmalıdır +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa kodlaması başarısız oldu: piksel arabelleği görüntü boyutuyla eşleşmiyor +@msg WebP encoding failed: {e} WebP kodlaması başarısız oldu: {e} +@msg the pixel buffer doesn't match the image size piksel arabelleği görüntü boyutuyla eşleşmiyor +@msg too many layers for PSD (at most 32767) PSD için çok fazla katman (en fazla 32767) +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} piksel GIF için çok büyük (kenar başına en fazla 65535 piksel): çözünürlüğü düşürün +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} piksel JPEG için çok büyük (kenar başına en fazla 65535 piksel): çözünürlüğü düşürün +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} piksel Targa için çok büyük (kenar başına en fazla 65535 piksel): çözünürlüğü düşürün +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} piksel PSD için çok büyük (kenar başına en fazla {MAX_SIDE} piksel): çözünürlüğü düşürün +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution görüntü {w} × {h} piksel olurdu; raster dışa aktarmalar kenar başına {MAX_RASTER_SIDE} piksel ve {_1} megapiksel ile sınırlıdır: ölçeği veya çözünürlüğü düşürün +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels {sw} × {sh} boyutundaki bir görüntü {width} × {height} piksele yeniden boyutlandırılamaz +@msg a {width} × {height} image is too large {width} × {height} boyutundaki bir görüntü çok büyük +@msg a {width} × {height} image: {e} {width} × {height} boyutundaki bir görüntü: {e} +@msg an image could not be written: {e} bir görüntü yazılamadı: {e} +@msg invalid scale {scale} geçersiz ölçek {scale} +@msg SVG options: {e} SVG seçenekleri: {e} +@msg Save for Web settings: {e} Web için Kaydet ayarları: {e} +@msg the optimised image can't be read back: {e} en iyileştirilmiş görüntü geri okunamıyor: {e} +@msg the preview: {e} önizleme: {e} Video video De-Interlace… Taramasızlaştırma… De-Interlace Taramasızlaştırma @@ -5265,6 +5356,31 @@ lighting Light Işık @msg {label} draws no faces for this object {label} bu nesne için hiçbir yüz çizmez @msg the wireframe has more than {MAX_WIRE_EDGES} edges tel kafeste {MAX_WIRE_EDGES} kenardan fazla var @msg The 3D surface is too complex; simplify the shape 3 boyutlu yüzey çok karmaşık; şekli basitleştir +@msg 3D effects require finite coordinates within 100 million points 3D efektleri 100 milyon pt sınırı içinde sonlu koordinatlar gerektirir +@msg 3D effects require one to ten lights 3D efektleri bir ile on arasında ışık gerektirir +@msg The 3D projection is not finite 3D izdüşümü sonlu değil +@msg The 3D shadow is too complex; turn Shadows off or simplify the art 3D gölgesi çok karmaşık; Gölgeler'i kapatın veya resmi basitleştirin +@msg The shape contains invalid coordinates Şekil geçersiz koordinatlar içeriyor +@msg Revolve profile contains invalid coordinates Döndür profili geçersiz koordinatlar içeriyor +@msg Revolve profile is too complex Döndür profili çok karmaşık +@msg Revolve projection is not finite Döndür izdüşümü sonlu değil +@msg Revolve requires finite profile coordinates within 100 million points Döndür, 100 milyon pt sınırı içinde sonlu profil koordinatları gerektirir +@msg Revolve surface is too complex; reduce Segments or simplify the profile Döndür yüzeyi çok karmaşık; Segmentler değerini azaltın veya profili basitleştirin +@msg Revolve surface is too complex; simplify the profile Döndür yüzeyi çok karmaşık; profili basitleştirin +@msg Revolve visibility cannot split the projected boundary Döndür görünürlüğü izdüşümü alınan sınırı bölemiyor +@msg Revolve visibility creates too many fragments Döndür görünürlüğü çok fazla parça oluşturuyor +@msg Revolve visibility creates too many vector anchors Döndür görünürlüğü çok fazla vektör bağlantı noktası oluşturuyor +@msg Revolve visibility exceeds its geometry work limit Döndür görünürlüğü geometri işlem sınırını aşıyor +@msg Revolve visibility exceeds its spatial index limit Döndür görünürlüğü uzamsal dizin sınırını aşıyor +@msg Revolve visibility has too many boundary crossings Döndür görünürlüğünde çok fazla sınır kesişimi var +@msg Revolve visibility has too many input anchors Döndür görünürlüğünde çok fazla girdi bağlantı noktası var +@msg Revolve visibility requires convex cap sectors Döndür görünürlüğü dışbükey kapak dilimleri gerektirir +@msg Revolve visibility requires finite projected faces Döndür görünürlüğü sonlu izdüşüm yüzleri gerektirir +@msg Too many Revolve faces for visibility evaluation Görünürlük değerlendirmesi için çok fazla Döndür yüzü var +@msg input contains NaN or infinite coordinates girdi NaN veya sonsuz koordinatlar içeriyor +@msg input path could not be closed girdi yolu kapatılamadı +@msg the shapes are too degenerate to combine şekiller birleştirilemeyecek kadar yozlaşmış +@msg the shapes cross themselves and each other too often to combine şekiller kendilerini ve birbirlerini birleştirilemeyecek kadar sık kesiyor Transform Objects Nesneleri Dönüştür @msg unknown parameter `{key}`; did you mean `{near}`? bilinmeyen parametre `{key}`; `{near}` mi demek istediniz? @msg unknown parameter `{key}`; the command takes no parameters bilinmeyen parametre `{key}`; komut hiçbir parametre almaz From 305a98de125ec3f95cc0740094e1847e1df60140 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:07:22 -0800 Subject: [PATCH 055/108] i18n: Czech translates 114 status and error messages that no catalog had untranslated_report lists status and error messages that no complete-message catalog translates. cs.tsv gains 114 @msg rows for the ones no open pull request covers: 3D and Revolve limits, image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, path operations, swatch, graphic style and action set libraries, and zip, script and regular expression errors. Placeholders, backticked names, command ids and listed values stay as the English writes them. The report still lists 54 messages for every language: 53 composite font, SVG filter, read root and graph design errors left to #7211, #7378 and #7405, and "`index` must be a whole number". The Czech row of docs/localization-parity.md gets the new counts, and docs/target-app-parity.md lists the change. --- crates/ui-egui/src/i18n/cs.tsv | 116 +++++++++++++++++++++++++++++++++ docs/localization-parity.md | 2 +- docs/target-app-parity.md | 1 + 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index c83c9945dc..d9781368f7 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -7439,6 +7439,122 @@ breakText Glyphs Glyfy @plural {n} line cut|{n} lines cut {n} řádek zkrácen|{n} řádky zkráceny|{n} řádků zkráceno @msg `first` and `last` must be numbers of lines the console holds, first before last `first` a `last` musí být čísla řádků, které konzole uchovává, `first` před `last` +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +@msg 3D effects require finite coordinates within 100 million points 3D efekty vyžadují konečné souřadnice v rozsahu 100 milionů bodů +@msg 3D effects require one to ten lights 3D efekty vyžadují jedno až deset světel +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel hloubka BMP {_1}: 1, 4, 8, 16, 24 nebo 32 bitů na obrazový bod +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer kódování BMP selhalo: {width} × {height} obrazových bodů neodpovídá formátu ani vyrovnávací paměti obrazových bodů +@msg GIF encoding failed: the palette image is malformed kódování GIF selhalo: obraz s paletou je chybně utvořený +@msg GIF encoding failed: {e} kódování GIF selhalo: {e} +@msg JPEG colour profile: {e} barevný profil JPEG: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size kódování JPEG selhalo: vyrovnávací paměť obrazových bodů neodpovídá velikosti obrazu +@msg JPEG encoding failed: {e} kódování JPEG selhalo: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size kódování PNG selhalo: vyrovnávací paměť obrazových bodů neodpovídá velikosti obrazu +@msg PNG encoding failed: the palette image is malformed kódování PNG selhalo: obraz s paletou je chybně utvořený +@msg PNG encoding failed: {e} kódování PNG selhalo: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size kódování PNG selhalo: {width} × {height} obrazových bodů není platná velikost obrazu +@msg PSD colour profile: {e} barevný profil PSD: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size kódování PSD selhalo: vyrovnávací paměť obrazových bodů neodpovídá velikosti obrazu +@msg Revolve profile contains invalid coordinates Profil rotačního tělesa obsahuje neplatné souřadnice +@msg Revolve profile is too complex Profil rotačního tělesa je příliš složitý +@msg Revolve projection is not finite Projekce rotačního tělesa není konečná +@msg Revolve requires finite profile coordinates within 100 million points Rotační těleso vyžaduje konečné souřadnice profilu v rozsahu 100 milionů bodů +@msg Revolve surface is too complex; reduce Segments or simplify the profile Povrch rotačního tělesa je příliš složitý; snižte Segmenty nebo zjednodušte profil +@msg Revolve surface is too complex; simplify the profile Povrch rotačního tělesa je příliš složitý; zjednodušte profil +@msg Revolve visibility cannot split the projected boundary Výpočet viditelnosti rotačního tělesa nedokáže rozdělit promítnutou hranici +@msg Revolve visibility creates too many fragments Výpočet viditelnosti rotačního tělesa vytváří příliš mnoho fragmentů +@msg Revolve visibility creates too many vector anchors Výpočet viditelnosti rotačního tělesa vytváří příliš mnoho vektorových kotevních bodů +@msg Revolve visibility exceeds its geometry work limit Výpočet viditelnosti rotačního tělesa překračuje svůj limit geometrických výpočtů +@msg Revolve visibility exceeds its spatial index limit Výpočet viditelnosti rotačního tělesa překračuje svůj limit prostorového indexu +@msg Revolve visibility has too many boundary crossings Výpočet viditelnosti rotačního tělesa má příliš mnoho průsečíků hranic +@msg Revolve visibility has too many input anchors Výpočet viditelnosti rotačního tělesa má příliš mnoho vstupních kotevních bodů +@msg Revolve visibility requires convex cap sectors Výpočet viditelnosti rotačního tělesa vyžaduje konvexní výseče podstav +@msg Revolve visibility requires finite projected faces Výpočet viditelnosti rotačního tělesa vyžaduje konečné promítnuté stěny +@msg SVG options: {e} Možnosti SVG: {e} +@msg Save for Web settings: {e} Nastavení Uložit pro web: {e} +@msg TIFF colour profile: {e} barevný profil TIFF: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size kódování TIFF selhalo: vyrovnávací paměť obrazových bodů neodpovídá velikosti obrazu +@msg TIFF encoding failed: {e} kódování TIFF selhalo: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel hloubka Targa {_1}: 16, 24 nebo 32 bitů na obrazový bod +@msg Targa encoding failed: the pixel buffer doesn't match the image size kódování Targa selhalo: vyrovnávací paměť obrazových bodů neodpovídá velikosti obrazu +@msg The 3D projection is not finite 3D projekce není konečná +@msg The 3D shadow is too complex; turn Shadows off or simplify the art 3D stín je příliš složitý; vypněte Stíny nebo zjednodušte kresbu +@msg The shape contains invalid coordinates Tvar obsahuje neplatné souřadnice +@msg Too many Revolve faces for visibility evaluation Rotační těleso má příliš mnoho stěn pro výpočet viditelnosti +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft čte ze souboru pro výměnu vzorníku nejvýše {ASE_MAX_ENTRIES} barev a skupin a tato knihovna jich má {entries} +@msg WebP encoding failed: {e} kódování WebP selhalo: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` je smallThumb, mediumThumb, largeThumb, smallList nebo largeList +@msg a line can't run from a point to itself čára nemůže vést z bodu zpět do téhož bodu +@msg a line needs at least two points čára potřebuje alespoň dva body +@msg a number cannot be read číslo nelze přečíst +@msg a swatch exchange block is too long blok souboru pro výměnu vzorníku je příliš dlouhý +@msg a swatch exchange name is too long název v souboru pro výměnu vzorníku je příliš dlouhý +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels velikost obrazu {sw} × {sh} nelze změnit na {width} × {height} obrazových bodů +@msg a {width} × {height} image is too large obraz {width} × {height} je příliš velký +@msg a {width} × {height} image: {e} obraz {width} × {height}: {e} +@msg an image could not be written: {e} obraz se nepodařilo zapsat: {e} +@msg an image that couldn't be read was left out obraz, který nešlo přečíst, byl vynechán +@msg can't open “{name}”: {e} nelze otevřít „{name}“: {e} +@msg cannot align zip entries to {align} bytes položky zipu nelze zarovnat na {align} bajtů +@msg cannot open the automation {kind} root `{_1}`: {e} nelze otevřít kořen automatizace pro {kind} `{_1}`: {e} +@msg cannot read profile: {0} profil nelze přečíst: {0} +@msg color book version {version} isn't supported (only 1) verze barevné knihy {version} není podporována (pouze 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) barevné knihy v barevném prostoru {other} nejsou podporovány (pouze RGB, CMYK a Lab) +@msg file name too long to zip: {_1} název souboru je pro zip příliš dlouhý: {_1} +@msg file name too long to zip: {name} název souboru je pro zip příliš dlouhý: {name} +@msg freeform line {i}: {e} volná čára {i}: {e} +@msg freeform point {i}: {e} volný bod {i}: {e} +@msg give `{key}` or `{other}`, not both zadejte `{key}` nebo `{other}`, ne obojí +@msg grayscale profiles can't be working spaces yet profily ve stupních šedi zatím nemohou být pracovními prostory +@msg input contains NaN or infinite coordinates vstup obsahuje souřadnice NaN nebo nekonečné souřadnice +@msg input path could not be closed vstupní cestu se nepodařilo uzavřít +@msg invalid ICC profile: {0} neplatný profil ICC: {0} +@msg invalid scale {scale} neplatné měřítko {scale} +@msg its localized names take more than {_1} KB jeho lokalizované názvy zabírají více než {_1} KB +@msg its objects are nested too deep ({e}) jeho objekty jsou vnořené příliš hluboko ({e}) +@msg its tag table lists the `{_1}` tag more than once jeho tabulka značek uvádí značku `{_1}` více než jednou +@msg not a graphic style library: {e} nejde o knihovnu grafických stylů: {e} +@msg not a swatch library (.vcswatches or .gpl) nejde o knihovnu vzorníku (.vcswatches nebo .gpl) +@msg not a swatch library (format `{_1}`) nejde o knihovnu vzorníku (formát `{_1}`) +@msg not a swatch library: {e} nejde o knihovnu vzorníku: {e} +@msg not an action set file ({e}) nejde o soubor sady akcí ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray barevný prostor profilu {other} není RGB, CMYK ani Gray +@msg regular expression too large regulární výraz je příliš velký +@msg script file is not UTF-8 text: {value} soubor skriptu není text v kódování UTF-8: {value} +@msg stop {i}: {e} zarážka {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) verze souboru pro výměnu vzorníku {major}.{minor} není podporována (pouze 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors barevná kniha obsahuje více než {ASE_MAX_ENTRIES} barev +@msg the color book is cut short barevná kniha je useknutá +@msg the color book's names take more than {_1} MB názvy barevné knihy zabírají více než {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution obraz by měl {w} × {h} obrazových bodů; rastrové exporty jsou omezeny na {MAX_RASTER_SIDE} obrazových bodů na stranu a {_1} megapixelů: snižte měřítko nebo rozlišení +@msg the optimised image can't be read back: {e} optimalizovaný obraz nelze zpětně přečíst: {e} +@msg the pixel buffer doesn't match the image size vyrovnávací paměť obrazových bodů neodpovídá velikosti obrazu +@msg the preview: {e} náhled: {e} +@msg the request may not read the New Document profiles folder požadavek nesmí číst složku profilů nového dokumentu +@msg the shapes are too degenerate to combine tvary jsou příliš degenerované na sloučení +@msg the shapes cross themselves and each other too often to combine tvary protínají samy sebe i sebe navzájem příliš často na sloučení +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups soubor pro výměnu vzorníku obsahuje více než {ASE_MAX_ENTRIES} barev a skupin +@msg the swatch exchange file is cut short soubor pro výměnu vzorníku je useknutý +@msg the {_1} plate can't be read: {e} výtažek {_1} nelze přečíst: {e} +@msg this binary DXF file is damaged or cut short tento binární soubor DXF je poškozený nebo useknutý +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that toto je výkres DWG, který nelze přečíst: uložte jej v aplikaci CAD jako DXF a otevřete ten +@msg too many classes příliš mnoho tříd znaků +@msg too many groups příliš mnoho skupin +@msg too many layers for PSD (at most 32767) příliš mnoho vrstev pro PSD (nejvýše 32767) +@msg too many swatch exchange blocks příliš mnoho bloků souboru pro výměnu vzorníku +@msg unknown colour profile: {0} neznámý barevný profil: {0} +@msg {_1} clashes with a built-in profile name {_1} koliduje s názvem vestavěného profilu +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} obrazových bodů je pro GIF příliš mnoho (nejvýše 65535 obrazových bodů na stranu): snižte rozlišení +@msg {_1}: no usable transform to/from sRGB {_1}: žádná použitelná transformace do sRGB nebo ze sRGB +@msg {name} is not a CMYK profile {name} není profil CMYK +@msg {name} is not an RGB profile {name} není profil RGB +@msg {path}: could not be read {path}: nelze přečíst +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} obrazových bodů je pro JPEG příliš mnoho (nejvýše 65535 obrazových bodů na stranu): snižte rozlišení +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} obrazových bodů je pro Targa příliš mnoho (nejvýše 65535 obrazových bodů na stranu): snižte rozlišení +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} obrazových bodů je pro PSD příliš mnoho (nejvýše {MAX_SIDE} obrazových bodů na stranu): snižte rozlišení + # Learn panel Learn Výuka Explore tutorials Prozkoumat výukové kurzy diff --git a/docs/localization-parity.md b/docs/localization-parity.md index ca5906af9e..c6c45d59c3 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -58,7 +58,7 @@ plus review. Native-speaker review is human work and isn't in the hours. | Hungarian | `hu` | 5,253 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form | full | | Polish | `pl` | 9,044 rows, 3,439 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 46 missing messages for it, and 47 menu strings, 26 `tl!` literals, 11 undo labels and 45 swatch names; one/few/many plurals | full; native review pending | | Finnish | `fi` | 5,318 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one/other plurals, 797 `@msg` rows | full; AI-assisted, native proofreading pending | -| Czech | `cs` | 9,155 rows, 3,445 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 40 missing messages for it | catalog complete; render-site gaps reduced; native review pending | +| Czech | `cs` | 9,273 rows, 3,560 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 2 missing Czech messages, and 54 messages that no language has a row for | catalog complete; render-site gaps reduced; native review pending | | Bosnian | `bs` | 5,841 rows (counted 2026-10-30): menus, `tl!` literals and messages complete when counted; one/few/other plurals | full; AI-assisted, native review pending | | Swedish | `sv` | 5,251 rows, 795 of them `@msg` (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one/other plurals | full; native review welcome | | Bulgarian | `bg` | 5,245 rows, 763 of them `@msg` (counted 2026-10-21): menus and `tl!` literals complete when counted; its messages are partial | full; AI-drafted, native review pending | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 2c74302900..1bbea1b810 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -894,6 +894,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Italian messages (2026-11-13): the Italian catalog (`it`) has 1,802 more status and error message rows, and the untranslated report's missing Italian messages go from 1,842 to 40; the translations are VectorCraft's own and await native review; scores and estimates unchanged. See [localization-parity.md](localization-parity.md). - Window › Help Bar shows or hides the tool-help strip at the bottom of the window apart from the status bar (`window.helpBar`). Each setting is kept with the UI preferences and in saved workspaces, and Presentation Mode hides both bars. Layouts saved before the setting existed show the Help Bar where they show the status bar (`help_bar_toggle_is_independent_and_saved_in_workspaces`, `help_bar_and_status_bar_render_independently`, `legacy_help_bar_visibility_follows_each_layouts_status_bar`, `a_help_bar_setting_the_file_lacks_is_saved`). - Czech render-site labels: desktop/web file filters, diagnostics, suggested preset names and contributor tooltips/plurals now use catalog lookups; gradients have Czech adjective agreement and printer marks have a separate context (PDF/Print and Summary). Search, Home, toolbar/panel tooltips and Preferences already look up their labels. Every complete catalog has rows for these labels and for the Roman and Japanese printer mark styles. Evidence: `i18n::tests::czech_render_site_follow_up`, `i18n::tests::complete_catalogs_translate_render_site_labels`, `dialogs::tests_modal::printer_mark_labels_are_distinct_from_language_names`; see [localization-parity.md](localization-parity.md). + - The Czech catalog (`crates/ui-egui/src/i18n/cs.tsv`) translates 114 status and error messages that no catalog had a row for: the 3D and Revolve limits, image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, path operations, swatch, graphic style and action set libraries, and zip, script and regular expression errors. The untranslated report (`untranslated_report`) still lists 54 messages for every language: the 53 composite font, SVG filter, read root and graph design errors that open #7211, #7378 and #7405 translate, and `` `index` must be a whole number ``. See [localization-parity.md](localization-parity.md). - The History panel, Edit › Undo and Edit › Redo translate the names of the steps that apply or redefine a character or paragraph style and of the step that redefines a graphic style: each such step keeps its template (`Apply {name}`, `Redefine {name}`, `Redefine Graphic Style “{name}”`) and the style's name, every complete catalog has a row for each template, and the panel and the menu show the style's name as the document holds it, except the Normal styles' names, which they show in the interface language (`steps_named_after_a_style_list_the_template_around_the_name`, `undo_and_redo_name_a_style_step_around_the_style_name`). - The Polish catalog (`crates/ui-egui/src/i18n/pl.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,439 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins. The report lists 46 Polish messages: 44 that open #7211, #7214, #7116, #7330 and #1931 translate, and 2 that no language has a row for. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. - The status bar translates the limits a plug-in run can exceed (its instruction, time and memory budgets and its output size) and the error of a plug-in removal that leaves the plug-in's grant in the plug-in store, in every language that translates every message. The untranslated-strings report also lists messages that an error or a status takes from a `&str` constant (`plugin_limit_errors_are_translated`, `message_scan_reads_messages_held_in_constants`). From 1c4f12690f3aa7770e88dfc0d8b16990a379af95 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:07:43 -0800 Subject: [PATCH 056/108] i18n: Korean translates the whole-number index error that no catalog had --- crates/ui-egui/src/i18n/ko.tsv | 1 + docs/localization-parity.md | 2 +- docs/target-app-parity.md | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index b09644c4ca..ab87da925e 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -7134,6 +7134,7 @@ breakText Glyphs 글리프 @msg WebP encoding failed: {e} WebP 인코딩 실패: {e} @msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} @msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `index` must be a whole number `index`은(는) 정수여야 합니다 @msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view`는 smallThumb, mediumThumb, largeThumb, smallList 또는 largeList여야 합니다 @msg a line can't run from a point to itself 선은 한 점에서 같은 점으로 이어질 수 없습니다 @msg a line needs at least two points 선에는 점이 두 개 이상 필요합니다 diff --git a/docs/localization-parity.md b/docs/localization-parity.md index 6f0485cf49..bfb6cc6b72 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -36,7 +36,7 @@ Chinese by `imachus`). Only Georgian is recorded as reviewed by a native speaker | Indonesian | `id` | 5,279 rows, 750 of them `@msg` (counted 2026-10-21): menus and `tl!` literals complete when counted; its messages are partial; one plural form | dialogs and tooltips all; 750 message rows (French has 796) | Latin | no | full | — (review) | | Japanese | `ja` | 4,004 / 4,020 (99.6%) | all | CJK UI font as above; Japanese IME; vertical type partial; Japanese crop marks and composition settings | no | full | — (review) | | German | `de` | 3,952 / 4,020 (98%; menus, literals and messages complete when counted) | all (3,433 `@msg` and 48 `@msgplural` rows, counted 2026-11-13: the untranslated report lists 48 missing messages for it) | Latin | contributor-written, not reviewed | full | — (review) | -| Korean | `ko` | 4,870 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form | dialogs and tooltips all; 1,743 `@msg` and 48 `@msgplural` rows (counted 2026-11-13): the untranslated report lists 1,867 missing messages for it | Hangul from an installed system font on the desktop (Apple SD Gothic Neo, Malgun Gothic, Noto Sans CJK KR…); the web build has no Korean UI font yet (craft-fonts); IME path exists | no (AI-drafted) | full | — (review; web font) | +| Korean | `ko` | 4,870 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form | dialogs and tooltips all; 1,744 `@msg` and 48 `@msgplural` rows (counted 2026-11-13): the untranslated report lists 1,867 missing messages for it | Hangul from an installed system font on the desktop (Apple SD Gothic Neo, Malgun Gothic, Noto Sans CJK KR…); the web build has no Korean UI font yet (craft-fonts); IME path exists | no (AI-drafted) | full | — (review; web font) | | Vietnamese | `vi` | 4,886 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one plural form; 4,046 plain + 18 `@plural` + 28 contextual + 794 `@msg` | all | Latin with Vietnamese diacritics (stacked marks attach in precomposed, decomposed and keyboard forms, #4491; glyph tests pass) | contributor is a Vietnamese speaker; AI-assisted draft, further native review welcome | full | — (review) | **Historical 12-language score: ~82%** (equal weights: 100 + 85 + 100 + 0 + 0 + 100 + 100 + 100 + 100 + 98 + 100 + 100, over 12). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index acd1f7d257..6be99681ca 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -908,7 +908,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Edit › Undo and Edit › Redo, in the in-window and native menus, name the step in the interface language as the History panel lists it (`panels::history::step_name`), so when the catalog has no plain row for a step named after an effect, such as Feather, the menu shows the translation of the effect's menu row without its ellipsis (`undo_and_redo_name_the_step_as_the_history_panel_does`). - The History panel translates the undo step names the engine, the tools and the shell write as literals: the untranslated report (`untranslated_report`) lists any a complete catalog lacks, and a step whose catalog row exists only with an ellipsis (such as an effect's menu name) shows that row without the ellipsis. - The German catalog (`crates/ui-egui/src/i18n/de.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,433 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins. The report lists 48 German messages; 38 of them are the composite font, select-a-path and justification order errors that open #7211, #7214 and #7116 translate. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. - - The Korean catalog (`crates/ui-egui/src/i18n/ko.tsv`) has 1,743 `@msg` rows, among them the 3D and Revolve limits, image export and encoding errors, color profile, color book and swatch exchange file errors, binary DXF and DWG import, path operation errors, the graphic style, swatch and action set library errors and the script, zip and regular expression errors. The untranslated report (`untranslated_report`) still lists 1,867 Korean messages, which are shown in English. + - The Korean catalog (`crates/ui-egui/src/i18n/ko.tsv`) has 1,744 `@msg` rows, among them the 3D and Revolve limits, image export and encoding errors, color profile, color book and swatch exchange file errors, binary DXF and DWG import, path operation errors, the graphic style, swatch and action set library errors and the script, zip and regular expression errors. The untranslated report (`untranslated_report`) still lists 1,867 Korean messages, which are shown in English. - The History panel menu has Step Backward and Step Forward, which run Edit › Undo and Edit › Redo and are disabled when there is no step to undo or redo, and Set History Limit…, which opens Preferences at Performance, where History States is set. - The History panel menu's Clear History (`edit.clearHistory`) removes every step to undo and to redo and leaves the document as it is; it is not an undo step itself, and it is disabled when there is no step to clear. - The New Document from State button at the bottom of the History panel (`edit.newDocumentFromState`) makes a new document, which becomes active, from the state the panel has selected ([public source](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/undo-edits-and-manage-design-history.html)). VectorCraft's own rules: the new document takes the next Untitled-N name, is marked unsaved, has nothing selected and has no steps to undo or redo, and the source document and its steps stay as they are. From ec7dfa592f02635cbece9f7a620333659b22f247 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:07:58 -0800 Subject: [PATCH 057/108] i18n: Catalan has a row for the messages no catalog translates yet The untranslated report lists 168 status and error messages that none of the 23 complete-message catalogs translates, so a Catalan interface showed them in English. ca.tsv gets 115 @msg rows under one comment line at the end of the file, written with the catalog's existing terms. Each row keeps the English key, its placeholders, backticked names, parameter names and accepted values (smallThumb, RGB, CMYK, Lab, Gray, sRGB, NaN, UTF-8) unchanged. The 53 messages that open #7211, #7378 and #7405 translate are left out, so the catalogs stay consistent. --- crates/ui-egui/src/i18n/ca.tsv | 116 +++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index c098a7cb4b..4034acb126 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -7476,3 +7476,119 @@ breakText Glyphs Glifs Grommets Ullets Grommet Inset Distància dels ullets a la vora Diameter Diàmetre +# Status and error messages of image export, color profiles and libraries, 3D effects, path operations and scripts. +@msg 3D effects require finite coordinates within 100 million points Els efectes 3D requereixen coordenades finites dins de 100 milions de punts +@msg 3D effects require one to ten lights Els efectes 3D requereixen d’un a deu llums +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel Profunditat BMP {_1}: 1, 4, 8, 16, 24 o 32 bits per píxel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer La codificació BMP ha fallat: {width} × {height} píxels no caben al format ni a la memòria intermèdia de píxels +@msg GIF encoding failed: the palette image is malformed La codificació GIF ha fallat: la imatge de paleta està mal formada +@msg GIF encoding failed: {e} La codificació GIF ha fallat: {e} +@msg JPEG colour profile: {e} Perfil de color JPEG: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size La codificació JPEG ha fallat: la memòria intermèdia de píxels no coincideix amb la mida de la imatge +@msg JPEG encoding failed: {e} La codificació JPEG ha fallat: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size La codificació PNG ha fallat: la memòria intermèdia de píxels no coincideix amb la mida de la imatge +@msg PNG encoding failed: the palette image is malformed La codificació PNG ha fallat: la imatge de paleta està mal formada +@msg PNG encoding failed: {e} La codificació PNG ha fallat: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size La codificació PNG ha fallat: {width} × {height} píxels no és una mida d’imatge vàlida +@msg PSD colour profile: {e} Perfil de color PSD: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size La codificació PSD ha fallat: la memòria intermèdia de píxels no coincideix amb la mida de la imatge +@msg Revolve profile contains invalid coordinates El perfil de Revolució conté coordenades no vàlides +@msg Revolve profile is too complex El perfil de Revolució és massa complex +@msg Revolve projection is not finite La projecció de Revolució no és finita +@msg Revolve requires finite profile coordinates within 100 million points Revolució requereix coordenades de perfil finites dins de 100 milions de punts +@msg Revolve surface is too complex; reduce Segments or simplify the profile La superfície de Revolució és massa complexa; redueix Segments o simplifica el perfil +@msg Revolve surface is too complex; simplify the profile La superfície de Revolució és massa complexa; simplifica el perfil +@msg Revolve visibility cannot split the projected boundary La visibilitat de Revolució no pot dividir el contorn projectat +@msg Revolve visibility creates too many fragments La visibilitat de Revolució crea massa fragments +@msg Revolve visibility creates too many vector anchors La visibilitat de Revolució crea massa punts d’ancoratge vectorials +@msg Revolve visibility exceeds its geometry work limit La visibilitat de Revolució supera el seu límit de treball geomètric +@msg Revolve visibility exceeds its spatial index limit La visibilitat de Revolució supera el seu límit d’índex espacial +@msg Revolve visibility has too many boundary crossings La visibilitat de Revolució té massa encreuaments de contorn +@msg Revolve visibility has too many input anchors La visibilitat de Revolució té massa punts d’ancoratge d’entrada +@msg Revolve visibility requires convex cap sectors La visibilitat de Revolució requereix sectors de tapa convexos +@msg Revolve visibility requires finite projected faces La visibilitat de Revolució requereix cares projectades finites +@msg SVG options: {e} Opcions SVG: {e} +@msg Save for Web settings: {e} Paràmetres de Desa per a web: {e} +@msg TIFF colour profile: {e} Perfil de color TIFF: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size La codificació TIFF ha fallat: la memòria intermèdia de píxels no coincideix amb la mida de la imatge +@msg TIFF encoding failed: {e} La codificació TIFF ha fallat: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Profunditat Targa {_1}: 16, 24 o 32 bits per píxel +@msg Targa encoding failed: the pixel buffer doesn't match the image size La codificació Targa ha fallat: la memòria intermèdia de píxels no coincideix amb la mida de la imatge +@msg The 3D projection is not finite La projecció 3D no és finita +@msg The 3D shadow is too complex; turn Shadows off or simplify the art L’ombra 3D és massa complexa; desactiva Ombres o simplifica la il·lustració +@msg The shape contains invalid coordinates La forma conté coordenades no vàlides +@msg Too many Revolve faces for visibility evaluation Massa cares de Revolució per avaluar-ne la visibilitat +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft llegeix com a màxim {ASE_MAX_ENTRIES} colors i grups d’un fitxer d’intercanvi de mostres, i aquesta biblioteca en té {entries} +@msg WebP encoding failed: {e} La codificació WebP ha fallat: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `index` must be a whole number `index` ha de ser un nombre enter +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` és smallThumb, mediumThumb, largeThumb, smallList o largeList +@msg a line can't run from a point to itself una línia no pot anar d’un punt a ell mateix +@msg a line needs at least two points una línia necessita almenys dos punts +@msg a number cannot be read no es pot llegir un número +@msg a swatch exchange block is too long un bloc d’intercanvi de mostres és massa llarg +@msg a swatch exchange name is too long un nom d’intercanvi de mostres és massa llarg +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels una imatge de {sw} × {sh} no es pot redimensionar a {width} × {height} píxels +@msg a {width} × {height} image is too large una imatge de {width} × {height} és massa gran +@msg a {width} × {height} image: {e} una imatge de {width} × {height}: {e} +@msg an image could not be written: {e} no s’ha pogut escriure una imatge: {e} +@msg an image that couldn't be read was left out s’ha omès una imatge que no s’ha pogut llegir +@msg can't open “{name}”: {e} no es pot obrir “{name}”: {e} +@msg cannot align zip entries to {align} bytes no es poden alinear les entrades del zip a {align} bytes +@msg cannot open the automation {kind} root `{_1}`: {e} no es pot obrir l’arrel {kind} de l’automatització `{_1}`: {e} +@msg cannot read profile: {0} no es pot llegir el perfil: {0} +@msg color book version {version} isn't supported (only 1) la versió {version} del llibre de colors no és compatible (només 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) els llibres de colors en l’espai de color {other} no són compatibles (només RGB, CMYK i Lab) +@msg file name too long to zip: {_1} nom de fitxer massa llarg per afegir-lo al zip: {_1} +@msg file name too long to zip: {name} nom de fitxer massa llarg per afegir-lo al zip: {name} +@msg freeform line {i}: {e} línia de forma lliure {i}: {e} +@msg freeform point {i}: {e} punt de forma lliure {i}: {e} +@msg give `{key}` or `{other}`, not both indiqueu `{key}` o `{other}`, no tots dos +@msg grayscale profiles can't be working spaces yet els perfils d’escala de grisos encara no poden ser espais de treball +@msg input contains NaN or infinite coordinates l’entrada conté coordenades NaN o infinites +@msg input path could not be closed no s’ha pogut tancar el traçat d’entrada +@msg invalid ICC profile: {0} perfil ICC no vàlid: {0} +@msg invalid scale {scale} escala no vàlida {scale} +@msg its localized names take more than {_1} KB els seus noms localitzats ocupen més de {_1} KB +@msg its objects are nested too deep ({e}) els seus objectes estan imbricats massa profundament ({e}) +@msg its tag table lists the `{_1}` tag more than once la seva taula d’etiquetes inclou l’etiqueta `{_1}` més d’una vegada +@msg not a graphic style library: {e} no és una biblioteca d’estils gràfics: {e} +@msg not a swatch library (.vcswatches or .gpl) no és una biblioteca de mostres (.vcswatches o .gpl) +@msg not a swatch library (format `{_1}`) no és una biblioteca de mostres (format `{_1}`) +@msg not a swatch library: {e} no és una biblioteca de mostres: {e} +@msg not an action set file ({e}) no és un fitxer de conjunt d’accions ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray l’espai de color del perfil, {other}, no és RGB, CMYK ni Gray +@msg regular expression too large expressió regular massa gran +@msg script file is not UTF-8 text: {value} el fitxer de l’script no és text UTF-8: {value} +@msg stop {i}: {e} la parada {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) la versió {major}.{minor} del fitxer d’intercanvi de mostres no és compatible (només 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors el llibre de colors conté més de {ASE_MAX_ENTRIES} colors +@msg the color book is cut short el llibre de colors està tallat +@msg the color book's names take more than {_1} MB els noms del llibre de colors ocupen més de {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution la imatge faria {w} × {h} píxels; les exportacions ràster estan limitades a {MAX_RASTER_SIDE} píxels per costat i {_1} megapíxels: reduïu l’escala o la resolució +@msg the optimised image can't be read back: {e} la imatge optimitzada no es pot tornar a llegir: {e} +@msg the pixel buffer doesn't match the image size la memòria intermèdia de píxels no coincideix amb la mida de la imatge +@msg the preview: {e} la previsualització: {e} +@msg the request may not read the New Document profiles folder la sol·licitud no pot llegir la carpeta de perfils de document nou +@msg the shapes are too degenerate to combine les formes són massa degenerades per combinar-les +@msg the shapes cross themselves and each other too often to combine les formes es creuen amb si mateixes i entre elles massa vegades per combinar-les +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups el fitxer d’intercanvi de mostres conté més de {ASE_MAX_ENTRIES} colors i grups +@msg the swatch exchange file is cut short el fitxer d’intercanvi de mostres està tallat +@msg the {_1} plate can't be read: {e} la planxa {_1} no es pot llegir: {e} +@msg this binary DXF file is damaged or cut short aquest fitxer DXF binari està malmès o tallat +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that aquest és un dibuix DWG, que no es pot llegir: desa’l des de l’aplicació CAD com a DXF i obre’l +@msg too many classes massa classes +@msg too many groups massa grups +@msg too many layers for PSD (at most 32767) massa capes per a PSD (com a màxim 32767) +@msg too many swatch exchange blocks massa blocs d’intercanvi de mostres +@msg unknown colour profile: {0} perfil de color desconegut: {0} +@msg {_1} clashes with a built-in profile name {_1} coincideix amb el nom d’un perfil integrat +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} píxels és massa gran per a GIF (com a màxim 65535 píxels per costat): reduïu la resolució +@msg {_1}: no usable transform to/from sRGB {_1}: no hi ha cap transformació utilitzable a sRGB o des de sRGB +@msg {name} is not a CMYK profile {name} no és un perfil CMYK +@msg {name} is not an RGB profile {name} no és un perfil RGB +@msg {path}: could not be read {path}: no s’ha pogut llegir +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} píxels és massa gran per a JPEG (com a màxim 65535 píxels per costat): reduïu la resolució +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} píxels és massa gran per a Targa (com a màxim 65535 píxels per costat): reduïu la resolució +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} píxels és massa gran per a PSD (com a màxim {MAX_SIDE} píxels per costat): reduïu la resolució From e76982bfadd09477f69a1df3225ccbc0ffe63720 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:08:11 -0800 Subject: [PATCH 058/108] Artwork Cleanup: named type on a locked artboard stays out of the text tools Add a test that Remove Breaks leaves type on a locked artboard as it is when ids names it, with no undo step. Rewrap the Text tools paragraph in docs/mcp.md and name the tests in docs/target-app-parity.md. --- .../engine/src/cmd/addons/cleanup/text/tests.rs | 17 +++++++++++++++++ docs/mcp.md | 4 ++-- docs/target-app-parity.md | 3 ++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/cmd/addons/cleanup/text/tests.rs b/crates/engine/src/cmd/addons/cleanup/text/tests.rs index cf5f95a667..6b03a26384 100644 --- a/crates/engine/src/cmd/addons/cleanup/text/tests.rs +++ b/crates/engine/src/cmd/addons/cleanup/text/tests.rs @@ -435,6 +435,23 @@ fn remove_breaks_named_story_with_a_locked_frame() { assert_eq!(obj(&s, a).plain_text(), "one two"); } +/// Type on a locked artboard stays as it is even when `ids` names it, with no undo step. +#[test] +fn remove_breaks_named_type_on_a_locked_artboard() { + let mut s = session(); + let on_board = text(&mut s, json!({"x": 40, "y": 60, "text": "a\nb", "size": 12})); + s.edit("Lock Artboard", |d, _| { + d.artboards[0].locked = true; + Ok(()) + }) + .unwrap(); + let steps = undo_steps(&s); + let r = s.execute("addon.cleanup.removeBreaks", &json!({"kind": "paragraph", "ids": [on_board.0]})); + assert_eq!(other(r), "No paragraph breaks to remove"); + assert_eq!(undo_steps(&s), steps); + assert_eq!(obj(&s, on_board).plain_text(), "a\nb"); +} + /// Break Text, Combine and Join Point Text, Set Alignment, Keep Position and Reset Text Transform /// act on the locked and hidden type that `ids` names (type in a locked layer included), each as /// one undo step, and leave it as it is when it is only selected. diff --git a/docs/mcp.md b/docs/mcp.md index a9b621b298..3a9a88e7c8 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10644,8 +10644,8 @@ topmost piece. The add-on's text tools act on the selected type (or `ids`), each as one undo step, and refuse with an error when there is nothing for them to do. From the selection they take only type that can be edited; the type that `ids` names, or that is inside a group or layer it names, is taken even when it, its group or its layer is locked or hidden (not type -on a locked artboard). The objects they make from locked or hidden type are not selected. The pieces they make are point type that keeps its characters' styles, each placed so the -glyph of its first character lands where it was drawn. +on a locked artboard). The objects they make from locked or hidden type are not selected. The pieces they make are +point type that keeps its characters' styles, each placed so the glyph of its first character lands where it was drawn. - `addon.cleanup.breakText {by?, ids?}` turns each horizontal point or area type object into point type objects, one per line (`by: "lines"`, the default), paragraph (`"paragraphs"`), word (`"words"`) or glyph (`"glyphs"`; a ligature diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index a5953d677e..481cd3e9d4 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -2050,7 +2050,8 @@ refusals), `addons::cleanup::tests` in `vectorcraft-ui-egui` (the submenu and th With `ids`, the text tools act on the type the ids name even when it, or its group or layer, is locked or hidden, as `text.convertListToText` does; from the selection they still take only type that can be edited (VectorCraft's own -rule). Tests: `named_locked_and_hidden_type` and the other `named_` tests in `cmd::addons::cleanup::text::tests`. +rule). Tests: `named_locked_and_hidden_type`, `remove_breaks_named_locked_and_hidden_type` and +`remove_breaks_named_story_with_a_locked_frame` in `cmd::addons::cleanup::text::tests`. ## Path Precision Tools add-on (2026-10-30) From ed623a5cc6f64f6d3f2eeba48d932aebccac64ec Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:09:55 -0800 Subject: [PATCH 059/108] i18n: Turkish translates the whole-number index error Main added "`index` must be a whole number" (document.activate and the index checks that refuse a fraction), which no catalog has. Turkish now has a row for it. --- crates/ui-egui/src/i18n/tr.tsv | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index 99b01b18af..3f60c793df 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -4246,6 +4246,7 @@ axis Both Her İkisi @msg `{key}` must be a string `{key}` bir dize olmalıdır @msg `{key}` must be a profile name or null `{key}` bir profil adı ya da null olmalıdır @msg `{key}` must be a whole number `{key}` bir tam sayı olmalıdır +@msg `index` must be a whole number `index` bir tam sayı olmalıdır @msg `{key}` must be a whole number between {min} and {max} (got {x}) `{key}`, {min} ile {max} arasında bir tam sayı olmalıdır ({x}'yi aldı) @msg `{key}` must be between {min} and {max} (got {x}) `{key}`, {min} ile {max} arasında olmalıdır ({x}'yi aldı) @msg `{key}` must be one of {_1} `{key}`, {_1}'den biri olmalıdır From f1d2d45f18797ada86b8e676a722172089c35ebd Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:10:16 -0800 Subject: [PATCH 060/108] i18n: Hungarian has a row for every message missing from all catalogs untranslated_report lists 167 status and error messages that no complete-message catalog translates. hu.tsv gains 114 @msg rows for them: image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, 3D and Revolve limits, and script, zip, line and file errors. Placeholders, parameter names and literal values stay as the English writes them. The other 53 listed messages are left to the open pull requests that already add their rows. --- crates/ui-egui/src/i18n/hu.tsv | 116 +++++++++++++++++++++++++++++++++ 1 file changed, 116 insertions(+) diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 8549bd5d63..67fb1b4c66 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -7479,3 +7479,119 @@ breakText Glyphs Glifák Grommets Ringlik Grommet Inset Ringlik távolsága a széltől Diameter Átmérő + +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +@msg 3D effects require finite coordinates within 100 million points A 3D effektusokhoz 100 millió ponton belüli véges koordináták kellenek +@msg 3D effects require one to ten lights A 3D effektusokhoz egy és tíz közötti számú fény kell +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP-színmélység {_1}: 1, 4, 8, 16, 24 vagy 32 bit/pixel lehet +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer A BMP-kódolás sikertelen: {width} × {height} pixel nem fér bele a formátumba vagy a pixelpufferbe +@msg GIF encoding failed: the palette image is malformed A GIF-kódolás sikertelen: a palettás kép hibás szerkezetű +@msg GIF encoding failed: {e} A GIF-kódolás sikertelen: {e} +@msg JPEG colour profile: {e} JPEG-színprofil: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size A JPEG-kódolás sikertelen: a pixelpuffer nem egyezik a kép méretével +@msg JPEG encoding failed: {e} A JPEG-kódolás sikertelen: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size A PNG-kódolás sikertelen: a pixelpuffer nem egyezik a kép méretével +@msg PNG encoding failed: the palette image is malformed A PNG-kódolás sikertelen: a palettás kép hibás szerkezetű +@msg PNG encoding failed: {e} A PNG-kódolás sikertelen: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size A PNG-kódolás sikertelen: {width} × {height} pixel nem érvényes képméret +@msg PSD colour profile: {e} PSD-színprofil: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size A PSD-kódolás sikertelen: a pixelpuffer nem egyezik a kép méretével +@msg Revolve profile contains invalid coordinates Forgatás tengely körül: a profil érvénytelen koordinátákat tartalmaz +@msg Revolve profile is too complex Forgatás tengely körül: a profil túl összetett +@msg Revolve projection is not finite Forgatás tengely körül: a vetület nem véges +@msg Revolve requires finite profile coordinates within 100 million points Forgatás tengely körül: 100 millió ponton belüli véges profilkoordináták kellenek +@msg Revolve surface is too complex; reduce Segments or simplify the profile Forgatás tengely körül: a felület túl összetett; csökkentsd a Szakaszok értékét, vagy egyszerűsítsd a profilt +@msg Revolve surface is too complex; simplify the profile Forgatás tengely körül: a felület túl összetett; egyszerűsítsd a profilt +@msg Revolve visibility cannot split the projected boundary Forgatás tengely körül: a láthatóság számítása nem tudja felosztani a vetített határvonalat +@msg Revolve visibility creates too many fragments Forgatás tengely körül: a láthatóság számítása túl sok darabot hoz létre +@msg Revolve visibility creates too many vector anchors Forgatás tengely körül: a láthatóság számítása túl sok vektoros horgonypontot hoz létre +@msg Revolve visibility exceeds its geometry work limit Forgatás tengely körül: a láthatóság számítása túllépi a geometriai számítások korlátját +@msg Revolve visibility exceeds its spatial index limit Forgatás tengely körül: a láthatóság számítása túllépi a térbeli index korlátját +@msg Revolve visibility has too many boundary crossings Forgatás tengely körül: a láthatóság számításában túl sok a határvonal-keresztezés +@msg Revolve visibility has too many input anchors Forgatás tengely körül: a láthatóság számításában túl sok a bemeneti horgonypont +@msg Revolve visibility requires convex cap sectors Forgatás tengely körül: a láthatóság számításához konvex zárólap-szektorok kellenek +@msg Revolve visibility requires finite projected faces Forgatás tengely körül: a láthatóság számításához véges vetített lapok kellenek +@msg SVG options: {e} SVG-beállítások: {e} +@msg Save for Web settings: {e} Webes mentés beállításai: {e} +@msg TIFF colour profile: {e} TIFF-színprofil: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size A TIFF-kódolás sikertelen: a pixelpuffer nem egyezik a kép méretével +@msg TIFF encoding failed: {e} A TIFF-kódolás sikertelen: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa-színmélység {_1}: 16, 24 vagy 32 bit/pixel lehet +@msg Targa encoding failed: the pixel buffer doesn't match the image size A Targa-kódolás sikertelen: a pixelpuffer nem egyezik a kép méretével +@msg The 3D projection is not finite A 3D vetület nem véges +@msg The 3D shadow is too complex; turn Shadows off or simplify the art A 3D árnyék túl összetett; kapcsold ki az Árnyékok beállítást, vagy egyszerűsítsd a rajzot +@msg The shape contains invalid coordinates Az alakzat érvénytelen koordinátákat tartalmaz +@msg Too many Revolve faces for visibility evaluation Túl sok lap a láthatóság kiértékeléséhez (Forgatás tengely körül) +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} A VectorCraft legfeljebb {ASE_MAX_ENTRIES} színt és csoportot olvas be egy színmintacsere-fájlból, ebben a könyvtárban pedig ennyi van: {entries} +@msg WebP encoding failed: {e} A WebP-kódolás sikertelen: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view`: smallThumb, mediumThumb, largeThumb, smallList vagy largeList lehet +@msg a line can't run from a point to itself egy vonal nem futhat egy pontból önmagába +@msg a line needs at least two points egy vonalhoz legalább két pont kell +@msg a number cannot be read egy szám nem olvasható be +@msg a swatch exchange block is too long egy színmintacsere-blokk túl hosszú +@msg a swatch exchange name is too long egy színmintacsere-név túl hosszú +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels egy {sw} × {sh} méretű kép nem méretezhető át erre: {width} × {height} pixel +@msg a {width} × {height} image is too large egy {width} × {height} méretű kép túl nagy +@msg a {width} × {height} image: {e} egy {width} × {height} méretű kép: {e} +@msg an image could not be written: {e} egy képet nem sikerült kiírni: {e} +@msg an image that couldn't be read was left out kimaradt egy kép, amely nem volt beolvasható +@msg can't open “{name}”: {e} nem nyitható meg: „{name}”: {e} +@msg cannot align zip entries to {align} bytes a zip-bejegyzések nem igazíthatók {align} bájtos határra +@msg cannot open the automation {kind} root `{_1}`: {e} az automatizálás gyökérmappája nem nyitható meg ({kind}): `{_1}`: {e} +@msg cannot read profile: {0} a profil nem olvasható: {0} +@msg color book version {version} isn't supported (only 1) a színkönyv verziója nem támogatott: {version} (csak 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) a színkönyvek nem támogatottak ebben a színtérben: {other} (csak RGB, CMYK és Lab) +@msg file name too long to zip: {_1} a fájlnév túl hosszú a zip-tömörítéshez: {_1} +@msg file name too long to zip: {name} a fájlnév túl hosszú a zip-tömörítéshez: {name} +@msg freeform line {i}: {e} szabad formájú vonal {i}: {e} +@msg freeform point {i}: {e} szabad formájú pont {i}: {e} +@msg give `{key}` or `{other}`, not both `{key}` vagy `{other}`: csak az egyiket add meg, ne mindkettőt +@msg grayscale profiles can't be working spaces yet a szürkeárnyalatos profilok egyelőre nem lehetnek munkaszínterek +@msg input contains NaN or infinite coordinates a bemenet NaN vagy végtelen koordinátákat tartalmaz +@msg input path could not be closed a bemeneti útvonalat nem sikerült lezárni +@msg invalid ICC profile: {0} érvénytelen ICC-profil: {0} +@msg invalid scale {scale} érvénytelen méretarány: {scale} +@msg its localized names take more than {_1} KB a honosított nevei több mint {_1} KB helyet foglalnak +@msg its objects are nested too deep ({e}) az objektumai túl mélyen egymásba ágyazottak ({e}) +@msg its tag table lists the `{_1}` tag more than once a címketáblája többször is felsorolja ezt a címkét: `{_1}` +@msg not a graphic style library: {e} nem grafikaistílus-könyvtár: {e} +@msg not a swatch library (.vcswatches or .gpl) nem színminta-könyvtár (.vcswatches vagy .gpl) +@msg not a swatch library (format `{_1}`) nem színminta-könyvtár (formátum: `{_1}`) +@msg not a swatch library: {e} nem színminta-könyvtár: {e} +@msg not an action set file ({e}) nem műveletkészlet-fájl ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray a profil színtere nem RGB, CMYK vagy szürkeárnyalatos: {other} +@msg regular expression too large a reguláris kifejezés túl nagy +@msg script file is not UTF-8 text: {value} a parancsfájl nem UTF-8 szöveg: {value} +@msg stop {i}: {e} színátmenet-pont {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) a színmintacsere-fájl verziója nem támogatott: {major}.{minor} (csak 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors a színkönyv több mint {ASE_MAX_ENTRIES} színt tartalmaz +@msg the color book is cut short a színkönyv csonka +@msg the color book's names take more than {_1} MB a színkönyv nevei több mint {_1} MB helyet foglalnak +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution a kép mérete {w} × {h} pixel lenne; a raszteres exportálás oldalanként legfeljebb {MAX_RASTER_SIDE} pixelt és összesen legfeljebb {_1} megapixelt enged: csökkentsd a méretarányt vagy a felbontást +@msg the optimised image can't be read back: {e} az optimalizált kép nem olvasható vissza: {e} +@msg the pixel buffer doesn't match the image size a pixelpuffer nem egyezik a kép méretével +@msg the preview: {e} az előnézeti kép: {e} +@msg the request may not read the New Document profiles folder a kérés nem olvashatja az Új dokumentum profiljainak mappáját +@msg the shapes are too degenerate to combine az alakzatok túlságosan elfajultak az egyesítéshez +@msg the shapes cross themselves and each other too often to combine az alakzatok túl sokszor keresztezik önmagukat és egymást az egyesítéshez +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups a színmintacsere-fájl több mint {ASE_MAX_ENTRIES} színt és csoportot tartalmaz +@msg the swatch exchange file is cut short a színmintacsere-fájl csonka +@msg the {_1} plate can't be read: {e} a nyomólemez nem olvasható be ({_1}): {e} +@msg this binary DXF file is damaged or cut short ez a bináris DXF-fájl sérült vagy csonka +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that ez DWG-rajz, amely nem olvasható: mentsd DXF-ként a CAD-alkalmazásból, és azt nyisd meg +@msg too many classes túl sok karakterosztály +@msg too many groups túl sok csoport +@msg too many layers for PSD (at most 32767) túl sok réteg a PSD formátumhoz (legfeljebb 32767) +@msg too many swatch exchange blocks túl sok színmintacsere-blokk +@msg unknown colour profile: {0} ismeretlen színprofil: {0} +@msg {_1} clashes with a built-in profile name {_1}: ütközik egy beépített profil nevével +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixel túl nagy a GIF formátumhoz (oldalanként legfeljebb 65535 pixel): csökkentsd a felbontást +@msg {_1}: no usable transform to/from sRGB {_1}: nincs használható átalakítás az sRGB színtérbe vagy onnan +@msg {name} is not a CMYK profile {name}: nem CMYK-profil +@msg {name} is not an RGB profile {name}: nem RGB-profil +@msg {path}: could not be read {path}: nem sikerült beolvasni +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pixel túl nagy a JPEG formátumhoz (oldalanként legfeljebb 65535 pixel): csökkentsd a felbontást +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pixel túl nagy a Targa formátumhoz (oldalanként legfeljebb 65535 pixel): csökkentsd a felbontást +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixel túl nagy a PSD formátumhoz (oldalanként legfeljebb {MAX_SIDE} pixel): csökkentsd a felbontást From 34857c6a67b19ecd814a1edb9554798f7192a813 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:11:05 -0800 Subject: [PATCH 061/108] i18n: Finnish translates 115 status and error messages that no catalog had MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit untranslated_report lists 168 status and error messages that none of the 23 complete-message catalogs translates. fi.tsv gains a row for 115 of them, in one commented block at the end of the file: image export and encoding errors, color profiles, color books and swatch exchange files, binary DXF and DWG import, 3D and Revolve limits, and script, zip, line and file errors. Placeholders, parameter names and literal values stay as the English writes them, and the rows use the catalog's existing terms (Pyöräytä, Segmentit, Varjot, värimalli, väripiste, painolevy, toimintosarjatiedosto). The other 53 listed messages are left out because open pull requests #7211, #7378, #7405 and #7434 add Finnish rows for them. --- crates/ui-egui/src/i18n/fi.tsv | 117 +++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 36f4c9f5a9..2661bf3191 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -7530,3 +7530,120 @@ breakText Glyphs Merkit Grommets Purjerenkaat Grommet Inset Purjerenkaiden etäisyys reunasta Diameter Halkaisija + +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +@msg 3D effects require finite coordinates within 100 million points 3D-tehosteet vaativat äärelliset koordinaatit 100 miljoonan pisteen rajoissa +@msg 3D effects require one to ten lights 3D-tehosteet vaativat 1–10 valonlähdettä +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP-värisyvyys {_1}: 1, 4, 8, 16, 24 tai 32 bittiä pikseliä kohti +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP-koodaus epäonnistui: {width} × {height} pikseliä ei mahdu tiedostomuotoon tai pikselipuskuriin +@msg GIF encoding failed: the palette image is malformed GIF-koodaus epäonnistui: palettikuva on virheellinen +@msg GIF encoding failed: {e} GIF-koodaus epäonnistui: {e} +@msg JPEG colour profile: {e} JPEG-väriprofiili: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG-koodaus epäonnistui: pikselipuskuri ei vastaa kuvan kokoa +@msg JPEG encoding failed: {e} JPEG-koodaus epäonnistui: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG-koodaus epäonnistui: pikselipuskuri ei vastaa kuvan kokoa +@msg PNG encoding failed: the palette image is malformed PNG-koodaus epäonnistui: palettikuva on virheellinen +@msg PNG encoding failed: {e} PNG-koodaus epäonnistui: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG-koodaus epäonnistui: {width} × {height} pikseliä ei ole kelvollinen kuvakoko +@msg PSD colour profile: {e} PSD-väriprofiili: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD-koodaus epäonnistui: pikselipuskuri ei vastaa kuvan kokoa +@msg Revolve profile contains invalid coordinates Pyöräytä-tehosteen profiilissa on virheellisiä koordinaatteja +@msg Revolve profile is too complex Pyöräytä-tehosteen profiili on liian monimutkainen +@msg Revolve projection is not finite Pyöräytä-tehosteen projektio ei ole äärellinen +@msg Revolve requires finite profile coordinates within 100 million points Pyöräytä vaatii äärelliset profiilin koordinaatit 100 miljoonan pisteen rajoissa +@msg Revolve surface is too complex; reduce Segments or simplify the profile Pyöräytä-tehosteen pinta on liian monimutkainen; pienennä Segmentit-arvoa tai yksinkertaista profiilia +@msg Revolve surface is too complex; simplify the profile Pyöräytä-tehosteen pinta on liian monimutkainen; yksinkertaista profiilia +@msg Revolve visibility cannot split the projected boundary Pyöräytä-tehosteen näkyvyyslaskenta ei voi jakaa projisoitua reunaa +@msg Revolve visibility creates too many fragments Pyöräytä-tehosteen näkyvyyslaskenta tuottaa liikaa osia +@msg Revolve visibility creates too many vector anchors Pyöräytä-tehosteen näkyvyyslaskenta tuottaa liikaa vektorin ankkuripisteitä +@msg Revolve visibility exceeds its geometry work limit Pyöräytä-tehosteen näkyvyyslaskenta ylittää geometrialaskennan työmäärän rajan +@msg Revolve visibility exceeds its spatial index limit Pyöräytä-tehosteen näkyvyyslaskenta ylittää paikkaindeksin rajan +@msg Revolve visibility has too many boundary crossings Pyöräytä-tehosteen näkyvyyslaskennassa on liikaa reunan ylityksiä +@msg Revolve visibility has too many input anchors Pyöräytä-tehosteen näkyvyyslaskennassa on liikaa syötteen ankkuripisteitä +@msg Revolve visibility requires convex cap sectors Pyöräytä-tehosteen näkyvyyslaskenta vaatii kuperat päätysektorit +@msg Revolve visibility requires finite projected faces Pyöräytä-tehosteen näkyvyyslaskenta vaatii äärelliset projisoidut tahkot +@msg SVG options: {e} SVG-asetukset: {e} +@msg Save for Web settings: {e} Verkkotallennuksen asetukset: {e} +@msg TIFF colour profile: {e} TIFF-väriprofiili: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF-koodaus epäonnistui: pikselipuskuri ei vastaa kuvan kokoa +@msg TIFF encoding failed: {e} TIFF-koodaus epäonnistui: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa-värisyvyys {_1}: 16, 24 tai 32 bittiä pikseliä kohti +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa-koodaus epäonnistui: pikselipuskuri ei vastaa kuvan kokoa +@msg The 3D projection is not finite 3D-projektio ei ole äärellinen +@msg The 3D shadow is too complex; turn Shadows off or simplify the art 3D-varjo on liian monimutkainen; poista Varjot käytöstä tai yksinkertaista kuvitusta +@msg The shape contains invalid coordinates Muodossa on virheellisiä koordinaatteja +@msg Too many Revolve faces for visibility evaluation Pyöräytä-tehosteessa on liian monta tahkoa näkyvyyden arviointiin +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft lukee värimallien vaihtotiedostosta enintään {ASE_MAX_ENTRIES} väriä ja ryhmää, ja tässä kirjastossa niitä on {entries} +@msg WebP encoding failed: {e} WebP-koodaus epäonnistui: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `index` must be a whole number `index` on oltava kokonaisluku +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` on smallThumb, mediumThumb, largeThumb, smallList tai largeList +@msg a line can't run from a point to itself viiva ei voi kulkea pisteestä samaan pisteeseen +@msg a line needs at least two points viiva tarvitsee vähintään kaksi pistettä +@msg a number cannot be read lukua ei voi lukea +@msg a swatch exchange block is too long värimallien vaihtotiedoston lohko on liian pitkä +@msg a swatch exchange name is too long värimallien vaihtotiedoston nimi on liian pitkä +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels {sw} × {sh} -kuvan kokoa ei voi muuttaa kokoon {width} × {height} pikseliä +@msg a {width} × {height} image is too large {width} × {height} -kuva on liian suuri +@msg a {width} × {height} image: {e} {width} × {height} -kuva: {e} +@msg an image could not be written: {e} kuvaa ei voitu kirjoittaa: {e} +@msg an image that couldn't be read was left out kuva, jota ei voitu lukea, jätettiin pois +@msg can't open “{name}”: {e} tiedostoa ”{name}” ei voi avata: {e} +@msg cannot align zip entries to {align} bytes zip-merkintöjä ei voi tasata {align} tavun rajoihin +@msg cannot open the automation {kind} root `{_1}`: {e} automaation {kind}-juurikansiota `{_1}` ei voi avata: {e} +@msg cannot read profile: {0} profiilia ei voi lukea: {0} +@msg color book version {version} isn't supported (only 1) värikirjan versiota {version} ei tueta (vain 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) väriavaruuden {other} värikirjoja ei tueta (vain RGB, CMYK ja Lab) +@msg file name too long to zip: {_1} tiedostonimi on liian pitkä zip-pakettiin: {_1} +@msg file name too long to zip: {name} tiedostonimi on liian pitkä zip-pakettiin: {name} +@msg freeform line {i}: {e} vapaamuotoinen viiva {i}: {e} +@msg freeform point {i}: {e} vapaamuotoinen piste {i}: {e} +@msg give `{key}` or `{other}`, not both anna `{key}` tai `{other}`, ei molempia +@msg grayscale profiles can't be working spaces yet harmaasävyprofiileja ei voi vielä käyttää työväriavaruuksina +@msg input contains NaN or infinite coordinates syötteessä on NaN-arvoja tai äärettömiä koordinaatteja +@msg input path could not be closed syötepolkua ei voitu sulkea +@msg invalid ICC profile: {0} virheellinen ICC-profiili: {0} +@msg invalid scale {scale} virheellinen skaalaus {scale} +@msg its localized names take more than {_1} KB sen lokalisoidut nimet vievät yli {_1} KB +@msg its objects are nested too deep ({e}) sen objektit ovat sisäkkäin liian monella tasolla ({e}) +@msg its tag table lists the `{_1}` tag more than once sen tunnistetaulukossa `{_1}`-tunniste on useammin kuin kerran +@msg not a graphic style library: {e} ei grafiikkatyylikirjasto: {e} +@msg not a swatch library (.vcswatches or .gpl) ei värimallikirjasto (.vcswatches tai .gpl) +@msg not a swatch library (format `{_1}`) ei värimallikirjasto (muoto `{_1}`) +@msg not a swatch library: {e} ei värimallikirjasto: {e} +@msg not an action set file ({e}) ei toimintosarjatiedosto ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray profiilin väriavaruus {other} ei ole RGB, CMYK tai Gray +@msg regular expression too large säännöllinen lauseke on liian suuri +@msg script file is not UTF-8 text: {value} komentosarjatiedosto ei ole UTF-8-tekstiä: {value} +@msg stop {i}: {e} väripiste {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) värimallien vaihtotiedoston versiota {major}.{minor} ei tueta (vain 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors värikirjassa on yli {ASE_MAX_ENTRIES} väriä +@msg the color book is cut short värikirja on katkennut +@msg the color book's names take more than {_1} MB värikirjan nimet vievät yli {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution kuvasta tulisi {w} × {h} pikseliä; rasteriviennin raja on {MAX_RASTER_SIDE} pikseliä sivua kohti ja {_1} megapikseliä: pienennä skaalausta tai tarkkuutta +@msg the optimised image can't be read back: {e} optimoitua kuvaa ei voi lukea takaisin: {e} +@msg the pixel buffer doesn't match the image size pikselipuskuri ei vastaa kuvan kokoa +@msg the preview: {e} esikatselu: {e} +@msg the request may not read the New Document profiles folder pyyntö ei saa lukea uuden asiakirjan profiilien kansiota +@msg the shapes are too degenerate to combine muodot ovat liian surkastuneita yhdistettäviksi +@msg the shapes cross themselves and each other too often to combine muodot leikkaavat itseään ja toisiaan liian usein yhdistettäviksi +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups värimallien vaihtotiedostossa on yli {ASE_MAX_ENTRIES} väriä ja ryhmää +@msg the swatch exchange file is cut short värimallien vaihtotiedosto on katkennut +@msg the {_1} plate can't be read: {e} {_1}-painolevyä ei voi lukea: {e} +@msg this binary DXF file is damaged or cut short tämä binäärinen DXF-tiedosto on vioittunut tai katkennut +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that tämä on DWG-piirustus, jota ei voi lukea: tallenna se CAD-sovelluksesta DXF-muodossa ja avaa se +@msg too many classes liikaa luokkia +@msg too many groups liikaa ryhmiä +@msg too many layers for PSD (at most 32767) liikaa tasoja PSD-tiedostoon (enintään 32767) +@msg too many swatch exchange blocks liikaa värimallien vaihtotiedoston lohkoja +@msg unknown colour profile: {0} tuntematon väriprofiili: {0} +@msg {_1} clashes with a built-in profile name {_1} on ristiriidassa sisäisen profiilin nimen kanssa +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pikseliä on liian suuri GIF-kuvalle (enintään 65535 pikseliä sivua kohti): pienennä tarkkuutta +@msg {_1}: no usable transform to/from sRGB {_1}: ei käyttökelpoista muunnosta sRGB:hen tai sRGB:stä +@msg {name} is not a CMYK profile {name} ei ole CMYK-profiili +@msg {name} is not an RGB profile {name} ei ole RGB-profiili +@msg {path}: could not be read {path}: ei voitu lukea +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pikseliä on liian suuri JPEG-kuvalle (enintään 65535 pikseliä sivua kohti): pienennä tarkkuutta +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pikseliä on liian suuri Targa-kuvalle (enintään 65535 pikseliä sivua kohti): pienennä tarkkuutta +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pikseliä on liian suuri PSD-kuvalle (enintään {MAX_SIDE} pikseliä sivua kohti): pienennä tarkkuutta From 2a2518c476928cc1f7e4e0da50e7a19cd4c1d9ae Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 23:04:53 -0800 Subject: [PATCH 062/108] i18n: Dutch translates 115 status and error messages that no catalog had Adds a Dutch @msg row for each message in the untranslated report's "messages, all 23 languages checked" list that neither main nor an open pull request translates: 3D and Revolve errors, image export, color profiles, swatch exchange files and color books, script regular expressions, the `index` whole-number check, and DXF and DWG files. Placeholders, backticked names, parameter names and command ids stay as the English writes them. The shared list drops from 168 to 53 messages; the other 53 have Dutch rows in open pull requests #7211, #7378, #7434 and #7362. --- crates/ui-egui/src/i18n/nl.tsv | 118 +++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index cd3aa43966..47d37105cb 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -7522,3 +7522,121 @@ breakText Glyphs Glyphs Grommets Zeilringen Grommet Inset Afstand van zeilringen tot de rand Diameter Diameter + +# Status and error messages: 3D effects and Revolve, image export, color profiles, swatch exchange files and +# color books, regular expressions in scripts, whole-number parameters, and DXF and DWG files. +@msg 3D effects require finite coordinates within 100 million points 3D-effecten vereisen eindige coördinaten binnen 100 miljoen punten +@msg 3D effects require one to ten lights 3D-effecten vereisen één tot tien lichten +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP-diepte {_1}: 1, 4, 8, 16, 24 of 32 bits per pixel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP-codering mislukt: {width} × {height} pixels past niet in het formaat of in de pixelbuffer +@msg GIF encoding failed: the palette image is malformed GIF-codering mislukt: de paletafbeelding is ongeldig +@msg GIF encoding failed: {e} GIF-codering mislukt: {e} +@msg JPEG colour profile: {e} JPEG-kleurprofiel: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG-codering mislukt: de pixelbuffer komt niet overeen met de afbeeldingsgrootte +@msg JPEG encoding failed: {e} JPEG-codering mislukt: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG-codering mislukt: de pixelbuffer komt niet overeen met de afbeeldingsgrootte +@msg PNG encoding failed: the palette image is malformed PNG-codering mislukt: de paletafbeelding is ongeldig +@msg PNG encoding failed: {e} PNG-codering mislukt: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG-codering mislukt: {width} × {height} pixels is geen geldige afbeeldingsgrootte +@msg PSD colour profile: {e} PSD-kleurprofiel: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD-codering mislukt: de pixelbuffer komt niet overeen met de afbeeldingsgrootte +@msg Revolve profile contains invalid coordinates Het profiel van Draaien bevat ongeldige coördinaten +@msg Revolve profile is too complex Het profiel van Draaien is te complex +@msg Revolve projection is not finite De projectie van Draaien is niet eindig +@msg Revolve requires finite profile coordinates within 100 million points Draaien vereist eindige profielcoördinaten binnen 100 miljoen punten +@msg Revolve surface is too complex; reduce Segments or simplify the profile Het oppervlak van Draaien is te complex; verlaag Segmenten of vereenvoudig het profiel +@msg Revolve surface is too complex; simplify the profile Het oppervlak van Draaien is te complex; vereenvoudig het profiel +@msg Revolve visibility cannot split the projected boundary De zichtbaarheid van Draaien kan de geprojecteerde rand niet splitsen +@msg Revolve visibility creates too many fragments De zichtbaarheid van Draaien maakt te veel fragmenten +@msg Revolve visibility creates too many vector anchors De zichtbaarheid van Draaien maakt te veel vectorankerpunten +@msg Revolve visibility exceeds its geometry work limit De zichtbaarheid van Draaien overschrijdt de werklimiet voor geometrie +@msg Revolve visibility exceeds its spatial index limit De zichtbaarheid van Draaien overschrijdt de limiet van de ruimtelijke index +@msg Revolve visibility has too many boundary crossings De zichtbaarheid van Draaien heeft te veel randkruisingen +@msg Revolve visibility has too many input anchors De zichtbaarheid van Draaien heeft te veel invoerankerpunten +@msg Revolve visibility requires convex cap sectors De zichtbaarheid van Draaien vereist convexe kapsectoren +@msg Revolve visibility requires finite projected faces De zichtbaarheid van Draaien vereist eindige geprojecteerde vlakken +@msg SVG options: {e} SVG-opties: {e} +@msg Save for Web settings: {e} Instellingen van Opslaan voor web: {e} +@msg TIFF colour profile: {e} TIFF-kleurprofiel: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF-codering mislukt: de pixelbuffer komt niet overeen met de afbeeldingsgrootte +@msg TIFF encoding failed: {e} TIFF-codering mislukt: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa-diepte {_1}: 16, 24 of 32 bits per pixel +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa-codering mislukt: de pixelbuffer komt niet overeen met de afbeeldingsgrootte +@msg The 3D projection is not finite De 3D-projectie is niet eindig +@msg The 3D shadow is too complex; turn Shadows off or simplify the art De 3D-schaduw is te complex; zet Schaduwen uit of vereenvoudig de illustratie +@msg The shape contains invalid coordinates De vorm bevat ongeldige coördinaten +@msg Too many Revolve faces for visibility evaluation Te veel vlakken van Draaien om de zichtbaarheid te bepalen +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft leest maximaal {ASE_MAX_ENTRIES} kleuren en groepen uit een uitwisselingsbestand voor stalen, en deze bibliotheek heeft er {entries} +@msg WebP encoding failed: {e} WebP-codering mislukt: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `index` must be a whole number `index` moet een geheel getal zijn +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` moet smallThumb, mediumThumb, largeThumb, smallList of largeList zijn +@msg a line can't run from a point to itself een lijn kan niet van een punt naar zichzelf lopen +@msg a line needs at least two points een lijn heeft minstens twee punten nodig +@msg a number cannot be read een getal kan niet worden gelezen +@msg a swatch exchange block is too long een blok van een uitwisselingsbestand voor stalen is te lang +@msg a swatch exchange name is too long een naam in een uitwisselingsbestand voor stalen is te lang +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels een afbeelding van {sw} × {sh} kan niet worden geschaald naar {width} × {height} pixels +@msg a {width} × {height} image is too large een afbeelding van {width} × {height} is te groot +@msg a {width} × {height} image: {e} een afbeelding van {width} × {height}: {e} +@msg an image could not be written: {e} een afbeelding kon niet worden geschreven: {e} +@msg an image that couldn't be read was left out een afbeelding die niet gelezen kon worden, is weggelaten +@msg can't open “{name}”: {e} kan „{name}” niet openen: {e} +@msg cannot align zip entries to {align} bytes zip-items kunnen niet op {align} bytes worden uitgelijnd +@msg cannot open the automation {kind} root `{_1}`: {e} kan de hoofdmap voor automatisering ({kind}) `{_1}` niet openen: {e} +@msg cannot read profile: {0} kan het profiel niet lezen: {0} +@msg color book version {version} isn't supported (only 1) kleurenboekversie {version} wordt niet ondersteund (alleen 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) kleurenboeken in kleurruimte {other} worden niet ondersteund (alleen RGB, CMYK en Lab) +@msg file name too long to zip: {_1} bestandsnaam te lang om te zippen: {_1} +@msg file name too long to zip: {name} bestandsnaam te lang om te zippen: {name} +@msg freeform line {i}: {e} lijn in vrije vorm {i}: {e} +@msg freeform point {i}: {e} punt in vrije vorm {i}: {e} +@msg give `{key}` or `{other}`, not both geef `{key}` of `{other}`, niet beide +@msg grayscale profiles can't be working spaces yet grijswaardenprofielen kunnen nog geen werkruimte zijn +@msg input contains NaN or infinite coordinates de invoer bevat NaN of oneindige coördinaten +@msg input path could not be closed het invoerpad kon niet worden gesloten +@msg invalid ICC profile: {0} ongeldig ICC-profiel: {0} +@msg invalid scale {scale} ongeldige schaal {scale} +@msg its localized names take more than {_1} KB de gelokaliseerde namen ervan nemen meer dan {_1} KB in beslag +@msg its objects are nested too deep ({e}) de objecten ervan zijn te diep genest ({e}) +@msg its tag table lists the `{_1}` tag more than once de tagtabel ervan vermeldt de tag `{_1}` meer dan eens +@msg not a graphic style library: {e} geen bibliotheek met grafische stijlen: {e} +@msg not a swatch library (.vcswatches or .gpl) geen staalbibliotheek (.vcswatches of .gpl) +@msg not a swatch library (format `{_1}`) geen staalbibliotheek (indeling `{_1}`) +@msg not a swatch library: {e} geen staalbibliotheek: {e} +@msg not an action set file ({e}) geen actiesetbestand ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray profielkleurruimte {other} is geen RGB, CMYK of grijs +@msg regular expression too large reguliere expressie te groot +@msg script file is not UTF-8 text: {value} scriptbestand is geen UTF-8-tekst: {value} +@msg stop {i}: {e} stop {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) versie {major}.{minor} van uitwisselingsbestanden voor stalen wordt niet ondersteund (alleen 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors het kleurenboek bevat meer dan {ASE_MAX_ENTRIES} kleuren +@msg the color book is cut short het kleurenboek is afgebroken +@msg the color book's names take more than {_1} MB de namen in het kleurenboek nemen meer dan {_1} MB in beslag +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution de afbeelding zou {w} × {h} pixels worden; rasterexports zijn beperkt tot {MAX_RASTER_SIDE} pixels per zijde en {_1} megapixels: verlaag de schaal of de resolutie +@msg the optimised image can't be read back: {e} de geoptimaliseerde afbeelding kan niet worden teruggelezen: {e} +@msg the pixel buffer doesn't match the image size de pixelbuffer komt niet overeen met de afbeeldingsgrootte +@msg the preview: {e} de voorvertoning: {e} +@msg the request may not read the New Document profiles folder het verzoek mag de map met profielen voor nieuwe documenten niet lezen +@msg the shapes are too degenerate to combine de vormen zijn te gedegenereerd om te combineren +@msg the shapes cross themselves and each other too often to combine de vormen kruisen zichzelf en elkaar te vaak om te combineren +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups het uitwisselingsbestand voor stalen bevat meer dan {ASE_MAX_ENTRIES} kleuren en groepen +@msg the swatch exchange file is cut short het uitwisselingsbestand voor stalen is afgebroken +@msg the {_1} plate can't be read: {e} de drukplaat {_1} kan niet worden gelezen: {e} +@msg this binary DXF file is damaged or cut short dit binaire DXF-bestand is beschadigd of afgebroken +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that dit is een DWG-tekening, die niet gelezen kan worden: sla hem in de CAD-app op als DXF en open die +@msg too many classes te veel tekenklassen +@msg too many groups te veel groepen +@msg too many layers for PSD (at most 32767) te veel lagen voor PSD (maximaal 32767) +@msg too many swatch exchange blocks te veel blokken in het uitwisselingsbestand voor stalen +@msg unknown colour profile: {0} onbekend kleurprofiel: {0} +@msg {_1} clashes with a built-in profile name {_1} botst met een ingebouwde profielnaam +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixels is te groot voor GIF (maximaal 65535 pixels per zijde): verlaag de resolutie +@msg {_1}: no usable transform to/from sRGB {_1}: geen bruikbare transformatie van of naar sRGB +@msg {name} is not a CMYK profile {name} is geen CMYK-profiel +@msg {name} is not an RGB profile {name} is geen RGB-profiel +@msg {path}: could not be read {path}: kon niet worden gelezen +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pixels is te groot voor JPEG (maximaal 65535 pixels per zijde): verlaag de resolutie +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pixels is te groot voor Targa (maximaal 65535 pixels per zijde): verlaag de resolutie +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixels is te groot voor PSD (maximaal {MAX_SIDE} pixels per zijde): verlaag de resolutie From 8969633c7104efef3360603c83852f8edd59573f Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 01:51:12 -0800 Subject: [PATCH 063/108] Flatten: boxes staggered right and down meet only the box before in the grouping sweep When an arriving box that joins everything it overlaps covers an open box to the right and below, and starts lower than it, the open box now keeps only its part above the arriving box's top in the sweep's tree. Any later box that would have met the removed part meets the arriving box instead, which is open at least as long and in the same set, so the groups stay the same. A box held by an open box is not opened and cuts nothing short. 512 boxes, each 1 pt right of and below the one before, now meet 511 open boxes in the sweep instead of 130,816, with and without transparency. Staggering right and up in sweep order still meets every earlier open box. The every-pair test oracle skips boxes that aren't finite, as the sweep does. --- crates/engine/src/cmd/flatten/analysis.rs | 112 ++++++++++++++++++++-- docs/target-app-parity.md | 2 +- 2 files changed, 103 insertions(+), 11 deletions(-) diff --git a/crates/engine/src/cmd/flatten/analysis.rs b/crates/engine/src/cmd/flatten/analysis.rs index 0adb06132a..37adcf438d 100644 --- a/crates/engine/src/cmd/flatten/analysis.rs +++ b/crates/engine/src/cmd/flatten/analysis.rs @@ -184,15 +184,17 @@ impl Sets { /// boxes it overlaps, not every open one (many objects stacked in a column, sharing their /// horizontal extent, would otherwise compare every pair). An open box inside a later box of /// its group, ending no further right, is closed early, and a box inside an open box of its group, -/// ending no further right, isn't opened: whatever overlaps it overlaps that box. Fails only when -/// cancelled ([`vectorcraft_doc::cancel`]). +/// ending no further right, isn't opened: whatever overlaps it overlaps that box. An open box that +/// a later box of its group overlaps, starting lower and ending no further right or lower, keeps +/// only its part above the later box's top, so boxes staggered right and down each meet only the +/// one before. Fails only when cancelled ([`vectorcraft_doc::cancel`]). pub(super) fn overlapping(bounds: &[Option<Rect>]) -> Result<Vec<Vec<usize>>, Cancelled> { Ok(sweep(bounds, None)?.groups()) } /// [`overlapping`]'s sweep. With `see_through`, two boxes are joined only when one of them is -/// see-through, and an open box is closed early, or a box isn't opened, only inside a see-through -/// box. The open +/// see-through, an open box is closed early, or a box isn't opened, only inside a see-through box, +/// and an open box is cut short only by a see-through box that is opened. The open /// see-through boxes and the open boxes without transparency are then in trees of their own, and /// a box without transparency meets only the see-through ones. fn sweep(bounds: &[Option<Rect>], see_through: Option<&[bool]>) -> Result<Sets, Cancelled> { @@ -285,12 +287,20 @@ fn sweep(bounds: &[Option<Rect>], see_through: Option<&[bool]>) -> Result<Sets, see_through.is_none_or(|s| s[boxes[o].0]) && b.x1 <= ob.x1 && ob.y0 <= b.y0 && b.y1 <= ob.y1 }); // Whatever overlaps a box inside this one overlaps this one, and joins it when this one is - // see-through. + // see-through. Likewise, whatever later overlaps the part of an open box at or below this + // one's top, when that box ends no further right or lower than this one, overlaps this + // one: the open box then keeps only the part above this one's top. + let cut = b.y0.next_down(); for &o in &met { sets.join(boxes[k].0, boxes[o].0); let ob = boxes[o].1; - if shadows && Some(o) != holder && ob.x1 <= b.x1 && b.y0 <= ob.y0 && ob.y1 <= b.y1 { + if !shadows || Some(o) == holder || b.x1 < ob.x1 || b.y1 < ob.y1 { + continue; + } + if b.y0 <= ob.y0 { set(&mut low[tree(o)], leaf[o], f64::NEG_INFINITY); + } else if holder.is_none() && cut < low[tree(o)][leaf[o] + size] { + set(&mut low[tree(o)], leaf[o], cut); } } if holder.is_none() { @@ -428,8 +438,10 @@ mod tests { every_pair_joining(bounds, |_, _| true) } - /// The groups of `bounds` comparing every pair, joining overlapping pairs that `joins`. + /// The groups of `bounds` comparing every pair, joining overlapping pairs that `joins`. A box + /// that isn't finite ([`finite`]) overlaps none. fn every_pair_joining(bounds: &[Option<Rect>], joins: impl Fn(usize, usize) -> bool) -> Vec<Vec<usize>> { + let bounds: Vec<Option<Rect>> = bounds.iter().map(|b| b.filter(finite)).collect(); let n = bounds.len(); let mut group: Vec<usize> = (0..n).collect(); let hit = |a: &Rect, b: &Rect| a.x0 <= b.x1 && b.x0 <= a.x1 && a.y0 <= b.y1 && b.y0 <= a.y1; @@ -731,9 +743,9 @@ mod tests { ]; let see = [false, true, true, false]; let mut sets = sweep(&bounds, Some(&see)).unwrap(); - // The second box meets the first; the third meets the second; the fourth meets the second - // and the third. - assert_eq!(sets.meets, 4); + // The second box meets the first; the third meets the second, which keeps only its part + // above the third's top; the fourth meets the third. + assert_eq!(sets.meets, 3); assert_eq!(sets.groups(), vec![vec![0, 1, 2, 3]]); // Opaque boxes alone meet nothing. let mut sets = sweep(&bounds, Some(&[false; 4])).unwrap(); @@ -741,6 +753,86 @@ mod tests { assert_eq!(sets.groups().len(), 4); } + /// `n` boxes of one size, each a little right of and below the one before, all overlapping and + /// none inside another. + fn staggered(n: usize) -> Vec<Option<Rect>> { + let w = 2.0 * n as f64; + (0..n).map(|i| Some(Rect::new(i as f64, i as f64, w + i as f64, w + i as f64))).collect() + } + + /// Each box of a stagger right and down meets only the box before it, which keeps only its + /// part above the new box's top, not every box still open. + #[test] + fn staggered_boxes_meet_only_the_box_before() { + let n = 512; + let bounds = staggered(n); + let mut sets = sweep(&bounds, None).unwrap(); + assert_eq!(sets.meets, n - 1); + assert_eq!(sets.groups(), vec![(0..n).collect::<Vec<_>>()]); + // See-through boxes do the same with transparency. + let mut sets = sweep(&bounds, Some(&vec![true; n])).unwrap(); + assert_eq!(sets.meets, n - 1); + assert_eq!(sets.groups(), vec![(0..n).collect::<Vec<_>>()]); + } + + /// An open box keeps the part a later box would meet without meeting the box that cut it short: + /// a part lower than that box, a part further right, or any part when that box is opaque. + #[test] + fn a_box_is_cut_short_only_where_the_later_box_covers_it() { + let k = Rect::new(5.0, 5.0, 15.0, 15.0); + // Lower than `k`: the last box overlaps only the bottom of the first. + let lower = [Some(Rect::new(0.0, 0.0, 10.0, 20.0)), Some(k), Some(Rect::new(8.0, 17.0, 9.0, 25.0))]; + assert_eq!(overlapping(&lower).unwrap(), vec![vec![0, 1, 2]]); + // Further right than `k`: the last box starts right of it and overlaps the first. + let right = [Some(Rect::new(0.0, 0.0, 20.0, 10.0)), Some(k), Some(Rect::new(17.0, 7.0, 25.0, 9.0))]; + assert_eq!(overlapping(&right).unwrap(), vec![vec![0, 1, 2]]); + // An opaque `k` doesn't join the opaque last box, which joins the see-through first one. + let opaque = [Some(Rect::new(0.0, 0.0, 10.0, 10.0)), Some(k), Some(Rect::new(6.0, 8.0, 7.0, 20.0))]; + let mut sets = sweep(&opaque, Some(&[true, false, false])).unwrap(); + assert_eq!(sets.groups(), vec![vec![0, 1, 2]]); + // A see-through `k` held by a see-through box around it isn't opened and cuts nothing short. + let held = [Some(Rect::new(0.0, 2.0, 30.0, 30.0)), Some(Rect::new(1.0, 0.0, 10.0, 10.0)), Some(k), Some(Rect::new(6.0, 8.0, 7.0, 20.0))]; + let see = [true, false, true, false]; + let mut sets = sweep(&held, Some(&see)).unwrap(); + assert_eq!(sets.groups(), vec![vec![0, 1, 2, 3]]); + assert_eq!(sets.groups(), every_pair_joining(&held, |i, j| see[i] || see[j])); + } + + /// Staggers in all four directions, of mixed sizes (empty ones included) with gaps and shared + /// edges, in either order, with signed zeros and boxes that aren't finite, some see-through, + /// group as comparing every pair groups them. + #[test] + fn staggered_boxes_group_as_comparing_every_pair() { + let mut seed = 0x3c6e_f372_fe94_f82bu64; + let mut next = |m: f64| { + seed ^= seed << 13; + seed ^= seed >> 7; + seed ^= seed << 17; + (seed % 1000) as f64 / 1000.0 * m + }; + for round in 0..48 { + let n = 8 + round * 2; + let (sx, sy) = (if round % 2 == 0 { 1.0 } else { -1.0 }, if round / 2 % 2 == 0 { 1.0 } else { -1.0 }); + let mut bounds: Vec<Option<Rect>> = (0..n) + .map(|i| { + let step = next(4.0).floor(); + let (x, y) = (sx * (i as f64 * 2.0 + step), sy * (i as f64 * 2.0 + next(4.0).floor())); + let (w, h) = (next(8.0).floor() * 2.0, next(8.0).floor() * 2.0); + Some(Rect::new(x, y, x + w, y + h)) + }) + .collect(); + bounds[0] = Some(Rect::new(-0.0, -0.0, 0.0, 6.0)); + bounds[n / 2] = Some(Rect::new(0.0, sy * 6.0, f64::INFINITY, sy * 6.0 + 4.0)); + if round / 4 % 2 == 1 { + bounds.reverse(); + } + assert_eq!(overlapping(&bounds).unwrap(), every_pair(&bounds), "round {round}"); + let see: Vec<bool> = (0..n).map(|_| next(1.0) < 0.5).collect(); + let mut sets = sweep(&bounds, Some(&see)).unwrap(); + assert_eq!(sets.groups(), every_pair_joining(&bounds, |i, j| see[i] || see[j]), "round {round}, with transparency"); + } + } + /// An opaque box between a member and its group's top that paints over the member joins, and /// so on along a chain; one under the member stays, but for one within the fringe. #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 746d751ea0..bf612d211a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1347,7 +1347,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Object › Flatten Transparency takes a frame of threaded text out of the thread in the same way when Convert All Text to Outlines outlines it or when the frame becomes flat regions or an image, and the other frames keep the text they hold. Object › Flatten Transparency, the Flattener Preview, and EPS, PDF and print output that flatten transparency stop building a group's flat regions at the first region past the raster/vector balance's limit (10^(balance/20), rounded down) and rasterize the whole group without building the remaining regions. Building every region gives the same flattened art and the same files. With Clip Complex Regions on, a group builds every region and its image is clipped to them. Object › Flatten Transparency, the Flattener Preview, and EPS, PDF and print output that flatten transparency leave art without transparency as it is when it overlaps only other art without transparency, unless it overlaps a member of a see-through object's group and lies above that member and below the group's topmost object. Such art joins the group, and the group takes the place of its topmost object, so the stacking order stays the same. In files without transparency with Clip Complex Regions on, art under the group within one image pixel of a member joins it too. The 1 pt antialiasing margin goes around a group's art once, however deeply its groups nest. On a grid of 3,000 rectangles with a 0.5 pt stroke, 60 of them with a drop shadow, the Flattener Preview counts 180 affected objects where it counted 3,000, and Flatten Transparency with the Medium preset makes 240 flat regions and 2 images where it made one image of the whole grid. These rules are VectorCraft's own (`tests::flatten::opaque_art_that_touches_only_opaque_art_stays`, `tests::flatten::opaque_art_the_group_would_move_under_joins_it`). - When they group art for flattening, Object › Flatten Transparency, the Flattener Preview, and EPS, PDF and print output that flatten transparency compare the box of an object without transparency only with the boxes of see-through objects in the pass that splits art by transparency. In both passes, a box that lies inside an earlier box that ends no further right and joins everything it overlaps is not compared with later boxes. With one see-through object inside 512 nested objects without transparency, the grouping compares 1,024 pairs of boxes where it compared 262,145, and the groups stay the same (`cmd::flatten::analysis::tests::nested_opaque_boxes_meet_only_the_see_through_box`, `a_shrinking_nest_meets_only_its_outermost_box`). + When they group art for flattening, Object › Flatten Transparency, the Flattener Preview, and EPS, PDF and print output that flatten transparency compare the box of an object without transparency only with the boxes of see-through objects in the pass that splits art by transparency. In both passes, a box that lies inside an earlier box that ends no further right and joins everything it overlaps is not compared with later boxes. With one see-through object inside 512 nested objects without transparency, the grouping compares 1,024 pairs of boxes where it compared 262,145, and the groups stay the same (`cmd::flatten::analysis::tests::nested_opaque_boxes_meet_only_the_see_through_box`, `a_shrinking_nest_meets_only_its_outermost_box`). When a later box that joins everything it overlaps covers an earlier box to the right and below, the grouping compares the earlier box with still later boxes only above the later box's top: 512 boxes, each 1 pt right of and below the one before, compare 511 pairs where they compared 130,816, with and without transparency, and the groups stay the same (`cmd::flatten::analysis::tests::staggered_boxes_meet_only_the_box_before`, `staggered_boxes_group_as_comparing_every_pair`). New Symbol and Redefine Symbol on a frame of threaded text take it out of the thread with the text it shows, which the symbol's art holds, and the other frames keep the text they hold. When the last frame goes into the symbol, the text it has no room for goes after the text of the last frame that stays. When every frame of a thread goes into the symbol, the copy of the last frame keeps all its text. With Optical Margin Alignment on, or Roman Hanging Punctuation on in the first paragraph, the glyphs at the ends of left-to-right type on a path hang outside its brackets, measured along the path. The type hangs at the start bracket when its line is placed there, hangs at the end bracket when the line is placed there, and hangs at both when it is centered. Glyphs that hang past the end bracket do not make the type overflow, and a hang stops at an open path's end. SVG export writes such type as outlines. Type › Type on a Path › Center on Top and Center on Bottom (`type.pathCenter.top`, `type.pathCenter.bottom`, also on the Contextual Task Bar for type on a closed path) slide type on a closed path so the middle of its span lands on the path's topmost or bottommost point as drawn, keep the span's length, and set the first paragraph to Center unless it is Center or Justify Center. This is VectorCraft's own behavior (`crates/geom/src/arc.rs`, `crates/engine/src/tests/pathtype.rs`). From cdd6ffa1f2df9d7e8ad529c29a60c4e8c31c2299 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:04:59 -0800 Subject: [PATCH 064/108] PDF/.ai import: graphic styles that paint with a named gradient load with it A graphic style from a .ai or EPS library whose fill, or the fill or stroke of a style of one paint, paints with one of the file's gradients by name was left out of the library. Such styles now load with that gradient at the style's angle. The style stores only the gradient's name and angle, so the gradient is fitted to the bounds of each object the style is applied to; this placement is VectorCraft's own rule. - A style of one paint reads a gradient instance's fill or stroke as that gradient; a gradient outside an instance is still not read. - A fill filter paints with its last paint: a color, a gradient or a pattern replaces whichever of the others came before it. - A style naming a gradient the file doesn't define, or painting with a pattern, is still left out. Docs: docs/mcp.md, graphicStyle.loadLibrary params, progress doc. --- .../engine/src/cmd/fileio/tests_aiimport.rs | 62 +++++++++++++++++- crates/engine/src/cmd/stylelib.rs | 2 +- crates/engine/tests/import_fuzz.rs | 9 ++- crates/eps/src/import/ai/read/document.rs | 2 +- crates/eps/src/import/ai/read/ops.rs | 27 ++++++-- crates/eps/src/import/ai/style.rs | 63 ++++++++++++++++--- crates/eps/src/import/ai/style/tests.rs | 38 +++++++++-- docs/mcp.md | 6 +- docs/target-app-parity.md | 1 + 9 files changed, 185 insertions(+), 25 deletions(-) diff --git a/crates/engine/src/cmd/fileio/tests_aiimport.rs b/crates/engine/src/cmd/fileio/tests_aiimport.rs index fafcc12215..c48b437b76 100644 --- a/crates/engine/src/cmd/fileio/tests_aiimport.rs +++ b/crates/engine/src/cmd/fileio/tests_aiimport.rs @@ -424,8 +424,8 @@ fn a_graphic_style_library_in_a_ai_file_without_layers_loads_its_styles() { /BasicFilter :\n(Fill Style Filter) 0 0 /Filter ,\n1 /Visible ,\n/Dictionary : /NotRecorded ,\n/FillStyle : 0 O\n{xa}0 1 Xd\n/Def ;\n (FillStyle) ,\n; /Dict ;\n /Part ,\n;\n" ) }; - // Styles of one paint (`/SimpleStyle`): a red 2 pt stroke and no fill, and a gradient fill, - // which isn't read, so it is left out rather than listed with no paint. + // Styles of one paint (`/SimpleStyle`): a red 2 pt stroke and no fill, and a fill with a gradient + // the file doesn't define, which is left out rather than listed with no paint. let one_paint = |name: &str, paint: &str| format!("/KnownStyle :\n({name}) /Name ,\n/SimpleStyle :\n{paint}/Paint ;\n/Def ;\n"); let styles = format!( "%AI9_BeginArtStyles\n{}{}{}{}{}%AI9_EndArtStyles\n\ @@ -465,6 +465,64 @@ fn a_graphic_style_library_in_a_ai_file_without_layers_loads_its_styles() { assert_eq!(styles, [("Red", 1), ("Green", 2), ("Blue", 3), ("Red outline", 4)], "{r}"); } +/// A `.ai` graphic style library's styles that paint with one of the file's gradients by name (a +/// fill style's, and the fill or stroke of a style of one paint) load with that gradient at the +/// style's angle, fitted to the bounds of each object the style is applied to; one naming a gradient +/// the file doesn't define is left out. +#[test] +fn graphic_styles_in_a_ai_library_that_paint_with_a_named_gradient_load_with_it() { + let gradient = + "%AI5_BeginGradient: (Sky)\n(Sky) 0 2 Bd\n[\n%_0 0 0 0 0 1 0 2 1 6 50 0 Bs\n%_0 0 0 0 1 1 1 2 1 6 50 100 Bs\nBD\n%AI5_EndGradient\n"; + let band = "/KnownStyle :\n(Sky band) /Name ,\n/ActiveStyle :\n/CompoundFilter :\n(Chain Style Filter) 0 0 /Filter ,\n1 /Visible ,\n\ + /BasicFilter :\n(Fill Style Filter) 0 0 /Filter ,\n1 /Visible ,\n/Dictionary : /NotRecorded ,\n/FillStyle : 0 O\n\ + 0 Bb\n2 (Sky) 0 0 45 100 1 0 0 1 0 0 Bg\n0 BB\n0 1 Xd\n/Def ;\n (FillStyle) ,\n; /Dict ;\n /Part ,\n;\n"; + let one_paint = |name: &str, paint: &str| format!("/KnownStyle :\n({name}) /Name ,\n/SimpleStyle :\n{paint}/Paint ;\n/Def ;\n"); + let styles = format!( + "%AI9_BeginArtStyles\n{band}{}{}{}%AI9_EndArtStyles\n\ + %AI9_BeginArtStyleList\n(Sky band)\n(Sky fill)\n(Sky outline)\n(Dusk fill)\n%AI9_EndArtStyleList\n", + one_paint("Sky fill", "0 O\n0 Bb\n2 (Sky) 0 0 0 100 1 0 0 1 0 0 Bg\n0 BB\n0 1 Xd\n"), + one_paint("Sky outline", "0 R\n0 J 0 j 2 w 10 M []0 d\n1 Bb\n2 (Sky) 0 0 90 100 1 0 0 1 0 0 1 Bg\n0 BB\n1 0 Xd\n"), + one_paint("Dusk fill", "0 O\n0 Bb\n2 (Dusk) 0 0 0 100 1 0 0 1 0 0 Bg\n0 BB\n0 1 Xd\n") + ); + // A palette with the gradient's swatch, so the document opened from the file shows its gradient. + let palette = INKS_PALETTE.replace("0 0 Pb\n", "0 0 Pb\nBb\n2 (Sky) 0 0 0 1 1 0 0 1 0 0 1 Bg\n0 BB\n(Sky)\nPc\n"); + let data = ai::editing_data(200.0, 100.0, &format!("{gradient}{palette}{styles}")); + let file = ai::ai(&compressed(data.as_bytes()), "1 0 0 rg 10 50 30 40 re f"); + let mut s = Session::new(); + let p = json!({"dataBase64": vectorcraft_format::base64_encode(&file), "name": "skies.ai"}); + let r = s.execute("graphicStyle.loadLibrary", &p).unwrap(); + let library = r["library"].clone(); + let lib = s.execute("graphicStyle.library", &json!({"library": library})).unwrap(); + let names: Vec<&str> = lib["styles"].as_array().unwrap().iter().map(|g| g["name"].as_str().unwrap()).collect(); + assert_eq!(names, ["Sky band", "Sky fill", "Sky outline"], "{lib}"); + // The file's gradient, as the document opened from it has its swatch. + open(&mut s, "skies.ai", &file, json!({})).unwrap(); + let sky = match s.doc().unwrap().doc.swatch("Sky").map(|w| w.paint.clone()) { + Some(vectorcraft_color::Paint::Gradient(g)) => g.gradient, + other => panic!("{other:?}"), + }; + // Applied to a small and a large rectangle, each gradient is fitted to the rectangle it paints. + s.execute("file.new", &json!({"width": 300, "height": 300})).unwrap(); + for (style, (x, size)) in [("Sky band", (10, 20)), ("Sky fill", (40, 200)), ("Sky outline", (10, 120))] { + let rect = json!({"x": x, "y": x, "width": size, "height": size / 2}); + let id = NodeId(s.execute("shape.rectangle", &rect).unwrap()["id"].as_u64().unwrap()); + let r = s.execute("graphicStyle.addFromLibrary", &json!({"library": library, "names": [style], "apply": true, "ids": [id.0]})).unwrap(); + assert_eq!(r["added"], json!([style]), "{r}"); + let look = &s.doc().unwrap().doc.node(id).unwrap().appearance; + let (paint, angle, stroked) = match style { + "Sky outline" => (look.stroke().map(|st| &st.paint), 90.0, true), + "Sky band" => (look.fill().map(|f| &f.paint), 45.0, false), + _ => (look.fill().map(|f| &f.paint), 0.0, false), + }; + let Some(vectorcraft_color::Paint::Gradient(g)) = paint else { panic!("{style}: {look:?}") }; + assert_eq!((&g.gradient, g.geom, g.angle), (&sky, None, angle), "{style}"); + assert_eq!(look.stroke().is_some(), stroked, "{style}: {look:?}"); + if stroked { + assert!(look.fill().is_none() && look.stroke().is_some_and(|st| st.width == 2.0), "{look:?}"); + } + } +} + /// A `.ai` symbol library (symbols and their list, no layers) opens with its symbols, and Other /// Library… in the Symbols panel lists them in the list's order. #[test] diff --git a/crates/engine/src/cmd/stylelib.rs b/crates/engine/src/cmd/stylelib.rs index 09b478e8c7..bc06f197e5 100644 --- a/crates/engine/src/cmd/stylelib.rs +++ b/crates/engine/src/cmd/stylelib.rs @@ -62,7 +62,7 @@ pub fn specs() -> Vec<CommandSpec> { "Other Library…", ["Window", "Graphic Style Libraries"], None, - "{path? | data?: file text | dataBase64?, name?: file name (default: the path's)} load a .vcstyles library, or the graphic styles of any document VectorCraft opens (see document.formats), for the library panel (Window → Graphic Style Libraries lists it until the app quits; a file of the user library folder, or a file with the same extension and bytes as one there, opens as that User Defined library) → {library: id, name, count}", + "{path? | data?: file text | dataBase64?, name?: file name (default: the path's)} load a .vcstyles library, or the graphic styles of any document VectorCraft opens (see document.formats), for the library panel (Window → Graphic Style Libraries lists it until the app quits; a file of the user library folder, or a file with the same extension and bytes as one there, opens as that User Defined library; a .ai or EPS style painting with one of the file's gradients by name takes it at the style's angle, fitted to each object it is applied to, VectorCraft's own placement) → {library: id, name, count}", always, load ), diff --git a/crates/engine/tests/import_fuzz.rs b/crates/engine/tests/import_fuzz.rs index 79178d6233..7e613460cd 100644 --- a/crates/engine/tests/import_fuzz.rs +++ b/crates/engine/tests/import_fuzz.rs @@ -4329,7 +4329,8 @@ proptest! { "0 R", "0 O", "0 1 1 0 K", "1 0 0 0 k", "0 0 0 0 1 0 0 Xa", "0 0 0 0 1 0 0 XA", "0.5 G", "0 g", "K", "Xa", "0 J 0 j 2 w 10 M []0 d", "-1 w", "1e400 w", "0 M", "[3 -1]0 d", "[]0 d", "1 0 Xd", "0 1 Xd", "1 1 Xd", "0 0 Xd", "1 Xd", "Xd", "0 1 0 0 0 Xy", "1 0.5 1 1 0 Xy", "Xy", - "0 Bb", "2 (Sky) 0 0 0 100 1 0 0 1 0 0 Bg", "0 BB", "(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] p", + "0 Bb", "1 Bb", "2 (Sky) 0 0 0 100 1 0 0 1 0 0 Bg", "2 (Sky) 0 0 1e400 100 1 0 0 1 0 0 Bg", "2 (Dusk) 0 0 0 100 1 0 0 1 0 0 Bg", + "0 BB", "(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] p", "(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] P", "0 XR", ]).prop_map(|op| (op.to_string(), true)), "[ -~]{0,12}".prop_map(|text| (text, false)), @@ -4338,9 +4339,11 @@ proptest! { ) { use vectorcraft_testkit::ai; let close = if closed { "/Paint ;\n/Def ;\n" } else { "" }; - // C, a red 2 pt stroke, comes first, so that it reads whatever A holds. + // C, a red 2 pt stroke, comes first, so that it reads whatever A holds. The file defines the + // gradient Sky, which a gradient paint of A may name. let header = format!( - "%AI9_BeginArtStyles\n/KnownStyle :\n(C) /Name ,\n/SimpleStyle :\n0 R\n0 1 1 0 K\n2 w\n1 0 Xd\n/Paint ;\n/Def ;\n\ + "%AI5_BeginGradient: (Sky)\n(Sky) 0 2 Bd\n[\n%_0 0 0 0 0 1 0 2 1 6 50 0 Bs\n%_0 0 0 0 1 1 1 2 1 6 50 100 Bs\nBD\n%AI5_EndGradient\n\ + %AI9_BeginArtStyles\n/KnownStyle :\n(C) /Name ,\n/SimpleStyle :\n0 R\n0 1 1 0 K\n2 w\n1 0 Xd\n/Paint ;\n/Def ;\n\ /KnownStyle :\n(A) /Name ,\n/SimpleStyle :\n{}\n{close}/KnownStyle :\n(B) /Name ,\n/SimpleStyle :\n1 0 Xd\n/Paint ;\n/Def ;\n\ %AI9_EndArtStyles\n%AI9_BeginArtStyleList\n(A)\n(B)\n(C)\n%AI9_EndArtStyleList\n", ops.iter().map(|(op, _)| op.as_str()).collect::<Vec<_>>().join("\n") diff --git a/crates/eps/src/import/ai/read/document.rs b/crates/eps/src/import/ai/read/document.rs index a7451c8b99..ecae1e8954 100644 --- a/crates/eps/src/import/ai/read/document.rs +++ b/crates/eps/src/import/ai/read/document.rs @@ -1147,7 +1147,7 @@ impl<'a> Reader<'a> { continue; } let Some(st) = self.styles.get(&name) else { continue }; - let Some(mut appearance) = appearance_from_art_style(st) else { continue }; + let Some(mut appearance) = appearance_from_art_style(st, &self.gradients) else { continue }; // A Large Canvas copy's styles are at its art's scale ([`Self::ensure_space`]). if let Some(s) = self.large_canvas.filter(|s| *s != 1.0) { appearance.scale_strokes(s); diff --git a/crates/eps/src/import/ai/read/ops.rs b/crates/eps/src/import/ai/read/ops.rs index f10682b592..f480688f5a 100644 --- a/crates/eps/src/import/ai/read/ops.rs +++ b/crates/eps/src/import/ai/read/ops.rs @@ -1296,9 +1296,11 @@ fn styled(object: &Node, look: &Node, st: &crate::import::ai::style::ArtStyle, p } /// A graphic style's appearance from art style `st`, on no object: `None` when the style isn't one -/// this reads, or paints with a gradient or a pattern (placed on each object as its drawn look has them). +/// this reads, paints with a pattern, or paints with a gradient that names no swatch of `gradients`. /// A style that is one paint is its fill and stroke ([`crate::import::ai::style::ArtStyle::one_paint`]). -pub(super) fn appearance_from_art_style(st: &crate::import::ai::style::ArtStyle) -> Option<Appearance> { +/// A style keeps only its gradients' names and angles, so each one's gradient, by VectorCraft's own +/// rule, is fitted to the bounds of whatever object the style is applied to, at its angle. +pub(super) fn appearance_from_art_style(st: &crate::import::ai::style::ArtStyle, gradients: &HashMap<String, Gradient>) -> Option<Appearance> { use crate::import::ai::style::StyleItem; if !st.plain { return None; @@ -1314,8 +1316,15 @@ pub(super) fn appearance_from_art_style(st: &crate::import::ai::style::ArtStyle) // A graphic style's brush isn't checked against the file's brushes: it is left out. StyleItem::Stroke { brush: Some(_), .. } => return None, StyleItem::Stroke { .. } => stroke_layer(item)?, - StyleItem::Gradient { .. } | StyleItem::Pattern { .. } => return None, + StyleItem::Gradient { name, angle } => AppearanceItem::Fill(FillLayer::new(named_gradient(name.as_deref()?, *angle, gradients)?)), + StyleItem::Pattern { .. } => return None, }; + // A one-paint style's gradient stroke names its swatch (`style::OnePaint::items`). + if let AppearanceItem::Stroke(s) = &mut layer + && let Paint::Gradient(g) = &s.paint + { + s.paint = named_gradient(g.swatch.as_deref()?, g.angle, gradients)?; + } if let Some(look) = st.looks.get(n) { with_look(&mut layer, look); } @@ -1324,6 +1333,14 @@ pub(super) fn appearance_from_art_style(st: &crate::import::ai::style::ArtStyle) Some(Appearance { items, effects: st.effects.clone(), contents_index: st.contents_index }) } +/// The gradient of `gradients` named `name` at `angle` degrees, fitted to the bounds of the object it +/// paints (`None` when there is no such gradient). +fn named_gradient(name: &str, angle: f64, gradients: &HashMap<String, Gradient>) -> Option<Paint> { + let mut g = vectorcraft_color::gradient::GradientPaint::new(gradients.get(name)?.clone()); + g.angle = angle; + Some(Paint::Gradient(Box::new(g))) +} + /// What the reader makes of art style `name` in `section` (the text between `%AI9_BeginArtStyles` /// and its end), for writers that check a style before they write it. #[derive(Clone, Debug)] @@ -1373,7 +1390,9 @@ pub(crate) fn read_art_style(section: &[u8], name: &str, own_gradient: Option<&P _ => None, }) .collect(); - let mut appearance = appearance_from_art_style(&st)?; + // No gradient is taken by name: on an object, one that isn't its own is placed where its drawn + // look has it. + let mut appearance = appearance_from_art_style(&st, &HashMap::new())?; for (item, brush) in appearance.items.iter_mut().zip(brushes) { if let (AppearanceItem::Stroke(s), Some(brush)) = (item, brush) { s.brush = Some(brush); diff --git a/crates/eps/src/import/ai/style.rs b/crates/eps/src/import/ai/style.rs index 891c058bb6..b9d62b278e 100644 --- a/crates/eps/src/import/ai/style.rs +++ b/crates/eps/src/import/ai/style.rs @@ -216,7 +216,8 @@ pub(super) struct ArtStyle { pub simple_pattern: Option<StyleItem>, /// A style that is one paint: its fill and stroke, bottom first, each there when its /// `stroke fill Xd` turns it on (none when neither is on). `Err` when it turns on a fill or - /// stroke whose paint isn't read here (a gradient, a pattern, a color that isn't read) or has + /// stroke whose paint isn't read here (a gradient that names no swatch or isn't in a gradient + /// instance, a pattern, a color that isn't read) or has /// no `Xd`. `None` for a style with filters, whose paint is [`Self::items`]. pub one_paint: Option<Result<Vec<StyleItem>, ()>>, } @@ -313,6 +314,8 @@ struct Filter { gradient_of: Option<(Option<String>, f64)>, /// `(name) … [matrix] p`, and the numbers between the name and the matrix. pattern: Option<(String, Option<[f64; 6]>, Vec<f64>)>, + /// Its last fill paint, which replaces those before it. + fill_last: LastPaint, /// The plug-in object it refers to (`/GObjRef : (name) (plug-in) /PluginObject`): its name and /// plug-in name. plugin_object: Option<(String, String)>, @@ -346,6 +349,7 @@ impl Default for Filter { gradient: false, gradient_of: None, pattern: None, + fill_last: LastPaint::None, plugin_object: None, xy: None, xy_group: None, @@ -354,6 +358,15 @@ impl Default for Filter { } } +/// Which paint a filter's paint operators set last. +#[derive(Clone, Copy, Debug, PartialEq)] +enum LastPaint { + None, + Color, + Gradient, + Pattern, +} + /// Most filters read in one style. const MAX_FILTERS: usize = 4096; @@ -662,7 +675,7 @@ fn paint_op(f: &mut Filter, op: &str, vals: &[V], names: &mut Names) { | "xz" => { let Some((p, _)) = paint::color_op_in(op, vals, names) else { return }; if op.ends_with(|c: char| c.is_ascii_lowercase()) { - f.fill = Some(p); + (f.fill, f.fill_last) = (Some(p), LastPaint::Color); } else { f.stroke = Some(p); } @@ -719,7 +732,7 @@ fn paint_op(f: &mut Filter, op: &str, vals: &[V], names: &mut Names) { } // `flag (name) x y angle length a b c d tx ty Bg`. "Bg" => { - f.gradient = true; + (f.gradient, f.fill_last) = (true, LastPaint::Gradient); let at = vals.iter().rposition(|v| matches!(v, V::Str(_))); let name = at.and_then(|i| vals.get(i)).and_then(|v| names.text(v)); let n: Vec<f64> = at.map_or(&[][..], |i| vals.get(i + 1..).unwrap_or_default()).iter().filter_map(V::num).collect(); @@ -728,7 +741,7 @@ fn paint_op(f: &mut Filter, op: &str, vals: &[V], names: &mut Names) { } "p" => { if let Some(pattern) = pattern_operands(vals, names) { - f.pattern = Some(pattern); + (f.pattern, f.fill_last) = (Some(pattern), LastPaint::Pattern); } } _ => {} @@ -786,6 +799,11 @@ struct OnePaint { stroke_unread: bool, /// Inside a gradient instance (`flag Bb` … `BB`): whether it paints the stroke (flag 1). instance: Option<bool>, + /// The gradient swatch's name and angle of its last fill paint, when that is a gradient + /// instance's `Bg`. + fill_gradient: Option<(String, f64)>, + /// The same for its last stroke paint. + stroke_gradient: Option<(String, f64)>, } impl OnePaint { @@ -811,9 +829,26 @@ impl OnePaint { _ => {} } paint_op(&mut self.paint, op, vals, names); + // A gradient instance's `Bg` names the swatch its fill or stroke paints with; any other + // paint of that side replaces it. Outside an instance, which side it paints isn't known. + let named = || match (op, &self.paint.gradient_of) { + ("Bg", Some((Some(name), angle))) => Some((name.clone(), *angle)), + _ => None, + }; + match op { + "Bg" if self.instance == Some(true) => self.stroke_gradient = named(), + "Bg" if self.instance == Some(false) => self.fill_gradient = named(), + "Bg" => (self.fill_gradient, self.stroke_gradient) = (None, None), + "p" | "Xa" | "k" | "g" | "x" | "Xx" | "Xk" | "Xs" | "Xz" | "xa" | "xx" | "xk" | "xs" | "xz" => self.fill_gradient = None, + "P" | "XA" | "K" | "G" | "X" | "XX" | "XK" | "XS" | "XZ" => self.stroke_gradient = None, + _ => {} + } } - /// Its fill and stroke ([`ArtStyle::one_paint`]). + /// Its fill and stroke ([`ArtStyle::one_paint`]). A gradient fill is its [`StyleItem::Gradient`]; + /// a gradient stroke's paint is a gradient that only names its swatch (`swatch`) at its angle, + /// with default stops: `read::ops`' `appearance_from_art_style` gives it the file's gradient of + /// that name. fn items(&self) -> Result<Vec<StyleItem>, ()> { let f = &self.paint; if !self.xd { @@ -822,14 +857,22 @@ impl OnePaint { let (stroked, filled) = f.paints; let mut items = vec![]; if filled { - match &f.fill { - Some(p) if !self.fill_unread => items.push(StyleItem::Fill(p.clone())), + match (&f.fill, &self.fill_gradient) { + (Some(p), _) if !self.fill_unread => items.push(StyleItem::Fill(p.clone())), + (_, Some((name, angle))) if self.fill_unread => items.push(StyleItem::Gradient { name: Some(name.clone()), angle: *angle }), _ => return Err(()), } } if stroked { - match &f.stroke { - Some(p) if !self.stroke_unread => items.push(StyleItem::Stroke { + let named = self.stroke_gradient.as_ref().filter(|_| self.stroke_unread).map(|(name, angle)| { + Paint::Gradient(Box::new(vectorcraft_color::gradient::GradientPaint { + angle: *angle, + swatch: Some(name.clone()), + ..vectorcraft_color::gradient::GradientPaint::new(vectorcraft_color::gradient::Gradient::default()) + })) + }); + match named.as_ref().or(f.stroke.as_ref().filter(|_| !self.stroke_unread)) { + Some(p) => items.push(StyleItem::Stroke { paint: p.clone(), width: f.width, cap: f.cap, @@ -1396,6 +1439,8 @@ fn paint_item(f: &Filter) -> Result<Option<StyleItem>, ()> { match f.name.as_str() { FILL if !f.paints.1 => Ok(None), FILL => match (&f.pattern, &f.gradient_of, &f.fill) { + (.., Some(p)) if f.fill_last == LastPaint::Color => Ok(Some(StyleItem::Fill(p.clone()))), + (_, Some((name, angle)), _) if f.fill_last == LastPaint::Gradient => Ok(Some(StyleItem::Gradient { name: name.clone(), angle: *angle })), (Some((name, matrix, controls)), ..) => Ok(Some(StyleItem::Pattern { name: name.clone(), matrix: *matrix, controls: controls.clone() })), (None, Some((name, angle)), _) => Ok(Some(StyleItem::Gradient { name: name.clone(), angle: *angle })), (None, None, _) if f.gradient => Ok(Some(StyleItem::Gradient { name: None, angle: 0.0 })), diff --git a/crates/eps/src/import/ai/style/tests.rs b/crates/eps/src/import/ai/style/tests.rs index ea8428809c..c4b006fe2a 100644 --- a/crates/eps/src/import/ai/style/tests.rs +++ b/crates/eps/src/import/ai/style/tests.rs @@ -471,6 +471,28 @@ fn lettering() -> String { format!("/KnownStyle :\n(Lettering) /Name ,\n/ActiveStyle :\n{root}\n/Execution ;\n /Def ;\n") } +/// A fill filter's last paint is its fill: a color, a gradient or a pattern replaces whichever of the +/// others came before it. +#[test] +fn a_fill_filter_paints_with_its_last_paint() { + let gradient = "0 Bb\n2 (Sky) 0 0 30 1 1 0 0 1 0 0 1 Bg\n0 BB"; + let pattern = "(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] p"; + let color = "0 0 0 0 1 0 0 Xa"; + let items = |paint: String| { + let root = compound("Chain Style Filter", &[fill(&paint)]); + let data = format!("/KnownStyle :\n(S) /Name ,\n/ActiveStyle :\n{root}\n/Execution ;\n /Def ;\n"); + art_styles(data.as_bytes()).remove("S").map(|s| s.items).unwrap_or_default() + }; + for before in [gradient, pattern] { + assert!(matches!(items(format!("{before}\n{color}")).as_slice(), [StyleItem::Fill(Paint::Solid { .. })]), "{before}"); + } + for before in [color, pattern] { + assert_eq!(items(format!("{before}\n{gradient}")), [StyleItem::Gradient { name: Some("Sky".into()), angle: 30.0 }], "{before}"); + } + assert!(matches!(items(format!("{color}\n{pattern}")).as_slice(), [StyleItem::Pattern { .. }])); + assert!(matches!(items(format!("{gradient}\n{pattern}")).as_slice(), [StyleItem::Pattern { .. }])); +} + #[test] fn a_stack_of_fills_with_effects_of_their_own_is_read_as_itself() { // GUARDS: more than one fill, or an effect on a fill, made the style not plain, and type @@ -1544,14 +1566,22 @@ fn a_style_of_one_paint_reads_as_the_fill_and_stroke_its_xd_turns_on() { // A gradient instance's flag says which one it paints: a stroke gradient leaves a solid fill read. let fill_and_stroke_gradient = one("0 0 1 0 k\n1 Bb\n2 (Ramp) 0 0 90 1 1 0 0 1 0 0 1 Bg\n0 BB\n0 1 Xd\n"); assert!(matches!(fill_and_stroke_gradient, Some(Ok(i)) if matches!(i.as_slice(), [StyleItem::Fill(_)]))); - // Not read: no `Xd`, a gradient or pattern fill, a pattern stroke, a gradient stroke after a solid one, a paint - // turned on with no color. + // A gradient instance's fill is its swatch at its angle; its stroke, after a solid one too, is a + // gradient naming its swatch at its angle, at the stroke's weight. + let gradient_fill = one("0 Bb\n2 (Sky) 0 0 30 100 1 0 0 1 0 0 Bg\n0 BB\n0 1 Xd\n"); + assert_eq!(gradient_fill, Some(Ok(vec![StyleItem::Gradient { name: Some("Sky".into()), angle: 30.0 }]))); + let gradient_stroke = one("0 R\n0 1 1 0 K\n1 Bb\n0 0 0 0 Bh\n2 (Ramp) 0 0 90 1 1 0 0 1 0 0 1 Bg\n0 BB\n2 w\n1 0 Xd\n"); + let Some(Ok(items)) = &gradient_stroke else { panic!("{gradient_stroke:?}") }; + let [StyleItem::Stroke { paint: Paint::Gradient(g), width, .. }] = items.as_slice() else { panic!("{items:?}") }; + assert_eq!((g.swatch.as_deref(), g.angle, g.geom, *width), (Some("Ramp"), 90.0, None, 2.0)); + // Not read: no `Xd`, a pattern fill, a pattern stroke, a gradient outside a gradient instance, a + // paint turned on with no color. for paint in [ format!("0 0 1 0 k\n{stroke}"), - "0 Bb\n2 (Sky) 0 0 0 100 1 0 0 1 0 0 Bg\n0 BB\n0 1 Xd\n".to_string(), "(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] p\n0 1 Xd\n".to_string(), "(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] P\n1 0 Xd\n".to_string(), - "0 R\n0 1 1 0 K\n1 Bb\n0 0 0 0 Bh\n2 (Ramp) 0 0 90 1 1 0 0 1 0 0 1 Bg\n0 BB\n2 w\n1 0 Xd\n".to_string(), + "2 (Sky) 0 0 0 100 1 0 0 1 0 0 Bg\n0 1 Xd\n".to_string(), + "0 Bb\n2 (Sky) 0 0 0 100 1 0 0 1 0 0 Bg\n0 BB\n(Dots) 0 0 1 1 0 0 0 0 0 [1 0 0 1 0 0] p\n0 1 Xd\n".to_string(), "0 0 1 0 k\n1 1 Xd\n".to_string(), ] { assert_eq!(one(&paint), Some(Err(())), "{paint}"); diff --git a/docs/mcp.md b/docs/mcp.md index ca77311c58..f0963771ee 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -4327,7 +4327,11 @@ with); without `path` it returns `{data}`, and `user: true` saves into the user (category `user`, User Defined). `graphicStyle.loadLibrary {path? | data? | dataBase64?, name?}` loads a `.vcstyles` file, or another document's graphic styles, as a library to add from (a `.ai` or EPS whose editing data holds graphic styles and no layers gives the styles of its style list, in that order); a file in the user library folder, or a file -with the same extension and bytes as one there, loads as that User Defined library. +with the same extension and bytes as one there, loads as that User Defined library. A `.ai` or EPS style that paints a +fill or stroke with one of the file's gradients by name loads with that gradient at the style's angle. The style stores +only the gradient's name and angle, so the gradient is fitted to the bounds of each object the style is applied to; this +placement is VectorCraft's own rule. A style that names a gradient the file doesn't define, or paints with a pattern, is +left out. ## Symbol libraries diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..55be444537 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -611,6 +611,7 @@ since 2026-10-01. - **Cached canvas frames during viewport changes:** Cached screen textures use their own raster dimensions and pixels-per-point when reprojected. `canvas::tests::cached_frames_keep_their_scale_during_resize_rotation_and_dpi_changes` holds the worker and checks every UV corner against the cached render transform, including isolated viewport-only resize at zero/30-degree rotation, fractional raster dimensions, zoom/pan, changed rotation, monitor-DPI changes in both directions, Pixel Preview and replacement-frame delivery. The contributor rebuilt and confirmed the original resize issue is fixed with their own artwork on 2026-10-19; the subsequent upstream rebase is checked by regressions and full CI. The artwork stays local. Scores and estimates are unchanged. - **PDF editable import:** Place from bytes or a path with `link: false`, and `clipboard.importPdf` followed by Paste, preserve live type on the selected page. Place still honors `textAs: "outlines"`. Synthetic two-page regressions: `crates/engine/src/cmd/fileio/tests_pdffidelity.rs`. No change to the PDF reader's existing fallback rules. - **Tab stops in `.ai`/EPS type and right-aligned lines with tabs (#6147):** type from the text document keeps its paragraphs' tab stops (key 30: positions and left, center, right and decimal alignments; leaders aren't read), at most 1,024 a paragraph and 2^20 a story, past which the default stops apply with a warning. In right-aligned area type, the text before a line's last tab sits at its stops, measured from the left edge, and the text after it (none when the tab ends the line, with its hyphen when the line is hyphenated) against the right edge; centred and justified lines, point type and right-to-left paragraphs are aligned as a whole as before. Evidence: `ate::tests::a_paragraph_keeps_its_tab_stops`, `ate::tests::a_story_s_tab_stops_are_bounded`, `tests::right_aligned_area_type_sets_the_text_after_its_last_tab_against_the_edge`, `import_fuzz::text_frames_with_hostile_paragraph_attributes_never_panic`. Scores unchanged. +- **`.ai`/EPS graphic styles that paint with a named gradient:** a graphic style library's style (or a file's listed style) whose fill, or the fill or stroke of a style of one paint, paints with one of the file's gradients by name loads with that gradient at the style's angle, fitted to the bounds of each object it is applied to (VectorCraft's own placement; the style stores only the gradient's name and angle). A style naming a gradient the file doesn't define, or painting with a pattern, is still left out. Evidence: `fileio::tests_aiimport::graphic_styles_in_a_ai_library_that_paint_with_a_named_gradient_load_with_it`, `style::tests::a_style_of_one_paint_reads_as_the_fill_and_stroke_its_xd_turns_on`. Scores unchanged. - **`.ai`/EPS type laid out closer to the file's page (#6137):** type from the text document keeps auto leading as auto, each line taking the paragraph's Auto Leading share (key 7) of the largest type on it ([Line and character spacing](https://helpx.adobe.com/illustrator/using/line-character-spacing.html)); the paragraph's hyphenation options (keys 10 to 15) are read; area type of one frame whose last lines the file sets, but which don't fit here, may get a frame taller from its bottom, by its lines' deepest descent plus 0.05 pt and only when that shows more of those lines and no more than the file has (`vectorcraft_text::fit_source_lines`), with a warning when it does: the frame can stay as it is, or show only some of them; and a line a soft return ends is justified as a wrapped line is, a paragraph's last line keeping its alignment. Evidence: `ate::tests::auto_leading_follows_the_size_of_each_line`, `ate::tests::a_paragraph_keeps_its_auto_leading`, `ate::tests::a_paragraph_keeps_its_hyphenation_options`, `ate::tests::the_last_lines_the_file_sets_in_its_frame_show`, `tests::fit_source_lines_keeps_the_last_lines_the_source_sets`, `tests::typo::soft_return_in_justified_text_spreads_like_a_wrapped_line`. Limits: frames grow only for area type of one frame, horizontal, by its lines' deepest descent plus 0.05 pt; type in a font that isn't installed, and hyphenation in a language that isn't imported, still lay out differently. Scores unchanged. - **Selected Grid Repeat handles (#2691):** `tools/src/repeat_grid.rs` tests place the handles outside the grid at zoom 0.5, 1 and 4, preview rows, columns and spacing, leave no undo step for a drag that ends where it began, and give bounding-box handles priority; a headless canvas regression drags the row handle two tiles down in a zoomed view (3 → 5 rows, the source unchanged, one Undo back) and the column-spacing slider. Scores and hours unchanged. - **Selected Mirror Repeat handles:** a headless canvas regression creates the default mirror repeat and drags its Top bounding-box handle where the axis crosses it; the repeat grows vertically while its width stays fixed. Existing mirror-axis checks cover center movement and end-handle hit priority. The focused UI mirror tests pass. Scores and hours unchanged. From 831c477ad61cc314f6b341a20df12c96d7561d2d Mon Sep 17 00:00:00 2001 From: ruchirguitar <113586074+ruchirguitar@users.noreply.github.com> Date: Sat, 14 Nov 2026 14:24:58 +0530 Subject: [PATCH 065/108] Symbols: built-in Weather Icons symbol library --- ROADMAP.md | 2 + crates/engine/src/cmd/symbollib.rs | 137 +++++++++++++++++- crates/engine/src/tests/symbollib.rs | 32 +++- .../src/panels/tests_symbol_libraries.rs | 5 +- docs/gaps.md | 13 +- docs/mcp.md | 4 +- docs/roadmap.md | 2 +- docs/target-app-parity.md | 10 +- 8 files changed, 188 insertions(+), 17 deletions(-) diff --git a/ROADMAP.md b/ROADMAP.md index 346c532277..dabed3eb94 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -124,6 +124,8 @@ Ranked; detail in [docs/roadmap.md](docs/roadmap.md) and [docs/gaps.md](docs/gap ## Progress log +- 2026-11-14: Built-in symbol library Weather Icons: adds a sixth procedural symbol library (Window › Symbol Libraries, the Symbols panel's Symbol Libraries Menu) containing six original vector symbols (Sun, Moon, Cloud, Rain, Thunder, Snow) generated in code without default 9-slice guides (part of Gap 5). Headline numbers unchanged. + - 2026-11-05: Window › Toolbars › Keep Tools Beside the Canvas, off by default, docks the Tools panel between left-side panels and the canvas instead of at the window's left edge, and the canvas's left edge then also docks a floating Tools panel (`window.toolsBesideCanvas`, #5395). Workspaces keep the setting; workspaces saved without it keep Tools at the window's edge. An optional VectorCraft layout choice; headline numbers unchanged. - 2026-11-12: Stencil Bridges in the Cutting Tools add-on (Object › Plug-ins › Cutting Tools): strips of a set width are cut out of the selected art so that every island of a stencil cut from it (the inside of an O, a hole in a shape) stays attached to the sheet, by the shortest crossings first, vertical, horizontal or the shortest among 12 directions 15° apart, with up to 16 bridges per island; type is measured by its glyph outlines and stays type, and the original goes to a hidden layer or is replaced. One undo step (`addon.cutting.bridges`). A VectorCraft addition: headline numbers unchanged. - 2026-11-13: Banner Hems and Grommets in the Cutting Tools add-on (Object › Plug-ins › Cutting Tools): on the chosen sides of the selected art's bounds, or of each artboard, a hem line at a set depth inside the edge and grommet marks (a circle with a cross) at a set inset, one at each end of a side and the rest spread evenly at most a set spacing apart, stroked in a chosen swatch; a dialog with Preview, one undo step (`addon.cutting.banner`). A VectorCraft addition: headline numbers unchanged. diff --git a/crates/engine/src/cmd/symbollib.rs b/crates/engine/src/cmd/symbollib.rs index 98b46a5d1a..7ddc6e4bb2 100644 --- a/crates/engine/src/cmd/symbollib.rs +++ b/crates/engine/src/cmd/symbollib.rs @@ -13,7 +13,7 @@ use std::sync::{Arc, LazyLock}; use serde_json::{Value, json}; use vectorcraft_color::{Color, Paint}; use vectorcraft_doc::{Appearance, Document, Node, NodeId, NodeKind, Symbol, SymbolNineSlice}; -use vectorcraft_geom::{Affine, Point, Rect, shapes}; +use vectorcraft_geom::{Affine, Anchor, AnchorKind, PathData, Point, Rect, SubPath, shapes}; use super::brushsym::{CURRENT_SYMBOL, natural_size, normalize, place_xf, set_natural_size}; use super::clipboard::Clipboard; @@ -160,6 +160,7 @@ pub const BUILTIN: &[BuiltinSymbolLibrary] = &[ BuiltinSymbolLibrary { id: "map-markers", name: "Map Markers", make: map_markers }, BuiltinSymbolLibrary { id: "inventory-icons", name: "Inventory Icons", make: inventory_icons }, BuiltinSymbolLibrary { id: "skill-icons", name: "Skill Icons", make: skill_icons }, + BuiltinSymbolLibrary { id: "weather-icons", name: "Weather Icons", make: weather_icons }, ]; /// Built-in library `id`, made once. @@ -358,6 +359,140 @@ fn skill_icons() -> SymbolLibrary { SymbolLibrary { name: "Skill Icons".into(), doc } } +/// Weather Icons: sun, moon, cloud, rain, thunder and snow for weather/status art (original, no 9-slice). +fn weather_icons() -> SymbolLibrary { + // 1. Sun: Central circular disk with radial rays. + let mut sun_subpaths = Vec::new(); + sun_subpaths.extend(shapes::ellipse(Rect::new(-8.5, -8.5, 8.5, 8.5)).subpaths); + for i in 0..8 { + let angle = (i as f64) * std::f64::consts::PI / 4.0; + let (sin, cos) = angle.sin_cos(); + let r_in = 11.5; + let r_out = 18.5; + let w = 1.5; + let p1 = Point::new(r_in * cos - w * sin, r_in * sin + w * cos); + let tip = Point::new(r_out * cos, r_out * sin); + let p2 = Point::new(r_in * cos + w * sin, r_in * sin - w * cos); + sun_subpaths.push(SubPath::polyline(&[p1, tip, p2], true)); + } + let sun = PathData::new(sun_subpaths); + + // 2. Moon: Crescent moon shape. + let moon_anchors = vec![ + Anchor { p: Point::new(3.0, -17.0), h_in: Point::new(-2.0, -10.0), h_out: Point::new(-8.0, -17.0), kind: AnchorKind::Corner }, + Anchor { p: Point::new(-16.0, 0.0), h_in: Point::new(-16.0, -9.0), h_out: Point::new(-16.0, 9.0), kind: AnchorKind::Smooth }, + Anchor { p: Point::new(5.0, 16.0), h_in: Point::new(-6.0, 16.0), h_out: Point::new(0.0, 8.0), kind: AnchorKind::Corner }, + Anchor { p: Point::new(-4.0, -1.0), h_in: Point::new(-4.0, 6.0), h_out: Point::new(-4.0, -8.0), kind: AnchorKind::Smooth }, + ]; + let moon = PathData::single(SubPath { anchors: moon_anchors, closed: true }); + + // Helper for cloud contour + let cloud_subpath = |offset_y: f64, scale: f64| -> SubPath { + let mut pts = Vec::new(); + let base_y = 8.0 * scale + offset_y; + pts.push(Point::new(9.0 * scale, base_y)); + pts.push(Point::new(-9.0 * scale, base_y)); + + let c1 = Point::new(-9.0 * scale, 2.0 * scale + offset_y); + let r1 = 6.0 * scale; + let steps_lobe = 8; + for i in 1..=steps_lobe { + let a = std::f64::consts::FRAC_PI_2 + (i as f64) * std::f64::consts::PI / (steps_lobe as f64); + pts.push(Point::new(c1.x + r1 * a.cos(), c1.y + r1 * a.sin())); + } + + let c2 = Point::new(0.0, -3.0 * scale + offset_y); + let r2 = 9.0 * scale; + let a_start = -2.973; + let a_end = -0.169; + let steps_top = 10; + for i in 1..=steps_top { + let a = a_start + (i as f64) * (a_end - a_start) / (steps_top as f64); + pts.push(Point::new(c2.x + r2 * a.cos(), c2.y + r2 * a.sin())); + } + + let c3 = Point::new(9.0 * scale, 2.0 * scale + offset_y); + let r3 = 6.0 * scale; + for i in 1..steps_lobe { + let a = -std::f64::consts::FRAC_PI_2 + (i as f64) * std::f64::consts::PI / (steps_lobe as f64); + pts.push(Point::new(c3.x + r3 * a.cos(), c3.y + r3 * a.sin())); + } + + SubPath::polyline(&pts, true) + }; + + // 3. Cloud: Merged circular lobes with a flat base. + let cloud = PathData::single(cloud_subpath(0.0, 1.0)); + + // 4. Rain: Cloud outline with angled falling droplet/dash lines. + let mut rain_subpaths = vec![cloud_subpath(-4.0, 0.9)]; + let drops = [(-6.0, 6.0), (0.0, 8.0), (6.0, 6.0)]; + for &(x0, y0) in &drops { + let (dx, dy) = (-2.0, 6.0); + let w = 1.0; + let d = [Point::new(x0 + w, y0), Point::new(x0 + dx + w, y0 + dy), Point::new(x0 + dx - w, y0 + dy), Point::new(x0 - w, y0)]; + rain_subpaths.push(SubPath::polyline(&d, true)); + } + let rain = PathData::new(rain_subpaths); + + // 5. Thunder: Angular zigzag lightning bolt polygon. + let bolt = [(3.0, -18.0), (-8.0, -1.0), (-1.0, -1.0), (-5.0, 18.0), (8.0, 1.0), (1.0, 1.0)]; + let bolt_pts: Vec<Point> = bolt.iter().map(|&(x, y)| Point::new(x, y)).collect(); + let thunder = PathData::single(SubPath::polyline(&bolt_pts, true)); + + // 6. Snow: Symmetrical snowflake with hexagonal cross and branching ticks. + let mut snow_pts = Vec::new(); + let r_hub = 3.5; + for k in 0..6 { + let angle = (k as f64) * std::f64::consts::PI / 3.0; + let (u_sin, u_cos) = angle.sin_cos(); + let u = Point::new(u_cos, u_sin); + let v = Point::new(-u_sin, u_cos); + let to_pt = |du: f64, dv: f64| Point::new(du * u.x + dv * v.x, du * u.y + dv * v.y); + + let valley_angle = angle - std::f64::consts::PI / 6.0; + snow_pts.push(Point::new(r_hub * valley_angle.cos(), r_hub * valley_angle.sin())); + + snow_pts.push(to_pt(5.0, -1.0)); + snow_pts.push(to_pt(8.5, -1.0)); + snow_pts.push(to_pt(10.0, -3.0)); + snow_pts.push(to_pt(11.5, -1.0)); + snow_pts.push(to_pt(15.5, -1.0)); + snow_pts.push(to_pt(15.5, -2.5)); + + snow_pts.push(to_pt(18.0, 0.0)); + + snow_pts.push(to_pt(15.5, 2.5)); + snow_pts.push(to_pt(15.5, 1.0)); + snow_pts.push(to_pt(11.5, 1.0)); + snow_pts.push(to_pt(10.0, 3.0)); + snow_pts.push(to_pt(8.5, 1.0)); + snow_pts.push(to_pt(5.0, 1.0)); + } + let snow = PathData::single(SubPath::polyline(&snow_pts, true)); + + let icons = [ + ("Sun", sun, "#f39c12"), + ("Moon", moon, "#5c6bc0"), + ("Cloud", cloud, "#78909c"), + ("Rain", rain, "#3498db"), + ("Thunder", thunder, "#f1c40f"), + ("Snow", snow, "#29b6f6"), + ]; + let mut doc = Document::new(100.0, 100.0); + for (name, path, hex) in icons { + let fill = Color::from_hex(hex).unwrap_or(Color::BLACK); + let edge = fill.lerp(&Color::BLACK, 0.35); + let id = doc.alloc_id(); + let art = Node::path(id, path, Appearance::basic(Paint::solid(fill), Paint::solid(edge), 1.25)); + let Ok((art, size, _)) = normalize(art) else { continue }; + doc.symbols.push(Symbol { dynamic: false, name: name.into(), art: Arc::new(art) }); + set_natural_size(&mut doc, name, Some(size)); + } + doc.title = "Weather Icons".into(); + SymbolLibrary { name: "Weather Icons".into(), doc } +} + /// An instance of symbol `name` (what the resource gathering follows). fn instance(name: &str) -> Node { Node::new(NodeId(0), NodeKind::SymbolInstance { symbol: name.into(), xf: Affine::IDENTITY }) diff --git a/crates/engine/src/tests/symbollib.rs b/crates/engine/src/tests/symbollib.rs index 54591c4658..c5d32e822a 100644 --- a/crates/engine/src/tests/symbollib.rs +++ b/crates/engine/src/tests/symbollib.rs @@ -84,7 +84,7 @@ fn the_builtin_library_is_original_art_generated_in_code() { let mut s = Session::new(); let list = run(&mut s, "symbol.libraries", json!({})); let libs = list["libraries"].as_array().unwrap(); - assert_eq!(libs.len(), 5, "{libs:?}"); + assert_eq!(libs.len(), 6, "{libs:?}"); assert_eq!((libs[0]["id"].as_str(), libs[0]["category"].as_str()), (Some("basic-shapes"), Some("builtIn"))); assert_eq!( (libs[1]["id"].as_str(), libs[1]["name"].as_str(), libs[1]["category"].as_str()), @@ -102,6 +102,10 @@ fn the_builtin_library_is_original_art_generated_in_code() { (libs[4]["id"].as_str(), libs[4]["name"].as_str(), libs[4]["category"].as_str()), (Some("skill-icons"), Some("Skill Icons"), Some("builtIn")) ); + assert_eq!( + (libs[5]["id"].as_str(), libs[5]["name"].as_str(), libs[5]["category"].as_str()), + (Some("weather-icons"), Some("Weather Icons"), Some("builtIn")) + ); let lib = run(&mut s, "symbol.library", json!({"library": "basic shapes"})); let names: Vec<&str> = lib["symbols"].as_array().unwrap().iter().map(|x| x["name"].as_str().unwrap()).collect(); assert_eq!(names, ["Circle", "Square", "Rounded Square", "Triangle", "Diamond", "Hexagon", "Star", "Burst", "Arrow"]); @@ -215,6 +219,32 @@ fn map_markers_symbols_add_without_nine_slice() { )); } +#[test] +fn weather_icons_library_lists_and_places() { + let mut s = session(); + let lib = run(&mut s, "symbol.library", json!({"library": "weather-icons"})); + let names: Vec<&str> = lib["symbols"].as_array().unwrap().iter().map(|x| x["name"].as_str().unwrap()).collect(); + assert_eq!(names, ["Sun", "Moon", "Cloud", "Rain", "Thunder", "Snow"]); + let mut placed = Vec::new(); + for (i, name) in names.iter().enumerate() { + let r = run( + &mut s, + "symbol.addFromLibrary", + json!({"library": "weather-icons", "name": name, "place": true, "x": 100.0 + 80.0 * i as f64, "y": 100.0}), + ); + assert_eq!(r["added"], json!([name])); + placed.push(r["placed"].as_u64().unwrap()); + } + let d = doc(&s); + for (i, name) in names.iter().enumerate() { + assert_eq!(d.symbol_nine_slice(name), None, "{name} should not carry 9-slice guides"); + assert!(matches!( + d.node(NodeId(placed[i])).map(|n| &n.kind), + Some(NodeKind::SymbolInstance { symbol, .. }) if symbol == *name + )); + } +} + #[test] fn a_saved_library_reopens_and_its_symbols_join_another_document_in_one_step() { let dir = folder("user"); diff --git a/crates/ui-egui/src/panels/tests_symbol_libraries.rs b/crates/ui-egui/src/panels/tests_symbol_libraries.rs index 9c58bc49c7..955b14327a 100644 --- a/crates/ui-egui/src/panels/tests_symbol_libraries.rs +++ b/crates/ui-egui/src/panels/tests_symbol_libraries.rs @@ -144,7 +144,10 @@ fn the_window_menu_and_the_symbols_panel_open_symbol_libraries() { let under = |e: &crate::menus::MenuEntry| e.path == ["Window", "Symbol Libraries"]; let opened: Vec<_> = entries.iter().filter(|e| under(e) && e.command.as_deref() == Some("window.symbolLibrary")).map(|e| e.params["library"].clone()).collect(); - assert_eq!(opened, [json!("basic-shapes"), json!("ui-frames"), json!("map-markers"), json!("inventory-icons"), json!("skill-icons")]); + assert_eq!( + opened, + [json!("basic-shapes"), json!("ui-frames"), json!("map-markers"), json!("inventory-icons"), json!("skill-icons"), json!("weather-icons")] + ); let has = |cmd: &str| entries.iter().find(|e| under(e) && e.command.as_deref() == Some(cmd)).map(|e| e.enabled); assert_eq!(has("window.symbolLibrary.other"), Some(true)); assert_eq!(has("ui.saveSymbolLibrary"), Some(false), "no symbols to save yet"); diff --git a/docs/gaps.md b/docs/gaps.md index 8aea143a47..00969238c2 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -34,6 +34,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard | Date | Change | Summary | |---|---|---| +| 2026-11-14 | minor | G5: Weather Icons joins Basic Shapes, UI Frames, Map Markers, Inventory Icons and Skill Icons as a sixth built-in symbol library (Sun, Moon, Cloud, Rain, Thunder, Snow; original procedural vector symbols generated in code, no default 9-slice); estimate decremented (5–15 → 4–14 h). | | 2026-11-14 | minor | G12: Layers panel row context menu (Options…, Duplicate, Delete, Lock Others/Show All/Hide Others/Unlock All, Locate Object, Collect for Export) with selection handling and undo tracking. Scores and estimates unchanged. | | 2026-11-13 | minor | PDF import: preserve Type 3 font text runs as named groups `<g>`, or as live text in `TextAs::Text` mode if `/ToUnicode` exists on non-colour fonts (`TextAs::Outlines` produces grouped outlines) (#6740); scores and estimates unchanged. | | 2026-11-08 | minor | #3380, deletion only: preserve gradient placement and exact surviving geometry; consume owned subpaths with a shared original-node snapshot; consolidate status/evidence and document command/helper contracts. Compound behavior and the existing M2 status entry are retained. Endpoint highlighting remains open; scores and estimates unchanged. | @@ -93,7 +94,7 @@ stage ([ROADMAP.md](../ROADMAP.md)). | 8 | [G2 Photoshop-style raster effects and the Effect Gallery](#g2-photoshop-style-raster-effects-and-the-effect-gallery) | 0 | no | [effects-parity.md](effects-parity.md) | | 9 | [G13 Illustrator 2026 (30.x) additions](#g13-illustrator-2026-30x-additions) | 13–23 | no | [target-app-parity.md](target-app-parity.md) | | 10 | [G14 Pen hardware beyond Windows pressure](#g14-pen-hardware-beyond-windows-pressure) | 4–10 | Wayland pressure | [hardware-parity.md](hardware-parity.md) | -| 11 | [G5 Brushes, symbols and libraries](#g5-brushes-symbols-and-libraries) | 5–15 | no | [target-app-parity.md](target-app-parity.md) | +| 11 | [G5 Brushes, symbols and libraries](#g5-brushes-symbols-and-libraries) | 4–14 | no | [target-app-parity.md](target-app-parity.md) | | 12 | [G3 3D and Materials](#g3-3d-and-materials) | 25–45 | no | [effects-parity.md](effects-parity.md) | | 13 | [G7 Views and windows](#g7-views-and-windows) | 15–25 | no | [ui-parity.md](ui-parity.md) | | 14 | [G6 Automation and scripting](#g6-automation-and-scripting) | 4–8 | no | [target-app-parity.md](target-app-parity.md) | @@ -636,10 +637,10 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi symbol static drops them; stored in the native format. Color eyedropper for scatter, art and pattern brushes (Hue Shift colorization; samples canvas art); symbol libraries ([public source](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-or-import-symbol-libraries.html)): Window › Symbol Libraries and the Symbols panel's Symbol - Libraries Menu open each library in a library panel of its own (five original libraries generated in code, + Libraries Menu open each library in a library panel of its own (six original libraries generated in code, Basic Shapes, UI Frames with default 9-slice guides on Panel, Button and Bar, Map Markers with Pin, - Flag, Crosshair and Checkpoint, Inventory Icons with Sword, Shield, Potion, Key and Gem, and Skill Icons with - Attack, Defend, Heal, Buff and Ult; User Defined; Other + Flag, Crosshair and Checkpoint, Inventory Icons with Sword, Shield, Potion, Key and Gem, Skill Icons with + Attack, Defend, Heal, Buff and Ult, and Weather Icons with Sun, Moon, Cloud, Rain, Thunder and Snow; User Defined; Other Library… reads the symbols of any document VectorCraft opens); a click adds a symbol to the document's Symbols with its Symbol Options and the resources it uses, as one undo step, and dragging one onto the canvas also places it; Save Symbols / Save Symbol Library writes the @@ -671,9 +672,9 @@ macOS cursor delivery (#2292) is narrowed to a native host adapter using the exi painted with the texture effects; User Defined; Other Library…; `graphicStyle.libraries`, `graphicStyle.addFromLibrary`). - **Missing:** more built-in brush libraries beyond the eight shipped (and further graphic-style libraries beyond the ten shipped, and further symbol libraries beyond Basic - Shapes, UI Frames, Map Markers, Inventory Icons and Skill Icons; original, generated in code, never Adobe's); dynamic symbols' `.ai` read and write; + Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons and Weather Icons; original, generated in code, never Adobe's); dynamic symbols' `.ai` read and write; Global Edit of rotated copies as matches. -- **Estimate:** 5–15 h. +- **Estimate:** 4–14 h. ## G3 3D and Materials diff --git a/docs/mcp.md b/docs/mcp.md index ca77311c58..05ad3abd56 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -4331,8 +4331,8 @@ with the same extension and bytes as one there, loads as that User Defined libra ## Symbol libraries -Symbol libraries are read-only sets of symbols: five generated in code (Basic Shapes, UI Frames, Map Markers, -Inventory Icons, Skill Icons), the `.vectorcraft` files in +Symbol libraries are read-only sets of symbols: six generated in code (Basic Shapes, UI Frames, Map Markers, +Inventory Icons, Skill Icons, Weather Icons), the `.vectorcraft` files in the user library folder of the desktop app (User Defined) and the symbols of any document loaded with `symbol.loadLibrary`. `symbol.libraries` lists them (`id`, `name`, `category`: `builtIn`, `user` or `loaded`, `count`) and `symbol.library {library}` returns one's symbols (`name`, `size`, `registration`, `exportType`; `library` is an diff --git a/docs/roadmap.md b/docs/roadmap.md index 9fa76dc027..1cf18c3ce3 100644 --- a/docs/roadmap.md +++ b/docs/roadmap.md @@ -165,7 +165,7 @@ Gujarati interface follow-up (2026-11-14): the catalog and zero/one plural rule | M7 | Type (point/area/path, editing, styles, OpenType, threading, glyphs) | Spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof and the custom dictionary and Ignore All commands and Auto Spell Check with its right-click suggestions, Ignore All and Add to Dictionary, and Spelling › Auto Spell Check in the context menu of type, and the Edit Custom Dictionary dialog (#4936; the Check Spelling dialog remains); Right-aligned area type sets the text after a line's last tab against the right edge, the text before it at its stops (#6147); A line a soft return ends is justified as a wrapped line is (#6137); Indian-language pattern hyphenation preserves syllables in both composers (#4947); 🟡 Hanging punctuation keeps its published amounts under Glyph Scaling, and Standard burasagari counts a hung line start as room; Fullwidth `!` / `?` keep an upright fallback in vertical type; Hyphenation… and Justification… per paragraph (#2310, #2755), Auto Leading also driving the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; Document-point character controls after object/group scaling (#1034; optional font-size preservation remains separate), Character/Paragraph Styles (explicit Auto-leading resets and local leading overrides), per-paragraph paragraph attributes, mixed paragraph alignment indication (headless regressions, full integration CI and visual review pass), Area Type Options (with Width/Height, Auto Size and Shrink Text to Fit; overflow reported to agents and vertical Align), type areas resized by their handles and reshaped with Direct Selection, threaded text, Fit Headline, Glyphs (feature-valued alternates and unencoded glyphs applied in one Undo step while keeping Arabic joining, #5514), OpenType panel (including font-defined Stylistic Sets), Find Font (Document, Recent and System replacement sources, #5217), installed system fonts in every font menu (fonts registered with Windows outside its font folders, the XDG and Flatpak host font folders on Linux, and fonts installed while the app runs, listed when it comes back to the front; searchable; the Character and Properties menus show each family's sample of the selected text, preview it live under the pointer or ↑/↓, show recently applied families first (#3515), filter by script and kind, list a family's styles, and star favourites; the Glyphs panel and Find Font's Replace With use the same menu without the live preview) and found by name on open/import (full-name aliases and Missing Fonts searches verified, #1258; Windows font-service QA pending), variable fonts' named instances as styles, CJK names in the UI, input methods (marked text in place, candidate window at the caret; Japanese IME), Text Wrap (offset, invert, both sides of an object; follows edits), Type on a Path effects and Options with draggable start/centre/end brackets (slide, flip), tab stops + Tabs panel (Above Text floats it over the selected text, its ruler at the canvas zoom so stops line up with the columns, #729), inline symbols in text (beyond parity), Hebrew/Arabic bidirectional text, Paragraph Direction, Every-line/Single-line Composer per object (ragged text too) done; paint-only Arabic harakat keep joining with GDEF-mark ownership and Insert Kashidas tatweels on the base letter's paint (`tests::harakat`); tab leaders, spell check, vertical type pending | 45–60 | | M8 | Transform & distort (Puppet Warp, Liquify tools, Envelopes, Blends, Perspective Grid) | ✅ done (M8.1–M8.20 on 2026-10-06, fidelity pass): Liquify Tool Options with one shared brush, pen pressure, hold-to-apply, a safe scope and incremental strokes; tool options that last; Puppet Warp rotation, multi-select, Control bar and a rest-shape session that follows Undo; Width tool on compound paths; Envelope dialogs with preview, Reset with Warp/Mesh, full Envelope Options, type/images/symbols/appearance/gradients/patterns distorted on canvas and in every export, warps that keep their frame, Edit Contents, mesh handles and Control bar; Blend Options, anchor-targeted Blend tool, editable spine, keys picked on the canvas, faithful interpolation and knockout; Anchor Point spine conversion/handle editing and selection priority (#2544), with #2425 Shift reshape preserved; Perspective Grid with Define Grid, presets, lock/snap/rulers, widgets, the 1–4 plane switch, movable planes, Perspective Selection scale/copy/perpendicular/Transform Again, and type and symbols truly projected with Edit Text. Left: Anti-Alias and Preserve Shape output, warp-envelope point editing, brush interpolation in blends, Free Transform/Scale/Reflect along a rotated box | 2–4 | | M9 | Live effects (+ 3D & Materials) | 🟡 2D effects done incl. Effect → Pathfinder, Color Adjustments and Document Raster Effects Settings; PDF export warns when the pixel cap lowers raster-effect resolution; Artistic › Colored Pencil, Cutout, Dry Brush, Film Grain, Fresco, Neon Glow, Paint Daubs, Palette Knife, Poster Edges, Rough Pastels, Smudge Stick, Sponge, Underpainting and Watercolor and Sketch › Halftone Pattern, Bas Relief, Charcoal, Conté Crayon, Photocopy, Stamp, Torn Edges and Water Paper done (57/57 Photoshop filters); Revolve with automatic smooth vector shading, default-on circular caps and continuous rims, Extrude & Bevel, Inflate and Rotate with one to ten colored directional lights and four original lighting presets; SVG Filters, remaining raster effects and 3D materials and shadows pending | 81–130 | -| M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG `<pattern>`/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, five generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, nine generated libraries including Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 | +| M10 | Brushes, symbols, patterns, Repeat | 🟡 pattern swatches (5 tile types, Pattern Options, editing mode, SVG `<pattern>`/PDF export) and live Repeat (radial/grid/mirror) done; interactive selected mirror axis implemented (focused and native checks passed; full CI blocked by an unrelated text test); symbol libraries done (Window › Symbol Libraries, six generated libraries (Basic Shapes, UI Frames, Map Markers, Inventory Icons, Skill Icons, Weather Icons), User Defined, Other Library…, Save Symbols); brush libraries done (Window › Brush Libraries, nine generated libraries including Ink and Wash, Bristle Brushes and Dry Media, User Defined, Other Library…, Save Brushes); symbol editing shows draggable 9-slice guides (#5280), with guides outside the artwork still unsupported; brushes/symbols in progress | 23–37 | | M11 | Artboards & views (selected-set deletion shared by Artboards menu, trash and Properties, retaining artboard 1 when all are selected; Artboard deletion keys keep the first of an all-selected set and protect artwork; history prunes invalid indices while preserving valid multiselection (history tests and full workspace CI pass); click-to-fit objects with the Artboard tool (#1227), artboard escape routing and document setup modal handoff done; artboard panel/tool with Move Artwork for X/Y fields and Artboard Options, Trim View, middle-button pan, print tiling and the status bar's artboard navigator with synchronized Artboard tool selection done; Window › Arrange › Tile and Consolidate All Windows done; multiple windows, presentation polish) (cached canvas reprojection preserves scale during resize, rotation and DPI changes; regression-tested and contributor-confirmed 2026-10-19; estimates unchanged) (cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission; regression-tested; estimates unchanged); status-bar pointer coordinates follow the active ruler origin and General units | 🟡; Artboard Options shares existing presets and orientation controls and can fit artwork without moving it; artwork fitting includes all drawn document art across artboards and off-board; artwork bounds are cached by active document and revision, and selection uses the shared bounds cache across artboards | 15–25 | | M12 | Advanced color & art (CMYK/ICC, separations, Gradient Mesh, Live Paint, Image Trace, Graphs) | 🟡 Gradient Mesh, Live Paint, Image Trace (junction-returning pieces retain their positioned boundaries; a simpler contour walk with identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments; large images trace with a warning; Auto Color keeps rare distinct colours; quick presets trace at once and the Image Trace button opens the adjustment controls; Properties reopens them; tiny fitted contours retain islands and holes; Create Strokes: exact crop EDT, Guo–Hall thinning and maximal-disc graph simplification; 15 presets, the 14 documented ones each with an enhanced version; Ignore Color, Shapes, Auto Grouping and Gradients options; measured in `image-trace-quality.md`; closed outlines retain their interior after straightening; the Flat Logo mode places edges to a fraction of a pixel, restores sharp corners, snaps lines and circles, and refuses gradients; live trace result bounds and selection highlights exclude the retained bitmap except in source-image views), Recolor Artwork, colour management (ICC, soft proofing, separations preview), Graphs (all 9 tools, Graph Data/Type, group-selected series colours persist through regenerate/save/open) done; Graph Design and Marker designs, Transpose and Switch x/y, `\|` label line breaks, the pie options, drop shadows, the legend across the top, overlapping widths, First Row/Column in Front, filled lines, kept label formatting and the Graph Data worksheet done; graph Column designs pending; Vector Halftone Preview keeps the selection box without drawing dot selection marks (#6369); Live Paint Bucket fills faces crossed in one drag (#6373) | 6–10 | | M13 | Automation (Actions ✅ record/playback, persisted; variables, scripting, batch) | 🟡 MCP `add_text` exposes existing vertical point, area and path type; `script.run` and File › Scripts › Other Script… run JavaScript files, and Window › Script Console shows their output; the script document model and batch work remain | 18–27 | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..10a8bffd3e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -243,7 +243,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | 3D and Materials (and Turntable) | 4 | ~25% | live Revolve with automatic smooth vector shading and default-on continuous circular caps, Extrude & Bevel (twist, taper, caps, five bevel shapes), Inflate and Rotate with Position presets (colored Inflate uses smooth membrane lighting; white-light Inflate retains its existing shading; Extrude & Bevel and Rotate retain planar shading; one to ten colored lights, shared neutral ambient, painter visibility); materials, light presets, shadows, ray tracing, the rest of 3D Classic (Map Art), Turntable views, textures, map art and shading in 3D export | 30–55 | estimated (Extrude & Bevel, Inflate and Rotate added 2026-10-12); every 3D seam has round joins (2026-11-12, [three-d.md](three-d.md#seams)), score, gaps and hours unchanged | | Type core | 9 | 80% | Auto-leading style resets are implemented; Hyphenation… and Justification… options are done (#2310, #2755), and a paragraph's Auto Leading also sets the Character panel's Leading, the Alt+↑/↓ leading nudge and Fill with Placeholder Text; remaining: Optical Margin Alignment, Middle Eastern features beyond bidi layout, optional group font-size preservation; transformed character controls fixed (#1034), see [type-parity.md](type-parity.md) | 14–19 | estimated; eleven-language pattern hyphenation in both composers, with grapheme and shaping-cluster protection (#4947, `hyphen::tests` and `layout::wrapping_tests`); Sanskrit patterns pending an allowlisted source; recent-font groups in font pickers (#3515); full-name font matches regression-tested (#1258); mixed paragraph alignment indication implemented; headless regressions, full integration CI and visual review pass; localized legacy family-name fallback with loaded/catalog regressions (#2208); Fractional Widths per type object regression-tested; color emoji fonts with bitmap glyphs (`sbix`, `CBDT`) draw and export; threading ports: every selected area type and type on a path shows its in and out ports (empty, arrow, red "+"), and the Selection tool threads from either, the in port into a frame before it, and a double-click on a threaded port breaks the thread there (`threads::tests::break_splits_the_thread_and_the_story_flows_into_the_first_part`, `select::tests::a_double_click_on_a_threaded_port_breaks_the_thread`, `canvas::tests::a_double_click_on_a_threaded_out_port_breaks_the_thread`) (#2572; `select::tests::a_click_on_the_in_port_threads_into_a_frame_before_it`, `text::tests::selected_type_shows_its_ports_in_each_state`, `threads::tests::add_before_threads_the_story_from_the_new_frame_into_the_clicked_one`, live screenshot); the Glyphs panel highlights and scrolls to the character selected with the Type tool (#4908, `panels::glyphs` tests); the OpenType panel lists only `ss01`–`ss20` sets present in the selected font and uses its custom names when supplied; Type-range desktop Copy publishes styled art and keeps font family, size and color on canvas Paste after editing (#5636); paint-only Arabic harakat keep joining with conditional GDEF-mark ownership and Insert Kashidas base-letter paint (`tests::harakat`) | | Type advanced (CJK, spelling, Touch Type, Retype) | 4 | 50% | CJK vertical composition (ruby, mojikumi), variable font axes, tab leaders, spell check (engine, custom dictionary and Auto Spell Check with its right-click suggestions and Spelling › Auto Spell Check, and the Edit Custom Dictionary dialog done, #4936; the Check Spelling dialog remains), Touch Type, Retype | 20–28 | estimated; upright fallback for fullwidth `!` / `?` regression-tested; score and hours unchanged | -| Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons and Skill Icons are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type (Graphic / Movie Clip) and 9-slice guides (drawn and draggable during symbol editing, #5280) and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) are done | 4–7 | estimated; Blend panel Type and Ramp control step easing with a separate color Shift (#2539); Blend Options retains spacing and orientation; polynomial curves are original approximations; interactive selected mirror axis implemented; bounding-box handles take priority over the axis line (focused regression and native checks passed; full CI blocked by an unrelated text test); #2544 spine Anchor Point conversion and picking regression-tested | +| Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons and Weather Icons are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type (Graphic / Movie Clip) and 9-slice guides (drawn and draggable during symbol editing, #5280) and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) are done | 4–7 | estimated; Blend panel Type and Ramp control step easing with a separate color Shift (#2539); Blend Options retains spacing and orientation; polynomial curves are original approximations; interactive selected mirror axis implemented; bounding-box handles take priority over the axis line (focused regression and native checks passed; full CI blocked by an unrelated text test); #2544 spine Anchor Point conversion and picking regression-tested | | Type advanced (CJK, spelling, Touch Type, Retype) | 4 | 50% | CJK vertical composition (ruby, mojikumi), tab leaders, spell check (engine, custom dictionary and Auto Spell Check with its right-click suggestions and Spelling › Auto Spell Check, and the Edit Custom Dictionary dialog done, #4936; the Check Spelling dialog remains), Touch Type, Retype | 20–28 | estimated; upright fallback for fullwidth `!` / `?` regression-tested; score and hours unchanged | | Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, and Map Markers are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type (Graphic / Movie Clip) and 9-slice guides (drawn and draggable during symbol editing, #5280) and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) are done | 4–7 | estimated; Blend panel Type and Ramp control step easing with a separate color Shift (#2539); Blend Options retains spacing and orientation; polynomial curves are original approximations; interactive selected mirror axis implemented; bounding-box handles take priority over the axis line (focused regression and native checks passed; full CI blocked by an unrelated text test); #2544 spine Anchor Point conversion and picking regression-tested | | Image Trace, graphs, image tools | 3 | 75% | graph Column designs, Image Trace Create Strokes depth (Create Object Mosaic is done; junction-returning piece survival has source-generated regressions in `image-trace-quality.md`; simpler contour walk, identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments, so Paths is monotone on the code-drawn sweep) | 5–8 | estimated (raised from 72%); quick presets reveal adjustment controls, Properties reopens them; Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views (scores/hours unchanged) | @@ -252,7 +252,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Type advanced (CJK, spelling, Touch Type, Retype) | 4 | 50% | CJK vertical composition (mojikumi), variable font axes, tab leaders, spell check (engine, custom dictionary and Auto Spell Check with its right-click suggestions and Spelling › Auto Spell Check, and the Edit Custom Dictionary dialog done, #4936; the Check Spelling dialog remains), Touch Type, Retype | 20–28 | estimated; No Break keeps marked characters on one line; upright fallback for fullwidth `!` / `?` regression-tested; score and hours unchanged | | Type advanced (CJK, spelling, Touch Type, Retype) | 4 | 50% | CJK vertical composition (mojikumi), tab leaders, spell check (engine, custom dictionary and Auto Spell Check with its right-click suggestions and Spelling › Auto Spell Check, and the Edit Custom Dictionary dialog done, #4936; the Check Spelling dialog remains), Touch Type, Retype | 20–28 | estimated; No Break keeps marked characters on one line; upright fallback for fullwidth `!` / `?` regression-tested; score and hours unchanged | | Raster effects (Effect Gallery) | 4 | 55% | — | — | estimated (raised from 52%: the Effect Gallery's filter thumbnails and in-dialog preview, an original landscape drawing passed through each filter, [Filter Gallery overview](https://helpx.adobe.com/photoshop/desktop/effects-filters/get-started-with-filters/filter-gallery.html), `dialogs::effect_gallery::tests::gallery_shows_thumbnails_and_an_in_dialog_preview`; the gallery itself shipped in #2883, six categories, per-filter settings, ordered stack, live canvas preview, one undo step, `stack_ok_is_one_undo_step`, `stack_preview_is_one_interaction`); measured count 57/57 (Artistic complete with Colored Pencil, Fresco, Paint Daubs, Palette Knife, Rough Pastels and Underpainting; Sketch complete with Torn Edges and Conté Crayon, `pixel::tests_sketch::conte_crayon_*`); texture redraw distances optimized (#1257), pixels verified; the score stays under 100% because the filters are original approximations; depth estimated | -| Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons and Skill Icons are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) and on-canvas 9-slice guides (#5280) are done | 4–7 | estimated | +| Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons and Weather Icons are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) and on-canvas 9-slice guides (#5280) are done | 4–7 | estimated | | Image Trace, graphs, image tools | 3 | 75% | graph Column designs, Image Trace Create Strokes depth (Create Object Mosaic is done; junction-returning piece survival has source-generated regressions in `image-trace-quality.md`; large images trace with a warning; Auto Color keeps rare distinct colours) | 5–8 | estimated (raised from 72%); quick presets reveal adjustment controls, Properties reopens them | | Layers, artboards, document setup | 5 | 78% | Selected-artboard deletion is consistent across panel actions (all-selected retains artboard 1); history prunes removed indices while preserving valid multiselection; remaining: 30.0's artboard locking and colours and managing artboards from the canvas, Layers row menu commands beyond Collect for Export and menus on guide and blend spine rows (click-to-fit objects is done, #1227) | 5–8 | estimated (lowered from 82%: target moved); Artboard deletion keys keep artwork and the first of an all-selected set; Artboard Options' Show Center Mark and Show Cross Hairs draw on the canvas only (exports and print leave them out), regression-tested; Artboard Options' Show Video Safe Areas and Video Ruler Pixel Aspect Ratio (per artboard, native format) are done ([video display options](#evidence-what-ships-today-by-area)), score unchanged | | View & navigation | 3 | 70% | multiple windows and the rest of Arrange (Cascade, Float in Window, Float All in Windows) | 9–14 | estimated; Window › Arrange › Tile and Consolidate All Windows done (score/hours unchanged); document-tab artwork hover/copy and lossless transfer tested (2026-10-22; score/hours unchanged); cached canvas reprojection preserves scale during resize, rotation and DPI changes (regression and contributor original-file evidence below; scores/hours unchanged); cached canvas dimensions match the renderer limit before cache-key creation, view construction and worker submission (regression evidence below) | @@ -516,7 +516,7 @@ about 1–1.5 agent-hours each, so the other rows (estimated on the older scale) | 3D and Materials | 4 | ~25% | Initial Revolve, Extrude & Bevel, Inflate and Rotate, with simple lighting and four original lighting presets; materials, shadows, ray tracing, Rotate (Classic), Map Art and more complete visibility remain | 25–45 | | Type advanced | 4 | 50% | CJK composition for vertical type (mojikumi beyond Line-end Punctuation Half Width — the other sets (and their paragraph-start bracket and indent rules), custom kinsoku sets (beyond Hard, Soft and None) and the Mojikumi Settings dialog —, manual tate-chu-yoko is done, its up/down settings remain; No Break is done), tab leaders, spell check (its engine, custom dictionary commands, the Edit Custom Dictionary dialog and Auto Spell Check are done, #4936: the Check Spelling dialog remains; a right-click on an underlined word offers its suggestions, Ignore All and Add to Dictionary, and a right-click on type has Spelling › Auto Spell Check), Touch Type, Retype; vertical point/area/path type and Type Orientation have initial support (beyond parity, not scored: inline symbols in text) | 20–28 | | Type core | 9 | 80% | Middle Eastern features beyond bidi layout, Paragraph Direction, digit types and Kashidas (the Middle Eastern composers, editable bidirectional SVG text, a split caret where directions meet); paint-only harakat keep joining with conditional GDEF-mark colour ownership, but fonts without GDEF mark classes and some AAT/`morx` ligatures can still leave marks painted as their letters; Every-line Composer fidelity for justified and ragged text (available per object; mixed type sizes in a paragraph still break single-line in non-rectangular area type and with text wrap), Optical Margin Alignment, paragraph spacing limit for vertically justified area type, hidden characters, paragraph attributes in the Type tool's copy and paste (the characters keep their styles, the paragraphs take the destination's), mixed-value display in the Paragraph panel for a selection across differing paragraphs, partial selection of type-area anchors by marquee, optional font-size preservation during group scaling (scaled character controls fixed in #1034). Hyphenation and Justification options, Fractional Widths, System Layout, styled Type-range canvas Paste (#5636), and pattern hyphenation for eleven Indian languages with grapheme/cluster protection (#4947) are done; Sanskrit automatic patterns remain pending an allowlisted source | 14–19 | -| Symbols, blends, envelopes, Repeat, perspective | 5 | 90% | further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons and Skill Icons are done), dynamic symbols' `.ai` round trip, envelope Anti-Alias/Preserve Shape output and warp point editing, brush interpolation in blends (M8 fidelity pass done); Symbol Options › Registration and Export Type and on-canvas dynamic part paint (gradient/pattern, opacity, blend) are done; symbol editing shows draggable 9-slice guides (#5280), while guides outside the artwork remain unsupported | 4–7 | +| Symbols, blends, envelopes, Repeat, perspective | 5 | 90% | further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons and Weather Icons are done), dynamic symbols' `.ai` round trip, envelope Anti-Alias/Preserve Shape output and warp point editing, brush interpolation in blends (M8 fidelity pass done); Symbol Options › Registration and Export Type and on-canvas dynamic part paint (gradient/pattern, opacity, blend) are done; symbol editing shows draggable 9-slice guides (#5280), while guides outside the artwork remain unsupported | 4–7 | | Image Trace, graphs, image tools | 3 | 72% | graph Column designs (Graph Design, Marker designs and series colours set with Group Selection are done), Create Object Mosaic, per-feature stroke/fill choice and varying widths in Image Trace's Create Strokes (Vector Halftone and the Image Trace View modes, Palette and Create Strokes are done) | 6–10 | | Layers, artboards, document setup | 5 | 82% | Layers panel: a confirmation before deleting layers that hold art, row menu commands beyond Collect for Export (now on every layer, sublayer, group and object row), menus on guide and blend spine rows, the Layer Options dialog for several rows with mixed values, Paste Remembers Layers for sublayers; artboard preset polish (artboard escape routing and document setup modal handoff done; Move Artwork for artboard X/Y edits, Rearrange All Artboards, Document Setup, New Document and the rest of the Layers panel are done) | 4–7 | | View & navigation | 3 | 70% | New View/Edit Views, multiple windows/arrange, Snap to Pixel/Glyph (print tiling is done) | 9–14 | @@ -559,7 +559,7 @@ since 2026-10-01. | **Interaction fidelity:** modifiers, cursors, small behaviours | ~30–40% | The dedicated pass hasn't started, and there has been no side-by-side session with Illustrator yet. A power user notices this first | | **Look & feel** | ~75–80% | Measured against Illustrator 2026 screenshots (2026-10-02); the panels added since haven't been re-measured | | **File interop** | ~85% | SVG/SVGZ, PDF and PDF-compatible `.ai` (and legacy version 7 `.ai` out, keeping layers, groups and type as text), EPS, DXF, EMF/WMF, raster formats, PSD export and PSD/PSB placement (merged image), Place and Links, Package, Print, clipboard flavours. Affinity documents (Affinity 1–3) open natively as editable art, checked against 51 pinned public files (33 current `.af`), with selected saved-thumbnail comparisons and every-board native/SVG/PDF/PSD checks for current files; Affinity export is missing and effects, adjustments and brushes don't import. Affinity isn't an Illustrator feature, so this doesn't raise the parity score. The editing copy inside an Illustrator EPS or `.ai` is read for its structure: layers, groups, names, hidden objects and type, colours, gradients, transparency, images and every artboard (see Out of scope for what it doesn't read yet); DWG has no open spec | -| **Bundled content:** brush, symbol, style and swatch libraries | ~46% | Ours are original and generated in code, and far fewer than Illustrator ships; symbol libraries have five (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons), graphic style libraries eight (including Game HUD and Status Effects) and brush libraries nine (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media) beside User Defined and Other Library… | +| **Bundled content:** brush, symbol, style and swatch libraries | ~46% | Ours are original and generated in code, and far fewer than Illustrator ships; symbol libraries have six (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons, Weather Icons), graphic style libraries eight (including Game HUD and Status Effects) and brush libraries nine (Art Ribbons, Ink and Wash, Calligraphic Nibs, Bristle Brushes, Pattern Borders, Scatter Shapes, Game Trails, Energy Beams, Dry Media) beside User Defined and Other Library… | | **Performance** | unverified | Multithreaded, off-thread rendering and caches are in place. The last budget run (2026-10-01, loaded machine) measured 290 ms for a 50k-path fit against a 16 ms budget. Re-run `vectorcraft-cli perf` on an idle machine | | **Robustness** | good, new | ~2,840 tests, property tests, no panics in shipped code (lints, the `guard` safety net, import fuzzing), Data Recovery. Missing: a corpus of real-world files, Windows/Linux/browser QA | | **Platforms and 1.0 polish** | ~60% | The macOS app and the web build work, and Finder opens every readable format with the macOS app (#295, #354); on macOS the menus are in the system menu bar, laid out as a Mac app's, with the in-window menus as a fallback (`--in-window-menus`; verified on Windows and by cross-compilation, not yet by hand on a Mac); hybrid-graphics laptops render on the power-saving GPU by default on Windows and macOS (#306), and Windows starts on Direct3D 12, falling back to OpenGL, and loads no Vulkan driver unless `WGPU_BACKEND` asks for it (#545: Vulkan flickered black on an Intel GPU, DX12 and OpenGL didn't; #806: a faulty Vulkan driver crashed the app before its window appeared; verified by unit tests and the reporter's runs with `WGPU_BACKEND`), and Linux on the GPU the desktop runs on, since a Wayland compositor may refuse frames from the other one; a window that fails on its GPU while starting up starts again on the next one instead of crashing (#502; the dual-GPU Wayland case is verified by unit tests and cross-compilation, not on such hardware); web drops land in the document they were dropped on (#359); desktop drops carry no pointer position (winit 0.30), so a dropped document opens as a tab of its own and a picture or text is placed in the middle of the view, while the web places anything dropped on the canvas and opens what is dropped off it, as Illustrator does (#472); a web page that loses its WebGPU device or WebGL context restarts its graphics with the same documents (#369); on Linux/Wayland the clipboard reads the compositor's own (data-control) and copied image files paste, but files can't be dropped on the window under native Wayland until eframe moves to winit 0.31 (#398; the Wayland side is verified by compilation only), so Preferences › Performance › Linux Display Server › X11 (XWayland) opens the window through XWayland, where drops work (#1151; verified by unit tests and cross-compilation, not on a Wayland desktop); on Linux the Paste menu checks the system clipboard on a background thread, so a clipboard owner that never answers no longer freezes the window, while Windows and macOS keep their quick in-line check (#510; the X11 hang verified by the contributor, here by headless tests); on KDE Plasma 6.3+ under Wayland, pens and pen displays reach the app only under XWayland (`WAYLAND_DISPLAY=`) or with KWin's `KWIN_WAYLAND_EMULATE_TABLET=1`, since winit 0.30 has no Wayland tablet input (#491, not verified on hardware); Windows/Linux packaging and accessibility are pending | @@ -945,7 +945,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - macOS: Finder opens every format File › Open reads with VectorCraft (double-click, Open With, a drop on the Dock icon, `open -a`), at launch or while it runs; the release and `cargo xtask bundle` apps share one `Info.plist` that declares those document types, owning only VectorCraft's own formats. The DMG opens on a designed Finder window, VectorCraft.app beside the `Applications` link over a background with the app icon (#493). - Swatch and graphic style libraries, Libraries panel files, presets and plug-ins open wherever they are dropped on the window, as File › Open opens them. - File › Open has a filter for each kind of file it opens other than a document, Graphic Style Libraries (`.vcstyles`, after Swatch libraries) and Perspective grid presets (`.vcperspective`, after Print presets) among them, and Other Library… lists its library filter once. Graph designs are stored in the document, with no file type or filter of their own. Tests: `open_exts_cover_every_readable_format`, `library_open_filters_list_library_formats_first`. - - **Symbol libraries** ([public source](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-or-import-symbol-libraries.html)): Window › Symbol Libraries and the Symbols panel's Symbol Libraries Menu open each library in a library panel of its own, as swatch and graphic style libraries do. The built-in libraries, Basic Shapes, UI Frames (Panel, Button and Bar with default 9-slice guides), Map Markers (Pin, Flag, Crosshair and Checkpoint, no default 9-slice), Inventory Icons (Sword, Shield, Potion, Key and Gem, no default 9-slice) and Skill Icons (Attack, Defend, Heal, Buff and Ult, no default 9-slice), are original art generated in code (`crates/engine/src/cmd/symbollib.rs`). A click on a symbol adds it to the document's Symbols as one undo step, with its Symbol Options (size, registration, export type, 9-slice guides) and every resource it uses (the symbols it nests, patterns, swatches, brushes, graphic styles, images), and makes it the current symbol; a symbol the document already has is not added again and another symbol of the same name keeps its name, the library's comes in numbered. Thumbnails, in the library panels and the Symbols panel, draw a symbol with the symbols it nests and the patterns and images it uses. Dragging a library symbol onto the canvas also places an instance there, in the same step ([placing from a library](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-and-place-symbols.html)). Save Symbols (the library menu) and Save Symbol Library… (the Symbols panel menu) write the document's symbols as a `.vectorcraft` document holding only them, into the user library folder (listed under User Defined) or a file; Other Library… reads the symbols of any document VectorCraft opens; a file it can't read is an error and opens no panel. Tests: `crates/engine/src/tests/symbollib.rs`, `crates/ui-egui/src/panels/tests_symbol_libraries.rs`, `panels::symbols::tests::thumbnails_show_the_symbols_a_symbol_nests`, `canvas::tests::a_library_symbol_dropped_on_the_canvas_is_added_and_placed_there_in_one_step`. + - **Symbol libraries** ([public source](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-or-import-symbol-libraries.html)): Window › Symbol Libraries and the Symbols panel's Symbol Libraries Menu open each library in a library panel of its own, as swatch and graphic style libraries do. The built-in libraries, Basic Shapes, UI Frames (Panel, Button and Bar with default 9-slice guides), Map Markers (Pin, Flag, Crosshair and Checkpoint, no default 9-slice), Inventory Icons (Sword, Shield, Potion, Key and Gem, no default 9-slice), Skill Icons (Attack, Defend, Heal, Buff and Ult, no default 9-slice) and Weather Icons (Sun, Moon, Cloud, Rain, Thunder and Snow, no default 9-slice), are original art generated in code (`crates/engine/src/cmd/symbollib.rs`). A click on a symbol adds it to the document's Symbols as one undo step, with its Symbol Options (size, registration, export type, 9-slice guides) and every resource it uses (the symbols it nests, patterns, swatches, brushes, graphic styles, images), and makes it the current symbol; a symbol the document already has is not added again and another symbol of the same name keeps its name, the library's comes in numbered. Thumbnails, in the library panels and the Symbols panel, draw a symbol with the symbols it nests and the patterns and images it uses. Dragging a library symbol onto the canvas also places an instance there, in the same step ([placing from a library](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/create-and-place-symbols.html)). Save Symbols (the library menu) and Save Symbol Library… (the Symbols panel menu) write the document's symbols as a `.vectorcraft` document holding only them, into the user library folder (listed under User Defined) or a file; Other Library… reads the symbols of any document VectorCraft opens; a file it can't read is an error and opens no panel. Tests: `crates/engine/src/tests/symbollib.rs`, `crates/ui-egui/src/panels/tests_symbol_libraries.rs`, `panels::symbols::tests::thumbnails_show_the_symbols_a_symbol_nests`, `canvas::tests::a_library_symbol_dropped_on_the_canvas_is_added_and_placed_there_in_one_step`. - **9-slice scaling** ([public source](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/maintain-proportions-while-scaling-symbols.html)): a scaled instance of a symbol with Enable Guides for 9-Slice Scaling on stays an instance and keeps the parts of its art outside the guides at their size. New guides sit a quarter of the symbol's width and height in from each edge ([reference](https://help.adobe.com/archive/en/illustrator/cs6/illustrator_reference.pdf), Use 9-slice scaling section); saved guides keep their values. The rest is VectorCraft's own rule: the corners keep both sizes, the top and bottom edges stretch in width, the left and right edges in height and the center in both; an instance smaller than its two outer cells on an axis shrinks them in proportion and leaves the center empty; the cells are sized along the symbol's axes before the instance's rotation, shear or reflection. A path with solid paint that crosses a guide is cut there and stays one path, its stroke at its weight with Scale Strokes & Effects on or off; type, images, live objects and gradient or pattern paint that cross a guide are drawn in each cell they reach, clipped to it, except those that draw symbol art (a nested instance, type with an inline graphic, a placed document, a brushed stroke, or a pattern whose tile draws one of these), which are placed by the cell their center is in; an object in one cell is placed by that cell and stays as it is. The canvas, bounds, the Eyedropper, Break Link to Symbol and the PDF, EPS, DXF, EMF/WMF and SVG exports place the art the same way; SVG writes such an instance as its placed art instead of a `<use>`, and DXF and WMF, which do not clip, cut every path that crosses a guide and place other such objects by the cell their center is in. Tests: `symbol_nine_slice::tests` in `crates/doc`, `crates/engine/src/tests/symbol_nine_slice.rs`, `a_scaled_nine_slice_instance_keeps_its_corners` (PDF), `a_scaled_nine_slice_instance_is_written_as_the_canvas_draws_it` (SVG), `a_scaled_nine_slice_instance_is_sampled_as_it_is_drawn` (Eyedropper). - **Symbol editing mode** ([Edit symbols](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/edit-symbols.html), [Symbols panel options](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/symbols-panel-options.html)): a double-click on a symbol instance, the Control bar's Edit Symbol button, a double-click on a symbol in the Symbols panel and the panel menu's Edit Symbol (`symbol.edit`) open the symbol's art on a temporary isolated layer, where the instance shows it (from the panel: centered on the active artboard, or in the view in a document without artboards), with the rest of the document dimmed. Each edit there changes every instance at once; the instances keep their own transforms and stay linked (Break Link to Symbol still expands one), and a dynamic symbol's instances keep their appearance changes to the objects the art still has. Escape, the isolation bar's back button, the Control bar's Exit Symbol Editing Mode and a double-click outside the art leave the mode (`symbol.exitEditing`); leaving without an edit adds no undo step. Saving leaves the editing layer out. Tests: `crates/engine/src/tests/symboledit.rs`, `select::tests::a_double_click_on_a_symbol_instance_edits_its_symbol`, `panels::symbols::tests::edit_symbol_from_the_panel_centers_the_art_on_the_active_artboard_or_the_view`. - **Dynamic symbol appearance follows what an object draws** (VectorCraft's own rule): `symbol.instance.setAppearance` refuses a fill or stroke for an object of the art that does not draw it (a guide, blend, envelope, Repeat, Intertwine group, gradient mesh or placed document; a nested symbol instance's stroke, and its fill unless a solid color or none, which stains its art; an image's fill or stroke without a Convert to Shape or Outline Object effect) with an error that names the key and the object, and the call changes nothing. Opacity, blend and `null`, which takes a stored change back, are taken for every object. Tests: `crates/engine/src/tests/dynamic_symbols.rs`. From 140df22be384e3463fca84658a48436694347b8c Mon Sep 17 00:00:00 2001 From: ruchirguitar <113586074+ruchirguitar@users.noreply.github.com> Date: Sat, 14 Nov 2026 14:45:12 +0530 Subject: [PATCH 066/108] docs: update feature status date and parity revision history for Weather Icons --- docs/gaps.md | 4 ++-- docs/target-app-parity.md | 4 +++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/gaps.md b/docs/gaps.md index 00969238c2..880b4d8f46 100644 --- a/docs/gaps.md +++ b/docs/gaps.md @@ -1,10 +1,10 @@ # Gaps -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-13 · **Change:** minor (3D: the seams of white-light Extrude & Bevel, Inflate and Rotate, and the face seams of the 3D (Classic) effects, have round joins instead of miters; previously: PDF import: preserve Type 3 font text runs as named groups <g>, or as live text in TextAs::Text mode if ToUnicode exists on non-colour fonts (TextAs::Outlines produces grouped outlines), #6740; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: oversized editing artboard import; Glyphs panel: Alternates for Current Selection applies an OpenType feature value (`salt=2`) to the selected letter alone, so an Arabic word stays joined, and Entire Font lists the unencoded glyphs, #5514; #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: G5: built-in Energy Beams brush library; estimate 5–15 → 4–14 h; previously minor: G5: built-in Skill Icons symbol library; estimate 6–16 → 5–15 h; previously minor: ruler double-click adds a guide at the pointer, #5239; G5: built-in Status Effects graphic style library; estimate 7–17 → 6–16 h; MCP docs catch-up for UI Frames and Map Markers; previously minor: G5: built-in Inventory Icons symbol library; estimate 8–18 → 7–17 h; previously minor: G9: `.ai` save names a variable font instance's design-space setting, #6388; previously minor: G5: built-in Game Trails brush library; estimate 9–19 → 8–18 h; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: docs tidy-up, no content change: stray notes at the top moved into the revision table; scores and estimates unchanged; previously minor: G5: built-in Game HUD graphic style library; estimate 10–20 → 9–19 h; previously minor: G5: built-in Map Markers symbol library; estimate 11–21 → 10–20 h; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview; estimate 1–2 h → 0; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: built-in UI Frames symbol library with default 9-slice; estimate 11–21 h; previously minor: G5: dynamic symbol part on-canvas takes opacity, blend, gradient and pattern; docs Overlap/auto-corners sync; estimate 12–22 h; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap, Pattern brush auto corners and Global Edit Shift-click leave-out moved from Missing to Done (code already shipped); previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; G9: EPS gradients drawn as abutting strips import as one gradient, without seams; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; opening a slow file shows a progress window, part of #5930; Hindi catalog and contributor loanword preferences; agent wording pass complete; wider native proofreading welcome; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); scores and estimates unchanged; a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window; scores and estimates unchanged; large images in CMYK documents are shrunk before they are separated into ink planes (#4155); scores and estimates unchanged; `.ai` paths with a Calligraphic brush open brushed, with the 6D Art Pen's channels, and Windows reads the pen's tilt and barrel rotation, #372; scores and estimates unchanged; Compound Shapes add-on, beyond Illustrator; scores and estimates unchanged; Contour add-on, beyond Illustrator; scores and estimates unchanged; a slow first frame is waited for instead of restarting without the graphics adapter, and the menu bar no longer waits for the installed fonts' scan; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-14 · **Change:** minor (G5: built-in Weather Icons symbol library (Sun, Moon, Cloud, Rain, Thunder, Snow); estimate 5–15 → 4–14 h; previously: 3D: the seams of white-light Extrude & Bevel, Inflate and Rotate, and the face seams of the 3D (Classic) effects, have round joins instead of miters; previously: PDF import: preserve Type 3 font text runs as named groups <g>, or as live text in TextAs::Text mode if ToUnicode exists on non-colour fonts (TextAs::Outlines produces grouped outlines), #6740; scores and estimates unchanged; previously: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: oversized editing artboard import; Glyphs panel: Alternates for Current Selection applies an OpenType feature value (`salt=2`) to the selected letter alone, so an Arabic word stays joined, and Entire Font lists the unencoded glyphs, #5514; #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: G5: built-in Energy Beams brush library; estimate 5–15 → 4–14 h; previously minor: G5: built-in Skill Icons symbol library; estimate 6–16 → 5–15 h; previously minor: ruler double-click adds a guide at the pointer, #5239; G5: built-in Status Effects graphic style library; estimate 7–17 → 6–16 h; MCP docs catch-up for UI Frames and Map Markers; previously minor: G5: built-in Inventory Icons symbol library; estimate 8–18 → 7–17 h; previously minor: G9: `.ai` save names a variable font instance's design-space setting, #6388; previously minor: G5: built-in Game Trails brush library; estimate 9–19 → 8–18 h; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: docs tidy-up, no content change: stray notes at the top moved into the revision table; scores and estimates unchanged; previously minor: G5: built-in Game HUD graphic style library; estimate 10–20 → 9–19 h; previously minor: G5: built-in Map Markers symbol library; estimate 11–21 → 10–20 h; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: G2: Effect Gallery thumbnails and in-dialog preview; estimate 1–2 h → 0; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: built-in UI Frames symbol library with default 9-slice; estimate 11–21 h; previously minor: G5: dynamic symbol part on-canvas takes opacity, blend, gradient and pattern; docs Overlap/auto-corners sync; estimate 12–22 h; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap, Pattern brush auto corners and Global Edit Shift-click leave-out moved from Missing to Done (code already shipped); previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; G9: EPS gradients drawn as abutting strips import as one gradient, without seams; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; Indian-language hyphenation review and license allowlist, #4947; opening a slow file shows a progress window, part of #5930; Hindi catalog and contributor loanword preferences; agent wording pass complete; wider native proofreading welcome; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); scores and estimates unchanged; a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window; scores and estimates unchanged; large images in CMYK documents are shrunk before they are separated into ink planes (#4155); scores and estimates unchanged; `.ai` paths with a Calligraphic brush open brushed, with the 6D Art Pen's channels, and Windows reads the pen's tilt and barrel rotation, #372; scores and estimates unchanged; Compound Shapes add-on, beyond Illustrator; scores and estimates unchanged; Contour add-on, beyond Illustrator; scores and estimates unchanged; a slow first frame is waited for instead of restarting without the graphics adapter, and the menu bar no longer waits for the installed fonts' scan; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x) ## Feature submission evidence -**Feature evidence last updated:** 2026-11-03. +**Feature evidence last updated:** 2026-11-14. Raster rendering fits and preflattens curved stroke outlines more tightly only below four times the raster tolerance, retaining thin-band coverage without changing stroke weight or vector export geometry. Current cached character/object outlines, cropped long strokes, gradient clips and effect rasters share the helper; cropped-region reuse and guarded flattening remain. The unchanged `fractional_curved_strokes_retain_coverage_between_notches` regression covers fractional weights, rotation, phase, opacity and f32-rounded endpoints. This is a quality/cost tradeoff, not a speed claim. Scores and estimates unchanged. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 10a8bffd3e..3956bfb3fa 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1,6 +1,6 @@ # Parity with Adobe Illustrator -> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-14 · **Change:** minor (a closed Pencil stroke closes with a straight segment; previously: Snap to Point with Smart Guides off draws no Smart Guides labels or lines, #7250; previously: 3D: the seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins, so white-light 3D output is expected to differ from the 2026-10-17 comparison at facet corners (not measured: the scenes were not exported again); previously: `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; Character panel: the Set Font Height Reference dropdown shows an icon before each reference, #6304; scores and estimates unchanged; previously: Envelopes: a top object's side whose pieces are all one curve split at anchors follows that curve's parameter, so a top object saved with its sides' curves in pieces draws as its `.ai` drawn art, #7097; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously minor: Object › Rasterize with the Grayscale or Bitmap colour model makes a grayscale image, #6969; scores and estimates unchanged; previously minor: `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, miter tips and moved strokes included, after its glyphs grown by half its strokes' weight (#6824; #6617: Swatches panel menu: Show Recent Colors; scores unchanged; previously minor: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Type tool: kerning at a caret at the start of a line moves the character after it, #5111; scores and estimates unchanged; previously minor: Rulers: the zero point dragged out of the rulers' corner snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Envelopes: with Distort Appearance, type's strokes paint along the bent glyph outlines at their own weight, as users' `.ai` files draw them, which changes how VectorCraft's own envelopes of stroked type draw (#6644; scores and estimates unchanged); previously minor: G5: Energy Beams brush library; bundled content ~44% → ~46%; previously minor: G5: Skill Icons symbol library; bundled content ~42% → ~44%; previously minor: `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art (#6570; scores and estimates unchanged); previously minor: ruler double-click adds a guide at the pointer, #5239; G5: Status Effects graphic style library; bundled content ~40% → ~42%; MCP symbol libraries list UI Frames and Map Markers; previously minor: G5: Inventory Icons built-in symbol library; bundled content ~38% → ~40%; previously minor: `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke (#3179; scores and estimates unchanged); previously minor: `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid where VectorCraft's warp doesn't draw as their drawn art (#3179; scores and estimates unchanged); G5: Game Trails brush library; bundled content ~36% → ~38%; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page (#3179; scores and estimates unchanged); G5: Game HUD graphic style library; bundled content ~34% → ~36%; previously minor: Line Arrow arrowhead (#5421; scores and estimates unchanged); G5: Map Markers built-in symbol library; bundled content ~32% → ~34%; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: Canvas: a 3D effect changed on type or a group redraws where its solid was; Fit to Artwork Bounds and per-artboard SVG export build each solid once for all artboards; previously minor: Effect Gallery: a thumbnail for each filter and a preview area inside the dialog, on an original drawing; Raster effects 52% → 55%, hours 1–2 → none; headline numbers unchanged; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: UI Frames built-in symbol library with default 9-slice; bundled content ~32%; previously minor: G5: dynamic symbol part on-canvas opacity/blend/gradient/pattern; strokes remaining no longer lists Overlap/auto corners; symbols ~88%; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: harakat paint fallback clarified; previously minor: current Guides feature-area rows consolidated using existing ruler evidence; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap and Pattern brush auto corners removed from strokes remaining; symbols remaining lists dynamic on-canvas beyond solid and guides outside the art; previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; `.ai` and EPS import: older Art brush objects read; numeric fields step on wheel hover without taking keyboard focus, and a panel wheel turn cannot seed a canvas zoom glide, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; the canvas keeps selection outlines and anchors between frames; Indian-language hyphenation review and license allowlist, #4947; Stroke gradients: an arrowhead aligned to the tip is painted to the corners of its base, #5964; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Hindi catalog and contributor loanword preferences; full wording review in progress; Properties in Edit Artboards: a Transform section with the reference point above the Artboards section, #5219; the Control bar's Stroke: and Opacity: links scrub their fields, #4088; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window, #4155; Control bar Paragraph section with type selected, #5372; translating unchanged type reuses its glyph and character-stroke outlines; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026; Units › East Asian Type acts, with Q and Ha units; scores unchanged) +> **Last reviewed:** 2026-10-10 · **Last updated:** 2026-11-14 · **Change:** minor (G5: Weather Icons joins built-in symbol libraries (Sun, Moon, Cloud, Rain, Thunder, Snow); scores and estimates unchanged; previously: a closed Pencil stroke closes with a straight segment; previously: Snap to Point with Smart Guides off draws no Smart Guides labels or lines, #7250; previously: 3D: the seams of Extrude & Bevel, Inflate and Rotate under a white light, and of the faces of Extrude & Bevel (Classic), Revolve (Classic) and Rotate (Classic), went from miter to round joins, so white-light 3D output is expected to differ from the 2026-10-17 comparison at facet corners (not measured: the scenes were not exported again); previously: `.ai` and EPS import: in layers that don't draw as the page, art that differs away from an envelope of type no longer costs it its editable type; it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, #7141; Character panel: the Set Font Height Reference dropdown shows an icon before each reference, #6304; scores and estimates unchanged; previously: Envelopes: a top object's side whose pieces are all one curve split at anchors follows that curve's parameter, so a top object saved with its sides' curves in pieces draws as its `.ai` drawn art, #7097; scores and estimates unchanged; previously: Graphic Styles list fills a taller panel, #2992; scores and estimates unchanged; previously: PDF import: glyphs in a span with an empty ActualText come in as outlines, #6971; scores and estimates unchanged; previously: library panels' lists fill a taller panel, #2992; scores and estimates unchanged; previously: Swatches list fills a taller panel, #1638; scores and estimates unchanged; previously minor: Object › Rasterize with the Grayscale or Bitmap colour model makes a grayscale image, #6969; scores and estimates unchanged; previously minor: `.ai` and EPS import: type in an envelope with Distort Appearance is also tried mapped from the box of what it paints, miter tips and moved strokes included, after its glyphs grown by half its strokes' weight (#6824; #6617: Swatches panel menu: Show Recent Colors; scores unchanged; previously minor: icon-strip flyouts also resize from the top edge and the canvas-side top corner, keeping the moved top in workspaces (storytold/craft-libs#1094); scores and estimates unchanged; previously: #6865: explicitly requested oversized editing artboard; macOS: the canvas cursor stays after the pointer moves, #6362; scores and estimates unchanged; previously minor: Type tool: kerning at a caret at the start of a line moves the character after it, #5111; scores and estimates unchanged; previously minor: Rulers: the zero point dragged out of the rulers' corner snaps as a drawn point does; previously minor: Live Paint Bucket fills faces crossed in one drag (#6373); previously: #6404: transform-aware Eyedropper character copying; scores and estimates unchanged; previously: Envelopes: with Distort Appearance, type's strokes paint along the bent glyph outlines at their own weight, as users' `.ai` files draw them, which changes how VectorCraft's own envelopes of stroked type draw (#6644; scores and estimates unchanged); previously minor: G5: Energy Beams brush library; bundled content ~44% → ~46%; previously minor: G5: Skill Icons symbol library; bundled content ~42% → ~44%; previously minor: `.ai` and EPS import: an envelope saved in Edit Contents whose mesh lies away from its drawn art by a move opens live on that art (#6570; scores and estimates unchanged); previously minor: ruler double-click adds a guide at the pointer, #5239; G5: Status Effects graphic style library; bundled content ~40% → ~42%; MCP symbol libraries list UI Frames and Map Markers; previously minor: G5: Inventory Icons built-in symbol library; bundled content ~38% → ~40%; previously minor: `.ai` and EPS import: stroked type in an envelope maps from its glyphs grown by half its stroke (#3179; scores and estimates unchanged); previously minor: `.ai` and EPS import: warps of type open as mesh envelopes on their saved grid where VectorCraft's warp doesn't draw as their drawn art (#3179; scores and estimates unchanged); G5: Game Trails brush library; bundled content ~36% → ~38%; previously minor: Edit › Edit Custom Dictionary…: its dialog adds, deletes and changes the custom dictionary's words, #4936; previously minor: `.ai` and EPS import: envelopes of type open live where they draw as their drawn art and the layers with them draw as the page (#3179; scores and estimates unchanged); G5: Game HUD graphic style library; bundled content ~34% → ~36%; previously minor: Line Arrow arrowhead (#5421; scores and estimates unchanged); G5: Map Markers built-in symbol library; bundled content ~32% → ~34%; previously minor: right-click on type: Spelling › Auto Spell Check, with its check mark, #4936; previously minor: right-click on a word Auto Spell Check underlined: its suggestions, Ignore All and Add to Dictionary, #4936; previously minor: Canvas: a 3D effect changed on type or a group redraws where its solid was; Fit to Artwork Bounds and per-artboard SVG export build each solid once for all artboards; previously minor: Effect Gallery: a thumbnail for each filter and a preview area inside the dialog, on an original drawing; Raster effects 52% → 55%, hours 1–2 → none; headline numbers unchanged; Auto Spell Check: `edit.autoSpellCheck` underlines the unknown words, #4936; previously minor: PDF editable import preserves authored ActualText once, including empty/nested spans and authored ordering (#6165); cross-line/style layout remains approximate; scores and estimates unchanged; PDF marked-text export (#6309): compatible glyphs stay on one layout line with per-glyph offsets; scores and estimates unchanged; G5: UI Frames built-in symbol library with default 9-slice; bundled content ~32%; previously minor: G5: dynamic symbol part on-canvas opacity/blend/gradient/pattern; strokes remaining no longer lists Overlap/auto corners; symbols ~88%; previously minor: interim macOS cursor delivery, #2292; native validation pending; scores and estimates unchanged; previously minor: harakat paint fallback clarified; previously minor: current Guides feature-area rows consolidated using existing ruler evidence; scores and estimates unchanged; previously minor: Control bar › Snapping includes the existing Snap to Glyph and Alignment Guides toggles (#6164); scores and estimates unchanged; previously minor: G5 docs: Art brush Overlap and Pattern brush auto corners removed from strokes remaining; symbols remaining lists dynamic on-canvas beyond solid and guides outside the art; previously minor: custom dictionary and Ignore All: `text.spelling.addWord`, `removeWord`, `changeWord`, `dictionary` and `ignoreAll`, #4936; previously minor: EPS import: embedded fonts (composite, Type 42, CID-keyed, Type 1, CFF FontSet) draw their glyphs; spell check engine: `text.spelling.check` and `text.spelling.suggest` on craft-proof, #4936; previously minor: floating tab groups collapse into the side icon rail and opened rail panels fold back into it, #5925 in part; `.ai`/EPS type keeps its tab stops, and right-aligned lines with tabs lay out as the file's page, #6147; `.ai`/EPS type from the text document lays its lines out closer to the file's page, within limits, #6137; `.ai` and EPS import: older Art brush objects read; numeric fields step on wheel hover without taking keyboard focus, and a panel wheel turn cannot seed a canvas zoom glide, #5949; Character Styles panel: a double-click on a style's row opens its Character Style Options; the dialog keeps a fixed width and scrolls its sections, so its buttons stay on screen; Tools stays beside the canvas with left-side panels; new gradients follow document color mode; Selection QoL: marquee modes and visible feedback, #5313; SVG CSS classes survive export and repeated import in all four styling modes (#2480); current-main integration retains event attributes and scripts; #3380 deletion-only review follow-up: independent survivors keep gradient placement, owned subpaths avoid discarded copies, and contracts/status/evidence are clarified; endpoint highlighting remains open; scores and estimates unchanged; the canvas keeps selection outlines and anchors between frames; Indian-language hyphenation review and license allowlist, #4947; Stroke gradients: an arrowhead aligned to the tip is painted to the corners of its base, #5964; Drop Shadow and glow dialogs: spinner arrows, #5367, #5368; Stroke Weight Up and Down shortcuts, #5797; Hindi catalog and contributor loanword preferences; full wording review in progress; Properties in Edit Artboards: a Transform section with the reference point above the Artboards section, #5219; the Control bar's Stroke: and Opacity: links scrub their fields, #4088; an image zoomed in on is separated, colorized or proofed only where it shows (#4155); a document's first frame renders on the render worker, so opening a heavy file no longer freezes the window, #4155; Control bar Paragraph section with type selected, #5372; translating unchanged type reuses its glyph and character-stroke outlines; scores and estimates unchanged) · **Target:** Adobe Illustrator 2026 (30.x; public release notes through 30.7, August 2026; Units › East Asian Type acts, with Q and Ha units; scores unchanged) > > Oversized artboard import update (2026-11-12): Explicit editing-data import retains a single artboard beyond a capped 14,400 pt PDF page (#6865). > @@ -58,6 +58,7 @@ Artboard Options forwards the active Artboard tool's Scale Artwork with Artboard | Date | Change | Summary | |---|---|---| +| 2026-11-14 | minor | G5: Weather Icons joins Basic Shapes, UI Frames, Map Markers, Inventory Icons and Skill Icons as a sixth built-in symbol library (Sun, Moon, Cloud, Rain, Thunder, Snow; original procedural vector symbols generated in code, no default 9-slice); area score and estimate unchanged. | | 2026-11-14 | minor | Pencil and Paintbrush: a closed stroke (Alt at the release, or ending within Close Paths When Ends Are Within of its start) is fitted as the open stroke would be and closed by a straight segment back to its start, instead of curving on past both ends (`pencil_alt_closes_a_stroke_straight_back_to_its_start` in `crates/engine/src/tests/draw2.rs`). Scores and estimates unchanged. | | 2026-11-13 | minor | Snap to Point: with Smart Guides off it still pulls drawn and dragged points onto anchors and ruler guides, but draws none of the Smart Guides labels ("anchor") or lines (#7250; `guides::tests::snap_to_point_without_smart_guides_shows_no_guides`). Scores and estimates unchanged. | | 2026-11-13 | minor | Graphic Styles: in a panel made taller the list fills the space above the footer instead of stopping at 220 pt (#2992; `the_list_fills_a_tall_panel_above_its_footer` in `crates/ui-egui/src/panels/graphic_styles.rs`). Scores and estimates unchanged. | @@ -2379,6 +2380,7 @@ Edit › Copy and Cut put the selected ruler guides on the clipboard, with the s | Date | Change | Summary | |---|---|---| +| 2026-11-14 | minor | G5: Weather Icons joins Basic Shapes, UI Frames, Map Markers, Inventory Icons and Skill Icons as a sixth built-in symbol library (Sun, Moon, Cloud, Rain, Thunder, Snow; original procedural vector symbols generated in code, no default 9-slice); area score and estimate unchanged. | | 2026-11-14 | minor | Gujarati (#6613): contributor proofreading completed for all 387 additions, with 11 wording corrections; 4,673 reviewed catalog rows. Status/error messages remain partial; web selection requires a bundled Gujarati face. Scores and estimates unchanged. | | 2026-11-12 | minor | Gujarati (`gu`): 4,286-row machine-assisted catalog reviewed by a native speaker, zero/one singular plurals, desktop font fallback and optional Gujarati craft-fonts fallback; all 72 translation tests pass; a web font and about 2,600 untranslated messages remain; scores and estimates unchanged | | 2026-11-13 | minor | File formats: in a `.ai` or EPS opened from its editing data whose layers don't draw as the page even with the drawn art of every live envelope put back, and are used all the same (trusted, their objects that differ coming in as the page's art, or opened alone), art that differs away from an envelope of type no longer costs it its editable type: it keeps its drawn art where, in the pixels it and its drawn art ink, the layers with it differ from the page more than its own check allows, or past the envelopes' share of the page check, and where a clip, mask, group appearance, another envelope, a repeat or a blend holds it (#7141); evidence updated; scores and hours unchanged. | From 54af8d3f0354bcd49e7d70e22813368942470fb3 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:14:23 -0800 Subject: [PATCH 067/108] i18n: Finnish translates the PDF warning for knockout groups with too many elements The warning that PDF export gives when a knockout group has too many overlapping translucent elements to draw through soft masks had no row in any catalog. fi.tsv now has one, keyed by the text the warning shows. --- crates/ui-egui/src/i18n/fi.tsv | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index e40c199f74..45b25c903a 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -7532,7 +7532,7 @@ breakText Glyphs Merkit Grommet Inset Purjerenkaiden etäisyys reunasta Diameter Halkaisija -# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +# Messages of the effects, 3D, image and PDF export, color profiles, swatch exchange files, color books and DXF import. @msg 3D effects require finite coordinates within 100 million points 3D-tehosteet vaativat äärelliset koordinaatit 100 miljoonan pisteen rajoissa @msg 3D effects require one to ten lights 3D-tehosteet vaativat 1–10 valonlähdettä @msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP-värisyvyys {_1}: 1, 4, 8, 16, 24 tai 32 bittiä pikseliä kohti @@ -7609,6 +7609,7 @@ breakText Glyphs Merkit @msg its localized names take more than {_1} KB sen lokalisoidut nimet vievät yli {_1} KB @msg its objects are nested too deep ({e}) sen objektit ovat sisäkkäin liian monella tasolla ({e}) @msg its tag table lists the `{_1}` tag more than once sen tunnistetaulukossa `{_1}`-tunniste on useammin kuin kerran +@msg knockout groups with too many overlapping translucent elements are written as PDF knockout groups: their translucent elements knock out what they cover fully poistoryhmät, joissa on liian monta päällekkäistä läpikuultavaa elementtiä, kirjoitetaan PDF-poistoryhminä: niiden läpikuultavat elementit poistavat peittämänsä alueen kokonaan @msg not a graphic style library: {e} ei grafiikkatyylikirjasto: {e} @msg not a swatch library (.vcswatches or .gpl) ei värimallikirjasto (.vcswatches tai .gpl) @msg not a swatch library (format `{_1}`) ei värimallikirjasto (muoto `{_1}`) From 9735e51473ad5d2bc7fc1ed4aee4e9ff5bddbc4a Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:24:26 -0800 Subject: [PATCH 068/108] Clipboard: files copied in a file manager paste as art on core Wayland Where the clipboard goes through the compositor's core Wayland protocol (the Flatpak on GNOME), Paste now reads the text/uri-list a file manager offers, else GNOME Files' x-special/gnome-copied-files, and pastes the first file that is art before the clipboard's other types, as on the other platforms. The list is read on the read worker and the files on the paste's background thread. Only file: URIs with no host or localhost are taken (RFC 8089), percent escapes decoded once (RFC 3986); other URIs are skipped, and a list of more than 1,024 URIs, a limit of VectorCraft's own, names no file. The Paste menu item is enabled when a file list is offered. --- apps/vectorcraft/src/clipboard.rs | 342 +++++++++++++++++++++++++++--- docs/development.md | 2 +- docs/target-app-parity.md | 1 + 3 files changed, 317 insertions(+), 28 deletions(-) diff --git a/apps/vectorcraft/src/clipboard.rs b/apps/vectorcraft/src/clipboard.rs index 17b9327956..bcd37ecce3 100644 --- a/apps/vectorcraft/src/clipboard.rs +++ b/apps/vectorcraft/src/clipboard.rs @@ -11,9 +11,9 @@ //! backend reads the compositor's clipboard (X11 through XWayland only sees what X11 apps //! copied), falling back to X11 where the compositor lacks the protocol, and where there is no //! X11 either (a Flatpak on GNOME) to the compositor's core protocol on the window's connection: -//! Copy offers SVG (`image/svg+xml`), PNG (`image/png`) and text together, and Paste reads SVG, -//! text and PNG. A clipboard that can't be opened is tried again after a wait that grows to a -//! minute, not each time Paste asks. On Linux and the BSDs a read waits 2 s at most for the app +//! Copy offers SVG (`image/svg+xml`), PNG (`image/png`) and text together, and Paste reads copied +//! files (`text/uri-list`), SVG, text and PNG. A clipboard that can't be opened is tried again +//! after a wait that grows to a minute, not each time Paste asks. On Linux and the BSDs a read waits 2 s at most for the app //! that copied to send its data (a bitmap 10 s), and until that app answers, later reads fail at //! once; a paste then waits for that read's answer off the UI thread. //! - Everywhere: files copied in a file manager paste as the first one that is art (SVG, PDF, EPS, @@ -172,6 +172,85 @@ fn copied_file(paths: Vec<PathBuf>, mimes: &[&'static str]) -> Option<Flavour> { }) } +/// The most URIs a copied file list may hold, VectorCraft's own limit: a longer list (untrusted +/// data) names no files. +const MAX_URIS: usize = 1024; + +/// The local files a `text/uri-list` names, in order ([`file_uri_path`]). Each line holds one URI +/// and a line that starts with `#` is a comment (RFC 2483, section 5); lines end in CRLF or LF. +/// Lines that are not UTF-8 and URIs that don't name a local file are skipped. A list of more than +/// [`MAX_URIS`] URIs names none. +#[cfg_attr(not(target_os = "linux"), allow(dead_code))] +fn uri_list_paths(list: &[u8]) -> Vec<PathBuf> { + let uris: Vec<&[u8]> = list + .split(|&b| b == b'\n') + .map(|line| line.strip_suffix(b"\r").unwrap_or(line)) + .filter(|line| !line.is_empty() && !line.starts_with(b"#")) + .take(MAX_URIS + 1) + .collect(); + if uris.len() > MAX_URIS { + return vec![]; + } + uris.into_iter().filter_map(|uri| file_uri_path(std::str::from_utf8(uri).ok()?)).collect() +} + +/// The local files GNOME Files' `x-special/gnome-copied-files` names: a first line of `copy` or +/// `cut`, then one URI a line, read as [`uri_list_paths`] reads them. A paste places the files' +/// art either way and leaves the files where they are. No files when the first line is neither. +#[cfg_attr(not(target_os = "linux"), allow(dead_code))] +fn gnome_copied_paths(list: &[u8]) -> Vec<PathBuf> { + let (action, uris) = match list.iter().position(|&b| b == b'\n') { + Some(end) => (list.get(..end).unwrap_or_default(), list.get(end + 1..).unwrap_or_default()), + None => (list, &[][..]), + }; + match action.strip_suffix(b"\r").unwrap_or(action) { + b"copy" | b"cut" => uri_list_paths(uris), + _ => vec![], + } +} + +/// The absolute path a `file:` URI names on this machine: `file:/path`, `file:///path` or +/// `file://localhost/path` (RFC 8089, section 2; scheme and host in any letter case), its percent +/// escapes decoded once (RFC 3986, section 2.1) and a fragment (`#…`) left out. None for another +/// scheme, another host, a relative path, a query (`?…`), a bad escape, an escaped NUL or a path +/// that is not UTF-8 once decoded. +#[cfg_attr(not(target_os = "linux"), allow(dead_code))] +fn file_uri_path(uri: &str) -> Option<PathBuf> { + let uri = uri.trim_matches(|c: char| c.is_ascii_whitespace()); + let uri = uri.split_once('#').map_or(uri, |(before, _)| before); + if uri.contains('?') { + return None; + } + let scheme = uri.get(..5).filter(|s| s.eq_ignore_ascii_case("file:"))?; + let rest = uri.get(scheme.len()..)?; + let path = match rest.strip_prefix("//") { + Some(authority_and_path) => { + let slash = authority_and_path.find('/')?; + let host = authority_and_path.get(..slash)?; + if !host.is_empty() && !host.eq_ignore_ascii_case("localhost") { + return None; + } + authority_and_path.get(slash..)? + } + None => rest.starts_with('/').then_some(rest)?, + }; + let mut bytes = Vec::with_capacity(path.len()); + let mut it = path.bytes(); + while let Some(b) = it.next() { + if b == b'%' { + let hex = |d: Option<u8>| char::from(d?).to_digit(16); + let (hi, lo) = (hex(it.next())?, hex(it.next())?); + bytes.push(u8::try_from(hi * 16 + lo).ok()?); + } else { + bytes.push(b); + } + } + if bytes.contains(&0) { + return None; + } + String::from_utf8(bytes).ok().map(PathBuf::from) +} + #[cfg(windows)] mod win { use std::num::NonZeroU32; @@ -1094,7 +1173,9 @@ mod portable { } } - /// Files copied in a file manager (none where the backend can't read a file list). + /// Files copied in a file manager, read through arboard. The Wayland core protocol reads + /// its file list with the rest of a paste + /// ([`DataClipboard::read`](super::wayland::DataClipboard::read)). fn file_list(&mut self) -> Vec<PathBuf> { match self { Self::Arboard(cb) => cb.read(Request::Files).files(), @@ -1233,8 +1314,9 @@ mod portable { } /// Text and copied files are read here, and work that reads arboard's image comes back. On - /// the Wayland core protocol the first of `mimes` the clipboard offers is read: text here, - /// SVG and PNG by the work that comes back, which waits [`IMAGE_WAIT`] at most. + /// the Wayland core protocol the copied files, else the first of `mimes` the clipboard + /// offers, is read: text here, file lists, SVG and PNG by the work that comes back, which + /// waits [`IMAGE_WAIT`] at most. fn read_now_or_later(&mut self, mimes: &[&'static str]) -> Option<ClipboardRead> { let cb = self.cb(Asker::User).ok()?; #[cfg(target_os = "linux")] @@ -1335,9 +1417,9 @@ mod portable { } /// Text, on macOS vector art or a bitmap (by the pasteboard's types), and on the Wayland - /// core protocol SVG, text or PNG (by the types offered, nothing read). arboard has no - /// cheap way to ask for a bitmap (reading one costs as much as pasting it): the paste keys - /// take it, the menu item waits for text. + /// core protocol copied files, SVG, text or PNG (by the types offered, nothing read). + /// arboard has no cheap way to ask for a bitmap (reading one costs as much as pasting it): + /// the paste keys take it, the menu item waits for text. fn has(&mut self, mimes: &[&'static str]) -> bool { #[cfg(target_os = "macos")] if super::mac::has(mimes) { @@ -1784,12 +1866,13 @@ mod portable { /// window's own Wayland connection: what Copy and Paste use where the compositor lacks the /// data-control protocol arboard needs (GNOME) and there is no X11 to fall back on (the Flatpak on /// a Wayland session). A Copy offers its SVG as `image/svg+xml`, its PNG as `image/png` and its -/// text under each of [`TEXT_TYPES`]; Paste reads the clipboard's SVG, text and PNG, and the paste -/// check looks at the types offered without reading any data. The protocol gives the clipboard to -/// the window with the keyboard focus only. A worker thread handles the protocol's events and -/// starts a thread for each paste of a Copy's data by another app ([`MAX_SENDS`] at once). Reads -/// run on another worker and take [`MAX_BYTES`] at most; text waits [`LOAD_WAIT`] at most, SVG and -/// PNG as long as a paste's bitmap from arboard. A read that gets no answer in its wait is kept for +/// text under each of [`TEXT_TYPES`]; Paste reads the files a file manager copied +/// ([`FILE_LISTS`]), then the clipboard's SVG, text and PNG, and the paste check looks at the types +/// offered without reading any data. The protocol gives the clipboard to the window with the +/// keyboard focus only. A worker thread handles the protocol's events and starts a thread for each +/// paste of a Copy's data by another app ([`MAX_SENDS`] at once). Reads run on another worker and +/// take [`MAX_BYTES`] at most; text waits [`LOAD_WAIT`] at most, file lists, SVG and PNG as long as +/// a paste's bitmap from arboard. A read that gets no answer in its wait is kept for /// a paste to wait for off the UI thread, as arboard's are. A read or send whose pipe moves no data /// for [`IDLE_WAIT`] fails and closes the pipe, which frees its worker or thread. #[cfg(target_os = "linux")] @@ -1817,11 +1900,17 @@ mod wayland { use wayland_client::{Connection, Dispatch, Proxy, QueueHandle, WEnum}; use super::loads::{Asker, GONE, LOAD_WAIT, Loads, wait_for_answer}; - use super::{BITMAP, Flavour, PNG, SVG, TEXT}; + use super::{BITMAP, Flavour, PNG, PathBuf, SVG, TEXT, copied_file, gnome_copied_paths, uri_list_paths}; /// The types text is offered under and read from, best first: `text/plain;charset=utf-8` (GTK /// and Qt apps), `UTF8_STRING` (X11 apps through XWayland) and `text/plain`. const TEXT_TYPES: [&str; 3] = ["text/plain;charset=utf-8", "UTF8_STRING", "text/plain"]; + /// What reads the files a file list names. + type PathsOf = fn(&[u8]) -> Vec<PathBuf>; + /// The types files copied in a file manager are offered under, each with what reads its files, + /// best first: `text/uri-list` (RFC 2483), and GNOME Files' own list, read only when the first + /// names no file. + const FILE_LISTS: [(&str, PathsOf); 2] = [("text/uri-list", uri_list_paths), ("x-special/gnome-copied-files", gnome_copied_paths)]; /// The most bytes a read takes from the app that copied (untrusted data), VectorCraft's own /// limit: a read of more fails. const MAX_BYTES: usize = 64 << 20; @@ -1905,6 +1994,35 @@ mod wayland { Some(first) } + /// Whether a paste of one of `mimes` can take a copied file: one of them is not text. + fn takes_files(mimes: &[&'static str]) -> bool { + mimes.iter().any(|&m| m != TEXT) + } + + /// The first type among `offered` that lists copied files ([`FILE_LISTS`]), in any letter case. + fn file_list_type(offered: &[String]) -> Option<&str> { + FILE_LISTS.iter().find_map(|(list, _)| offered.iter().find(|o| o.eq_ignore_ascii_case(list))).map(String::as_str) + } + + /// The first file a file manager copied that pastes as one of `mimes` ([`copied_file`]), from + /// the first of [`FILE_LISTS`] among `offered` that names a file, `read` reading each list. + fn copied(offered: &[String], mimes: &[&'static str], mut read: impl FnMut(&str) -> Option<Vec<u8>>) -> Option<Flavour> { + if !takes_files(mimes) { + return None; + } + let paths = FILE_LISTS.iter().find_map(|(list, paths_of)| { + let wire = offered.iter().find(|o| o.eq_ignore_ascii_case(list))?; + Some(paths_of(&read(wire)?)).filter(|paths| !paths.is_empty()) + })?; + copied_file(paths, mimes) + } + + /// What a paste of one of `mimes` takes: the first copied file that is art ([`copied`]), else + /// what [`pick`] takes. + fn pick_pasted(offered: &[String], mimes: &[&'static str], mut read: impl FnMut(&str) -> Option<Vec<u8>>) -> Option<Flavour> { + copied(offered, mimes, &mut read).or_else(|| pick(offered, mimes, read)) + } + /// The time `idle` from now; None when that is past the clock's range (no limit). fn idle_until(idle: Duration) -> Option<Instant> { Instant::now().checked_add(idle) @@ -2089,9 +2207,9 @@ mod wayland { impl Unanswered { /// What a paste of one of `mimes` takes once this read's answer comes, waiting for it until - /// `limit` after the read was sent: the clipboard read again as [`pick`] reads it, each read - /// waiting as long, [`LOAD_WAIT`] at least, since the app that answers late may have lost the - /// clipboard meanwhile. None when the answer doesn't come or the clipboard holds this + /// `limit` after the read was sent: the clipboard read again as [`pick_pasted`] reads it, + /// each read waiting as long, [`LOAD_WAIT`] at least, since the app that answers late may + /// have lost the clipboard meanwhile. None when the answer doesn't come or the clipboard holds this /// connection's Copy. pub(super) fn paste(self, mimes: &[&'static str], limit: Duration) -> Option<Flavour> { let left = |now: Instant| (self.sent + limit).saturating_duration_since(now); @@ -2103,7 +2221,9 @@ mod wayland { } seen.offered.clone() }; - pick(&offered, mimes, |wire| wait_for_answer(&self.reads.ask(wire.to_string()).ok()?, LOAD_WAIT.max(left(Instant::now()))).ok()?.ok()) + pick_pasted(&offered, mimes, |wire| { + wait_for_answer(&self.reads.ask(wire.to_string()).ok()?, LOAD_WAIT.max(left(Instant::now()))).ok()?.ok() + }) } } @@ -2136,12 +2256,36 @@ mod wayland { } } - /// What a paste of one of `mimes` reads: the first the clipboard offers. Text is read here, - /// [`LOAD_WAIT`] at most, and pasted unless it is empty; SVG and PNG are asked for here and - /// waited for, `wait` at most, by the work that comes back. When that read fails or is - /// empty, the work reads the rest of `mimes` as [`pick`] does, each read waiting until - /// `wait` after the first was sent, [`LOAD_WAIT`] at least. + /// What a paste of one of `mimes` reads: the files a file manager copied, else the first of + /// `mimes` the clipboard offers. A file list is asked for here and read, with the files, + /// by the work that comes back, which pastes the first file that is art ([`copied`]) and + /// else reads `mimes` as [`pick`] does. Text is read here, [`LOAD_WAIT`] at most, and + /// pasted unless it is empty; SVG and PNG are asked for here and waited for, `wait` at most, + /// by the work that comes back. When that read fails or is empty, the work reads the rest + /// of `mimes` as [`pick`] does. Each read the work makes after the first waits until `wait` + /// after the first was sent, [`LOAD_WAIT`] at least. pub(super) fn read(&mut self, mimes: &[&'static str], wait: Duration) -> Option<ClipboardRead> { + if takes_files(mimes) { + let offered = lock(&self.seen).offered.clone(); + if let Some(list) = file_list_type(&offered).map(str::to_string) { + let sent = Instant::now(); + let answer = self.loads.ask(list.clone()).ok()?; + self.unanswered = None; + let (reads, mimes) = (self.loads.asker(), mimes.to_vec()); + return Some(ClipboardRead::Later(Box::new(move || { + let left = || LOAD_WAIT.max((sent + wait).saturating_duration_since(Instant::now())); + // The list asked for here is read from its answer, every other type anew. + let mut first = Some((list, answer)); + pick_pasted(&offered, &mimes, |wire| { + let answer = match first.take_if(|(list, _)| list.as_str() == wire) { + Some((_, answer)) => answer, + None => reads.ask(wire.to_string()).ok()?, + }; + wait_for_answer(&answer, left()).ok()?.ok() + }) + }))); + } + } mimes.iter().enumerate().find_map(|(i, &mime)| { let wire = self.wire(mime)?; if mime == TEXT { @@ -2163,10 +2307,11 @@ mod wayland { }) } - /// Whether the clipboard offers one of `mimes`; nothing is read. + /// Whether the clipboard offers one of `mimes`, or files a file manager copied when a paste + /// of `mimes` can take a file; nothing is read. pub(super) fn has(&self, mimes: &[&'static str]) -> bool { let seen = lock(&self.seen); - mimes.iter().any(|m| wire_type(m, &seen.offered).is_some()) + (takes_files(mimes) && file_list_type(&seen.offered).is_some()) || mimes.iter().any(|m| wire_type(m, &seen.offered).is_some()) } /// Whether the clipboard holds this connection's last Copy. @@ -2835,6 +2980,85 @@ mod wayland { let Some(ClipboardRead::Later(work)) = reads.read(&[BITMAP], Duration::from_secs(600)) else { panic!("the PNG is asked for") }; assert!(work().is_none()); } + + /// Reads of a clipboard holding `data` by type, answered at once. + fn reads_holding(data: Vec<(String, Vec<u8>)>) -> Reads { + let types: Vec<String> = data.iter().map(|(t, _)| t.clone()).collect(); + let loads = Loads::spawn("test", Duration::ZERO, move |wire: String| { + data.iter().find(|(t, _)| *t == wire).map(|(_, d)| d.clone()).ok_or_else(|| "not offered".to_string()) + }) + .unwrap(); + let types: Vec<&str> = types.iter().map(String::as_str).collect(); + Reads::new(loads, Arc::new(Mutex::new(Seen::offering(&types)))) + } + + /// The `file:` URI of `path`, its spaces escaped. + fn file_uri(path: &std::path::Path) -> String { + format!("file://{}", path.display().to_string().replace(' ', "%20")) + } + + /// What a paste of `mimes` takes from `reads`. + fn paste(reads: &mut Reads, mimes: &[&'static str]) -> Option<(&'static str, Vec<u8>)> { + match reads.read(mimes, Duration::from_secs(600))? { + ClipboardRead::Now(f) => Some((f.mime, f.data)), + ClipboardRead::Later(work) => work().map(|f| (f.mime, f.data)), + } + } + + #[test] + fn files_copied_in_a_file_manager_paste_as_their_art() { + use vectorcraft_engine::cmd::clipboard::PASTE_ORDER; + let d = tempfile::Builder::new().prefix("vectorcraft-wayland-files-").tempdir().unwrap(); + let (notes, red) = (d.path().join("notes.txt"), d.path().join("red image.png")); + let mut png = vec![]; + image::RgbaImage::new(2, 2).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap(); + std::fs::write(¬es, "not art").unwrap(); + std::fs::write(&red, &png).unwrap(); + let list = |paths: &[&std::path::Path]| paths.iter().map(|p| file_uri(p) + "\r\n").collect::<String>().into_bytes(); + let held = |types: &[(&str, Vec<u8>)]| reads_holding(types.iter().map(|(t, d)| (t.to_string(), d.clone())).collect()); + let text = ("text/plain;charset=utf-8", b"the files' paths".to_vec()); + // A file list alone enables Paste and pastes the first file that is art. + let mut reads = held(&[("text/uri-list", list(&[¬es, &red]))]); + assert!(reads.has(&PASTE_ORDER) && reads.has(&[BITMAP])); + assert_eq!(paste(&mut reads, &PASTE_ORDER), Some((PNG, png.clone()))); + // A paste of text alone takes no file. + assert!(!reads.has(&[TEXT])); + assert_eq!(paste(&mut reads, &[TEXT]), None); + // The files come before the other types offered, as on the other platforms; the type in + // any letter case. + let mut reads = held(&[(SVG, b"<svg/>".to_vec()), text.clone(), ("Text/URI-List", list(&[&red]))]); + assert_eq!(paste(&mut reads, &PASTE_ORDER), Some((PNG, png.clone()))); + assert_eq!(paste(&mut reads, &[TEXT]), Some((TEXT, text.1.clone()))); + // With no file that is art, the paste takes the other types. + let mut reads = held(&[("text/uri-list", list(&[¬es, &d.path().join("gone.png")])), text.clone()]); + assert_eq!(paste(&mut reads, &PASTE_ORDER), Some((TEXT, text.1.clone()))); + let mut reads = held(&[("text/uri-list", b"https://example.com/art.png\r\n".to_vec())]); + assert_eq!(paste(&mut reads, &PASTE_ORDER), None); + // GNOME Files' own list, alone or when the URI list names no local file. + let gnome = [b"copy\n".to_vec(), file_uri(&red).into_bytes()].concat(); + let mut reads = held(&[("x-special/gnome-copied-files", gnome.clone())]); + assert!(reads.has(&PASTE_ORDER)); + assert_eq!(paste(&mut reads, &PASTE_ORDER), Some((PNG, png.clone()))); + let mut reads = held(&[("text/uri-list", b"file://server/art.png\r\n".to_vec()), ("x-special/gnome-copied-files", gnome)]); + assert_eq!(paste(&mut reads, &PASTE_ORDER), Some((PNG, png.clone()))); + // KDE's cut marker is not a file list. + let mut reads = held(&[("application/x-kde-cutselection", b"1".to_vec())]); + assert!(!reads.has(&PASTE_ORDER)); + assert_eq!(paste(&mut reads, &PASTE_ORDER), None); + } + + #[test] + fn a_file_list_that_cant_be_read_gives_way_to_the_other_types() { + use vectorcraft_engine::cmd::clipboard::PASTE_ORDER; + let offered = offered(&["text/uri-list", "text/plain"]); + let mut asked = vec![]; + let f = pick_pasted(&offered, &PASTE_ORDER, |wire| { + asked.push(wire.to_string()); + (wire == "text/plain").then(|| b"words".to_vec()) + }); + assert_eq!(f.map(|f| (f.mime, f.data)), Some((TEXT, b"words".to_vec()))); + assert_eq!(asked, ["text/uri-list", "text/plain"]); + } } } @@ -2952,6 +3176,70 @@ mod tests { assert_eq!(copied_file(vec![with_cr], &PASTE_ORDER).map(|f| f.mime), Some(PNG)); } + fn uri_paths(list: &[u8]) -> Vec<String> { + uri_list_paths(list).into_iter().map(|p| p.to_string_lossy().into_owned()).collect() + } + + #[test] + fn a_uri_list_names_the_local_files_of_its_lines() { + // CRLF or LF, comment lines and blank lines. + assert_eq!(uri_paths(b"# copied\r\nfile:///home/a/one.svg\r\n\r\nfile:///home/a/two.png\n"), ["/home/a/one.svg", "/home/a/two.png"]); + assert_eq!(uri_paths(b"file:///a.svg"), ["/a.svg"]); + // Percent escapes are decoded once; `+` and an escaped `#` are part of the name. + assert_eq!(uri_paths(b"file:///home/a/red%20image.png"), ["/home/a/red image.png"]); + assert_eq!(uri_paths(b"file:///home/a/caf%C3%A9.svg\nfile:///home/a/caf\xC3\xA9.svg"), ["/home/a/café.svg", "/home/a/café.svg"]); + assert_eq!(uri_paths(b"file:///a/%231+2.svg"), ["/a/#1+2.svg"]); + assert_eq!(uri_paths(b"file:///a/100%2525.svg"), ["/a/100%25.svg"]); + // No host, `localhost` in any case, and the short form name this machine; a fragment is + // left out. + assert_eq!( + uri_paths(b"file://localhost/a.svg\nFILE://LocalHost/b.svg\nfile:/c.svg\nfile:///d.svg#page=2"), + ["/a.svg", "/b.svg", "/c.svg", "/d.svg"] + ); + // Other hosts and schemes, relative paths, queries, bad escapes, an escaped NUL, a name + // that is not UTF-8 once decoded and a line that is not UTF-8 name no file. + for uri in [ + &b"file://server/a.svg"[..], + b"https://example.com/a.svg", + b"file:a.svg", + b"file://", + b"file://localhost", + b"file:///a.svg?x=1", + b"file:///a%2", + b"file:///a%zz.svg", + b"file:///a%00b.svg", + b"file:///a%FF.svg", + b"file:///a\xFF.svg", + b"/home/a/one.svg", + b"#file:///a.svg", + ] { + assert!(uri_list_paths(uri).is_empty(), "{}", String::from_utf8_lossy(uri)); + } + // The files beside a URI that names none are kept. + assert_eq!(uri_paths(b"https://example.com/a.svg\r\nfile:///b.svg\r\n"), ["/b.svg"]); + assert!(uri_list_paths(b"").is_empty()); + } + + #[test] + fn a_uri_list_longer_than_the_limit_names_no_file() { + assert_eq!(MAX_URIS, 1024); + let list = |n: usize| (0..n).map(|i| format!("# file {i}\r\nfile:///f{i}.svg\r\n")).collect::<String>(); + // Comment lines don't count. + assert_eq!(uri_list_paths(list(MAX_URIS).as_bytes()).len(), MAX_URIS); + assert!(uri_list_paths(list(MAX_URIS + 1).as_bytes()).is_empty()); + } + + #[test] + fn gnome_files_list_names_its_files_after_copy_or_cut() { + let paths = |list: &[u8]| gnome_copied_paths(list).into_iter().map(|p| p.to_string_lossy().into_owned()).collect::<Vec<_>>(); + assert_eq!(paths(b"copy\nfile:///a.svg\nfile:///b%20c.png"), ["/a.svg", "/b c.png"]); + assert_eq!(paths(b"cut\r\nfile:///a.svg\r\n"), ["/a.svg"]); + // Another first line, none, or no files. + for list in [&b"move\nfile:///a.svg"[..], b"file:///a.svg\nfile:///b.svg", b"copy", b"", b"Copy\nfile:///a.svg"] { + assert!(gnome_copied_paths(list).is_empty(), "{}", String::from_utf8_lossy(list)); + } + } + /// A DIB of `w`×`h` pixels (top row first when `h` is negative): a `header`-byte header (40, /// or 124 for a BITMAPV5HEADER with BGRA masks), `extra` (the masks after a 40-byte header, a /// colour table), then `rows`, each padded to 4 bytes. diff --git a/docs/development.md b/docs/development.md index 82ffbd4a5a..96c063a2a1 100644 --- a/docs/development.md +++ b/docs/development.md @@ -125,7 +125,7 @@ On GNOME/Wayland, enable **Preferences › User Interface › System Title Bar** The window runs natively on Wayland (eframe's `wayland` feature) and on X11. On machines with two GPUs it renders on the one the desktop runs on unless Preferences say otherwise; see [Desktop graphics processor](#desktop-graphics-processor) (#502). The system clipboard (`apps/vectorcraft/src/clipboard.rs`) is arboard with its `wayland-data-control` feature: -- **Clipboard:** under Wayland arboard talks to the compositor through the data-control protocol (wlroots compositors such as Sway and Hyprland, KDE Plasma), so bitmaps (`image/png`), SVG markup and text copied in any app paste (#398). Where the compositor lacks the protocol (GNOME's Mutter, [arboard#223](https://github.com/1Password/arboard/issues/223)), arboard falls back to the X11 clipboard through XWayland, which only holds what X11 apps copied. Where there is no X11 either (the Flatpak on a Wayland session: `--socket=fallback-x11` gives it none), Copy and Paste use the compositor's core data-device protocol (`wl_data_device`) on the window's own connection, and only while the window has focus. One Copy offers the PNG as `image/png`, the SVG as `image/svg+xml` (with Include SVG Code on) and the text as `text/plain;charset=utf-8`, `UTF8_STRING` and `text/plain`; a format with no data is not offered. Paste reads `image/svg+xml`, then text, then `image/png`, and blank text or text that only names a picture gives way to the PNG; the Paste menu item is enabled by the types offered, without reading any data. Whether the clipboard still holds VectorCraft's Copy is told by its data source, which the compositor cancels when another app copies. A read takes 64 MiB at most and fails beyond that. Reads run on a worker thread: text waits 2 s at most on the UI thread, SVG and PNG 10 s on the paste's background thread. An owner that never sends its data costs one read its wait, and later reads return at once until it answers. When a text read gets no answer in its 2 s, the paste waits on its background thread for that read's answer, up to 10 s after the read was sent, then reads the clipboard again unless it holds VectorCraft's Copy. Another app's paste of a Copy is sent on a thread of its own, 8 at once at most; a paste beyond them gets nothing. A clipboard neither backend opens is tried again after 1 s, doubling to a minute (a Copy or Paste of the user's at most once a second), and logged once when it goes and once when it comes back: before, the background Paste check reconnected and logged a warning every 250 ms. egui's own text paste into fields goes through smithay-clipboard and works either way. +- **Clipboard:** under Wayland arboard talks to the compositor through the data-control protocol (wlroots compositors such as Sway and Hyprland, KDE Plasma), so bitmaps (`image/png`), SVG markup and text copied in any app paste (#398). Where the compositor lacks the protocol (GNOME's Mutter, [arboard#223](https://github.com/1Password/arboard/issues/223)), arboard falls back to the X11 clipboard through XWayland, which only holds what X11 apps copied. Where there is no X11 either (the Flatpak on a Wayland session: `--socket=fallback-x11` gives it none), Copy and Paste use the compositor's core data-device protocol (`wl_data_device`) on the window's own connection, and only while the window has focus. One Copy offers the PNG as `image/png`, the SVG as `image/svg+xml` (with Include SVG Code on) and the text as `text/plain;charset=utf-8`, `UTF8_STRING` and `text/plain`; a format with no data is not offered. Paste reads the files a file manager copied (`text/uri-list`, else `x-special/gnome-copied-files`; local `file:` URIs only, 1,024 at most), then `image/svg+xml`, then text, then `image/png`, and blank text or text that only names a picture gives way to the PNG; the Paste menu item is enabled by the types offered, without reading any data. Whether the clipboard still holds VectorCraft's Copy is told by its data source, which the compositor cancels when another app copies. A read takes 64 MiB at most and fails beyond that. Reads run on a worker thread: text waits 2 s at most on the UI thread, file lists, SVG and PNG 10 s on the paste's background thread. An owner that never sends its data costs one read its wait, and later reads return at once until it answers. When a text read gets no answer in its 2 s, the paste waits on its background thread for that read's answer, up to 10 s after the read was sent, then reads the clipboard again unless it holds VectorCraft's Copy. Another app's paste of a Copy is sent on a thread of its own, 8 at once at most; a paste beyond them gets nothing. A clipboard neither backend opens is tried again after 1 s, doubling to a minute (a Copy or Paste of the user's at most once a second), and logged once when it goes and once when it comes back: before, the background Paste check reconnected and logged a warning every 250 ms. egui's own text paste into fields goes through smithay-clipboard and works either way. - **Clipboard owners that never answer (#510):** reading the clipboard waits on the app that owns it: arboard gives up on an X11 owner after 4 s for each format it tries, and a Wayland read waits for the owner to send its data. So on Linux the check that enables the Paste menu items runs on a background thread with a second clipboard handle (`crates/ui-egui/src/clipboard_probe.rs`, installed as `Services::clipboard_probe`), only while nothing is copied in the app and a document is open, and the window keeps drawing. Every arboard read on Linux and the BSDs, including the UI thread's (a paste, and a Copy or Cut checking what the clipboard held), runs on a worker thread with a handle of its own and waits 2 s at most: an owner that never sends its data costs one read that wait, and later reads fail at once until it answers. A paste's bitmap read waits up to 10 s on the paste's background thread, so the UI thread does not wait for it. When one of a paste's reads gets no answer in its 2 s, or a paste follows a read that has not been answered yet, such as the paste's own check whether the clipboard still holds what VectorCraft copied, the paste waits on that thread for that read's answer, up to 10 s after the read was sent, and pastes what it holds. When the answer is what VectorCraft copied, holds nothing to paste, or does not come, the paste takes the internal clipboard. On X11, quitting within 25 s of a read that got no answer waits for that read to end, so the app's own handle is the last one and hands what it copied to the clipboard manager when one runs. That includes a read of the Paste menu check's handle: quitting waits up to 27 s for the background thread to drop it before the app drops its own, and quits after that wait even when the handle has not been dropped. The app hides its main window before these waits (`hide_before_teardown` in `apps/vectorcraft/src/app.rs`), so an X11 window, an XWayland one included, closes at once; winit cannot hide a native Wayland window, which stays on screen until the waits end. Windows and macOS keep the check on the UI thread: Windows only asks which formats the clipboard holds, macOS asks the pasteboard server. - **Copied files:** files copied in a file manager (`text/uri-list`; `CF_HDROP` on Windows, file URLs on macOS) paste as the first one that is art (SVG, PDF, EPS, EMF/WMF or a bitmap; a `.ai` or `.ait` file from the editing data it holds, else as the PDF or PostScript it holds), before the clipboard's other formats (which include the files' paths as text). - **Dropping files on the window does not work under Wayland:** winit 0.30, which eframe 0.37 runs on, has no Wayland drag and drop ([winit#1881](https://github.com/rust-windowing/winit/issues/1881), added in winit 0.31; [egui#1563](https://github.com/emilk/egui/issues/1563)), so no `dropped_files` arrive. Until eframe moves to winit 0.31: copy the files in the file manager and paste them, use File › Place or Open, or open the window through XWayland, where drops work: set **Preferences › Performance › Linux Display Server** to **X11 (XWayland)** and restart (#1151), or start the app with `WAYLAND_DISPLAY= vectorcraft`. The preference (`linuxDisplayServer`, read at startup in `apps/vectorcraft/src/main.rs`, shown on Linux only) has winit open the window on X11 (`EventLoopBuilderExtX11::with_x11`) when the session is Wayland, `DISPLAY` is set and the X11 libraries winit loads are installed (`apps/vectorcraft/src/xwayland.rs` reads `ldconfig -p` and the usual library directories); otherwise the window opens on Wayland and the log says why. Unlike clearing `WAYLAND_DISPLAY`, it leaves the clipboard on the compositor's own. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..b931f74721 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1789,6 +1789,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - On the desktop, Copy and Cut make the system clipboard's formats (text, SVG, PDF, PNG) from a copy of the clipboard on the thread that writes background saves and exports, and write them when they are ready; while that thread has a save, an export, a print or a recovery copy to finish, they are made and written at once. Until they are written, Paste in VectorCraft takes the internal clipboard, and while a text field or the Type tool has the keyboard the app waits for them. Another Copy or Cut, or a copy of text in VectorCraft, drops them. - In the Linux Flatpak on GNOME, where the clipboard goes through the compositor's core Wayland protocol, one Copy offers the PNG (`image/png`), the SVG (`image/svg+xml`, with Include SVG Code on) and the text, and Paste takes another app's SVG, text or PNG in that order, a picture over blank text or text that only names it; the Paste menu item is enabled by the types offered (`clipboard::wayland` tests in `apps/vectorcraft/src/clipboard.rs`; not yet run in the Flatpak on a GNOME session). - On that core Wayland clipboard, a paste from an app that leaves its pipe open and sends no data for 2 s fails and pastes nothing, and a paste of VectorCraft's Copy by an app that takes no data for 2 s is stopped and its pipe closed, so later pastes and copies are read and sent again; the 2 s limit is VectorCraft's own and starts again after each byte that moves (`clipboard::wayland::tests::a_read_from_an_app_that_stops_sending_fails_and_closes_the_pipe` and `a_send_to_an_app_that_stops_reading_fails_and_frees_its_thread`). + - On that core Wayland clipboard, files copied in a file manager paste as the first one that is art, before the clipboard's other types, as on the other platforms: Paste reads the `text/uri-list` the file manager offers (RFC 2483), else GNOME Files' `x-special/gnome-copied-files`, off the UI thread, and takes the `file:` URIs with no host or `localhost` (RFC 8089), percent escapes decoded; other URIs are skipped, and a list of more than 1,024 URIs, VectorCraft's own limit, names no file. The Paste menu item is enabled when a file list is offered (`clipboard::wayland::tests::files_copied_in_a_file_manager_paste_as_their_art`; not yet run in the Flatpak on a GNOME session). - On the desktop with Enable Background Export on (Preferences › File Handling), File › Package… collects the linked files and fonts and writes the package from the document as it was at OK on the thread that writes background saves and exports, with "Packaging" in the status bar and the busy spinner until it is written; a save of unsaved changes that Package starts is written first. `file.package` over MCP and scripts replies as before. - On the desktop with Enable Background Export on, Export for Screens and the Asset Export panel's Export encode and write their files (into the folder, or one ZIP in it) from the document as it was at OK on the thread that writes background saves and exports, with "Exporting" in the status bar and the export progress dialog, which counts the files and whose Cancel stops before the next file. `document.exportForScreens` and `assets.export` over MCP and scripts reply as before. - With Enable Background Export on, an Export for Screens with no folder of its own also writes in the background into the folder its `exportPreset` keeps, with the same progress dialog and Cancel, and the status bar names that folder. When that folder is outside an MCP client's read roots, the reply, its errors and the status bar name it by its own name, as for an export made at once (`dialogs::tests_screens::an_export_into_a_presets_folder_writes_in_the_background`, `fileio::tests_screens::a_prepared_export_into_a_presets_folder_outside_the_read_root_leaves_it_out`). Behavior reference: the help page, https://helpx.adobe.com/illustrator/using/exporting-artwork.html (exports run in the background by default). From cd86168e34f6c242e6e8d8e88dbafade196e81bf Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Fri, 13 Nov 2026 22:33:24 -0800 Subject: [PATCH 069/108] Color management: documents behind the front one draw through their own profiles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With Window › Arrange › Tile or floating document windows, every document other than the front one was drawn through the profiles the front document is assigned, since the active color settings are process-wide. - cms::with_active puts other settings in place of the active ones on one thread, fast paths included, and puts them back after (also on a panic). cms::for_document gives the context a document's assigned profiles make, the same one each time for the same profiles and working settings. - Each pane renders its document's art through colormgmt::doc_cms, on the render worker and on the UI thread alike, and draws its paper, artboard colors and transparency grid through the same settings. - Loading or removing a profile redraws the documents assigned it, the ones behind the front one included. - The ink and separation tables keep the tables of up to four color settings, so documents with different CMYK profiles side by side do not rebuild them on each redraw. Placed documents inside a document behind the front one still draw through the front document's profiles. --- crates/color/src/cms.rs | 116 ++++++++++++++++-- crates/color/src/cms/tests.rs | 39 ++++++ crates/engine/src/cmd/colormgmt.rs | 26 +++- crates/engine/tests/color_settings.rs | 28 +++++ crates/render/src/ink.rs | 66 ++++++++--- crates/ui-egui/src/canvas/panes.rs | 38 ++++-- crates/ui-egui/src/canvas/panes/tests.rs | 144 +++++++++++++++++++++++ docs/target-app-parity.md | 2 +- 8 files changed, 417 insertions(+), 42 deletions(-) diff --git a/crates/color/src/cms.rs b/crates/color/src/cms.rs index f4297343a6..7fd8707a99 100644 --- a/crates/color/src/cms.rs +++ b/crates/color/src/cms.rs @@ -9,13 +9,16 @@ //! any CMYK `.icc` the user loads goes through `moxcms` (LUT-based profiles). //! * The **active settings** are process-wide: the working settings (Edit → Color Settings), with //! the profiles [`use_document_profiles`] last put in place of the working spaces; -//! [`crate::Color::to_rgb`] uses them. Code that needs deterministic numbers builds its own [`Cms`] with [`Cms::new`]. +//! [`crate::Color::to_rgb`] uses them. [`with_active`] puts other settings in their place on one +//! thread, as for a document drawn through its own profiles ([`for_document`]). Code that needs +//! deterministic numbers builds its own [`Cms`] with [`Cms::new`]. pub mod display; pub mod generic; pub mod icc; pub mod lab; +use std::cell::{Cell, RefCell}; use std::sync::atomic::{AtomicBool, AtomicU64, Ordering}; use std::sync::{Arc, Mutex, OnceLock, RwLock}; @@ -910,9 +913,32 @@ static WORKING: RwLock<Option<Arc<Cms>>> = RwLock::new(None); static RGB_IS_SRGB: AtomicBool = AtomicBool::new(true); static CMYK_IS_DEVICE: AtomicBool = AtomicBool::new(false); +thread_local! { + /// The settings [`with_active`] put in place of the active settings on this thread. + static SCOPED: RefCell<Option<Arc<Cms>>> = const { RefCell::new(None) }; + /// [`SCOPED`]'s flags for the fast paths: [`SCOPED_SET`] while it is set, [`SCOPED_SRGB`] when + /// its RGB space is sRGB, and [`SCOPED_DEVICE`] when its CMYK space is device CMYK. + static SCOPED_FLAGS: Cell<u8> = const { Cell::new(0) }; +} +const SCOPED_SET: u8 = 1; +const SCOPED_SRGB: u8 = 2; +const SCOPED_DEVICE: u8 = 4; + /// The active color-management context: the working settings, with the profiles -/// [`use_document_profiles`] last put in place of the working spaces. +/// [`use_document_profiles`] last put in place of the working spaces. Inside [`with_active`] on +/// this thread: the settings it was given. pub fn active() -> Arc<Cms> { + if SCOPED_FLAGS.with(Cell::get) & SCOPED_SET != 0 + && let Some(c) = SCOPED.with(|s| s.borrow().clone()) + { + return c; + } + installed() +} + +/// The active settings of the process, as [`use_document_profiles`] or [`set_active`] last put them +/// in place. +fn installed() -> Arc<Cms> { if let Some(c) = ACTIVE.read().unwrap_or_else(|e| e.into_inner()).as_ref() { return c.clone(); } @@ -954,14 +980,8 @@ pub fn set_active(settings: &ColorSettings) -> Result<(), CmsError> { /// the active settings changed. pub fn use_document_profiles(rgb: Option<&str>, cmyk: Option<&str>) -> bool { let working = working(); - let mut st = working.settings.clone(); - if let Some(p) = rgb.and_then(profile).filter(|p| p.kind == ProfileKind::Rgb) { - st.rgb = p.name; - } - if let Some(p) = cmyk.and_then(profile).filter(|p| p.kind == ProfileKind::Cmyk) { - st.cmyk = p.name; - } - if st == active().settings { + let st = document_settings(&working.settings, rgb, cmyk); + if st == installed().settings { return false; } if st == working.settings { @@ -976,6 +996,72 @@ pub fn use_document_profiles(rgb: Option<&str>, cmyk: Option<&str>) -> bool { true } +/// The working settings `working` with the profiles a document is assigned (`None`: none) in place +/// of the working spaces, as [`use_document_profiles`] takes them. +fn document_settings(working: &ColorSettings, rgb: Option<&str>, cmyk: Option<&str>) -> ColorSettings { + let mut st = working.clone(); + if let Some(p) = rgb.and_then(profile).filter(|p| p.kind == ProfileKind::Rgb) { + st.rgb = p.name; + } + if let Some(p) = cmyk.and_then(profile).filter(|p| p.kind == ProfileKind::Cmyk) { + st.cmyk = p.name; + } + st +} + +/// How many contexts [`for_document`] keeps. +const DOCUMENT_CONTEXTS: usize = 8; + +/// The color-management context a document assigned the profiles `rgb` and `cmyk` (`None`: none) +/// draws through: the one [`use_document_profiles`] would make active for it. A context that is the +/// active or the working one is that one; the others are kept for the same working settings and +/// loaded profiles, so the same document gets the same context again. A profile that cannot be +/// loaded gives the working settings. +pub fn for_document(rgb: Option<&str>, cmyk: Option<&str>) -> Arc<Cms> { + static KEPT: Mutex<Vec<(u64, Arc<Cms>)>> = Mutex::new(Vec::new()); + let working = working(); + let st = document_settings(&working.settings, rgb, cmyk); + let installed = installed(); + if st == installed.settings { + return installed; + } + if st == working.settings { + return working; + } + let generation = profiles_generation(); + let mut kept = KEPT.lock().unwrap_or_else(|e| e.into_inner()); + kept.retain(|(g, c)| *g == generation && c.working.as_ref().is_some_and(|w| Arc::ptr_eq(w, &working))); + if let Some((_, c)) = kept.iter().find(|(_, c)| c.settings == st) { + return c.clone(); + } + let Ok(mut cms) = Cms::new(&st) else { return working }; + cms.working = Some(working); + let cms = Arc::new(cms); + if kept.len() >= DOCUMENT_CONTEXTS { + kept.remove(0); + } + kept.push((generation, cms.clone())); + cms +} + +/// Run `f` with `cms` as the active settings on this thread ([`active`], [`crate::Color::to_rgb`] +/// and the conversions that read them), as when drawing a document other than the front one +/// through its own profiles. Other threads, and this thread after `f`, keep the settings they had. +pub fn with_active<R>(cms: Arc<Cms>, f: impl FnOnce() -> R) -> R { + /// Puts back the settings this thread had before, when `f` returns or unwinds. + struct Restore(Option<Arc<Cms>>, u8); + impl Drop for Restore { + fn drop(&mut self) { + SCOPED.with(|s| *s.borrow_mut() = self.0.take()); + SCOPED_FLAGS.with(|c| c.set(self.1)); + } + } + let flags = SCOPED_SET | if cms.rgb_is_srgb() { SCOPED_SRGB } else { 0 } | if matches!(cms.cmyk, CmykSpace::Device) { SCOPED_DEVICE } else { 0 }; + let before = SCOPED.with(|s| s.borrow_mut().replace(cms)); + let _restore = Restore(before, SCOPED_FLAGS.with(|c| c.replace(flags))); + f() +} + fn install(cms: Arc<Cms>) { RGB_IS_SRGB.store(cms.rgb_is_srgb(), Ordering::Relaxed); CMYK_IS_DEVICE.store(matches!(cms.cmyk, CmykSpace::Device), Ordering::Relaxed); @@ -984,10 +1070,16 @@ fn install(cms: Arc<Cms>) { /// Fast path for [`Color::to_rgb`]: RGB colours need no conversion while the working space is sRGB. pub(crate) fn rgb_is_srgb() -> bool { - RGB_IS_SRGB.load(Ordering::Relaxed) + match SCOPED_FLAGS.with(Cell::get) { + f if f & SCOPED_SET != 0 => f & SCOPED_SRGB != 0, + _ => RGB_IS_SRGB.load(Ordering::Relaxed), + } } pub(crate) fn cmyk_is_device() -> bool { - CMYK_IS_DEVICE.load(Ordering::Relaxed) + match SCOPED_FLAGS.with(Cell::get) { + f if f & SCOPED_SET != 0 => f & SCOPED_DEVICE != 0, + _ => CMYK_IS_DEVICE.load(Ordering::Relaxed), + } } #[cfg(test)] diff --git a/crates/color/src/cms/tests.rs b/crates/color/src/cms/tests.rs index 57709abe66..7b22163525 100644 --- a/crates/color/src/cms/tests.rs +++ b/crates/color/src/cms/tests.rs @@ -403,3 +403,42 @@ fn lab_colours_round_trip_through_the_cms() { let Color::Gray { k } = c.convert(&Color::lab(50.0, 0.0, 0.0), Model::Gray, ri) else { panic!("Gray") }; assert!((k - 0.53).abs() < 0.01, "{k}"); } + +#[test] +fn with_active_puts_settings_in_place_on_this_thread_only() { + let p3 = Arc::new(Cms::new(&ColorSettings { rgb: DISPLAY_P3.into(), cmyk: DEVICE_CMYK.into(), ..Default::default() }).unwrap()); + let (rgb, ink) = (Color::Rgb { r: 0.2, g: 0.6, b: 0.4 }, Color::Cmyk { c: 0.2, m: 0.3, y: 0.4, k: 0.1 }); + let before = (rgb.to_rgb(), ink.to_rgb()); + let (inside, ink_inside, other_thread, nested) = with_active(p3.clone(), || { + let other = std::thread::spawn(move || rgb.to_rgb()).join().unwrap(); + let nested = with_active(Arc::new(cms()), || rgb.to_rgb()); + (rgb.to_rgb(), ink.to_rgb(), other, nested) + }); + assert_eq!(inside, p3.display_rgb(&rgb), "RGB is drawn through the settings given"); + assert_ne!(inside, before.0); + assert_eq!(ink_inside, naive_cmyk_to_rgb([0.2, 0.3, 0.4, 0.1]), "CMYK takes the device formula of the settings given"); + assert_eq!(other_thread, before.0, "another thread keeps the active settings"); + assert_eq!(nested, before.0, "an inner call puts its own settings in place"); + assert_eq!((rgb.to_rgb(), ink.to_rgb()), before, "the active settings come back after"); + let unwound = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| with_active(p3.clone(), || panic!("unwinds")))); + assert!(unwound.is_err()); + assert_eq!((rgb.to_rgb(), ink.to_rgb()), before, "the active settings come back after a panic"); +} + +#[test] +fn a_document_gets_the_same_context_for_the_same_profiles() { + // Other tests load profiles meanwhile, and a load makes the contexts again: try until one pair + // of calls sees none. + let same = (0..100).any(|_| { + let generation = profiles_generation(); + let (a, b) = (for_document(Some(DISPLAY_P3), None), for_document(Some(DISPLAY_P3), None)); + profiles_generation() == generation && Arc::ptr_eq(&a, &b) + }); + assert!(same, "the same profiles give the same context"); + let p3 = for_document(Some(DISPLAY_P3), None); + assert_eq!(p3.settings().rgb, DISPLAY_P3); + assert_eq!(p3.settings().cmyk, working_settings().cmyk, "the working CMYK space stays"); + assert_eq!(for_document(None, None).settings(), &working_settings(), "no profiles: the working settings"); + let unknown = for_document(Some("no such profile"), Some(SRGB)); + assert_eq!(unknown.settings(), &working_settings(), "an unknown profile or one of the other model leaves the working space"); +} diff --git a/crates/engine/src/cmd/colormgmt.rs b/crates/engine/src/cmd/colormgmt.rs index 66295f50f2..4e4da57f9c 100644 --- a/crates/engine/src/cmd/colormgmt.rs +++ b/crates/engine/src/cmd/colormgmt.rs @@ -9,7 +9,8 @@ //! ([`use_front_profiles`]): when they are assigned, when the working settings change, and when the //! document comes to the front or its assignment comes back (an open, a switch, a close, a revert, //! an undo or a rollback, [`Session::sync_front_profiles`]); the working spaces stay as Edit → Color -//! Settings set them. +//! Settings set them. A document drawn while another is in front draws through its own profiles +//! ([`doc_cms`]). use std::collections::BTreeMap; use std::sync::Arc; @@ -236,6 +237,9 @@ fn load_profile(s: &mut Session, p: &Value) -> Result<Value> { } else if proof_targets(&info.name) { // A new file of the CMYK profile View → Proof Setup targets: redraw. touch_all(s); + } else { + // Documents behind the front one draw through their own profiles: those assigned it redraw. + touch_assigned(s, &info.name); } Ok(json!({"name": info.name, "kind": info.kind, "remembered": remembered})) } @@ -266,9 +270,21 @@ fn remove_profile(s: &mut Session, p: &Value) -> Result<Value> { if proof_targets(&info.name) { touch_all(s); } + // Documents behind the front one draw through their own profiles: those assigned it redraw. + touch_assigned(s, &info.name); Ok(json!({"removed": info.name})) } +/// Redraw the open documents assigned the profile `name`. +fn touch_assigned(s: &mut Session, name: &str) { + for d in &mut s.docs { + let (rgb, cmyk) = doc_profiles(&d.doc); + if [rgb, cmyk].iter().any(|n| n.as_deref() == Some(name)) { + d.revision += 1; + } + } +} + /// Whether View → Proof Setup targets the CMYK profile `name`. fn proof_targets(name: &str) -> bool { matches!(proof::view().setup.target, ProofTarget::Cmyk(t) if t == name) @@ -285,6 +301,14 @@ pub fn doc_profiles(d: &vectorcraft_doc::Document) -> (Option<String>, Option<St (get(&d.color_profiles.rgb), get(&d.color_profiles.cmyk)) } +/// The color-management context the document draws through: the working settings with its +/// assigned profiles in place of the working spaces, whether or not it is in front +/// ([`cms::for_document`]). +pub fn doc_cms(d: &vectorcraft_doc::Document) -> Arc<cms::Cms> { + let (rgb, cmyk) = doc_profiles(d); + cms::for_document(rgb.as_deref(), cmyk.as_deref()) +} + fn assign_profile(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "edit.assignProfile"; let (mut rgb, mut cmyk) = doc_profiles(&s.doc()?.doc); diff --git a/crates/engine/tests/color_settings.rs b/crates/engine/tests/color_settings.rs index e8b3ab0906..b02e34690b 100644 --- a/crates/engine/tests/color_settings.rs +++ b/crates/engine/tests/color_settings.rs @@ -149,6 +149,34 @@ fn loading_an_assigned_profile_again_keeps_it_in_use() { assert_eq!(cms::working_settings(), working); } +/// A document behind the front one draws through its own assigned profile: loading that profile's +/// file again or removing it redraws the document, and the front document stays as it was. +#[test] +fn loading_or_removing_a_back_documents_profile_redraws_it() { + const NAME: &str = "Back RGB P"; + let _g = settings(); + let dir = fresh_dir("back-assigned"); + let _reset = ColorSettingsReset { profile: Some(NAME), paths: vec![dir.clone()] }; + std::fs::create_dir_all(&dir).unwrap(); + let path = dir.join("back.icc"); + std::fs::write(&path, icc_named(NAME)).unwrap(); + let mut s = session(); + let load = |s: &mut Session| assert_eq!(exec(s, "color.loadProfile", json!({"path": path.to_str().unwrap()}))["name"], NAME); + load(&mut s); + exec(&mut s, "edit.assignProfile", json!({"rgb": NAME})); + exec(&mut s, "file.new", json!({"width": 100, "height": 100})); + let revisions = |s: &Session| s.documents().iter().map(|d| d.revision).collect::<Vec<_>>(); + let before = revisions(&s); + load(&mut s); + let loaded = revisions(&s); + assert!(loaded[0] > before[0], "the back document assigned the profile redraws after a load"); + assert_eq!(loaded[1], before[1], "the front document does not use it"); + exec(&mut s, "color.removeProfile", json!({"name": NAME})); + let removed = revisions(&s); + assert!(removed[0] > loaded[0], "the back document assigned the profile redraws after a removal"); + assert_eq!(removed[1], loaded[1], "the front document does not use it"); +} + /// A batch that assigns a profile and then changes the color mode, as Document Setup's OK does, /// converts the colors through the profile it assigns. #[test] diff --git a/crates/render/src/ink.rs b/crates/render/src/ink.rs index 2d67db2073..7bcc117a23 100644 --- a/crates/render/src/ink.rs +++ b/crates/render/src/ink.rs @@ -239,19 +239,29 @@ fn inks(c: &Color) -> [f32; 4] { let key = c.key(); let cms = cms::active(); SEPARATED.with(|s| { - let (owner, seen) = &mut *s.borrow_mut(); + let kept = &mut *s.borrow_mut(); + let i = match kept.iter().position(|(owner, _)| Arc::ptr_eq(owner, &cms)) { + Some(i) => i, + None => { + if kept.len() >= KEPT_TABLES { + kept.remove(0); + } + kept.push((cms.clone(), HashMap::new())); + kept.len() - 1 + } + }; + let seen = &mut kept[i].1; // Large enough for the many colours of gradient meshes and blends, which otherwise cleared // it over and over and separated every colour through the profile again. - if !owner.as_ref().is_some_and(|o| Arc::ptr_eq(o, &cms)) || seen.len() >= 1 << 16 { + if seen.len() >= 1 << 16 { seen.clear(); - *owner = Some(cms.clone()); } *seen.entry(key).or_insert_with(|| cms.to_cmyk(c, cms.settings().intent)) }) } -/// Separated colours, for the colour settings they were separated with. -type Separated = (Option<Arc<Cms>>, HashMap<[u32; 5], [f32; 4]>); +/// Separated colours, for each of the colour settings they were separated with, the newest last. +type Separated = Vec<(Arc<Cms>, HashMap<[u32; 5], [f32; 4]>)>; thread_local! { static SEPARATED: RefCell<Separated> = RefCell::default(); @@ -276,31 +286,37 @@ impl InkLut { } } -/// A table built for the colour settings it was built with, and its generation (see [`cached`]). -type Cached<T> = Mutex<Option<(Arc<Cms>, Arc<T>, u64)>>; +/// Tables built for the colour settings they were built with, and their generations, the newest +/// last (see [`cached`]). +type Cached<T> = Mutex<Vec<(Arc<Cms>, Arc<T>, u64)>>; + +/// How many tables each [`Cached`] keeps: documents drawn side by side through their own profiles +/// don't make them again and again. +const KEPT_TABLES: usize = 4; /// The last table generation handed out: images made with a table are cached under its /// generation (see [`crate::images`]), and none is ever reused. static GENERATION: AtomicU64 = AtomicU64::new(0); -static DISPLAY: Cached<InkLut> = Mutex::new(None); +static DISPLAY: Cached<InkLut> = Mutex::new(Vec::new()); /// Screen colours → [`Ink::Cmy`] and [`Ink::K`] values (placed images). -static SEPARATE: Cached<[ProofLut; 2]> = Mutex::new(None); +static SEPARATE: Cached<[ProofLut; 2]> = Mutex::new(Vec::new()); -/// The table in `slot` for the active colour settings, built by `build` when they changed, and -/// its generation. +/// The table in `slot` for the active colour settings, built by `build` when none is kept for +/// them, and its generation. fn cached<T>(slot: &Cached<T>, build: impl FnOnce(&Cms) -> T) -> (Arc<T>, u64) { let cms = cms::active(); let mut s = slot.lock().unwrap_or_else(|e| e.into_inner()); - match &*s { - Some((owner, t, g)) if Arc::ptr_eq(owner, &cms) => (t.clone(), *g), - _ => { - let t = Arc::new(build(&cms)); - let g = GENERATION.fetch_add(1, Ordering::Relaxed) + 1; - *s = Some((cms, t.clone(), g)); - (t, g) - } + if let Some((_, t, g)) = s.iter().find(|(owner, _, _)| Arc::ptr_eq(owner, &cms)) { + return (t.clone(), *g); } + let t = Arc::new(build(&cms)); + let g = GENERATION.fetch_add(1, Ordering::Relaxed) + 1; + if s.len() >= KEPT_TABLES { + s.remove(0); + } + s.push((cms, t.clone(), g)); + (t, g) } /// [`compose`] puts at least this many pixels in each band but the last. @@ -585,6 +601,18 @@ mod tests { assert_eq!(pm.data()[0].r, 204, "source pixels remain unchanged"); } + #[test] + fn tables_of_two_color_settings_are_kept_side_by_side() { + // Two documents drawn in turn through their own settings each keep their tables. + let settings = || Arc::new(Cms::new(&cms::ColorSettings::default()).unwrap()); + let (a, b) = (settings(), settings()); + let tables = |c: &Arc<Cms>| cms::with_active(c.clone(), || (display_lut().1, separation().1)); + let (first_a, first_b) = (tables(&a), tables(&b)); + assert_ne!(first_a, first_b, "each settings get their own tables"); + assert_eq!(tables(&a), first_a, "the first settings' tables are not made again"); + assert_eq!(tables(&b), first_b, "the second settings' tables are not made again"); + } + #[test] fn the_ink_table_matches_the_profile() { let cms = cms::active(); diff --git a/crates/ui-egui/src/canvas/panes.rs b/crates/ui-egui/src/canvas/panes.rs index 76fb599fda..0a26f26843 100644 --- a/crates/ui-egui/src/canvas/panes.rs +++ b/crates/ui-egui/src/canvas/panes.rs @@ -107,17 +107,16 @@ impl Panes { } let current = self.shown.get(&slot).is_some_and(|(k, _)| *k == key) || self.pending.get(&slot) == Some(&key); if !current { + // The document draws through its own assigned profiles, not the front document's, on + // the worker too. + let cms = vectorcraft_engine::cmd::colormgmt::doc_cms(&doc); let mut queued = false; if let Some(worker) = &self.worker { - let (job_doc, job_opts, job_display) = (doc.clone(), opts.clone(), display.clone()); + let (job_doc, job_opts, job_display, job_cms) = (doc.clone(), opts.clone(), display.clone(), cms.clone()); queued = worker.submit( slot, (slot, key.clone()), - Box::new(move |r| { - let mut img = r.render(&job_doc, w, h, view, &job_opts); - crate::display_profile::convert(job_display.as_deref(), &mut img.pixels); - Some(img) - }), + Box::new(move |r| Some(render_pane(r, (&job_doc, w, h, view, &job_opts), job_display.as_deref(), job_cms))), ); if queued { self.pending.insert(slot, key.clone()); @@ -126,8 +125,8 @@ impl Panes { } } if !queued { - let mut img = self.renderer.get_or_insert_with(vectorcraft_render::Renderer::new).render(&doc, w, h, view, &opts); - crate::display_profile::convert(display.as_deref(), &mut img.pixels); + let r = self.renderer.get_or_insert_with(vectorcraft_render::Renderer::new); + let img = render_pane(r, (&doc, w, h, view, &opts), display.as_deref(), cms); self.upload(ctx, slot, key, &img); } } @@ -146,6 +145,19 @@ impl Panes { } } +/// Render `doc` (`w` × `h` pixels through `view`, with `opts`) through the color settings `cms`, +/// then convert it into the display profile `display`. +fn render_pane( + r: &mut vectorcraft_render::Renderer, + (doc, w, h, view, opts): (&vectorcraft_doc::Document, u32, u32, Affine, &vectorcraft_render::RenderOptions), + display: Option<&vectorcraft_color::cms::display::DisplayTransform>, + cms: Arc<vectorcraft_color::cms::Cms>, +) -> vectorcraft_render::Rendered { + let mut img = vectorcraft_color::cms::with_active(cms, || r.render(doc, w, h, view, opts)); + crate::display_profile::convert(display, &mut img.pixels); + img +} + /// The grid of `n` panes in `area`, filled row by row: as many columns as the square root of `n` /// rounded up, and as many rows as those columns need. The panes meet edge to edge and cover /// `area`; the spare cells of the last row stay empty. @@ -294,8 +306,16 @@ fn fit_pane(v: &mut View, doc: &vectorcraft_doc::Document, rect: egui::Rect, ui_ /// art, grid, artboards, guides and selected objects, and its rulers and the room of the canvas's /// scroll bars, so the document stays where it is when the pane becomes the canvas. True when a /// press in the pane asks for its window to become the current one. A floating window draws its -/// view with this too ([`crate::doc_windows`]). +/// view with this too ([`crate::doc_windows`]). The document's colors, its paper and transparency +/// grid included, draw through its own assigned profiles, not the front document's. pub(crate) fn pane(app: &mut VectorcraftApp, ui: &Ui, w: Win, cell: egui::Rect) -> bool { + let Some(st) = app.session.documents().get(w.0) else { return false }; + let cms = vectorcraft_engine::cmd::colormgmt::doc_cms(&st.doc); + vectorcraft_color::cms::with_active(cms, || draw_pane(app, ui, w, cell)) +} + +/// [`pane`], drawn through the color settings in place. +fn draw_pane(app: &mut VectorcraftApp, ui: &Ui, w: Win, cell: egui::Rect) -> bool { let t = Tokens::get(ui.ctx()); let ppp = ui.ctx().pixels_per_point(); let (full, rect) = view_rects(app, cell, ppp); diff --git a/crates/ui-egui/src/canvas/panes/tests.rs b/crates/ui-egui/src/canvas/panes/tests.rs index cb1394f612..005b930d01 100644 --- a/crates/ui-egui/src/canvas/panes/tests.rs +++ b/crates/ui-egui/src/canvas/panes/tests.rs @@ -358,3 +358,147 @@ fn a_resized_window_fits_the_tiled_documents_again_unless_one_was_zoomed() { } assert_eq!(app.views[1].zoom, zoomed.zoom, "the zoomed document keeps its zoom"); } + +/// The RGB of the middle pixel of the render that document `i`'s pane uploaded in `out`. +fn pane_middle(app: &VectorcraftApp, out: &egui::FullOutput, i: usize) -> [u8; 3] { + let uid = app.session.documents()[i].uid; + let id = app.canvas.panes.shown.iter().find(|(slot, _)| slot.0 == uid).map(|(_, (_, tex))| tex.id()).unwrap(); + let image = out.textures_delta.set.iter().find(|(t, _)| **t == id).and_then(|(_, d)| d.last()).map(|d| d.image.clone()).unwrap(); + let egui::ImageData::Color(img) = image; + let p = img.pixels[img.size[1] / 2 * img.size[0] + img.size[0] / 2]; + [p.r(), p.g(), p.b()] +} + +#[test] +fn other_panes_draw_through_their_documents_profiles() { + const CHILD: &str = "VECTORCRAFT_TEST_PANE_PROFILES"; + if std::env::var_os(CHILD).is_none() { + // Color settings are process-wide: assign profiles in a separate test process. + let output = std::process::Command::new(std::env::current_exe().unwrap()) + .args(["--exact", "canvas::panes::tests::other_panes_draw_through_their_documents_profiles", "--nocapture"]) + .env(CHILD, "1") + .output() + .unwrap(); + let stdout = String::from_utf8_lossy(&output.stdout); + assert!( + output.status.success() && stdout.contains("test result: ok. 1 passed; 0 failed;"), + "isolated pane profile test failed:\n{stdout}\n{}", + String::from_utf8_lossy(&output.stderr), + ); + return; + } + use vectorcraft_color::cms::{self, Cms, ColorSettings}; + let mut app = app_with(2); + app.session.prefs.monitor_profile_display = false; + // Each document is covered by one RGB rectangle; the second is assigned Display P3. + for i in 0..2 { + app.run("document.activate", json!({"index": i})).unwrap(); + app.run("shape.rectangle", json!({"x": -50, "y": -50, "width": 500, "height": 400})).unwrap(); + app.run("paint.setFill", json!({"color": "#339966"})).unwrap(); + } + app.run("edit.assignProfile", json!({"rgb": cms::DISPLAY_P3})).unwrap(); + // Its simulated paper shows in another color. + app.run("document.setup", json!({"gridColors": ["#cc6633", "#ffffff"], "simulatePaper": true})).unwrap(); + let in_p3 = |r: u8, g: u8, b: u8| { + let color = vectorcraft_color::Color::Rgb { r: r as f32 / 255.0, g: g as f32 / 255.0, b: b as f32 / 255.0 }; + let p3 = Cms::new(&ColorSettings { rgb: cms::DISPLAY_P3.into(), ..cms::working_settings() }).unwrap().display_rgb(&color); + (color, p3.map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8)) + }; + let (color, p3) = in_p3(0x33, 0x99, 0x66); + let srgb = [0x33, 0x99, 0x66]; + assert_ne!(p3, srgb, "Display P3 draws the color differently"); + let (_, paper_p3) = in_p3(0xcc, 0x66, 0x33); + let near = |a: [u8; 3], b: [u8; 3]| a.iter().zip(b).all(|(x, y)| x.abs_diff(y) <= 1); + // Whether `out` fills a shape with the RGB `rgb`, give or take one. + let fills = |out: &egui::FullOutput, rgb: [u8; 3]| { + fn any(s: &Shape, f: &dyn Fn(Color32) -> bool) -> bool { + match s { + Shape::Vec(v) => v.iter().any(|s| any(s, f)), + Shape::Path(p) => f(p.fill), + _ => false, + } + } + out.shapes.iter().any(|c| any(&c.shape, &|c: Color32| c.a() == 255 && near([c.r(), c.g(), c.b()], rgb))) + }; + let ctx = egui::Context::default(); + let raw = || egui::RawInput { + screen_rect: Some(egui::Rect::from_min_size(Pos2::ZERO, vec2(1200.0, 800.0))), + max_texture_side: Some(8192), + ..Default::default() + }; + app.run("window.arrange.tile", json!({})).unwrap(); + // The first document in front: the second one's pane draws through Display P3, its paper too. + app.run("document.activate", json!({"index": 0})).unwrap(); + let mut out = ctx.run_ui(raw(), |ui| app.canvas_area(ui)); + let shown = pane_middle(&app, &out, 1); + assert!(fills(&out, paper_p3), "the back document's paper draws through its Display P3: {paper_p3:?}"); + assert!(!fills(&out, [0xcc, 0x66, 0x33]), "the back document's paper does not draw through the working space"); + out.textures_delta.clear(); + assert!(near(shown, p3), "the back document draws through its Display P3: {shown:?}, not {p3:?}"); + // The same in a floating window. + app.run("window.arrange.consolidateAllWindows", json!({})).unwrap(); + app.run("document.activate", json!({"index": 1})).unwrap(); + app.run("window.arrange.floatInWindow", json!({})).unwrap(); + app.run("document.activate", json!({"index": 0})).unwrap(); + let floating = |app: &mut VectorcraftApp| { + ctx.run_ui(raw(), |ui| { + app.canvas_area(ui); + crate::doc_windows::show(app, ui.ctx()); + }) + }; + // The window takes its place in the first frame and fades in over the next few. + for _ in 0..30 { + floating(&mut app).textures_delta.clear(); + } + app.canvas.panes.clear(); + let mut out = floating(&mut app); + let shown = pane_middle(&app, &out, 1); + assert!(fills(&out, paper_p3), "the floating document's paper draws through its Display P3: {paper_p3:?}"); + out.textures_delta.clear(); + assert!(near(shown, p3), "the floating document draws through its Display P3: {shown:?}, not {p3:?}"); + app.run("window.arrange.consolidateAllWindows", json!({})).unwrap(); + app.run("window.arrange.tile", json!({})).unwrap(); + app.canvas.panes.clear(); + // The second document in front: the first one's pane draws through the working sRGB. + app.run("document.activate", json!({"index": 1})).unwrap(); + let mut out = ctx.run_ui(raw(), |ui| app.canvas_area(ui)); + let shown = pane_middle(&app, &out, 0); + out.textures_delta.clear(); + assert!(near(shown, srgb), "the back document draws through the working space: {shown:?}, not {srgb:?}"); + // The same off the UI thread. + app.canvas.panes.clear(); + app.canvas.panes.worker = crate::thumb_worker::ThumbWorker::start(&ctx, "test-panes"); + app.canvas.panes.worker_started = true; + ctx.run_ui(raw(), |ui| app.canvas_area(ui)).textures_delta.clear(); + let done = app.canvas.panes.worker.as_ref().unwrap().wait().unwrap(); + assert_eq!(done.key.0.0, app.session.documents()[0].uid); + let img = done.img.unwrap(); + let at = ((img.height / 2 * img.width + img.width / 2) * 4) as usize; + let shown = [img.pixels[at], img.pixels[at + 1], img.pixels[at + 2]]; + assert!(near(shown, srgb), "the worker draws the back document through the working space: {shown:?}, not {srgb:?}"); + // A CMYK document behind the front one draws through its own assigned CMYK profile. + app.run("document.activate", json!({"index": 0})).unwrap(); + let steps = json!([ + {"command": "edit.assignProfile", "params": {"cmyk": cms::DEVICE_CMYK}}, + {"command": "file.documentColorMode", "params": {"mode": "cmyk"}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + app.run("select.all", json!({})).unwrap(); + app.run("paint.setFill", json!({"color": {"c": 60, "m": 10, "y": 80, "k": 0}})).unwrap(); + app.run("document.activate", json!({"index": 1})).unwrap(); + let ink = vectorcraft_color::Color::cmyk(0.6, 0.1, 0.8, 0.0); + let to_u8 = |c: [f32; 3]| c.map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8); + let device = to_u8(Cms::new(&ColorSettings { cmyk: cms::DEVICE_CMYK.into(), ..cms::working_settings() }).unwrap().display_rgb(&ink)); + let front = to_u8(cms::active().display_rgb(&ink)); + let close = |a: [u8; 3], b: [u8; 3]| a.iter().zip(b).all(|(x, y)| x.abs_diff(y) <= 3); + assert!(!close(device, front), "the two CMYK profiles draw the color differently: {device:?}, {front:?}"); + app.canvas.panes.clear(); + ctx.run_ui(raw(), |ui| app.canvas_area(ui)).textures_delta.clear(); + let done = app.canvas.panes.worker.as_ref().unwrap().wait().unwrap(); + assert_eq!(done.key.0.0, app.session.documents()[0].uid); + let img = done.img.unwrap(); + let at = ((img.height / 2 * img.width + img.width / 2) * 4) as usize; + let shown = [img.pixels[at], img.pixels[at + 1], img.pixels[at + 2]]; + assert!(close(shown, device), "the back CMYK document draws through its Device CMYK: {shown:?}, not {device:?} (front: {front:?})"); + assert!(near(cms::active().display_rgb(&color).map(|v| (v * 255.0).round() as u8), p3), "the front document's profile stays active"); +} diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 296bd84b2b..becf0cd6df 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -727,7 +727,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Document Setup › Color:** a Color tab shows the document color mode (RGB Color or CMYK Color), a Convert to CMYK or Convert to RGB box for a mode change (cleared: the colors keep their numbers), and the RGB and CMYK profiles assigned to the document, with a working-space entry for none. OK runs `edit.assignProfile` and then `file.documentColorMode` with the dialog's other changes in one `command.batch`, and the document's changes are one undo step. An unchanged Color tab adds no color commands, and Cancel, or OK with nothing changed, records no undo step. A Color tab field with a value of the wrong kind is an error, and the dialog stays open. The tab is VectorCraft's own layout; File › Document Color Mode and Edit › Assign Profile… stay as they are. Tests in `dialogs/document_setup.rs`. - **Canvas through the display's profile on Windows and X11:** Preferences › Performance › Use Monitor Profile for Canvas (on by default) converts the canvas's art, artboard paper and transparency grid from sRGB into the ICC profile of the display that shows most of the main window, after any proof, as the help page describes the monitor's profile translating the document's colors for the monitor ([the help page](https://help.adobe.com/archive/en_US/illustrator/cs4/illustrator_cs4_help.pdf#page=151)). Windows gives the display's default profile, and a display with Advanced Color on is left to Windows ([Microsoft Learn](https://learn.microsoft.com/en-us/windows/win32/wcs/advanced-color-icc-profiles)); X11 gives colord's profile for the output or the `_ICC_PROFILE` property. macOS converts the window itself, and a Wayland session stays sRGB. `ui.inspect` reports `displayProfile`. Tests in `color/src/cms/display.rs`, `ui-egui/src/display_profile.rs` and `canvas::tests::the_canvas_is_drawn_through_the_display_profile_while_the_preference_is_on`. - **Out-of-gamut warning after a profile change:** the out-of-gamut warning and its closest-color correction in the Color panel and Color Picker ([the help page](https://helpx.adobe.com/illustrator/using/adjusting-colors.html)) check the color against the document's assigned CMYK profile, else the working CMYK space, and update when Edit › Assign Profile… or Edit › Color Settings… changes that space or a loaded profile changes, without a change of color. Which CMYK space the warning uses is VectorCraft's own rule. Tests: `gamut_warning_follows_a_profile_change` and `gamut_warning_follows_a_profile_loaded_again` in `dialogs/color_picker/tests.rs`. -- **Assign Profile and the working spaces:** Edit › Assign Profile… tags the document and leaves the working spaces of Edit › Color Settings… as they are, in Color Settings, the Separations panel and the settings saved for the next start. Colors show and convert through the profiles assigned; a change in Color Settings keeps the profiles the document in front is assigned in use, and removing an assigned profile in use puts the working space back in its place. The profiles in use follow the document in front: a new, opened or reverted document, a switch to another tab, a close, Undo and Redo of Assign Profile, a failed batch, each step of a batch, Export All Open and the update of placed documents put that document's profiles in use, and the working spaces where it is assigned none or no document is open. View › Proof Setup › Working CMYK simulates the working CMYK space of Color Settings in Proof Colors and Separations Preview, also in a document assigned another CMYK profile. Public references: [Changing the color profile for a document and About color working spaces](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=150) and [Soft-proof presets](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=134). Tests in `engine/tests/color_settings.rs`. +- **Assign Profile and the working spaces:** Edit › Assign Profile… tags the document and leaves the working spaces of Edit › Color Settings… as they are, in Color Settings, the Separations panel and the settings saved for the next start. Colors show and convert through the profiles assigned; a change in Color Settings keeps the profiles the document in front is assigned in use, and removing an assigned profile in use puts the working space back in its place. The profiles in use follow the document in front: a new, opened or reverted document, a switch to another tab, a close, Undo and Redo of Assign Profile, a failed batch, each step of a batch, Export All Open and the update of placed documents put that document's profiles in use, and the working spaces where it is assigned none or no document is open. With Window › Arrange › Tile or floating document windows, each document behind the front one draws its art, paper and transparency grid through its own assigned profiles, and loading or removing a profile redraws the documents assigned it; placed documents inside it still draw through the front document's profiles. How documents behind the front one draw is VectorCraft's own rule. View › Proof Setup › Working CMYK simulates the working CMYK space of Color Settings in Proof Colors and Separations Preview, also in a document assigned another CMYK profile. Public references: [Changing the color profile for a document and About color working spaces](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=150) and [Soft-proof presets](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=134). Tests in `engine/tests/color_settings.rs`. - **New Document's More Settings and Save Preset:** More Settings opens a pop-up over New Document with only Number of Artboards, the artboard layout, Change to Right-to-Left Layout, Spacing and Columns; Done, Escape or a click outside closes it and keeps the values. Save Preset turns the top of Preset Details into a Save Document Preset heading with the preset's name, Cancel and Save, and hides the document's name, Close and Create until the preset is saved or canceled; nothing in that mode creates a document. Save Preset's default name is the first "Preset N" no saved preset has. VectorCraft's own layout. Harness tests in `dialogs/new_document.rs` cover both. - **New Document profiles:** each built-in category's presets start documents from that category's profile, a native document holding the starting swatches, graphic styles, brushes, symbols and other assets, the ruler and Document Setup options and the print settings ([Create a custom new document profile](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/start-a-new-file/create-a-custom-new-document-profile.html)). New Document's Manage Profiles pop-up opens a profile to edit and resets one to the shipped profile (`file.newProfiles`, `file.newProfiles.edit`, `file.newProfiles.reset`; `file.new {profile}`). The profiles live in VectorCraft's own `New Document Profiles` folder next to the preferences; a profile that cannot be read or is larger than 64 MiB leaves the defaults and is reported. Tests: `tests::newdoc::an_edited_profile_starts_the_documents_of_its_category`, `the_profile_follows_the_preset_access_and_reset`, `profile_errors_name_the_file_by_its_name_outside_the_read_roots`, `a_damaged_or_oversized_profile_leaves_the_defaults_and_is_reported`, `profile_names_are_checked_and_editing_needs_the_folder`, `dialogs::new_document::tests::manage_profiles_edits_and_resets_the_profiles`. - **Control bar with the Artboard tool:** while the Artboard tool is in use, the Control bar shows the active artboard's controls in place of the object controls: Preset, Portrait and Landscape, New Artboard, Delete Artboard, the Name field, Artboard Options, Rearrange All Artboards, the Transform link, Move and Scale Artwork with Artboard and, while the bar has room, the reference point with X and Y, and W and H with the Constrain Width and Height Proportions link. Each runs the command its Properties or Transform panel counterpart runs (`artboard.setProps`, `artboard.new`, `artboard.delete`, `tool.options {tool: "artboard"}`), and the reference point is the one the Transform panel uses. In an 800-point window the controls up to the Transform link fit, Move and Scale Artwork with Artboard show as their boxes alone with their names in tooltips, and the link opens the Transform panel with the artboard's position and size. Pointer and key tests in `panels/artboards.rs` cover the controls, W about the reference point, the orientation and the name. Public reference: [Using multiple artboards](https://web.archive.org/web/20210925094818/https://helpx.adobe.com/illustrator/using/using-multiple-artboards.html) (archived copy). From 82e220802f0c11fde258ad190dd4a2eddc4fb66f Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:21:57 -0800 Subject: [PATCH 070/108] Graph Data: Import Data refuses a file larger than 1 MB without reading it all Import Data in the Graph Data window read the whole picked file into memory before cutting its rows and columns to the graph's limits. It now reads at most one byte past 1 MB (1,048,576 bytes, the limit Import Data Sets uses) where the host can read part of a file, and refuses a larger file with "the file is larger than 1 MB", which every complete catalog already translates. The sheet is left as it was. --- crates/ui-egui/src/dialogs/graph_data.rs | 55 ++++++++++++++++++++++-- 1 file changed, 52 insertions(+), 3 deletions(-) diff --git a/crates/ui-egui/src/dialogs/graph_data.rs b/crates/ui-egui/src/dialogs/graph_data.rs index 16d22d4430..32d8dcb2e9 100644 --- a/crates/ui-egui/src/dialogs/graph_data.rs +++ b/crates/ui-egui/src/dialogs/graph_data.rs @@ -32,6 +32,8 @@ const MAX_COLS: usize = MAX_GRAPH_SERIES + 1; const MIN_ROWS: usize = 8; const MIN_COLS: usize = 6; const MAX_CELL: usize = 256; +/// The largest file Import Data reads, 1 MB (1,048,576 bytes), the same as Import Data Sets'. +const MAX_IMPORT_BYTES: usize = 1 << 20; /// The Cell Style limits (Adjust column width and decimal digits). const MAX_DECIMALS: u64 = 10; const MAX_WIDTH: u64 = 20; @@ -332,9 +334,16 @@ fn revert(app: &mut VectorcraftApp, d: &mut Dialog) -> Result<(), String> { fn import(app: &mut VectorcraftApp, d: &mut Dialog) -> Result<(), String> { let pick = crate::FilePick { filters: vec![crate::FilePick::filter("Text", &["txt", "tsv", "csv"])], ..Default::default() }; let path = crate::picks::open(app, &pick).ok_or("cancelled")?; - // The button is off where files can't be read. - let Some(read) = app.services.read.as_ref() else { return Ok(()) }; - let bytes = read(&path)?; + // One byte past the limit tells a larger file apart without reading all of it. + let bytes = match (&app.services.read_head, &app.services.read) { + (Some(read_head), _) => read_head(&path, MAX_IMPORT_BYTES + 1)?, + (None, Some(read)) => read(&path)?, + // The button is off where files can't be read. + (None, None) => return Ok(()), + }; + if bytes.len() > MAX_IMPORT_BYTES { + return Err("the file is larger than 1 MB".into()); + } replace_grid(d, grid_from_text(&decode(&bytes))); Ok(()) } @@ -527,6 +536,46 @@ mod tests { assert_eq!(p["series"].as_array().unwrap().len(), MAX_COLS - 1); } + /// Import Data reads a file no further than one byte past 1 MB where the host can read part of + /// a file: a larger file is refused with the sheet left as it was, and a file at the limit is + /// read. Where the host only reads whole files, a larger file is refused too. + #[test] + fn import_data_refuses_a_file_larger_than_its_limit() { + use std::{cell::RefCell, collections::HashMap, rc::Rc}; + let (mut app, _) = app_with(",a\nQ1,1", "column"); + open(&mut app).unwrap(); + let mut d = app.ui.dialog.clone().unwrap(); + let at_limit = [b"\tb\nQ2\t2\n".as_slice(), &vec![b' '; MAX_IMPORT_BYTES - 8]].concat(); + let files: HashMap<String, Vec<u8>> = + [("/big.txt".to_string(), vec![b'1'; MAX_IMPORT_BYTES + 1]), ("/limit.txt".to_string(), at_limit)].into(); + let files = Rc::new(files); + let picked = Rc::new(RefCell::new(String::new())); + let p = picked.clone(); + app.services.pick_open = Some(Box::new(move |_: &crate::FilePick| Some(p.borrow().clone()))); + app.services.read = Some(Box::new(|_: &str| Err("the whole file was read".to_string()))); + let asked = Rc::new(RefCell::new(vec![])); + let (f, a) = (files.clone(), asked.clone()); + app.services.read_head = Some(Box::new(move |path: &str, max: usize| { + a.borrow_mut().push(max); + Ok(f.get(path).ok_or("no such file")?.iter().copied().take(max).collect()) + })); + let before = grid(&d); + *picked.borrow_mut() = "/big.txt".into(); + assert_eq!(import(&mut app, &mut d), Err("the file is larger than 1 MB".to_string())); + assert_eq!(grid(&d), before, "the sheet is left as it was"); + *picked.borrow_mut() = "/limit.txt".into(); + import(&mut app, &mut d).unwrap(); + assert_eq!((cell_at(&d, 0, 1), cell_at(&d, 1, 0)), ("b", "Q2")); + assert_eq!(*asked.borrow(), [MAX_IMPORT_BYTES + 1; 2], "each read stops one byte past the limit"); + // A host that reads only whole files. + app.services.read_head = None; + let f = files.clone(); + app.services.read = Some(Box::new(move |path: &str| Ok(f.get(path).ok_or("no such file")?.clone()))); + *picked.borrow_mut() = "/big.txt".into(); + assert_eq!(import(&mut app, &mut d), Err("the file is larger than 1 MB".to_string())); + assert_eq!(cell_at(&d, 0, 1), "b"); + } + #[test] fn transpose_switch_and_moves() { assert_eq!(transpose(&g(&[&["", "a", "b"], &["Q1", "1", "2"]])), g(&[&["", "Q1"], &["a", "1"], &["b", "2"]])); From e0fe95325852f6a628a00ac46bfc44fdeb769851 Mon Sep 17 00:00:00 2001 From: ruchirguitar <113586074+ruchirguitar@users.noreply.github.com> Date: Sat, 14 Nov 2026 16:05:47 +0530 Subject: [PATCH 071/108] docs: sync symbols area row inventory in target-app-parity --- 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 3956bfb3fa..a534ecb801 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -246,7 +246,7 @@ dominate; 3D, graphs and automation are specialist). They sum to 105. Feature de | Type advanced (CJK, spelling, Touch Type, Retype) | 4 | 50% | CJK vertical composition (ruby, mojikumi), variable font axes, tab leaders, spell check (engine, custom dictionary and Auto Spell Check with its right-click suggestions and Spelling › Auto Spell Check, and the Edit Custom Dictionary dialog done, #4936; the Check Spelling dialog remains), Touch Type, Retype | 20–28 | estimated; upright fallback for fullwidth `!` / `?` regression-tested; score and hours unchanged | | Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons and Weather Icons are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type (Graphic / Movie Clip) and 9-slice guides (drawn and draggable during symbol editing, #5280) and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) are done | 4–7 | estimated; Blend panel Type and Ramp control step easing with a separate color Shift (#2539); Blend Options retains spacing and orientation; polynomial curves are original approximations; interactive selected mirror axis implemented; bounding-box handles take priority over the axis line (focused regression and native checks passed; full CI blocked by an unrelated text test); #2544 spine Anchor Point conversion and picking regression-tested | | Type advanced (CJK, spelling, Touch Type, Retype) | 4 | 50% | CJK vertical composition (ruby, mojikumi), tab leaders, spell check (engine, custom dictionary and Auto Spell Check with its right-click suggestions and Spelling › Auto Spell Check, and the Edit Custom Dictionary dialog done, #4936; the Check Spelling dialog remains), Touch Type, Retype | 20–28 | estimated; upright fallback for fullwidth `!` / `?` regression-tested; score and hours unchanged | -| Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, and Map Markers are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type (Graphic / Movie Clip) and 9-slice guides (drawn and draggable during symbol editing, #5280) and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) are done | 4–7 | estimated; Blend panel Type and Ramp control step easing with a separate color Shift (#2539); Blend Options retains spacing and orientation; polynomial curves are original approximations; interactive selected mirror axis implemented; bounding-box handles take priority over the axis line (focused regression and native checks passed; full CI blocked by an unrelated text test); #2544 spine Anchor Point conversion and picking regression-tested | +| Symbols, blends, envelopes, Repeat, perspective | 5 | 88% | remaining: dynamic symbols' `.ai` round trip, further built-in symbol libraries (Basic Shapes, UI Frames with default 9-slice, Map Markers, Inventory Icons, Skill Icons and Weather Icons are done), envelope Anti-Alias/Preserve Shape, 9-slice guides outside the art; Symbol Options › Registration, Export Type (Graphic / Movie Clip) and 9-slice guides (drawn and draggable during symbol editing, #5280) and Symbol Type (dynamic on-canvas fill/stroke including gradient/pattern, opacity and blend, #4938) are done | 4–7 | estimated; Blend panel Type and Ramp control step easing with a separate color Shift (#2539); Blend Options retains spacing and orientation; polynomial curves are original approximations; interactive selected mirror axis implemented; bounding-box handles take priority over the axis line (focused regression and native checks passed; full CI blocked by an unrelated text test); #2544 spine Anchor Point conversion and picking regression-tested | | Image Trace, graphs, image tools | 3 | 75% | graph Column designs, Image Trace Create Strokes depth (Create Object Mosaic is done; junction-returning piece survival has source-generated regressions in `image-trace-quality.md`; simpler contour walk, identical output; an edge's sub-pixel shift is the same from either side; notches read only their own piece; collapsed loops keep few segments, so Paths is monotone on the code-drawn sweep) | 5–8 | estimated (raised from 72%); quick presets reveal adjustment controls, Properties reopens them; Live trace result bounds and selection highlights exclude the retained bitmap except in source-image views (scores/hours unchanged) | | Live vector effects | 5 | 85% | Outline Object, SVG Filters | 4–8 | measured count 49/50 (Pathfinder 13/13 with Trap), depth estimated; Warp Options controls verified by focused checks and original-image review | | 3D and Materials (and Turntable) | 4 | ~25% | live Revolve with automatic smooth vector shading and default-on continuous circular caps, Extrude & Bevel (twist, taper, caps, five bevel shapes), Inflate and Rotate with Position presets (colored Inflate uses smooth membrane lighting; white-light Inflate retains its existing shading; Extrude & Bevel and Rotate retain planar shading; one to ten colored lights, shared neutral ambient, original lighting presets, painter visibility), Revolve (Classic) with Angle, Cap, Offset and the Plastic, Diffuse, No Shading and Wireframe surfaces, the Quick Actions › Expand as Wireframes command (#6354); materials, shadows, ray tracing, the rest of 3D Classic (Map Art), Turntable views, textures, map art and shading in 3D export | 30–55 | estimated (Extrude & Bevel, Inflate and Rotate added 2026-10-12); Revolve (Classic) is covered by the `revolve::classic` tests and `dialogs::revolve::tests::classic_revolve_shows_its_options_and_applies_as_one_step`; Expand as Wireframes is covered by `crates/effects/src/solids/wireframe/tests.rs` and `crates/engine/src/cmd/wireframe/tests.rs` (score, gaps and hours unchanged); every 3D seam has round joins (2026-11-12, [three-d.md](three-d.md#seams)), score, gaps and hours unchanged | From 7694627a39c18ea3df8606a5cf22a8592674ef58 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:07:47 -0800 Subject: [PATCH 072/108] Perspective: reapplying the current grid preset adds no undo step perspective.grid.preset stored the preset's grid every time, so applying the preset the document already holds recorded an undo step that changed nothing. It now compares the new grid with the stored one, as perspective.grid.set does through grid_kept, and records a step only when the grid changes. When only whether the grid shows or its active plane differs, the preset sets them without an undo step, as perspective.grid.show and perspective.plane.set do. --- crates/engine/src/cmd/distortcmds.rs | 4 +-- .../engine/src/cmd/distortcmds/perspective.rs | 2 +- crates/engine/src/cmd/perspgrid.rs | 21 ++++++++--- crates/engine/src/tests/perspgrid.rs | 36 +++++++++++++++++++ docs/mcp.md | 6 ++-- 5 files changed, 59 insertions(+), 10 deletions(-) diff --git a/crates/engine/src/cmd/distortcmds.rs b/crates/engine/src/cmd/distortcmds.rs index 2dbb7a9a18..8f1b5b97e6 100644 --- a/crates/engine/src/cmd/distortcmds.rs +++ b/crates/engine/src/cmd/distortcmds.rs @@ -26,7 +26,7 @@ pub use perspective::perspective_click; use perspective::{ attach, edit_text, grid_set, grid_show, persp_draw, persp_move, persp_nudge, persp_transform, plane_match, plane_move, plane_set, release, }; -pub(crate) use perspective::{finish_edit_text, grid_of, perspective_rewrite, silent, store_grid, transform_again}; +pub(crate) use perspective::{finish_edit_text, grid_kept, grid_of, perspective_rewrite, silent, store_grid, transform_again}; pub fn specs() -> Vec<CommandSpec> { vec![ @@ -107,7 +107,7 @@ pub fn specs() -> Vec<CommandSpec> { "Perspective Grid Preset", [], None, - "{kind: 1|2|3 (its normal view) | name: a preset (see perspective.presets.list)} reset the grid to the preset fitted to the first artboard (and show it; attached objects stay attached)", + "{kind: 1|2|3 (its normal view) | name: a preset (see perspective.presets.list)} reset the grid to the preset fitted to the first artboard (and show it; attached objects stay attached). No undo step when the document already holds that grid; when only whether it shows or its active plane differs, those are set without one", has_doc, super::perspgrid::grid_preset ), diff --git a/crates/engine/src/cmd/distortcmds/perspective.rs b/crates/engine/src/cmd/distortcmds/perspective.rs index 62b72a8e0f..89091248df 100644 --- a/crates/engine/src/cmd/distortcmds/perspective.rs +++ b/crates/engine/src/cmd/distortcmds/perspective.rs @@ -18,7 +18,7 @@ pub(crate) fn store_grid(d: &mut Document, g: &PerspectiveGrid) { /// Whether `d` holds `g` as [`store_grid`] writes it (with `attached` cleared): then storing `g` /// leaves `d` as it is. -fn grid_kept(d: &Document, g: &PerspectiveGrid) -> bool { +pub(crate) fn grid_kept(d: &Document, g: &PerspectiveGrid) -> bool { let mut g = g.clone(); g.attached.clear(); serde_json::to_value(&g).is_ok_and(|v| d.unknown.get(persp::DOC_KEY) == Some(&v)) diff --git a/crates/engine/src/cmd/perspgrid.rs b/crates/engine/src/cmd/perspgrid.rs index d13e7d8c52..aaeee36d80 100644 --- a/crates/engine/src/cmd/perspgrid.rs +++ b/crates/engine/src/cmd/perspgrid.rs @@ -19,7 +19,7 @@ use vectorcraft_tools::distort::perspective::widget::{WidgetCorner, WidgetPlace} use vectorcraft_tools::distort::perspective::{GridDefinition, PerspectiveGrid}; use vectorcraft_tools::{PointerEvent, PointerKind, ToolKey}; -use super::distortcmds::{grid_of, silent, store_grid}; +use super::distortcmds::{grid_kept, grid_of, silent, store_grid}; use super::{CommandSpec, EngineError, Result, Session, always, bad, bool_or, cmd, has_doc, str_param, switch_or, unique_name}; pub fn specs() -> Vec<CommandSpec> { @@ -261,10 +261,21 @@ pub(crate) fn grid_preset(s: &mut Session, p: &Value) -> Result<Value> { let g = s.perspective_preset_grid(&name, ab).ok_or_else(|| bad(C, format!("no perspective grid preset named `{name}`")))?; // The objects stay attached and the view options stay as they were. let g = PerspectiveGrid { attached: old.attached, locked: old.locked, lock_station: old.lock_station, snap: old.snap, rulers: old.rulers, ..g }; - s.edit("Perspective Grid Preset", |d, _| { - store_grid(d, &g); - Ok(()) - })?; + // When the document holds this grid already, apart from whether it shows and its active plane, + // the preset only sets those two, without an undo step (as perspective.grid.show and + // perspective.plane.set do). + let view = PerspectiveGrid { visible: old.visible, plane: old.plane, ..g.clone() }; + if !grid_kept(&s.doc()?.doc, &view) { + s.edit("Perspective Grid Preset", |d, _| { + store_grid(d, &g); + Ok(()) + })?; + } else if (old.visible, old.plane) != (g.visible, g.plane) { + silent(s, |cur| { + cur.visible = g.visible; + cur.plane = g.plane; + })?; + } Ok(g.definition_json()) } diff --git a/crates/engine/src/tests/perspgrid.rs b/crates/engine/src/tests/perspgrid.rs index 07fce547da..dce149e98c 100644 --- a/crates/engine/src/tests/perspgrid.rs +++ b/crates/engine/src/tests/perspgrid.rs @@ -150,6 +150,42 @@ fn built_in_views_apply_by_name_or_type() { assert!(s.execute("perspective.grid.preset", &json!({})).is_err()); } +#[test] +fn reapplying_the_current_grid_preset_records_no_undo_step() { + let mut s = session(); + // On a document with no grid defined, a preset defines and shows one: an undo step. + run(&mut s, "perspective.grid.preset", json!({"kind": 2})); + assert_eq!(undo_len(&s), 1); + let g = grid(&s); + // The same preset again, by type or by name, leaves the grid as it is: no undo step. + run(&mut s, "perspective.grid.preset", json!({"kind": 2})); + run(&mut s, "perspective.grid.preset", json!({"name": "[2P-Normal View]"})); + assert_eq!((grid(&s), undo_len(&s)), (g.clone(), 1)); + // Another active plane, or a hidden grid, is set back without an undo step. + run(&mut s, "perspective.plane.set", json!({"plane": "ground"})); + run(&mut s, "perspective.grid.show", json!({"visible": false})); + assert_ne!(grid(&s), g); + run(&mut s, "perspective.grid.preset", json!({"kind": 2})); + assert_eq!((grid(&s), undo_len(&s)), (g, 1)); + // Another preset changes the grid. + run(&mut s, "perspective.grid.preset", json!({"kind": 3})); + assert_eq!((grid(&s).kind, undo_len(&s)), (3, 2)); +} + +#[test] +fn define_grid_with_unchanged_fields_records_no_undo_step() { + let mut s = session(); + // On a document with no grid defined, `perspective.grid.set` stores the grid: an undo step, + // and the grid no longer follows the first artboard. + run(&mut s, "perspective.grid.set", json!({})); + assert_eq!((run(&mut s, "perspective.grid.get", json!({}))["defined"].clone(), undo_len(&s)), (json!(true), 1)); + // The stored grid's own values leave it as it is: no undo step. + let g = grid(&s); + run(&mut s, "perspective.grid.set", json!({})); + run(&mut s, "perspective.grid.set", json!({"cell": g.cell, "horizon": g.horizon})); + assert_eq!((grid(&s), undo_len(&s)), (g, 1)); +} + #[test] fn presets_save_rename_delete_and_protect_the_built_in_ones() { let mut s = session(); diff --git a/docs/mcp.md b/docs/mcp.md index 1ad05ba3df..3154b9110b 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10028,8 +10028,10 @@ Perspective grid presets: `perspective.presets.list` lists the built-in views (` `[1P-High View]`, `[2P-Normal View]`, `[2P-Low View]`, `[2P-High View]`, `[3P-Normal View]`, `[3P-Low View]`; `builtIn: true`, fitted to the first artboard, protected), then the saved ones, each with its Define Grid fields. `perspective.grid.preset {name}` (or `{kind}`, that type's normal view) resets the grid to one, fitted to the first -artboard. `perspective.presets.save {name?, newName?, preset?, …fields}` saves a preset: just `{name}` saves the -document's grid (View → Perspective Grid → Save Grid as Preset). `perspective.presets.delete {name}`, +artboard. It adds no undo step when the document already holds that grid. When only whether the grid shows or its +active plane differs, it sets them without an undo step, as `perspective.grid.show` and `perspective.plane.set` do. +`perspective.presets.save {name?, newName?, preset?, …fields}` saves a preset: just `{name}` saves the document's grid +(View → Perspective Grid → Save Grid as Preset). `perspective.presets.delete {name}`, `perspective.presets.export {names?, path?}` (a `.vcperspective` JSON file; without `path` it returns `data`) and `perspective.presets.import {path? | data? | dataBase64?, replace?}` manage them. Saved presets are kept with the preferences, and a grid whose fields are a preset's is named after it (`name`). From 55595f0cff387d924e2ce1ab32e0e077d2968ecd Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:40:39 -0800 Subject: [PATCH 073/108] i18n: Dutch messages keep the bracketed field names in English Ten nl rows translated the field names inside [subpath, anchor], [x, y, width, height] and [width, height], which a command reads only in English. They now keep the English names, as the other catalogs do. --- crates/ui-egui/src/i18n/nl.tsv | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 730f237173..50995ac702 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -5648,7 +5648,7 @@ imageTrace Outline Contour @msg `alignOn` must be a string `alignOn` moet een string zijn @msg `align` is start, center or end `align` is start, center of end @msg `align` must be a string `align` moet een string zijn -@msg `anchors` must be an array of [subpath, anchor] pairs `anchors` moet een array van paren [subpad, anker] zijn +@msg `anchors` must be an array of [subpath, anchor] pairs `anchors` moet een array van paren [subpath, anchor] zijn @msg `anchors` must list anchor indices (0, 1, 2…), not {k} `anchors` moet ankerindexen bevatten (0, 1, 2…), niet {k} @msg `anchors` must list anchor indices (0, 1, 2…), not {v} `anchors` moet ankerindexen bevatten (0, 1, 2…), niet {v} @msg `answer` for this {kind} dialog must be one of: {_1} `answer` voor dit dialoogvenster {kind} moet een van de volgende zijn: {_1} @@ -5713,7 +5713,7 @@ imageTrace Outline Contour @msg `fidelity` must be from {lo} to {hi} pt `fidelity` moet van {lo} tot {hi} pt zijn @msg `files` must be 1 to 1000 paths of font files the last text.findFontFiles search found `files` moet 1 tot 1000 paden van lettertypebestanden bevatten die de laatste zoekopdracht van text.findFontFiles heeft gevonden @msg `focal` and `radius` cannot be used together `focal` en `radius` kunnen niet samen worden gebruikt -@msg `focal` must be an array of [subpath, anchor] pairs `focal` moet een array van paren [subpad, anker] zijn +@msg `focal` must be an array of [subpath, anchor] pairs `focal` moet een array van paren [subpath, anchor] zijn @msg `focal` names [{si}, {ai}], which is not an anchor of the path `focal` noemt [{si}, {ai}], en dat is geen anker van het pad @msg `folder` must be an absolute folder path `folder` moet een absoluut mappad zijn @msg `fontAxes` must be an object of axis tags and values, such as {"wght"} `fontAxes` moet een object met astags en waarden zijn, zoals {"wght"} @@ -5795,8 +5795,8 @@ imageTrace Outline Contour @msg `preset` must be a string `preset` moet een string zijn @msg `radius` must be 0 or more `radius` moet 0 of meer zijn @msg `ratio` must be from 0.1 to 0.5 `ratio` moet van 0,1 tot 0,5 zijn -@msg `rect` must be [x, y, width, height] `rect` moet [x, y, breedte, hoogte] zijn -@msg `rect` must be [x, y, width, height] with a positive size `rect` moet [x, y, breedte, hoogte] met een positieve grootte zijn +@msg `rect` must be [x, y, width, height] `rect` moet [x, y, width, height] zijn +@msg `rect` must be [x, y, width, height] with a positive size `rect` moet [x, y, width, height] met een positieve grootte zijn @msg `rect` must be [x0, y0, x1, y1] (got {r}) `rect` moet [x0, y0, x1, y1] zijn (kreeg {r}) @msg `relation` must be overlap, inside or outside `relation` moet overlap, inside of outside zijn @msg `replace` must be a string `replace` moet een string zijn @@ -6224,7 +6224,7 @@ imageTrace Outline Contour @msg distance must be > 0 distance moet > 0 zijn @msg dx and dy give the arrow's direction dx en dy geven de richting van de pijl @msg dx and dy must be numbers dx en dy moeten getallen zijn -@msg dxf fitTo must be [width, height], positive dxf fitTo moet [breedte, hoogte] zijn, positief +@msg dxf fitTo must be [width, height], positive dxf fitTo moet [width, height] zijn, positief @msg dxf must be an object of DXF import options dxf moet een object met DXF-importopties zijn @msg dxf scale must be a positive number up to {_1}, not {s} dxf scale moet een positief getal tot en met {_1} zijn, niet {s} @msg dxf unit `{u}`: a unit such as mm, cm, in or pt dxf unit `{u}`: een eenheid zoals mm, cm, in of pt @@ -6380,7 +6380,7 @@ imageTrace Outline Contour @msg instruction {pc} reached with stack depths {seen} and {d} instructie {pc} bereikt met stackdiepten {seen} en {d} @msg invalid `color` ongeldige `color` @msg invalid anchor index {v}: expected a non-negative integer ongeldige ankerindex {v}: verwacht een niet-negatief geheel getal -@msg invalid anchor reference {v}: expected [subpath, anchor] ongeldige ankerverwijzing {v}: verwacht [subpad, anker] +@msg invalid anchor reference {v}: expected [subpath, anchor] ongeldige ankerverwijzing {v}: verwacht [subpath, anchor] @msg invalid angle ongeldige hoek @msg invalid array length ongeldige arraylengte @msg invalid brush: {e} ongeldig penseel: {e} @@ -6489,7 +6489,7 @@ imageTrace Outline Contour @msg missing `{k}` `{k}` ontbreekt @msg missing anchor anker ontbreekt @msg missing anchors ankers ontbreken -@msg missing anchors [[subpath, anchor]…] anchors [[subpad, anker]…] ontbreekt +@msg missing anchors [[subpath, anchor]…] anchors [[subpath, anchor]…] ontbreekt @msg missing array `{key}` array `{key}` ontbreekt @msg missing case case ontbreekt @msg missing color color ontbreekt @@ -6822,9 +6822,9 @@ imageTrace Outline Contour @msg rating must be a whole number from 0 to {MAX_RATING} rating moet een geheel getal van 0 tot {MAX_RATING} zijn @msg rect and {k} contradict each other: give the area or the artboards rect en {k} spreken elkaar tegen: geef het gebied of de tekengebieden @msg rect applies to raster formats, not {_1} rect geldt voor rasterindelingen, niet voor {_1} -@msg rect is [x, y, width, height] in points rect is [x, y, breedte, hoogte] in punten -@msg rect must be [x, y, width, height] rect moet [x, y, breedte, hoogte] zijn -@msg rect must be [x, y, width, height] with a positive width and height rect moet [x, y, breedte, hoogte] met een positieve breedte en hoogte zijn +@msg rect is [x, y, width, height] in points rect is [x, y, width, height] in punten +@msg rect must be [x, y, width, height] rect moet [x, y, width, height] zijn +@msg rect must be [x, y, width, height] with a positive width and height rect moet [x, y, width, height] met een positieve breedte en hoogte zijn @msg rect needs finite numbers and a positive width and height rect heeft eindige getallen en een positieve breedte en hoogte nodig @msg redraw needs id redraw heeft id nodig @msg redraw within must be a finite distance of 0 or more within van redraw moet een eindige afstand van 0 of meer zijn From af750ee5992a9303818f751b1f7258e8671ce225 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:41:23 -0800 Subject: [PATCH 074/108] i18n: Finnish translates the PDF warning for knockout groups with brushed strokes PDF export warns when a knockout group has a brushed stroke over other translucent elements and is written as a PDF knockout group. No catalog had a row for that warning, and untranslated_report does not list it, because the scanner does not follow the constant into the Err it is returned in. fi.tsv now has a Finnish row for it, next to the row for the knockout warning about too many elements. --- crates/ui-egui/src/i18n/fi.tsv | 1 + 1 file changed, 1 insertion(+) diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 0b44797132..097e1fbb67 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -7612,6 +7612,7 @@ breakText Glyphs Merkit @msg its objects are nested too deep ({e}) sen objektit ovat sisäkkäin liian monella tasolla ({e}) @msg its tag table lists the `{_1}` tag more than once sen tunnistetaulukossa `{_1}`-tunniste on useammin kuin kerran @msg knockout groups with too many overlapping translucent elements are written as PDF knockout groups: their translucent elements knock out what they cover fully poistoryhmät, joissa on liian monta päällekkäistä läpikuultavaa elementtiä, kirjoitetaan PDF-poistoryhminä: niiden läpikuultavat elementit poistavat peittämänsä alueen kokonaan +@msg knockout groups with brushed strokes over other translucent elements are written as PDF knockout groups: their translucent elements knock out what they cover fully poistoryhmät, joissa on sivellinviivoja muiden läpikuultavien elementtien päällä, kirjoitetaan PDF-poistoryhminä: niiden läpikuultavat elementit poistavat peittämänsä alueen kokonaan @msg not a graphic style library: {e} ei grafiikkatyylikirjasto: {e} @msg not a swatch library (.vcswatches or .gpl) ei värimallikirjasto (.vcswatches tai .gpl) @msg not a swatch library (format `{_1}`) ei värimallikirjasto (muoto `{_1}`) From 795fbf0148538a6d525b1d37203333db6ae54144 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:26:37 -0800 Subject: [PATCH 075/108] i18n: Swedish translates 114 more status and error messages The untranslated report listed these messages as missing from the Swedish catalog. Among them are the image export encoders and size limits, color profiles, color books, swatch exchange files, DXF import, 3D and Revolve errors, and the `index` check of document.activate. Each now has an @msg row in sv.tsv, with its placeholders, backticked names, format names and values kept as the English writes them. Messages that open pull requests already translate into Swedish are left to them. The Swedish row in docs/localization-parity.md is recounted, and docs/target-app-parity.md gets a line for the Swedish catalog. --- crates/ui-egui/src/i18n/sv.tsv | 116 +++++++++++++++++++++++++++++++++ docs/localization-parity.md | 2 +- docs/target-app-parity.md | 1 + 3 files changed, 118 insertions(+), 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index b491d33649..d96c3affa6 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -8973,3 +8973,119 @@ digits Hindi Hindi Grommets Öljetter Grommet Inset Öljetternas avstånd från kanten Diameter Diameter + +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books and DXF import. +@msg 3D effects require finite coordinates within 100 million points 3D-effekter kräver ändliga koordinater inom 100 miljoner punkter +@msg 3D effects require one to ten lights 3D-effekter kräver en till tio ljuskällor +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel BMP-djup {_1}: 1, 4, 8, 16, 24 eller 32 bitar per pixel +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer BMP-kodningen misslyckades: {width} × {height} pixlar passar inte formatet eller pixelbufferten +@msg GIF encoding failed: the palette image is malformed GIF-kodningen misslyckades: palettbilden är felaktigt uppbyggd +@msg GIF encoding failed: {e} GIF-kodningen misslyckades: {e} +@msg JPEG colour profile: {e} JPEG-färgprofil: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size JPEG-kodningen misslyckades: pixelbufferten stämmer inte med bildens storlek +@msg JPEG encoding failed: {e} JPEG-kodningen misslyckades: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size PNG-kodningen misslyckades: pixelbufferten stämmer inte med bildens storlek +@msg PNG encoding failed: the palette image is malformed PNG-kodningen misslyckades: palettbilden är felaktigt uppbyggd +@msg PNG encoding failed: {e} PNG-kodningen misslyckades: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size PNG-kodningen misslyckades: {width} × {height} pixlar är inte en giltig bildstorlek +@msg PSD colour profile: {e} PSD-färgprofil: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size PSD-kodningen misslyckades: pixelbufferten stämmer inte med bildens storlek +@msg Revolve profile contains invalid coordinates Profilen för Rotera runt axel innehåller ogiltiga koordinater +@msg Revolve profile is too complex Profilen för Rotera runt axel är för komplex +@msg Revolve projection is not finite Projektionen för Rotera runt axel är inte ändlig +@msg Revolve requires finite profile coordinates within 100 million points Rotera runt axel kräver ändliga profilkoordinater inom 100 miljoner punkter +@msg Revolve surface is too complex; reduce Segments or simplify the profile Ytan för Rotera runt axel är för komplex; minska Segment eller förenkla profilen +@msg Revolve surface is too complex; simplify the profile Ytan för Rotera runt axel är för komplex; förenkla profilen +@msg Revolve visibility cannot split the projected boundary Synlighetsberäkningen för Rotera runt axel kan inte dela den projicerade gränsen +@msg Revolve visibility creates too many fragments Synlighetsberäkningen för Rotera runt axel skapar för många fragment +@msg Revolve visibility creates too many vector anchors Synlighetsberäkningen för Rotera runt axel skapar för många vektorankarpunkter +@msg Revolve visibility exceeds its geometry work limit Synlighetsberäkningen för Rotera runt axel överskrider sin gräns för geometriarbete +@msg Revolve visibility exceeds its spatial index limit Synlighetsberäkningen för Rotera runt axel överskrider sin gräns för det rumsliga indexet +@msg Revolve visibility has too many boundary crossings Synlighetsberäkningen för Rotera runt axel har för många gränskorsningar +@msg Revolve visibility has too many input anchors Synlighetsberäkningen för Rotera runt axel har för många inkommande ankarpunkter +@msg Revolve visibility requires convex cap sectors Synlighetsberäkningen för Rotera runt axel kräver konvexa sektorer i locken +@msg Revolve visibility requires finite projected faces Synlighetsberäkningen för Rotera runt axel kräver ändliga projicerade ytor +@msg SVG options: {e} SVG-alternativ: {e} +@msg Save for Web settings: {e} Inställningar för Spara för webben: {e} +@msg TIFF colour profile: {e} TIFF-färgprofil: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size TIFF-kodningen misslyckades: pixelbufferten stämmer inte med bildens storlek +@msg TIFF encoding failed: {e} TIFF-kodningen misslyckades: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Targa-djup {_1}: 16, 24 eller 32 bitar per pixel +@msg Targa encoding failed: the pixel buffer doesn't match the image size Targa-kodningen misslyckades: pixelbufferten stämmer inte med bildens storlek +@msg The 3D projection is not finite 3D-projektionen är inte ändlig +@msg The 3D shadow is too complex; turn Shadows off or simplify the art 3D-skuggan är för komplex; stäng av Skuggor eller förenkla grafiken +@msg The shape contains invalid coordinates Formen innehåller ogiltiga koordinater +@msg Too many Revolve faces for visibility evaluation För många ytor i Rotera runt axel för synlighetsberäkningen +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} VectorCraft läser högst {ASE_MAX_ENTRIES} färger och grupper från en fil för färgruteutbyte, och det här biblioteket har {entries} +@msg WebP encoding failed: {e} WebP-kodningen misslyckades: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `index` must be a whole number `index` måste vara ett heltal +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view` är smallThumb, mediumThumb, largeThumb, smallList eller largeList +@msg a line can't run from a point to itself en linje kan inte gå från en punkt till sig själv +@msg a line needs at least two points en linje behöver minst två punkter +@msg a number cannot be read ett tal kan inte läsas +@msg a swatch exchange block is too long ett block i en fil för färgruteutbyte är för långt +@msg a swatch exchange name is too long ett namn i en fil för färgruteutbyte är för långt +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels en bild på {sw} × {sh} kan inte skalas om till {width} × {height} pixlar +@msg a {width} × {height} image is too large en bild på {width} × {height} är för stor +@msg a {width} × {height} image: {e} en bild på {width} × {height}: {e} +@msg an image could not be written: {e} en bild kunde inte skrivas: {e} +@msg an image that couldn't be read was left out en bild som inte kunde läsas utelämnades +@msg can't open “{name}”: {e} kan inte öppna ”{name}”: {e} +@msg cannot align zip entries to {align} bytes kan inte justera zip-posterna till {align} byte +@msg cannot open the automation {kind} root `{_1}`: {e} kan inte öppna automatiseringens rotmapp ({kind}) `{_1}`: {e} +@msg cannot read profile: {0} kan inte läsa profilen: {0} +@msg color book version {version} isn't supported (only 1) färgboksversion {version} stöds inte (endast 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) färgböcker i färgrymden {other} stöds inte (endast RGB, CMYK och Lab) +@msg file name too long to zip: {_1} filnamnet är för långt för att zippas: {_1} +@msg file name too long to zip: {name} filnamnet är för långt för att zippas: {name} +@msg freeform line {i}: {e} fri linje {i}: {e} +@msg freeform point {i}: {e} fri punkt {i}: {e} +@msg give `{key}` or `{other}`, not both ange `{key}` eller `{other}`, inte båda +@msg grayscale profiles can't be working spaces yet gråskaleprofiler kan inte vara arbetsfärgrymder än +@msg input contains NaN or infinite coordinates indata innehåller NaN eller oändliga koordinater +@msg input path could not be closed den inkommande banan kunde inte slutas +@msg invalid ICC profile: {0} ogiltig ICC-profil: {0} +@msg invalid scale {scale} ogiltig skala {scale} +@msg its localized names take more than {_1} KB dess lokaliserade namn tar mer än {_1} KB +@msg its objects are nested too deep ({e}) dess objekt är kapslade för djupt ({e}) +@msg its tag table lists the `{_1}` tag more than once dess taggtabell listar taggen `{_1}` mer än en gång +@msg not a graphic style library: {e} inte ett bibliotek med grafiska stilar: {e} +@msg not a swatch library (.vcswatches or .gpl) inte ett färgrutebibliotek (.vcswatches eller .gpl) +@msg not a swatch library (format `{_1}`) inte ett färgrutebibliotek (format `{_1}`) +@msg not a swatch library: {e} inte ett färgrutebibliotek: {e} +@msg not an action set file ({e}) inte en fil med åtgärdsuppsättning ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray profilens färgrymd {other} är inte RGB, CMYK eller Gray +@msg regular expression too large det reguljära uttrycket är för stort +@msg script file is not UTF-8 text: {value} skriptfilen är inte UTF-8-text: {value} +@msg stop {i}: {e} stopp {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) version {major}.{minor} av filer för färgruteutbyte stöds inte (endast 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors färgboken innehåller fler än {ASE_MAX_ENTRIES} färger +@msg the color book is cut short färgboken är avkortad +@msg the color book's names take more than {_1} MB färgbokens namn tar mer än {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution bilden skulle bli {w} × {h} pixlar; rasterexporter är begränsade till {MAX_RASTER_SIDE} pixlar per sida och {_1} megapixel: sänk skalan eller upplösningen +@msg the optimised image can't be read back: {e} den optimerade bilden kan inte läsas tillbaka: {e} +@msg the pixel buffer doesn't match the image size pixelbufferten stämmer inte med bildens storlek +@msg the preview: {e} förhandsgranskningen: {e} +@msg the request may not read the New Document profiles folder begäran får inte läsa mappen med profiler för nytt dokument +@msg the shapes are too degenerate to combine formerna är för degenererade för att kombineras +@msg the shapes cross themselves and each other too often to combine formerna korsar sig själva och varandra för ofta för att kombineras +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups filen för färgruteutbyte innehåller fler än {ASE_MAX_ENTRIES} färger och grupper +@msg the swatch exchange file is cut short filen för färgruteutbyte är avkortad +@msg the {_1} plate can't be read: {e} plåten {_1} kan inte läsas: {e} +@msg this binary DXF file is damaged or cut short den här binära DXF-filen är skadad eller avkortad +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that det här är en DWG-ritning, som inte kan läsas: spara den från CAD-appen som DXF och öppna den +@msg too many classes för många klasser +@msg too many groups för många grupper +@msg too many layers for PSD (at most 32767) för många lager för PSD (högst 32767) +@msg too many swatch exchange blocks för många block i filen för färgruteutbyte +@msg unknown colour profile: {0} okänd färgprofil: {0} +@msg {_1} clashes with a built-in profile name {_1} krockar med namnet på en inbyggd profil +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution {_1} × {_2} pixlar är för stort för GIF (högst 65535 pixlar per sida): sänk upplösningen +@msg {_1}: no usable transform to/from sRGB {_1}: ingen användbar transformering till/från sRGB +@msg {name} is not a CMYK profile {name} är inte en CMYK-profil +@msg {name} is not an RGB profile {name} är inte en RGB-profil +@msg {path}: could not be read {path}: kunde inte läsas +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution {width} × {height} pixlar är för stort för JPEG (högst 65535 pixlar per sida): sänk upplösningen +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution {width} × {height} pixlar är för stort för Targa (högst 65535 pixlar per sida): sänk upplösningen +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution {w} × {h} pixlar är för stort för PSD (högst {MAX_SIDE} pixlar per sida): sänk upplösningen diff --git a/docs/localization-parity.md b/docs/localization-parity.md index 9080695a8e..9e8c17c07a 100644 --- a/docs/localization-parity.md +++ b/docs/localization-parity.md @@ -63,7 +63,7 @@ plus review. Native-speaker review is human work and isn't in the hours. | Finnish | `fi` | 5,318 rows (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one/other plurals, 797 `@msg` rows | full; AI-assisted, native proofreading pending | | Czech | `cs` | 9,155 rows, 3,445 of them `@msg` and 48 `@msgplural` (counted 2026-11-13): the untranslated report lists 40 missing messages for it | catalog complete; render-site gaps reduced; native review pending | | Bosnian | `bs` | 5,841 rows (counted 2026-10-30): menus, `tl!` literals and messages complete when counted; one/few/other plurals | full; AI-assisted, native review pending | -| Swedish | `sv` | 5,251 rows, 795 of them `@msg` (counted 2026-10-21): menus, `tl!` literals and messages complete when counted; one/other plurals | full; native review welcome | +| Swedish | `sv` | 8,991 rows, 3,106 of them `@msg` and 48 `@msgplural` (counted 2026-11-14): the untranslated report lists 518 missing messages for it, and 12 menu strings, 1 `tl!` literal and 3 undo labels; one/other plurals | full; native review welcome | | Bulgarian | `bg` | 5,245 rows, 763 of them `@msg` (counted 2026-10-21): menus and `tl!` literals complete when counted; its messages are partial | full; AI-drafted, native review pending | | Greek | `el` | 5,251 rows, 795 of them `@msg` (counted 2026-10-21): menus, `tl!` literals and messages complete when counted | full; native review welcome | | Georgian | `ka` | 5,200 rows (counted 2026-10-21): menus, panels, dialogs, plurals (one count-neutral form) and messages, tested complete; reviewed by a native speaker | full | diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..bfe19d7bd4 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -915,6 +915,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - The History panel translates the undo step names the engine, the tools and the shell write as literals: the untranslated report (`untranslated_report`) lists any a complete catalog lacks, and a step whose catalog row exists only with an ellipsis (such as an effect's menu name) shows that row without the ellipsis. - The German catalog (`crates/ui-egui/src/i18n/de.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,433 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins. The report lists 48 German messages; 38 of them are the composite font, select-a-path and justification order errors that open #7211, #7214 and #7116 translate. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. - The Korean catalog (`crates/ui-egui/src/i18n/ko.tsv`) has an `@msg` row for the status and error messages the untranslated report (`untranslated_report`) finds in the sources, 3,438 `@msg` rows in all: the errors of commands, scripts, file import and export and plug-ins. The report lists 39 Korean messages; they are the composite font, select-a-path, justification order and `path.freehand` connect errors that open #7211, #7214, #7116 and #7330 translate. A message with two placeholders in a row (`Template::parse` in `crates/ui-egui/src/i18n/catalog.rs`) is still shown in English. + - The Swedish catalog (`crates/ui-egui/src/i18n/sv.tsv`) translates status and error messages, among them the image export, color profile, color book, swatch exchange file, DXF import, 3D and Revolve errors and the `index` check of `document.activate`, 3,106 `@msg` rows in all. The untranslated report (`untranslated_report`) lists 518 Swedish messages, 54 of them messages that no catalog translates yet. - The History panel menu has Step Backward and Step Forward, which run Edit › Undo and Edit › Redo and are disabled when there is no step to undo or redo, and Set History Limit…, which opens Preferences at Performance, where History States is set. - The History panel menu's Clear History (`edit.clearHistory`) removes every step to undo and to redo and leaves the document as it is; it is not an undo step itself, and it is disabled when there is no step to clear. - The New Document from State button at the bottom of the History panel (`edit.newDocumentFromState`) makes a new document, which becomes active, from the state the panel has selected ([public source](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/undo-edits-and-manage-design-history.html)). VectorCraft's own rules: the new document takes the next Untitled-N name, is marked unsaved, has nothing selected and has no steps to undo or redo, and the source document and its steps stay as they are. From ffbc5446d53fcabaa2fe37d98520e00688a84ee3 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:43:44 -0800 Subject: [PATCH 076/108] i18n: Hungarian translates the index and PDF knockout messages no catalog had Adds Hungarian rows for two messages that reached main after the earlier rows: the `index` whole-number error and the warning for PDF knockout groups with too many overlapping translucent elements. --- crates/ui-egui/src/i18n/hu.tsv | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 1dfc9e5c70..9fbe7a7275 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -7527,6 +7527,7 @@ breakText Glyphs Glifák @msg WebP encoding failed: {e} A WebP-kódolás sikertelen: {e} @msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} @msg `answers[{i}]` {e} `answers[{i}]` {e} +@msg `index` must be a whole number `index`: egész szám kell @msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view`: smallThumb, mediumThumb, largeThumb, smallList vagy largeList lehet @msg a line can't run from a point to itself egy vonal nem futhat egy pontból önmagába @msg a line needs at least two points egy vonalhoz legalább két pont kell @@ -7557,6 +7558,7 @@ breakText Glyphs Glifák @msg its localized names take more than {_1} KB a honosított nevei több mint {_1} KB helyet foglalnak @msg its objects are nested too deep ({e}) az objektumai túl mélyen egymásba ágyazottak ({e}) @msg its tag table lists the `{_1}` tag more than once a címketáblája többször is felsorolja ezt a címkét: `{_1}` +@msg knockout groups with too many overlapping translucent elements are written as PDF knockout groups: their translucent elements knock out what they cover fully a túl sok egymást átfedő áttetsző elemet tartalmazó kiütő csoportok PDF-kiütőcsoportként íródnak: az áttetsző elemeik teljesen kiütik azt, amit takarnak @msg not a graphic style library: {e} nem grafikaistílus-könyvtár: {e} @msg not a swatch library (.vcswatches or .gpl) nem színminta-könyvtár (.vcswatches vagy .gpl) @msg not a swatch library (format `{_1}`) nem színminta-könyvtár (formátum: `{_1}`) From b1d364033e20ebc7f02c3d1698330537df016d9b Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:45:50 -0800 Subject: [PATCH 077/108] Artwork Cleanup: Combine and Join Point Text keep hidden and locked pieces apart With ids, Combine Point Text and Join Point Text take locked and hidden type. They kept the first piece's object and removed the others, so naming a visible piece and a hidden one beside it hid the visible text or showed the hidden text, and the same held for locked pieces and for pieces in a locked or hidden group or layer. A piece now joins only pieces that are as visible and as locked as it is, counting their groups and layers. The selection route takes only editable type, so it behaves as before. --- crates/engine/src/cmd/addons/cleanup/text.rs | 26 ++++++--- .../src/cmd/addons/cleanup/text/tests.rs | 58 +++++++++++++++++++ docs/mcp.md | 21 ++++--- 3 files changed, 88 insertions(+), 17 deletions(-) diff --git a/crates/engine/src/cmd/addons/cleanup/text.rs b/crates/engine/src/cmd/addons/cleanup/text.rs index 0f22b184f3..00d75e9888 100644 --- a/crates/engine/src/cmd/addons/cleanup/text.rs +++ b/crates/engine/src/cmd/addons/cleanup/text.rs @@ -54,7 +54,7 @@ pub fn specs() -> Vec<CommandSpec> { "Combine Point Text", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} merge one-line horizontal point type into as few objects as it can, every glyph staying where it was: pieces turned and sheared alike whose baselines line up (within 0.4 em; the difference becomes baseline shift) join left to right, a space goes between pieces at least half a space apart, and tracking on the character before each piece keeps the spacing; each object keeps its character styles, and the leftmost piece of each run its place and paint, as one undo step → {ids (the objects made, selected), combined (pieces merged into them)}", + "{ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} merge one-line horizontal point type into as few objects as it can, every glyph staying where it was: pieces turned and sheared alike, as visible and as locked (their groups and layers included), whose baselines line up (within 0.4 em; the difference becomes baseline shift) join left to right, a space goes between pieces at least half a space apart, and tracking on the character before each piece keeps the spacing; each object keeps its character styles, and the leftmost piece of each run its place and paint, as one undo step → {ids (the objects made, selected), combined (pieces merged into them)}", has_selection, combine_text ), @@ -63,7 +63,7 @@ pub fn specs() -> Vec<CommandSpec> { "Join Point Text", ["Object", "Plug-ins", "Artwork Cleanup"], None, - "{ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} join one-line horizontal point type into one point type object, as one undo step: pieces turned and sheared like the top-left one are read as lines (baselines within 0.4 em of each other), top to bottom, each line's pieces left to right with a space between them; each line becomes a paragraph, left aligned, and keeps the distance between baselines as its leading. The text keeps its character styles; the object takes the top-left piece's place and paint, and the other pieces go → {id (selected), joined (pieces merged into it), lines}", + "{ids?: [id…] (default: the selection; the type they name is taken locked or hidden too)} join one-line horizontal point type into one point type object, as one undo step: pieces turned and sheared like the top-left one, and as visible and as locked (their groups and layers included), are read as lines (baselines within 0.4 em of each other), top to bottom, each line's pieces left to right with a space between them; each line becomes a paragraph, left aligned, and keeps the distance between baselines as its leading. The text keeps its character styles; the object takes the top-left piece's place and paint, and the other pieces go → {id (selected), joined (pieces merged into it), lines}", has_selection, join_text ), @@ -466,6 +466,9 @@ fn split_text(s: &mut Session, _: &Value) -> Result<Value> { struct Piece { id: NodeId, t: TextObject, + /// Whether the object and every group and layer above it are visible, and whether they are all + /// unlocked. + state: (bool, bool), /// The object's turn and shear (`xf` without its move). turn: [f64; 4], /// Where its first character's glyph starts on its baseline, in that frame. @@ -503,13 +506,19 @@ impl Piece { if !(at.x.is_finite() && at.y.is_finite() && size > 0.0) { return None; } - Some((Self { id, t, turn: [a, b, c, dd], at, end: at.x + end, size, pens }, node)) + let state = d.ancestry(id)?.iter().filter_map(|i| d.node(*i)).fold((true, true), |(v, u), n| (v && n.visible, u && !n.locked)); + Some((Self { id, t, state, turn: [a, b, c, dd], at, end: at.x + end, size, pens }, node)) } /// Whether `o` is turned and sheared alike. fn turned_like(&self, o: &Piece) -> bool { self.turn.iter().zip(&o.turn).all(|(x, y)| (x - y).abs() <= 1e-6 * x.abs().max(y.abs()).max(1.0)) } + + /// Whether `o` is turned and sheared alike and has the same `state`. + fn joins(&self, o: &Piece) -> bool { + self.turned_like(o) && self.state == o.state + } } /// Whether two objects look alike apart from their text (paint, opacity, blending, effects). @@ -612,13 +621,13 @@ fn combine_text(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "addon.cleanup.combineText"; let d = &s.doc()?.doc; let mut pieces: Vec<(Piece, &Node)> = target_texts(s, p, C)?.into_iter().filter_map(|id| Piece::of(d, id)).collect(); - // Lines: pieces turned alike and looking alike, by baseline, then left to right. + // Lines: pieces turned alike, as visible and as locked and looking alike, by baseline, then left + // to right. pieces.sort_by(|x, y| x.0.at.y.total_cmp(&y.0.at.y).then(x.0.at.x.total_cmp(&y.0.at.x))); let mut lines: Vec<Vec<(&Piece, &Node)>> = vec![]; for (piece, node) in &pieces { let fits = |l: &Vec<(&Piece, &Node)>| { - l.first() - .is_some_and(|(f, n)| f.turned_like(piece) && same_look(n, node) && (f.at.y - piece.at.y).abs() <= SAME_LINE * f.size.min(piece.size)) + l.first().is_some_and(|(f, n)| f.joins(piece) && same_look(n, node) && (f.at.y - piece.at.y).abs() <= SAME_LINE * f.size.min(piece.size)) }; match lines.iter_mut().find(|l| fits(l)) { Some(l) => l.push((piece, node)), @@ -698,13 +707,14 @@ fn join_text(s: &mut Session, p: &Value) -> Result<Value> { const C: &str = "addon.cleanup.joinText"; let d = &s.doc()?.doc; let pieces: Vec<Piece> = target_texts(s, p, C)?.into_iter().filter_map(|id| Piece::of(d, id).map(|p| p.0)).collect(); - // The piece top-left on the page sets the turn; the others turned like it are read in that frame. + // The piece top-left on the page sets the turn; the others turned like it, and as visible and as + // locked, are read in that frame. let on_page = |p: &Piece| Affine::new([p.turn[0], p.turn[1], p.turn[2], p.turn[3], 0.0, 0.0]) * p.at; let first = pieces.iter().min_by(|x, y| { let (a, b) = (on_page(x), on_page(y)); a.y.total_cmp(&b.y).then(a.x.total_cmp(&b.x)) }); - let mut kept: Vec<&Piece> = first.map(|f| pieces.iter().filter(|p| p.turned_like(f)).collect()).unwrap_or_default(); + let mut kept: Vec<&Piece> = first.map(|f| pieces.iter().filter(|p| f.joins(p)).collect()).unwrap_or_default(); kept.sort_by(|x, y| x.at.y.total_cmp(&y.at.y).then(x.at.x.total_cmp(&y.at.x))); // Lines, top to bottom, by baseline; each line's pieces left to right. let mut lines: Vec<Vec<&Piece>> = vec![]; diff --git a/crates/engine/src/cmd/addons/cleanup/text/tests.rs b/crates/engine/src/cmd/addons/cleanup/text/tests.rs index 6b03a26384..c9ed79122c 100644 --- a/crates/engine/src/cmd/addons/cleanup/text/tests.rs +++ b/crates/engine/src/cmd/addons/cleanup/text/tests.rs @@ -511,6 +511,64 @@ fn named_locked_and_hidden_type() { assert!(b.abs() < 1e-9 && c.abs() < 1e-9, "the rotation is gone"); } +/// Combine Point Text joins named pieces only with pieces as visible and as locked, a group's lock +/// included: a visible piece and a hidden one beside it, or a free piece and one in a locked group, +/// stay as they are, with no undo step. +#[test] +fn combine_keeps_hidden_and_locked_pieces_apart() { + let mut s = session(); + let a = text(&mut s, json!({"x": 50, "y": 100, "text": "Left", "size": 20})); + let b = text(&mut s, json!({"x": 110, "y": 100, "text": "Right", "size": 20})); + lock_or_hide(&mut s, b, false); + let steps = undo_steps(&s); + assert!(s.execute("addon.cleanup.combineText", &json!({"ids": [a.0, b.0]})).is_err()); + assert_eq!(undo_steps(&s), steps); + assert_eq!((obj(&s, a).plain_text(), obj(&s, b).plain_text()), ("Left".into(), "Right".into())); + let d = &s.doc().unwrap().doc; + assert!(d.is_visible(a) && !d.is_visible(b), "the visible text stays shown and the hidden text stays hidden"); + + let mut s = session(); + let a = text(&mut s, json!({"x": 50, "y": 100, "text": "Left", "size": 20})); + let b = text(&mut s, json!({"x": 110, "y": 100, "text": "Right", "size": 20})); + select(&mut s, &[b]); + let group = NodeId(s.execute("object.group", &json!({})).unwrap()["id"].as_u64().unwrap()); + lock_or_hide(&mut s, group, true); + let steps = undo_steps(&s); + assert!(s.execute("addon.cleanup.combineText", &json!({"ids": [a.0, group.0]})).is_err()); + assert_eq!(undo_steps(&s), steps); + assert_eq!((obj(&s, a).plain_text(), obj(&s, b).plain_text()), ("Left".into(), "Right".into())); +} + +/// Join Point Text joins only the named pieces as visible and as locked as the top-left one: a +/// hidden piece between two visible lines stays as it is, hidden, and a hidden top-left piece +/// with only a visible one below it joins nothing, with no undo step. +#[test] +fn join_keeps_a_hidden_piece_apart() { + let mut s = session(); + let first = text(&mut s, json!({"x": 50, "y": 100, "text": "First", "size": 20})); + let hidden = text(&mut s, json!({"x": 50, "y": 130, "text": "Hidden", "size": 20})); + let third = text(&mut s, json!({"x": 50, "y": 160, "text": "Third", "size": 20})); + lock_or_hide(&mut s, hidden, false); + let steps = undo_steps(&s); + let r = s.execute("addon.cleanup.joinText", &json!({"ids": [first.0, hidden.0, third.0]})).unwrap(); + assert_eq!((r["id"].as_u64(), r["joined"].as_u64(), undo_steps(&s)), (Some(first.0), Some(2), steps + 1)); + assert_eq!(obj(&s, first).plain_text(), "First\nThird"); + assert_eq!(obj(&s, hidden).plain_text(), "Hidden"); + let d = &s.doc().unwrap().doc; + assert!(d.is_visible(first) && !d.is_visible(hidden), "the visible text stays shown and the hidden text stays hidden"); + assert!(d.node(third).is_none()); + + let mut s = session(); + let top = text(&mut s, json!({"x": 50, "y": 100, "text": "Top", "size": 20})); + let below = text(&mut s, json!({"x": 50, "y": 130, "text": "Below", "size": 20})); + lock_or_hide(&mut s, top, false); + let steps = undo_steps(&s); + assert!(s.execute("addon.cleanup.joinText", &json!({"ids": [top.0, below.0]})).is_err()); + assert_eq!(undo_steps(&s), steps); + assert_eq!((obj(&s, top).plain_text(), obj(&s, below).plain_text()), ("Top".into(), "Below".into())); + assert!(s.doc().unwrap().doc.is_visible(below)); +} + #[test] fn split_at_the_cursor_and_around_a_selection() { for (anchor, caret, want) in [(6, 6, &["Split", "here please"][..]), (6, 10, &["Split", "here", "please"][..])] { diff --git a/docs/mcp.md b/docs/mcp.md index 283990618f..7ce64ecca4 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10711,8 +10711,10 @@ topmost piece. The add-on's text tools act on the selected type (or `ids`), each as one undo step, and refuse with an error when there is nothing for them to do. From the selection they take only type that can be edited; the type that `ids` names, or that is inside a group or layer it names, is taken even when it, its group or its layer is locked or hidden (not type -on a locked artboard). The objects they make from locked or hidden type are not selected. The pieces they make are -point type that keeps its characters' styles, each placed so the glyph of its first character lands where it was drawn. +on a locked artboard). The objects they make from locked or hidden type are not selected. Combine Point Text and Join +Point Text join a piece only with pieces that are as visible and as locked as it is, counting their groups and layers. +The pieces they make are point type that keeps its characters' styles, each placed so the glyph of its first character +lands where it was drawn. - `addon.cleanup.breakText {by?, ids?}` turns each horizontal point or area type object into point type objects, one per line (`by: "lines"`, the default), paragraph (`"paragraphs"`), word (`"words"`) or glyph (`"glyphs"`; a ligature @@ -10724,14 +10726,15 @@ point type that keeps its characters' styles, each placed so the glyph of its fi staying where it was (within 0.01 pt). Pieces turned and sheared alike whose baselines lie within 0.4 em of each other join left to right (a baseline a little off becomes baseline shift); a space goes between pieces at least half a space apart, and tracking on the character before each piece keeps its place. A gap wider than 10 em, an overlap of - more than 1 em, another look (paint, opacity, effects) or a piece that can't keep its place once joined (a ligature - forming across the join) starts another object. Each object made takes the place and paint of its leftmost piece. The - main use is type from a PDF that arrives one glyph per object. + more than 1 em, another look (paint, opacity, effects), another visibility or lock state, or a piece that can't keep + its place once joined (a ligature forming across the join) starts another object. Each object made takes the place + and paint of its leftmost piece. The main use is type from a PDF that arrives one glyph per object. - `addon.cleanup.joinText {ids?}` (Join Point Text) joins one-line horizontal point type into one point type object, - for text that arrives one line or fragment per object. Pieces turned and sheared like the top-left one are read as - lines (baselines within 0.4 em), top to bottom; a line's pieces join left to right with a space between them. Each - line becomes a left-aligned paragraph whose leading is the distance from the baseline above, so the lines stay where - they were. Character styles stay; the object takes the top-left piece's place and paint. Returns `{id, joined, lines}`. + for text that arrives one line or fragment per object. Pieces turned and sheared like the top-left one, and as visible + and as locked as it is, are read as lines (baselines within 0.4 em), top to bottom; a line's pieces join left to + right with a space between them. Each line becomes a left-aligned paragraph whose leading is the distance from the + baseline above, so the lines stay where they were. Character styles stay; the object takes the top-left piece's + place and paint. Returns `{id, joined, lines}`. - `addon.cleanup.removeBreaks {kind, ids?}` removes the forced line breaks (`kind: "line"`) or paragraph returns (`"paragraph"`) in the characters selected with a Type tool, else in all the text of the selected type. After Select All in a frame of threaded text, it removes them from the text of every frame of the story, as one undo step. From c21f44b94020ffd514d3455779a49e03a1ff9110 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:31:27 -0800 Subject: [PATCH 078/108] Actions: test that a tool's command is checked against the recording limit A command a tool runs (the Enclosing Lasso's select.set) that takes a recording past 10,000 steps or past an 8 MiB set file now has tests: the edit and journal stay, the status bar names the limit on release, the next recorded command is refused, and Stop Playing/Recording keeps the steps that fit. The place cursor's file.place has the same test, read at once and read off the UI thread, where the limit is named on the frame that places the file. A test-only Placing::wait_for_reads waits for the reader thread by sending it a marker job after the reads. The comment on tool_commit_checks_recording_step_limit now says that the Selection and Rectangle tools both commit a preview. --- crates/ui-egui/src/panels/actions.rs | 117 ++++++++++++++++++++++++++- crates/ui-egui/src/placing.rs | 17 ++++ 2 files changed, 130 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/panels/actions.rs b/crates/ui-egui/src/panels/actions.rs index 20a57b7d63..5e6a4d3b9e 100644 --- a/crates/ui-egui/src/panels/actions.rs +++ b/crates/ui-egui/src/panels/actions.rs @@ -6034,10 +6034,10 @@ mod tests { } } - /// A drag with the Selection tool (a committed preview) or the Rectangle tool (a command the - /// tool runs) that takes a recording past 10,000 steps keeps its edit and the journal, the - /// status bar names the limit as the tool ends, and Stop Playing/Recording keeps the 10,000 - /// steps that fit. One that fills the action exactly names no limit. + /// A drag with the Selection tool or the Rectangle tool (each commits its preview) that takes a + /// recording past 10,000 steps keeps its edit and the journal, the status bar names the limit + /// as the tool ends, and Stop Playing/Recording keeps the 10,000 steps that fit. One that fills + /// the action exactly names no limit. #[test] fn tool_commit_checks_recording_step_limit() { let steps = "the action already has 10,000 steps"; @@ -6090,6 +6090,115 @@ mod tests { } } + /// Drags the Enclosing Lasso away from the selected rectangle, which runs `select.set` with no + /// objects, and checks that the tool journaled that one step and cleared the selection. + fn lasso_nothing(app: &mut VectorcraftApp) { + app.select_tool(vectorcraft_tools::addons::enclosing_lasso::ID); + assert_eq!(app.session.tool_id(), vectorcraft_tools::addons::enclosing_lasso::ID); + assert!(!app.session.active().unwrap().selection.objects.is_empty()); + let journal = app.session.journal.len(); + tool_drag(app, (100.0, 80.0), (120.0, 80.0)); + assert_eq!(app.session.journal.len(), journal + 1, "the tool journals one step"); + assert_eq!(app.session.journal.last(), Some(&("select.set".to_string(), json!({"ids": []})))); + assert!(app.session.active().unwrap().selection.objects.is_empty(), "the edit stays"); + } + + /// A command a tool runs (the Enclosing Lasso's `select.set`) that takes a recording past + /// 10,000 steps keeps its edit and the journal, the status bar names the limit as the tool + /// ends, the next recorded command does not run, and Stop Playing/Recording keeps the 10,000 + /// steps that fit. One that fills the action exactly names no limit. + #[test] + fn tool_exec_checks_recording_step_limit() { + let steps = "the action already has 10,000 steps"; + for filler in [files::MAX_ACTION_STEPS, files::MAX_ACTION_STEPS - 1] { + let (mut app, _) = app_with_three_moves(); + recording_with(&mut app, filler); + app.ui.status.clear(); + lasso_nothing(&mut app); + if filler < files::MAX_ACTION_STEPS { + assert_eq!(app.ui.status, "", "10,000 steps fit"); + continue; + } + assert_eq!(app.ui.status, steps, "the status bar names the limit now"); + assert!(app.ui.recording.is_some(), "the recording goes on"); + let (journal, art) = (app.session.journal.len(), app.session.active().unwrap().doc.art_bounds()); + let r = app.run("shape.rectangle", json!({"x": 50, "y": 50, "width": 20, "height": 20})); + assert_eq!(r.unwrap_err(), steps, "no later command runs"); + assert_eq!(app.session.journal.len(), journal); + assert_eq!(app.session.active().unwrap().doc.art_bounds(), art, "no rectangle is drawn"); + assert_eq!(app.session.journal.since(recording_start(&app).unwrap()).len(), files::MAX_ACTION_STEPS + 1, "the journal keeps the step"); + app.run(STOP_RECORDING, json!({})).unwrap(); + assert_eq!(app.ui.action_sets[0].actions.last().unwrap().steps.len(), files::MAX_ACTION_STEPS); + } + } + + /// A command a tool runs (the Enclosing Lasso's `select.set`) whose step gives the recording's + /// set a file larger than 8 MiB keeps its edit, the status bar names the limit as the tool + /// ends, and Stop Playing/Recording leaves the step out of a set that Load Actions… reads. + #[test] + fn tool_exec_checks_recording_byte_limit() { + let size = "the action set would be larger than 8 MiB"; + let (mut app, _) = app_with_three_moves(); + app.run(START_RECORDING, json!({})).unwrap(); + let pad = |n: usize| ("object.move".to_string(), json!({"dx": 1, "dy": 0, "pad": "x".repeat(n)})); + app.ui.action_sets[0].actions[0].steps = vec![pad(0)]; + let room = files::MAX_SET_FILE - files::write_set(&app.ui.action_sets[0]).len(); + app.ui.action_sets[0].actions[0].steps = vec![pad(room)]; + app.ui.recording_into = Some(app.ui.action_sets[0].actions[0].id); + app.ui.status.clear(); + lasso_nothing(&mut app); + assert_eq!(app.ui.status, size, "the status bar names the limit now"); + assert_eq!(app.session.journal.since(recording_start(&app).unwrap()).len(), 1, "the journal keeps the step"); + app.run(STOP_RECORDING, json!({})).unwrap(); + assert_eq!(app.ui.action_sets[0].actions[0].steps.len(), 1, "the step is left out"); + let saved = files::write_set(&app.ui.action_sets[0]); + assert!(saved.len() <= files::MAX_SET_FILE); + assert!(files::read_set(&saved, "Test").is_ok()); + } + + /// The place cursor's `file.place` that takes a recording past 10,000 steps keeps the placed + /// file and the journal, and the status bar names the limit once the file is placed: on the + /// release when the file is read at once, and on the frame that places it when it is read off + /// the UI thread. Stop Playing/Recording keeps the 10,000 steps that fit. + #[test] + fn place_cursor_exec_checks_recording_step_limit_on_completion() { + let steps = "the action already has 10,000 steps"; + let mut png = vec![]; + image::RgbImage::new(8, 8).write_to(&mut std::io::Cursor::new(&mut png), image::ImageFormat::Png).unwrap(); + let placed = |app: &VectorcraftApp| { + let st = app.session.active().unwrap(); + st.doc.layers.iter().flat_map(|l| l.children().into_iter().flatten()).filter(|n| n.name.as_deref() == Some("a.png")).count() + }; + for background in [false, true] { + let (mut app, _) = app_with_three_moves(); + app.placing.off_the_ui_thread = background; + app.run("file.place.queue", json!({"files": [{"name": "a.png", "dataBase64": vectorcraft_format::base64_encode(&png)}]})).unwrap(); + assert_eq!(app.session.tool_id(), "place"); + recording_with(&mut app, files::MAX_ACTION_STEPS); + app.ui.status.clear(); + let journal = app.session.journal.len(); + tool_drag(&mut app, (40.0, 40.0), (80.0, 80.0)); + if background { + assert_eq!(app.session.journal.len(), journal, "the release places nothing yet"); + assert_eq!(placed(&app), 0); + assert_ne!(app.ui.status, steps, "nothing is checked before the file is placed"); + app.placing.wait_for_reads(); + let ctx = egui::Context::default(); + app.begin_host_iteration(); + let mut out = ctx.run_ui(egui::RawInput::default(), |ui| app.tick(ui.ctx())); + out.textures_delta.clear(); + assert!(app.placing.pending.is_empty(), "the frame after the read places the file"); + } + assert_eq!(app.session.journal.len(), journal + 1, "background {background}: the place journals one step"); + assert_eq!(app.session.journal.last().map(|(c, _)| c.as_str()), Some("file.place")); + assert_eq!(placed(&app), 1, "background {background}: the placed file stays"); + assert_eq!(app.ui.status, steps, "background {background}: the status bar names the limit once the file is placed"); + assert!(app.ui.recording.is_some(), "the recording goes on"); + app.run(STOP_RECORDING, json!({})).unwrap(); + assert_eq!(app.ui.action_sets[0].actions.last().unwrap().steps.len(), files::MAX_ACTION_STEPS, "background {background}"); + } + } + /// A step that reaches the journal outside a command, as a panel's or a dialog's commit does, is /// checked on the app's next frame. A journal rewrite that makes a checked step larger is /// checked again, and a frame with no new step does not name the limit again. diff --git a/crates/ui-egui/src/placing.rs b/crates/ui-egui/src/placing.rs index 11ae770d5d..a627321d76 100644 --- a/crates/ui-egui/src/placing.rs +++ b/crates/ui-egui/src/placing.rs @@ -178,6 +178,23 @@ pub struct Placing { pub(crate) reading: std::sync::Arc<[std::sync::atomic::AtomicUsize; 2]>, } +impl Placing { + /// Unit tests: wait until the reader thread has finished every read started so far. The thread + /// runs its jobs in order, so a job sent after them runs once they have handed back their files. + #[cfg(test)] + pub(crate) fn wait_for_reads(&self) { + if let Some(reader) = &self.reader { + let (tx, rx) = channel(); + let marker: Job = Box::new(move || { + let _ = tx.send(()); + }); + if reader.send(marker).is_ok() { + let _ = rx.recv(); + } + } + } +} + struct PendingSwatch { clipboard: Clipboard, insertion: Insertion, From a7abb3f348b4134876337795022b8977c933de6d Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:53:24 -0800 Subject: [PATCH 079/108] i18n: Greek translates 115 status and error messages it showed in English Adds a Greek row for 115 status and error messages that the Greek catalog did not translate: effects, 3D, image export, color profiles, swatch exchange files, color books, DXF import, the `index` whole-number error and the PDF export warning for knockout groups. Placeholders, parameter names, command ids and literal values stay as the English writes them. --- crates/ui-egui/src/i18n/el.tsv | 117 +++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index 7b61589c18..2f5634f5e8 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -7451,3 +7451,120 @@ breakText Glyphs Γλύφοι Grommets Τρουκς Grommet Inset Απόσταση τρουκς από την άκρη Diameter Διάμετρος + +# Messages of the effects, 3D, image export, color profiles, swatch exchange files, color books, DXF import and PDF export. +@msg 3D effects require finite coordinates within 100 million points Τα εφέ 3D απαιτούν πεπερασμένες συντεταγμένες εντός 100 εκατομμυρίων τυπογραφικών στιγμών +@msg 3D effects require one to ten lights Τα εφέ 3D απαιτούν από ένα έως δέκα φώτα +@msg BMP depth {_1}: 1, 4, 8, 16, 24 or 32 bits per pixel Βάθος BMP {_1}: 1, 4, 8, 16, 24 ή 32 bit ανά εικονοστοιχείο +@msg BMP encoding failed: {width} × {height} pixels doesn't fit the format or the pixel buffer Η κωδικοποίηση BMP απέτυχε: τα {width} × {height} εικονοστοιχεία δεν ταιριάζουν στη μορφή ή στην προσωρινή μνήμη εικονοστοιχείων +@msg GIF encoding failed: the palette image is malformed Η κωδικοποίηση GIF απέτυχε: η εικόνα παλέτας είναι κακοσχηματισμένη +@msg GIF encoding failed: {e} Η κωδικοποίηση GIF απέτυχε: {e} +@msg JPEG colour profile: {e} Προφίλ χρώματος JPEG: {e} +@msg JPEG encoding failed: pixel buffer doesn't match the image size Η κωδικοποίηση JPEG απέτυχε: η προσωρινή μνήμη εικονοστοιχείων δεν αντιστοιχεί στο μέγεθος της εικόνας +@msg JPEG encoding failed: {e} Η κωδικοποίηση JPEG απέτυχε: {e} +@msg PNG encoding failed: pixel buffer doesn't match the image size Η κωδικοποίηση PNG απέτυχε: η προσωρινή μνήμη εικονοστοιχείων δεν αντιστοιχεί στο μέγεθος της εικόνας +@msg PNG encoding failed: the palette image is malformed Η κωδικοποίηση PNG απέτυχε: η εικόνα παλέτας είναι κακοσχηματισμένη +@msg PNG encoding failed: {e} Η κωδικοποίηση PNG απέτυχε: {e} +@msg PNG encoding failed: {width} × {height} pixels is not a valid image size Η κωδικοποίηση PNG απέτυχε: τα {width} × {height} εικονοστοιχεία δεν είναι έγκυρο μέγεθος εικόνας +@msg PSD colour profile: {e} Προφίλ χρώματος PSD: {e} +@msg PSD encoding failed: the pixel buffer doesn't match the image size Η κωδικοποίηση PSD απέτυχε: η προσωρινή μνήμη εικονοστοιχείων δεν αντιστοιχεί στο μέγεθος της εικόνας +@msg Revolve profile contains invalid coordinates Το προφίλ της περιστροφής γύρω από άξονα περιέχει μη έγκυρες συντεταγμένες +@msg Revolve profile is too complex Το προφίλ της περιστροφής γύρω από άξονα είναι πολύ σύνθετο +@msg Revolve projection is not finite Η προβολή της περιστροφής γύρω από άξονα δεν είναι πεπερασμένη +@msg Revolve requires finite profile coordinates within 100 million points Η περιστροφή γύρω από άξονα απαιτεί πεπερασμένες συντεταγμένες προφίλ εντός 100 εκατομμυρίων τυπογραφικών στιγμών +@msg Revolve surface is too complex; reduce Segments or simplify the profile Η επιφάνεια περιστροφής είναι πολύ σύνθετη· μειώστε τα «Τμήματα» ή απλοποιήστε το προφίλ +@msg Revolve surface is too complex; simplify the profile Η επιφάνεια περιστροφής είναι πολύ σύνθετη· απλοποιήστε το προφίλ +@msg Revolve visibility cannot split the projected boundary Ο έλεγχος ορατότητας της περιστροφής δεν μπορεί να διαιρέσει το προβαλλόμενο όριο +@msg Revolve visibility creates too many fragments Ο έλεγχος ορατότητας της περιστροφής δημιουργεί πάρα πολλά κομμάτια +@msg Revolve visibility creates too many vector anchors Ο έλεγχος ορατότητας της περιστροφής δημιουργεί πάρα πολλά διανυσματικά σημεία αγκύρωσης +@msg Revolve visibility exceeds its geometry work limit Ο έλεγχος ορατότητας της περιστροφής υπερβαίνει το όριο γεωμετρικών υπολογισμών του +@msg Revolve visibility exceeds its spatial index limit Ο έλεγχος ορατότητας της περιστροφής υπερβαίνει το όριο του χωρικού ευρετηρίου του +@msg Revolve visibility has too many boundary crossings Ο έλεγχος ορατότητας της περιστροφής έχει πάρα πολλές διασταυρώσεις ορίων +@msg Revolve visibility has too many input anchors Ο έλεγχος ορατότητας της περιστροφής έχει πάρα πολλά σημεία αγκύρωσης εισόδου +@msg Revolve visibility requires convex cap sectors Ο έλεγχος ορατότητας της περιστροφής απαιτεί κυρτούς τομείς καλυμμάτων +@msg Revolve visibility requires finite projected faces Ο έλεγχος ορατότητας της περιστροφής απαιτεί πεπερασμένες προβαλλόμενες έδρες +@msg SVG options: {e} Επιλογές SVG: {e} +@msg Save for Web settings: {e} Ρυθμίσεις αποθήκευσης για ιστό: {e} +@msg TIFF colour profile: {e} Προφίλ χρώματος TIFF: {e} +@msg TIFF encoding failed: the pixel buffer doesn't match the image size Η κωδικοποίηση TIFF απέτυχε: η προσωρινή μνήμη εικονοστοιχείων δεν αντιστοιχεί στο μέγεθος της εικόνας +@msg TIFF encoding failed: {e} Η κωδικοποίηση TIFF απέτυχε: {e} +@msg Targa depth {_1}: 16, 24 or 32 bits per pixel Βάθος Targa {_1}: 16, 24 ή 32 bit ανά εικονοστοιχείο +@msg Targa encoding failed: the pixel buffer doesn't match the image size Η κωδικοποίηση Targa απέτυχε: η προσωρινή μνήμη εικονοστοιχείων δεν αντιστοιχεί στο μέγεθος της εικόνας +@msg The 3D projection is not finite Η προβολή 3D δεν είναι πεπερασμένη +@msg The 3D shadow is too complex; turn Shadows off or simplify the art Η σκιά 3D είναι πολύ σύνθετη· απενεργοποιήστε τις «Σκιές» ή απλοποιήστε το σχέδιο +@msg The shape contains invalid coordinates Το σχήμα περιέχει μη έγκυρες συντεταγμένες +@msg Too many Revolve faces for visibility evaluation Πάρα πολλές έδρες περιστροφής για τον έλεγχο ορατότητας +@msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} Το VectorCraft διαβάζει το πολύ {ASE_MAX_ENTRIES} χρώματα και ομάδες από ένα αρχείο ανταλλαγής δειγμάτων, και αυτή η βιβλιοθήκη έχει {entries} +@msg WebP encoding failed: {e} Η κωδικοποίηση WebP απέτυχε: {e} +@msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} +@msg `index` must be a whole number Το `index` πρέπει να είναι ακέραιος αριθμός +@msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList Το `view` είναι smallThumb, mediumThumb, largeThumb, smallList ή largeList +@msg a line can't run from a point to itself μια γραμμή δεν μπορεί να ξεκινά και να καταλήγει στο ίδιο σημείο +@msg a line needs at least two points μια γραμμή χρειάζεται τουλάχιστον δύο σημεία +@msg a number cannot be read ένας αριθμός δεν μπορεί να διαβαστεί +@msg a swatch exchange block is too long ένα μπλοκ του αρχείου ανταλλαγής δειγμάτων είναι πολύ μεγάλο +@msg a swatch exchange name is too long ένα όνομα του αρχείου ανταλλαγής δειγμάτων είναι πολύ μεγάλο +@msg a {sw} × {sh} image can't be resized to {width} × {height} pixels μια εικόνα {sw} × {sh} δεν μπορεί να αλλάξει μέγεθος σε {width} × {height} εικονοστοιχεία +@msg a {width} × {height} image is too large μια εικόνα {width} × {height} είναι πολύ μεγάλη +@msg a {width} × {height} image: {e} μια εικόνα {width} × {height}: {e} +@msg an image could not be written: {e} μια εικόνα δεν μπόρεσε να γραφτεί: {e} +@msg an image that couldn't be read was left out παραλείφθηκε μια εικόνα που δεν μπόρεσε να διαβαστεί +@msg can't open “{name}”: {e} δεν είναι δυνατό το άνοιγμα του «{name}»: {e} +@msg cannot align zip entries to {align} bytes δεν είναι δυνατή η στοίχιση των καταχωρίσεων zip σε {align} byte +@msg cannot open the automation {kind} root `{_1}`: {e} δεν είναι δυνατό το άνοιγμα της ρίζας αυτοματισμού ({kind}) `{_1}`: {e} +@msg cannot read profile: {0} δεν είναι δυνατή η ανάγνωση του προφίλ: {0} +@msg color book version {version} isn't supported (only 1) η έκδοση {version} του βιβλίου χρωμάτων δεν υποστηρίζεται (μόνο 1) +@msg color books in color space {other} aren't supported (only RGB, CMYK and Lab) τα βιβλία χρωμάτων στον χρωματικό χώρο {other} δεν υποστηρίζονται (μόνο RGB, CMYK και Lab) +@msg file name too long to zip: {_1} το όνομα αρχείου είναι πολύ μεγάλο για συμπίεση zip: {_1} +@msg file name too long to zip: {name} το όνομα αρχείου είναι πολύ μεγάλο για συμπίεση zip: {name} +@msg freeform line {i}: {e} γραμμή ελεύθερης μορφής {i}: {e} +@msg freeform point {i}: {e} σημείο ελεύθερης μορφής {i}: {e} +@msg give `{key}` or `{other}`, not both δώστε `{key}` ή `{other}`, όχι και τα δύο +@msg grayscale profiles can't be working spaces yet τα προφίλ κλίμακας του γκρι δεν μπορούν ακόμη να είναι χρωματικοί χώροι εργασίας +@msg input contains NaN or infinite coordinates η είσοδος περιέχει συντεταγμένες NaN ή άπειρες συντεταγμένες +@msg input path could not be closed η διαδρομή εισόδου δεν μπόρεσε να κλείσει +@msg invalid ICC profile: {0} μη έγκυρο προφίλ ICC: {0} +@msg invalid scale {scale} μη έγκυρη κλίμακα {scale} +@msg its localized names take more than {_1} KB τα τοπικοποιημένα ονόματά του καταλαμβάνουν περισσότερα από {_1} KB +@msg its objects are nested too deep ({e}) τα αντικείμενά του είναι ένθετα σε πολύ μεγάλο βάθος ({e}) +@msg its tag table lists the `{_1}` tag more than once ο πίνακας ετικετών του περιέχει την ετικέτα `{_1}` περισσότερες από μία φορές +@msg knockout groups with too many overlapping translucent elements are written as PDF knockout groups: their translucent elements knock out what they cover fully οι ομάδες διάτρησης με πάρα πολλά επικαλυπτόμενα ημιδιαφανή στοιχεία γράφονται ως ομάδες διάτρησης PDF: τα ημιδιαφανή στοιχεία τους διατρυπούν πλήρως ό,τι καλύπτουν +@msg not a graphic style library: {e} δεν είναι βιβλιοθήκη στυλ γραφικών: {e} +@msg not a swatch library (.vcswatches or .gpl) δεν είναι βιβλιοθήκη δειγμάτων (.vcswatches ή .gpl) +@msg not a swatch library (format `{_1}`) δεν είναι βιβλιοθήκη δειγμάτων (μορφή `{_1}`) +@msg not a swatch library: {e} δεν είναι βιβλιοθήκη δειγμάτων: {e} +@msg not an action set file ({e}) δεν είναι αρχείο συνόλου ενεργειών ({e}) +@msg profile colour space {other} is not RGB, CMYK or Gray ο χρωματικός χώρος {other} του προφίλ δεν είναι RGB, CMYK ή Gray +@msg regular expression too large η κανονική έκφραση είναι πολύ μεγάλη +@msg script file is not UTF-8 text: {value} το αρχείο σεναρίου δεν είναι κείμενο UTF-8: {value} +@msg stop {i}: {e} σημείο χρώματος {i}: {e} +@msg swatch exchange version {major}.{minor} isn't supported (only 1.x) η έκδοση {major}.{minor} του αρχείου ανταλλαγής δειγμάτων δεν υποστηρίζεται (μόνο 1.x) +@msg the color book holds more than {ASE_MAX_ENTRIES} colors το βιβλίο χρωμάτων περιέχει περισσότερα από {ASE_MAX_ENTRIES} χρώματα +@msg the color book is cut short το βιβλίο χρωμάτων είναι περικομμένο +@msg the color book's names take more than {_1} MB τα ονόματα του βιβλίου χρωμάτων καταλαμβάνουν περισσότερα από {_1} MB +@msg the image would be {w} × {h} pixels; raster exports are limited to {MAX_RASTER_SIDE} pixels per side and {_1} megapixels: lower the scale or resolution η εικόνα θα ήταν {w} × {h} εικονοστοιχεία· οι εξαγωγές raster περιορίζονται σε {MAX_RASTER_SIDE} εικονοστοιχεία ανά πλευρά και {_1} μεγαεικονοστοιχεία: μειώστε την κλίμακα ή την ανάλυση +@msg the optimised image can't be read back: {e} η βελτιστοποιημένη εικόνα δεν μπορεί να διαβαστεί ξανά: {e} +@msg the pixel buffer doesn't match the image size η προσωρινή μνήμη εικονοστοιχείων δεν αντιστοιχεί στο μέγεθος της εικόνας +@msg the preview: {e} η προεπισκόπηση: {e} +@msg the request may not read the New Document profiles folder το αίτημα δεν επιτρέπεται να διαβάσει τον φάκελο προφίλ νέου εγγράφου +@msg the shapes are too degenerate to combine τα σχήματα είναι πολύ εκφυλισμένα για να συνδυαστούν +@msg the shapes cross themselves and each other too often to combine τα σχήματα τέμνουν τον εαυτό τους και το ένα το άλλο πάρα πολλές φορές για να συνδυαστούν +@msg the swatch exchange file holds more than {ASE_MAX_ENTRIES} colors and groups το αρχείο ανταλλαγής δειγμάτων περιέχει περισσότερα από {ASE_MAX_ENTRIES} χρώματα και ομάδες +@msg the swatch exchange file is cut short το αρχείο ανταλλαγής δειγμάτων είναι περικομμένο +@msg the {_1} plate can't be read: {e} η πλάκα {_1} δεν μπορεί να διαβαστεί: {e} +@msg this binary DXF file is damaged or cut short αυτό το δυαδικό αρχείο DXF είναι κατεστραμμένο ή περικομμένο +@msg this is a DWG drawing, which can't be read: save it from the CAD app as a DXF and open that αυτό είναι σχέδιο DWG και δεν μπορεί να διαβαστεί: αποθηκεύστε το ως DXF από την εφαρμογή CAD και ανοίξτε το +@msg too many classes υπερβολικά πολλές κλάσεις +@msg too many groups υπερβολικά πολλές ομάδες +@msg too many layers for PSD (at most 32767) πάρα πολλά επίπεδα για PSD (το πολύ 32767) +@msg too many swatch exchange blocks πάρα πολλά μπλοκ στο αρχείο ανταλλαγής δειγμάτων +@msg unknown colour profile: {0} άγνωστο προφίλ χρώματος: {0} +@msg {_1} clashes with a built-in profile name το {_1} συγκρούεται με το όνομα ενός ενσωματωμένου προφίλ +@msg {_1} × {_2} pixels is too large for GIF (at most 65535 pixels a side): lower the resolution τα {_1} × {_2} εικονοστοιχεία είναι υπερβολικό μέγεθος για GIF (το πολύ 65535 εικονοστοιχεία ανά πλευρά): μειώστε την ανάλυση +@msg {_1}: no usable transform to/from sRGB {_1}: δεν υπάρχει χρησιμοποιήσιμος μετασχηματισμός προς/από sRGB +@msg {name} is not a CMYK profile το {name} δεν είναι προφίλ CMYK +@msg {name} is not an RGB profile το {name} δεν είναι προφίλ RGB +@msg {path}: could not be read {path}: δεν ήταν δυνατή η ανάγνωση +@msg {width} × {height} pixels is too large for JPEG (at most 65535 pixels a side): lower the resolution τα {width} × {height} εικονοστοιχεία είναι υπερβολικό μέγεθος για JPEG (το πολύ 65535 εικονοστοιχεία ανά πλευρά): μειώστε την ανάλυση +@msg {width} × {height} pixels is too large for Targa (at most 65535 pixels a side): lower the resolution τα {width} × {height} εικονοστοιχεία είναι υπερβολικό μέγεθος για Targa (το πολύ 65535 εικονοστοιχεία ανά πλευρά): μειώστε την ανάλυση +@msg {w} × {h} pixels is too large for PSD (at most {MAX_SIDE} pixels a side): lower the resolution τα {w} × {h} εικονοστοιχεία είναι υπερβολικό μέγεθος για PSD (το πολύ {MAX_SIDE} εικονοστοιχεία ανά πλευρά): μειώστε την ανάλυση From cdbd079ee97c3c0dc421c2d5117a166bbcf71a01 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 02:59:05 -0800 Subject: [PATCH 080/108] Fix #7525: Extrude & Bevel cuts sharp corners square instead of spiking MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit An inset ring limited a corner's miter by moving the corner four times the bevel width along its bisector. At a corner sharper than about 29° that the bevel opens (a convex corner with the bevel outside, a notch with it inside), the bevel still ran out to a spike up to four times the width and no longer lined up with the art. With the bevel outside, the wall behind it spiked the same way. Such a corner is now given twice in the outline before the solid is built, and each copy moves along its own edge's normal, so the bevel (and, with the bevel outside, the wall) cuts the corner square, as a bevel join cuts a stroke. Corners within the limit keep their miters, and corners where the inset edges meet keep the four-times limit. A cap's outline skips the straight segment of no length between the two copies where they do not move apart. Docs: docs/three-d.md, docs/target-app-parity.md. --- crates/three-d/src/solid/build.rs | 16 +++++-- crates/three-d/src/solid/outline.rs | 3 +- crates/three-d/src/solid/rings.rs | 53 +++++++++++++++++++-- crates/three-d/src/solid/tests.rs | 72 +++++++++++++++++++++++++++++ docs/target-app-parity.md | 1 + docs/three-d.md | 6 ++- 6 files changed, 141 insertions(+), 10 deletions(-) diff --git a/crates/three-d/src/solid/build.rs b/crates/three-d/src/solid/build.rs index 2aa218e558..f3fda46685 100644 --- a/crates/three-d/src/solid/build.rs +++ b/crates/three-d/src/solid/build.rs @@ -3,7 +3,7 @@ use vectorcraft_geom::kurbo::ParamCurveDeriv; use super::outline::{self, Along, Budget, CURVE_TOLERANCE}; use super::rings::{ CURVE_PIECES, MAX_PIECES, MAX_PLANE_POINTS, MAX_SOLID_POINTS, Ring, Span, TOO_COMPLEX_SURFACE, curve_pieces, inset, left, signed_area, - solid_rings_traced, + solid_rings_traced, square_corners, }; use super::{ Bevel, DepthPlane, Extrude, Facet, FillRule, MAX_FACES, MAX_SOLID_FACES, ParamCurve, PathData, PlanarFace, Point, Rect, Revolve, V3, View, @@ -458,10 +458,15 @@ pub(super) fn check_bounds(b: Rect) -> Result<(), String> { } /// The art's outward direction at edge `i` of `ring` (before rotation), tilted towards the face -/// it borders by `z` (+1 front, -1 back, 0 a side wall). +/// it borders by `z` (+1 front, -1 back, 0 a side wall). An edge of no length (a corner cut +/// square, see [`square_corners`]) faces out between the edges on either side of it. pub(super) fn outward(ring: &[Point], i: usize, z: f64) -> V3 { let n = ring.len(); - let (lx, ly) = left(ring[i], ring[(i + 1) % n]); + let (mut lx, mut ly) = left(ring[i], ring[(i + 1) % n]); + if lx == 0.0 && ly == 0.0 && n > 2 { + let (a, b) = (left(ring[(i + n - 1) % n], ring[i]), left(ring[(i + 1) % n], ring[(i + 2) % n])); + (lx, ly) = (a.0 + b.0, a.1 + b.1); + } V3(-lx, -ly, z) } @@ -607,7 +612,10 @@ pub(crate) fn extrude_faces(path: &PathData, rule: FillRule, bounds: Rect, optio let (bands, caps) = (steps.len().saturating_sub(1), if o.cap { 2 } else { 0 }); let size = bounds.width().max(bounds.height()); let most = curve_pieces(path, size, bands, caps)?; - let traced = solid_rings_traced(path, rule, size, MAX_SOLID_POINTS, most)?; + // Every inset of one extrusion goes the same way: into the shape for a bevel inside, out of it + // for one outside. The corners that way opens are cut square past the miter limit. + let side = steps.iter().map(|s| s.inset).find(|w| *w != 0.0).unwrap_or(0.0); + let traced: Vec<Ring> = solid_rings_traced(path, rule, size, MAX_SOLID_POINTS, most)?.iter().map(|r| square_corners(r, side)).collect(); let rings: Vec<&[Point]> = traced.iter().map(|r| r.points.as_slice()).collect(); let edges = rings.iter().map(|r| r.len()).fold(0usize, usize::saturating_add); if edges.saturating_mul(bands).saturating_add(caps) > MAX_SOLID_FACES { diff --git a/crates/three-d/src/solid/outline.rs b/crates/three-d/src/solid/outline.rs index 07fb0ce58b..93d9d70340 100644 --- a/crates/three-d/src/solid/outline.rs +++ b/crates/three-d/src/solid/outline.rs @@ -123,7 +123,8 @@ fn contour(path: &mut BezPath, ring: &Ring, points: &[Point], step: &Along, budg while i < n { let end = |k: usize| points.get((k + 1) % n).copied().unwrap_or(first); let Some(span) = ring.spans.get(i).copied().flatten() else { - if i + 1 < n { + // A corner cut square (see `square_corners`) whose two copies did not move apart. + if i + 1 < n && points.get(i).copied() != Some(end(i)) { path.line_to(end(i)); } i += 1; diff --git a/crates/three-d/src/solid/rings.rs b/crates/three-d/src/solid/rings.rs index 80dc66407c..882bd245af 100644 --- a/crates/three-d/src/solid/rings.rs +++ b/crates/three-d/src/solid/rings.rs @@ -16,6 +16,10 @@ pub(super) const CURVE_PIECES: u32 = 32; /// for fewer takes fewer. pub(super) const MIN_CURVE_PIECES: u32 = 4; +/// How far an inset corner's miter reaches at most, as a multiple of the inset. [`square_corners`] +/// cuts a corner whose miter would reach further square across instead. +const MITER_LIMIT: f64 = 4.0; + const TOO_COMPLEX_SHAPE: &str = "The shape is too complex for a 3D effect"; /// The error a solid past its limits returns, and a 3D effect whose solids together pass /// [`crate::MAX_OBJECT_FACES`]. @@ -472,8 +476,10 @@ pub(super) fn left(a: Point, b: Point) -> (f64, f64) { } /// `ring` moved `w` points towards its filled side (negative: away from it), each corner along -/// its bisector, its mitre limited to four times `w` so sharp corners don't shoot off. Each point -/// stays the partner of its source point, so rings at different insets join face to face. +/// its bisector, its miter limited to [`MITER_LIMIT`] times `w` so sharp corners don't shoot off. +/// A point given twice (a corner [`square_corners`] cut) moves each copy along its one edge's +/// normal. Each point stays the partner of its source point, so rings at different insets join +/// face to face. pub(super) fn inset(ring: &[Point], w: f64) -> Vec<Point> { if w == 0.0 { return ring.to_vec(); @@ -486,6 +492,12 @@ pub(super) fn inset(ring: &[Point], w: f64) -> Vec<Point> { let next = ring[(i + 1) % n]; let (ax, ay) = left(prev, p); let (bx, by) = left(p, next); + if ax == 0.0 && ay == 0.0 { + return Point::new(p.x + bx * w, p.y + by * w); + } + if bx == 0.0 && by == 0.0 { + return Point::new(p.x + ax * w, p.y + ay * w); + } let (mut mx, mut my) = (ax + bx, ay + by); let ml = mx.hypot(my); if ml < 1e-9 { @@ -493,8 +505,43 @@ pub(super) fn inset(ring: &[Point], w: f64) -> Vec<Point> { } else { (mx, my) = (mx / ml, my / ml); } - let cos = (mx * ax + my * ay).max(0.25); + let cos = (mx * ax + my * ay).max(1.0 / MITER_LIMIT); Point::new(p.x + mx * w / cos, p.y + my * w / cos) }) .collect() } + +/// `ring` with each corner whose miter an inset towards `side` (positive: the filled side, +/// negative: away from it) would reach past [`MITER_LIMIT`] given twice, joined by an edge of no +/// length that follows no curve. [`inset`] moves the two copies apart along their own edges' +/// normals, so the inset ring cuts the corner square, as a bevel join does, instead of running out +/// to a point along the bisector. Corners on the other side of the turn, whose inset edges meet +/// before the corner, keep one point. +pub(super) fn square_corners(ring: &Ring, side: f64) -> Ring { + let n = ring.points.len(); + if side == 0.0 || n < 3 || ring.spans.len() != n { + return ring.clone(); + } + let mut out = Ring { points: Vec::with_capacity(n), spans: Vec::with_capacity(n) }; + for (i, (&p, span)) in ring.points.iter().zip(&ring.spans).enumerate() { + let prev = ring.points[(i + n - 1) % n]; + let next = ring.points[(i + 1) % n]; + let (a, b) = (left(prev, p), left(p, next)); + let (mx, my) = (a.0 + b.0, a.1 + b.1); + let ml = mx.hypot(my); + // The cosine of the half angle between the bisector and each edge's normal: the miter + // reaches 1 / cos times the inset. + let cos = if ml < 1e-9 { 0.0 } else { (mx * a.0 + my * a.1) / ml }; + // Which way the outline turns at `p`: an inset towards `side` opens the corner when the + // turn is against it. + let turn = (p - prev).cross(next - p); + let edges = (a.0 != 0.0 || a.1 != 0.0) && (b.0 != 0.0 || b.1 != 0.0); + out.points.push(p); + if edges && cos < 1.0 / MITER_LIMIT && turn * side < 0.0 { + out.spans.push(None); + out.points.push(p); + } + out.spans.push(*span); + } + out +} diff --git a/crates/three-d/src/solid/tests.rs b/crates/three-d/src/solid/tests.rs index 335f434419..7afce495ad 100644 --- a/crates/three-d/src/solid/tests.rs +++ b/crates/three-d/src/solid/tests.rs @@ -255,6 +255,78 @@ fn a_bevel_inside_shrinks_the_cap_and_outside_grows_the_walls() { assert!(inside.iter().any(|f| !close(f.brightness, inside[inside.len() - 1].brightness, 1e-3))); } +/// A bevel past a sharp corner is cut square, as a bevel join cuts a stroke, instead of running +/// out to a spike along the corner's bisector: seen straight on, no point of the solid lies further +/// from the art than the miters of its corners of about 90° (14.6 pt for a 10 pt bevel), where the +/// sharp corner's spike reached 40 pt. The bevel opens the corner of a thin spike (with its +/// neighbor in the same compound path) when it is outside, and of a narrow notch when it is inside; +/// the other two cases, where the inset edges meet, keep their limited miters and are checked too. +#[test] +fn a_bevel_cuts_sharp_corners_square() { + let poly = |pts: &[(f64, f64)]| { + let mut b = BezPath::new(); + b.move_to(pts[0]); + pts[1..].iter().for_each(|p| b.line_to(*p)); + b.close_path(); + b + }; + let spike = [(50.0, 0.0), (56.0, 100.0), (44.0, 100.0)]; + let block = [(80.0, 40.0), (120.0, 40.0), (120.0, 100.0), (80.0, 100.0)]; + let notched = [(0.0, 0.0), (100.0, 0.0), (100.0, 100.0), (52.0, 100.0), (50.0, 20.0), (48.0, 100.0), (0.0, 100.0)]; + let mut both = poly(&spike); + both.extend(poly(&block).elements().iter().copied()); + let bevel = Bevel { width: 10.0, height: 10.0, ..Bevel::default() }; + let mut far_cases = vec![]; + for (name, art, outline) in [("spike", both, vec![spike.to_vec(), block.to_vec()]), ("notch", poly(¬ched), vec![notched.to_vec()])] { + let (p, b) = shape(&art); + let outline: Vec<Vec<Point>> = outline.iter().map(|r| r.iter().map(|q| Point::new(q.0, q.1)).collect()).collect(); + for inside in [false, true] { + for shape in [BevelShape::Classic, BevelShape::Rounded] { + let o = Extrude { bevel: Some(Bevel { inside, shape, ..bevel }), ..Extrude::default() }; + let f = extrude(&p, FillRule::NonZero, b, o, front()).unwrap(); + let far = f.iter().flat_map(|f| f.contours.iter().flatten()).map(|q| edge_distance(&outline, *q)).fold(0.0, f64::max); + if far > 15.0 { + far_cases.push(format!("{name} inside {inside} {shape:?}: a point {far} pt from the art")); + } + assert!(f.iter().all(|f| f.normal.iter().all(|v| v.is_finite())), "{name} inside {inside} {shape:?}"); + } + // Turned, every face still has a normal it can be lit and sorted by. + let o = Extrude { bevel: Some(Bevel { inside, ..bevel }), ..Extrude::default() }; + let f = extrude(&p, FillRule::NonZero, b, o, View::default()).unwrap(); + assert!(f.iter().all(|f| f.normal.iter().all(|v| v.is_finite()) && f.brightness.is_finite()), "{name} inside {inside}"); + } + } + assert!(far_cases.is_empty(), "{far_cases:#?}"); +} + +/// With the bevel outside, the cap is the outline itself, so a corner cut square keeps its two +/// points together there: the cap's outline draws no straight segment of no length at that corner. +#[test] +fn a_cap_draws_no_empty_segment_at_a_corner_cut_square() { + use vectorcraft_geom::kurbo::PathEl; + let mut art = BezPath::new(); + art.move_to((50.0, 0.0)); + art.line_to((56.0, 100.0)); + art.curve_to((56.0, 120.0), (44.0, 120.0), (44.0, 100.0)); + art.close_path(); + let (p, b) = shape(&art); + let o = Extrude { bevel: Some(Bevel { width: 10.0, height: 10.0, ..Bevel::default() }), ..Extrude::default() }; + let f = extrude(&p, FillRule::NonZero, b, o, front()).unwrap(); + let cap = f.iter().find(|f| f.depth == f64::MAX && f.outline.is_some()).unwrap(); + let mut at = None; + for el in cap.path().to_bezpath().elements() { + match *el { + PathEl::MoveTo(q) => at = Some(q), + PathEl::LineTo(q) => { + assert_ne!(at, Some(q), "a segment of no length at {q:?}"); + at = Some(q); + } + PathEl::QuadTo(_, q) | PathEl::CurveTo(_, _, q) => at = Some(q), + PathEl::ClosePath => {} + } + } +} + #[test] fn bevel_shapes_repeats_and_both_sides_change_the_surface() { let (p, b) = shape(&square(0.0, 0.0, 100.0)); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..8942b30e35 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1266,6 +1266,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - When the fill and strokes are at full opacity with Normal blending, under a stroke that leaves parts of the fill's edge uncovered (dashed, with a width profile or a brush, on an open subpath, or in a paint that may show through), Extrude & Bevel (both kinds) and Inflate cut each stroke face that passes through a face of the fill's solid, or of another of the shape's strokes, where their depths meet, and draw the faces of the shape's fill and strokes that overlap in the order of their depths where they overlap, instead of by the depths of their centers. Inflate orders a plain stroke the same way, since its fill can rise in front of the stroke. The fill no longer paints over a nearer dash, and a dash's end no longer covers the fill wall in front of it; a fill wall in a gap between dashes stays visible. The same order applies inside a group member's own opacity mask or blending mode, to a gradient with transparent stops under a colored light with graphics on its caps, and to Inflate in gradients under a colored light. Tests: `solids::tests::fill_walls_and_strokes_that_leave_gaps_draw_in_the_order_of_their_depths_where_they_overlap`, `solids::tests::local_order_puts_overlapping_fill_walls_and_stroke_faces_in_depth_order`, `solids::tests::a_stroke_face_through_a_fill_wall_is_cut_where_their_depths_meet`, `solids::tests::a_masked_members_fill_and_stroke_faces_go_in_one_order`, `solids::tests::a_colored_inflate_in_gradients_draws_its_faces_in_one_order`, `solids::tests::a_depth_cycle_keeps_the_cap_last`, `solids::graphics::tests::a_transparent_gradient_with_a_graphic_keeps_the_shared_face_order`. - Under a colored light, an Inflate fill and strokes in solid colors, opaque with Normal blending, also draw their faces in that one order, inside a group member's own opacity mask too, instead of each solid as one composite with the stroke's faces over every fill face. Each face keeps the composite's paint, light ramps and seam width; a lone solid, the solids of an object with a translucent or blended fill or stroke, and such solids holding more than 30,720 faces together (VectorCraft's own limit) are still drawn as one composite each. Tests: `solids::tests::colored_solid_fills_and_strokes_share_face_depth_order`, `solids::tests::a_colored_solid_face_on_its_own_keeps_the_composites_colors`, `solids::tests::colored_solid_inflate_batches_channels_and_clips_once_per_surface`, `solids::tests::colored_solids_past_the_face_limit_draw_as_composites`. - Without a twist, a tapered Extrude & Bevel wall (and each bevel band) is one flat face; only a twist cuts walls into slices, so no seam between slices paints a light tick or a light line on a tapered, untwisted wall (#7019). Test: `solid::tests::a_tapered_wall_is_one_flat_face_and_a_twisted_one_is_sliced`. + - Extrude & Bevel cuts a corner square where the bevel opens it and its miter would reach past four times the width (a sharp point with the bevel outside, a narrow notch with it inside), so the bevel (and, with the bevel outside, the walls) no longer runs out to a spike that does not line up with the art (#7525). Tests: `solid::tests::a_bevel_cuts_sharp_corners_square`, `solid::tests::a_cap_draws_no_empty_segment_at_a_corner_cut_square`. - Extrude & Bevel, Inflate and Rotate apply to type: it makes a solid of its glyph outlines, painted with its own fills and strokes or, when it has none, its characters' colour (the first run's), and stays type, so editing the text reshapes the solid (#4715). - Extrude & Bevel, Inflate and Rotate (Effect › 3D and Materials): live effects in the `three-d` crate with depth, twist, taper, solid or hollow caps, five original bevel shapes (width, height, repeat, spacing, inside, both sides), Inflate's volume, both sides, twist, taper and cap, Rotate's turned fills and strokes, Position presets, the rotation and light gizmos, SVG/PDF vector output and Expand Appearance; one 3D effect per object; covered by geometry, effect, canvas-versus-export, command and dialog tests ([three-d.md](three-d.md)). - Extrude & Bevel and Inflate build detailed shapes: each solid takes up to 65,536 outline points and 163,840 faces (VectorCraft's own limits, was 2,048 points and 32,768 faces), counted before any point is sampled; when the faces do not fit, every curve takes fewer pieces, down to 4. A closed path of 2,000 curves extrudes with a bevel and inflates, and paths of 5,000 and 10,000 curves build at the default settings (`crates/three-d/src/solid/tests_limits.rs`). diff --git a/docs/three-d.md b/docs/three-d.md index 6de07fc2fe..92d425ec9d 100644 --- a/docs/three-d.md +++ b/docs/three-d.md @@ -85,8 +85,10 @@ object is where the art was. | Bevel Inside | The bevel carved into the shape (the front face shrinks) instead of added around it (the walls stand outside the art). | | Bevel both sides | The back is bevelled too. | -Holes stay holes, with walls of their own. Bevels move each corner along its bisector (mitres are limited to four -times the width), so a bevel wider than a narrow part of the shape folds over itself. Each facet has a seam ([Seams](#seams)). +Holes stay holes, with walls of their own. Bevels move each corner along its bisector. A corner the bevel opens (a +sharp point with the bevel outside, a narrow notch with it inside) whose miter would reach past four times the width is +cut square across instead; at the other corners the miter is limited to four times the width. A bevel wider than a +narrow part of the shape folds over itself. Each facet has a seam ([Seams](#seams)). ## Inflate From e04fa729594450eed03ba105fd825202e51cab2c Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:15:13 -0800 Subject: [PATCH 081/108] Docs: the automation-roots section names the app-folder commands that are confined The Confining file access bullet said the app's own folders are not confined. It now names the commands that check the roots for a file there: the arrowheads edit, reload and list commands, the New Document profile commands and file.new, and the Scripts folder listing and run, each linked to its section. --- docs/mcp.md | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/mcp.md b/docs/mcp.md index ca77311c58..dce535dffe 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -289,7 +289,13 @@ the suite) keep the agent to the folders you give it: - The preferences that move folders the app reads or writes on its own (`fontsFolder`, `pluginsFolder`, `recoveryFolder`, `templatesFolder`) can only be set inside the roots. The app's own folders (preferences, Data Recovery, the User Defined library folders, VectorCraft's Fonts folder) are not - confined: no agent names a path there. + confined. These commands that act on a file there are confined: `stroke.arrowheads.edit` and + `stroke.arrowheads.reload` refuse an arrowheads file outside the read roots, and `stroke.arrowheads.list` gives its + `file` as `null` there (see [Arrowheads](#arrowheads)); `file.newProfiles.edit` needs read and write access to the + New Document profile's file, `file.newProfiles.reset` needs write access, and `file.new` starts with the defaults + when the read roots leave out the profiles folder (see [New Document profiles](#new-document-profiles)); + `script.listInstalled` lists the Scripts folder and `ui.runInstalledScript` runs a script only inside a read root + (see [Script engines](#script-engines)). - The roots must be existing folders; a missing one stops the server with an error. Each flag takes one folder per use (`--flag <dir>` or `--flag=<dir>`) and may be used again for more. From 6d7da503745b76be90a7beb2e3b6751b541413aa Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:17:09 -0800 Subject: [PATCH 082/108] i18n: Hungarian leaves the answers[{i}] message to the script.run answers change #7532 adds a Hungarian row for `answers[{i}]` {e}. Two rows with the same source would fail the catalog's duplicate check once both merge. --- crates/ui-egui/src/i18n/hu.tsv | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index e0d54229d8..423b004f0f 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -7528,7 +7528,6 @@ breakText Glyphs Glifák @msg VectorCraft reads at most {ASE_MAX_ENTRIES} colors and groups from a swatch exchange file, and this library has {entries} A VectorCraft legfeljebb {ASE_MAX_ENTRIES} színt és csoportot olvas be egy színmintacsere-fájlból, ebben a könyvtárban pedig ennyi van: {entries} @msg WebP encoding failed: {e} A WebP-kódolás sikertelen: {e} @msg [{j}] `{_1}`: {why} [{j}] `{_1}`: {why} -@msg `answers[{i}]` {e} `answers[{i}]` {e} @msg `index` must be a whole number `index`: egész szám kell @msg `view` is smallThumb, mediumThumb, largeThumb, smallList or largeList `view`: smallThumb, mediumThumb, largeThumb, smallList vagy largeList lehet @msg a line can't run from a point to itself egy vonal nem futhat egy pontból önmagába From 848a5ee9043409db5608f1449c8304404c177644 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:41:39 -0800 Subject: [PATCH 083/108] Zoom: Space moves a text-edit zoom marquee after Cmd is let go While the Type tool edits text, a zoom marquee started with Cmd+Space read Space as up once Cmd was let go. Space pressed again moved the marquee only in the frame of the key press, and later frames sized it. The marquee now reads the Space key itself, so it moves and sizes as it does outside text editing. A space typed or committed by an input method during a Zoom tool drag (the marquee or an animated zoom) is no longer typed into the text. With no zoom drag, Space types a space as before. --- crates/ui-egui/src/canvas.rs | 5 ++ crates/ui-egui/src/canvas/input.rs | 17 ++++--- crates/ui-egui/src/canvas/tests.rs | 67 ++++++++++++++++++++++++++ crates/ui-egui/src/shortcuts/typing.rs | 23 +++++++-- docs/target-app-parity.md | 1 + 5 files changed, 103 insertions(+), 10 deletions(-) diff --git a/crates/ui-egui/src/canvas.rs b/crates/ui-egui/src/canvas.rs index a947dde852..486c70de88 100644 --- a/crates/ui-egui/src/canvas.rs +++ b/crates/ui-egui/src/canvas.rs @@ -186,6 +186,11 @@ pub(crate) fn dragging(ctx: &egui::Context) -> bool { ctx.data(|d| d.get_temp::<Drag>(drag_id()).is_some()) } +/// Whether the canvas is holding a Zoom tool drag: a marquee, which Space moves, or an animated zoom. +pub(crate) fn dragging_zoom(ctx: &egui::Context) -> bool { + ctx.data(|d| matches!(d.get_temp::<Drag>(drag_id()), Some(Drag::ZoomBox { .. } | Drag::ZoomScrub { .. }))) +} + /// The part of `outer` inside the scroll bars, and the part of that inside the rulers, which shows /// the document. Normal Screen Mode and Full Screen Mode with Menu Bar keep the scroll bars along /// the right and bottom edges; Full Screen and Presentation Mode have none. diff --git a/crates/ui-egui/src/canvas/input.rs b/crates/ui-egui/src/canvas/input.rs index 4d121eb2a3..57dbef9ff8 100644 --- a/crates/ui-egui/src/canvas/input.rs +++ b/crates/ui-egui/src/canvas/input.rs @@ -373,7 +373,7 @@ fn drag_held(app: &mut VectorcraftApp, ui: &Ui, f: &Pointing, d: Drag, p: Pos2) } } Drag::ZoomBox { start } => { - let start = zoom_marquee_start(ui, start, before, p, space); + let start = zoom_marquee_start(ui, start, before, p); ui.data_mut(|dd| dd.insert_temp(drag_id(), Drag::ZoomBox { start })); marquee(ui.painter(), egui::Rect::from_two_pos(start, p)); } @@ -480,7 +480,7 @@ fn drag_released(app: &mut VectorcraftApp, ui: &Ui, f: &Pointing, d: Drag, p: Po let ui_zoom = app.canvas_ui_zoom; match d { Drag::ZoomBox { start } => { - let start = zoom_marquee_start(ui, start, before, p, space); + let start = zoom_marquee_start(ui, start, before, p); ui.data_mut(|dd| dd.remove::<bool>(zoom_space_free_id())); let r = egui::Rect::from_two_pos(start, p); if let Some(vm) = app.view_mut() { @@ -612,22 +612,25 @@ fn zoom_space_free_id() -> egui::Id { /// sizes the marquee until it is let go. A marquee with no size yet is sized by the movement, so /// Space pressed before the pointer moves does not keep it at the press point. The frame's pointer /// moves and Space presses and releases are taken in the order they came, so each move follows the -/// Space state it came with. -fn zoom_marquee_start(ui: &Ui, start: Pos2, before: Option<Pos2>, p: Pos2, space: bool) -> Pos2 { +/// Space state it came with. The Space key counts as held whatever the modifiers, so a marquee that +/// Cmd+Space started while the Type tool edits text follows the same rules once Cmd is let go. +fn zoom_marquee_start(ui: &Ui, start: Pos2, before: Option<Pos2>, p: Pos2) -> Pos2 { enum Step { Space(bool), Move(Pos2), } let id = zoom_space_free_id(); - let steps: Vec<Step> = ui.input(|i| { - i.events + let (steps, space): (Vec<Step>, bool) = ui.input(|i| { + let steps = i + .events .iter() .filter_map(|e| match e { egui::Event::Key { key: egui::Key::Space, pressed, repeat: false, .. } => Some(Step::Space(*pressed)), egui::Event::PointerMoved(q) => Some(Step::Move(*q)), _ => None, }) - .collect() + .collect(); + (steps, i.key_down(egui::Key::Space)) }); // Space as it was when the frame began: the opposite of its first press or release, else as it is now. let mut held = steps.iter().find_map(|s| if let Step::Space(down) = s { Some(!down) } else { None }).unwrap_or(space); diff --git a/crates/ui-egui/src/canvas/tests.rs b/crates/ui-egui/src/canvas/tests.rs index 4d609f2b5e..6c01b2ed32 100644 --- a/crates/ui-egui/src/canvas/tests.rs +++ b/crates/ui-egui/src/canvas/tests.rs @@ -7416,6 +7416,73 @@ fn space_types_a_space_while_editing_text_and_does_not_pan() { assert_eq!(plain(&app, id), "a ", "the text is as typed"); } +/// While the Type tool edits text, a zoom marquee that Cmd+Space started keeps its Space rules once +/// Cmd is let go: Space held since the press sizes it, and Space pressed again moves it on every +/// frame it stays held, without typing a space. With no marquee, Space types a space again, and +/// during an animated zoom drag it types none. +#[test] +fn space_moves_a_text_edit_zoom_marquee_after_cmd_is_let_go() { + use egui::{Event, Modifiers}; + let mut app = VectorcraftApp::new(Session::new(), Default::default()); + app.session.prefs.placeholder_text = false; + app.run("prefs.set", json!({"key": "animatedZoom", "value": false})).unwrap(); + let ctx = egui::Context::default(); + let id = start_typing(&mut app, &ctx); + let rect = app.canvas_rect.unwrap(); + let at = rect.center() - vec2(100.0, 50.0); + let space = |pressed, modifiers| Event::Key { key: egui::Key::Space, physical_key: None, pressed, repeat: false, modifiers }; + let button = |pos, pressed, modifiers| Event::PointerButton { pos, button: egui::PointerButton::Primary, pressed, modifiers }; + let corners = |app: &mut VectorcraftApp| -> (Pos2, Pos2) { + let lines: Vec<Vec<Pos2>> = shapes(app, &ctx) + .into_iter() + .filter_map(|s| match s { + Shape::Path(p) if p.stroke.color == egui::epaint::ColorMode::Solid(Color32::from_white_alpha(230)) => Some(p.points), + _ => None, + }) + .collect(); + let [line] = &lines[..] else { panic!("one marquee: {lines:?}") }; + (line[0], line[2]) + }; + typing_frame(&mut app, &ctx, vec![Event::Text("a".into())]); + let z0 = app.view().unwrap().zoom; + // Space held since the Cmd+Space press sizes the marquee, also once Cmd is let go. + typing_frame(&mut app, &ctx, vec![Event::ModifiersChanged(Modifiers::COMMAND), space(true, Modifiers::COMMAND), Event::PointerMoved(at)]); + typing_frame(&mut app, &ctx, vec![button(at, true, Modifiers::COMMAND)]); + typing_frame(&mut app, &ctx, vec![Event::PointerMoved(at + vec2(50.0, 25.0))]); + typing_frame(&mut app, &ctx, vec![Event::ModifiersChanged(Modifiers::NONE), Event::PointerMoved(at + vec2(80.0, 40.0))]); + typing_frame(&mut app, &ctx, vec![Event::PointerMoved(at + vec2(100.0, 50.0))]); + assert_eq!(corners(&mut app), (at, at + vec2(100.0, 50.0)), "Space held since the press sizes it"); + // Let go and pressed again, Space moves the marquee on this frame and the frames after it. + typing_frame(&mut app, &ctx, vec![space(false, Modifiers::NONE)]); + typing_frame(&mut app, &ctx, vec![space(true, Modifiers::NONE), Event::Text(" ".into()), Event::PointerMoved(at + vec2(120.0, 60.0))]); + typing_frame(&mut app, &ctx, vec![Event::PointerMoved(at + vec2(140.0, 70.0))]); + assert_eq!(corners(&mut app), (at + vec2(40.0, 20.0), at + vec2(140.0, 70.0)), "Space moves it and keeps its 100 × 50 size"); + assert_eq!(plain(&app, id), "a", "the Space that moves the marquee types nothing"); + typing_frame(&mut app, &ctx, vec![space(false, Modifiers::NONE)]); + typing_frame(&mut app, &ctx, vec![space(true, Modifiers::NONE), Event::Ime(egui::ImeEvent::Commit(" ".into()))]); + assert_eq!(plain(&app, id), "a", "nor does a space an input method commits for it"); + // Let go, the drag sizes it again, and the release zooms to the moved marquee. + typing_frame(&mut app, &ctx, vec![space(false, Modifiers::NONE), Event::PointerMoved(at + vec2(180.0, 95.0))]); + assert_eq!(corners(&mut app), (at + vec2(40.0, 20.0), at + vec2(180.0, 95.0)), "let go, the drag sizes it again"); + typing_frame(&mut app, &ctx, vec![button(at + vec2(180.0, 95.0), false, Modifiers::NONE)]); + let want = z0 * f64::from((rect.width() / 140.0).min(rect.height() / 75.0)); + assert!((app.view().unwrap().zoom - want).abs() < 1e-6, "{z0} → {}, not {want}", app.view().unwrap().zoom); + assert!(app.session.tool_wants_text(), "editing goes on"); + // With no marquee, Space types a space. + typing_frame(&mut app, &ctx, vec![space(true, Modifiers::NONE), Event::Text(" ".into())]); + typing_frame(&mut app, &ctx, vec![space(false, Modifiers::NONE)]); + assert_eq!(plain(&app, id), "a ", "Space types a space"); + // With Animated Zoom, Space during the Cmd+Space drag does not type a space either. + app.run("prefs.set", json!({"key": "animatedZoom", "value": true})).unwrap(); + typing_frame(&mut app, &ctx, vec![Event::ModifiersChanged(Modifiers::COMMAND), space(true, Modifiers::COMMAND), Event::PointerMoved(at)]); + typing_frame(&mut app, &ctx, vec![button(at, true, Modifiers::COMMAND)]); + typing_frame(&mut app, &ctx, vec![Event::ModifiersChanged(Modifiers::NONE), space(false, Modifiers::NONE)]); + typing_frame(&mut app, &ctx, vec![space(true, Modifiers::NONE), Event::Text(" ".into())]); + typing_frame(&mut app, &ctx, vec![button(at, false, Modifiers::NONE)]); + typing_frame(&mut app, &ctx, vec![space(false, Modifiers::NONE)]); + assert_eq!(plain(&app, id), "a ", "the text is as typed"); +} + #[test] fn space_shift_drag_rotates_the_view_whatever_the_tool() { use egui::{Event, Modifiers}; diff --git a/crates/ui-egui/src/shortcuts/typing.rs b/crates/ui-egui/src/shortcuts/typing.rs index cee164c7f8..2befac02c3 100644 --- a/crates/ui-egui/src/shortcuts/typing.rs +++ b/crates/ui-egui/src/shortcuts/typing.rs @@ -42,6 +42,8 @@ enum Seq { Text(String), Preedit(String, Option<std::ops::Range<usize>>), Commit(String), + /// A space the IME commits during a Zoom tool drag on the canvas, where Space moves the marquee. + MarqueeSpace, Erase(ToolKey, Mods), /// An input method replaces text around the composition (upstream's character counts or /// the fork's exact UTF-8 byte counts), then commits. @@ -82,6 +84,11 @@ pub(super) fn type_text(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { // Set once the IME commits text in this frame. let mut committed = false; for e in seq { + // With text marked, the IME's space commits that text as usual. + let e = match e { + Seq::MarqueeSpace if app.session.tool_composing() || app.ime_marked.is_some() => Seq::Commit(" ".into()), + e => e, + }; // Before the UI, a changed composition or guard is settled `pending`: a token bound here // could outlive a route this pass invalidates later (a palette/dialog/Home) and attach to // the stock descriptor. The post-UI finalizer binds the confirmed replacement. @@ -94,10 +101,16 @@ pub(super) fn type_text(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { match &e { // Accepted old payloads precede the fence even when their terminal arrives. // None of these events proves the local reset has reached its boundary. - Seq::Commit(_) | Seq::DeleteSurrounding(..) | Seq::Preedit(..) => continue, + Seq::Commit(_) | Seq::MarqueeSpace | Seq::DeleteSurrounding(..) | Seq::Preedit(..) => continue, _ => {} } } + // Otherwise the IME's input ends there, and the space is not typed. + if matches!(e, Seq::MarqueeSpace) { + committed = true; + app.ime_compositions.remove(&viewport); + continue; + } // A pointer/navigation/command notice has not reached its real handler yet. Text and // erases after it belong to the old caret, not to the destination it will establish. if crate::ime::deferred(app, ctx) { @@ -135,10 +148,11 @@ pub(super) fn type_text(app: &mut VectorcraftApp, ctx: &egui::Context) -> bool { } /// Take this frame's typed text, IME events, editing keys, Enter and clipboard events, in the order -/// they arrived. +/// they arrived. A space typed during the canvas's Zoom tool drag is not typed. fn type_sequence(ctx: &egui::Context) -> Vec<Seq> { let mut seq = vec![]; let mut edits = vec![]; + let zooming = crate::canvas::dragging_zoom(ctx); ctx.input_mut(|i| { // Move the events out instead of cloning their strings: a keyboard hook that reinjects a // batch keeps the batch in `seq` only, not in both the input list and a second copy. @@ -155,10 +169,13 @@ fn type_sequence(ctx: &egui::Context) -> Vec<Seq> { .unwrap_or_else(|| i.pointer.primary_down()); for e in std::mem::take(&mut i.events) { match e { + // The zoom drag lasts until the primary button goes up. + egui::Event::Text(t) if zooming && primary_down && t == " " => {} egui::Event::Text(t) => seq.push(Seq::Text(t)), egui::Event::Ime(egui::ImeEvent::Preedit { text, active_range_chars }) => { seq.push(Seq::Preedit(text, active_range_chars)); } + egui::Event::Ime(egui::ImeEvent::Commit(t)) if zooming && primary_down && t == " " => seq.push(Seq::MarqueeSpace), egui::Event::Ime(egui::ImeEvent::Commit(t)) => seq.push(Seq::Commit(t)), egui::Event::Ime(egui::ImeEvent::DeleteSurrounding { before_chars, after_chars }) => { seq.push(Seq::DeleteSurrounding(before_chars, after_chars, SurroundingUnit::Chars)); @@ -254,7 +271,7 @@ fn apply_type_event( } Ok(vec![]) } - Seq::ResetCompleted(_) => Ok(vec![]), + Seq::ResetCompleted(_) | Seq::MarqueeSpace => Ok(vec![]), // Keys the IME passed through come as text only when nothing is marked. This is an // application edit (also a hook IME's reinjected characters): `Other` dominates. Seq::Text(t) if !app.session.tool_composing() && !shortcut_mods => { diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..38de56892f 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1152,6 +1152,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Space held while the Zoom tool drags a marquee moves the marquee and keeps its size ([Default keyboard shortcuts](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)). When Space is let go, the drag sizes the marquee again from where it moved to. A Space+Shift drag rotates the view whatever the tool, as a Rotate View tool drag does, and Shift does not round the angle to 15°. While the Type tool edits text, Space types a space: held, it does not show the hand, pan or rotate the view, and Cmd+Space still zooms ([the help page](https://web.archive.org/web/20260726060015/https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html) lists the Spacebar as the Hand tool when not in text-edit mode). Test: `canvas::tests::space_types_a_space_while_editing_text_and_does_not_pan`. + As VectorCraft's own rule, a zoom marquee that Cmd+Space starts while the Type tool edits text keeps the marquee's Space rules after Cmd is let go: Space held since the press sizes it, Space pressed again moves it ([the help page](https://helpx.adobe.com/illustrator/using/viewing-artwork.html) describes holding the spacebar to move the marquee), and that Space types no space, nor does it during an animated zoom drag. With no zoom drag, Space types a space. Test: `canvas::tests::space_moves_a_text_edit_zoom_marquee_after_cmd_is_let_go`. - **Swatches panel clicks:** Ctrl/Cmd-clicking New Swatch makes a spot color, and Ctrl/Cmd+Shift-clicking it makes a global process color. - **Panel drag and drop:** art dragged off the canvas onto the Symbols panel becomes a symbol, art dragged onto the Swatches panel becomes a pattern swatch, and art dropped on the Brushes panel opens New Brush for that art; a symbol dragged onto the canvas places an instance where it is dropped, and a brush dragged onto a path is applied to it. New Brush asks for the type of brush first, as the [Brushes](https://web.archive.org/web/20241230205225/https://helpx.adobe.com/illustrator/using/brushes.html) page (archived copy) describes. The Brushes panel's New Brush button, its menu's New Brush… and art dropped on the panel open the New Brush dialog, where Scatter Brush, Art Brush and Pattern Brush need selected or dropped art. OK opens that type's Brush Options for the new brush, and their OK makes the brush with the name and options set; Cancel in either dialog adds no brush (`ui.newBrush`). The menu's New Calligraphic Brush, New Bristle Brush and New Art, Scatter and Pattern Brush from Selection items still make a brush at once. From 5803d2da4a2f887c4313410c592e230c5b5e760f Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:26:28 -0800 Subject: [PATCH 084/108] Fix #7411: a selection grabbed by an anchor snaps it onto other paths With Smart Guides on, a selection the Selection tool grabbed by one of its anchors only landed that anchor on other anchors and centers, or lined its bounds up. The anchor now also lands on the other objects' paths ("path"), and where a path crosses another path or a ruler guide ("intersect"), in the order Direct Selection uses for a dragged anchor. When the anchor lands on a path, the bounds do not also line up with other objects, and a ruler guide nearby does not pull it off the path. A selection grabbed anywhere else keeps lining its bounds up. - Targets::for_move_by_anchor gathers the other art's path segments as well, and Targets::snap_onto_path lands a point on them or on their crossings with each other and with the ruler guides. - MoveSnap::by_anchor uses those targets; the Selection tool picks it when the press grabbed an anchor. Reported by pivot-al. Docs: docs/target-app-parity.md. --- crates/tools/src/guides/targets.rs | 38 ++++++++++++- crates/tools/src/select.rs | 68 +++++++++++++++++------ crates/tools/src/select/tests.rs | 88 ++++++++++++++++++++++++++++++ docs/target-app-parity.md | 2 +- 4 files changed, 176 insertions(+), 20 deletions(-) diff --git a/crates/tools/src/guides/targets.rs b/crates/tools/src/guides/targets.rs index fa31174afa..e3e6abeef6 100644 --- a/crates/tools/src/guides/targets.rs +++ b/crates/tools/src/guides/targets.rs @@ -36,7 +36,8 @@ pub struct Targets { pub(super) xs: Vec<(f64, Point, Kind)>, pub(super) ys: Vec<(f64, Point, Kind)>, /// Path segments and their control bounds, which a point lands on ("path"): gathered only for - /// dragged anchors ([`Self::for_anchor_drag`]). + /// dragged anchors ([`Self::for_anchor_drag`]) and selections moved by an anchor + /// ([`Self::for_move_by_anchor`]). pub(super) segments: Vec<(Rect, PathSeg)>, /// Ruler guides, which pull a point into line where they run (Snap to Point). pub(super) rulers: Vec<Ruler>, @@ -170,7 +171,18 @@ impl Targets { /// Guides › Snap to Last Location, a move (not a copy, which has nothing in `exclude`) goes back /// to where it began when it comes near ([`Self::snap_back`]), unless Snap to Pixel snaps moves. pub fn for_move(cx: &ToolContext, exclude: &[NodeId]) -> Self { - let mut t = Self::collect(cx.doc, exclude, None).styled(cx); + Self::moving(cx, exclude, Gather::Bounds) + } + + /// [`Self::for_move`]'s targets for a selection moved by one of its anchors (#7411): the path + /// segments of the art but `exclude` too, which that anchor lands on ([`Self::snap_onto_path`]), + /// as a dragged anchor does with Direct Selection. + pub fn for_move_by_anchor(cx: &ToolContext, exclude: &[NodeId]) -> Self { + Self::moving(cx, exclude, Gather::Segments) + } + + fn moving(cx: &ToolContext, exclude: &[NodeId], gather: Gather) -> Self { + let mut t = Self::collect_inner(cx.doc, exclude, None, None, gather).styled(cx); if cx.spacing_guides { t.boxes = object_boxes(cx.doc, &cx.selection.objects); } @@ -858,6 +870,21 @@ impl Targets { self.line(from, q).into_iter().chain(self.label(q, "align")).collect() } + /// A point `p` near no target anchor or center landed where two target paths cross + /// ("intersect"), else on the nearest target path ("path"), within `tol`: the point and its + /// label, as [`Self::snap_point`] lands it. The ruler guides of `rulers` count as paths that + /// cross ([`Self::rulers`]). None when no path is in reach, or the targets hold no segments. + pub(crate) fn snap_onto_path(&self, p: Point, tol: f64, rulers: Option<&Targets>) -> Option<(Point, Vec<Overlay>)> { + if self.segments.is_empty() { + return None; + } + if let Some(q) = self.crossing_with(p, tol, rulers.map_or(&self.rulers, |r| &r.rulers)) { + return Some((q, self.label(q, "intersect").into_iter().collect())); + } + let q = self.on_segment(p, tol)?; + Some((q, self.label(q, Kind::Edge.label()).into_iter().collect())) + } + /// The nearest point within `tol` of `p` on a target segment. fn on_segment(&self, p: Point, tol: f64) -> Option<Point> { self.segments @@ -872,6 +899,11 @@ impl Targets { /// Where two target paths, a path and a ruler guide, or two ruler guides cross, the crossing /// nearest `p` within `tol` ("intersect", #1602). fn crossing(&self, p: Point, tol: f64) -> Option<Point> { + self.crossing_with(p, tol, &self.rulers) + } + + /// [`Self::crossing`] with the ruler guides `rulers`. + fn crossing_with(&self, p: Point, tol: f64, rulers: &[Ruler]) -> Option<Point> { // A ruler guide running past, as a short line through the reach of `p`. let ruler = |r: &Ruler| { let (pos, ..) = r.line_at(p, tol)?; @@ -885,7 +917,7 @@ impl Targets { .iter() .filter(|(b, c)| b.inflate(tol, tol).contains(p) && c.nearest(p, 1e-6).distance_sq <= tol * tol) .map(|(_, c)| *c) - .chain(self.rulers.iter().filter_map(ruler)) + .chain(rulers.iter().filter_map(ruler)) // shortcut: the first 32 lines in reach are paired, raise it if busier crossings matter .take(32) .collect(); diff --git a/crates/tools/src/select.rs b/crates/tools/src/select.rs index 70060ebc2b..76e4a5c977 100644 --- a/crates/tools/src/select.rs +++ b/crates/tools/src/select.rs @@ -94,6 +94,9 @@ enum State { /// The point that snaps, moving with the pointer: `start`, or where a press on a path's /// stroke or beside its edge took hold of the path ([`hold_point`]). hold: Point, + /// The press grabbed the selection by an anchor (`start`): it snaps as + /// [`MoveSnap::by_anchor`] says. + by_anchor: bool, began: bool, /// Shift-pressed on this selected object: released without a drag, it leaves the /// selection. @@ -247,13 +250,24 @@ pub(crate) struct MoveSnap { impl MoveSnap { pub(crate) fn new(cx: &ToolContext) -> Self { + Self::gather(cx, Targets::for_move) + } + + /// [`Self::new`] for a selection grabbed by one of its anchors: with Smart Guides, that anchor + /// also lands on the other art's paths and where they cross (#7411), as Direct Selection lands + /// an anchor it drags. + pub(crate) fn by_anchor(cx: &ToolContext) -> Self { + Self::gather(cx, Targets::for_move_by_anchor) + } + + fn gather(cx: &ToolContext, for_move: fn(&ToolContext, &[NodeId]) -> Targets) -> Self { let guides = cx.smart_guides && !cx.snap_to_grid; let points = |exclude: &[NodeId]| if cx.snap_to_grid { None } else { Targets::snap_to_point(cx, exclude) }; Self { bounds: selection_bounds(cx), - targets: guides.then(|| Targets::for_move(cx, &cx.selection.objects)), + targets: guides.then(|| for_move(cx, &cx.selection.objects)), points: points(&cx.selection.objects), - copy_targets: guides.then(|| Targets::for_move(cx, &[])), + copy_targets: guides.then(|| for_move(cx, &[])), copy_points: points(&[]), rulers: (guides && cx.snap_to_point).then(|| Targets::rulers(cx)), } @@ -286,6 +300,9 @@ impl MoveSnap { } // The axes (x, y) Smart Guides already put in line with other art. let mut taken = [false; 2]; + // The grabbed anchor landed on a path or a crossing, which a ruler guide does not pull + // it off. + let mut on_path = false; if let (Some(t), Some(b)) = (targets, self.bounds) { // The point the selection was grabbed by, near another object's anchor or centre, // lands on it, rather than the bounds lining up a little beside it (#955). @@ -294,6 +311,13 @@ impl MoveSnap { d = q - start; guides = ov; taken = [true; 2]; + } else if let Some((q, ov)) = t.snap_onto_path(start + d, cx.snap_tol(), self.rulers.as_ref()) { + // Grabbed by an anchor ([`Self::by_anchor`]), it lands on a path near it, or where + // the path crosses another or a ruler guide, instead of lining the bounds up. + d = q - start; + guides = ov; + taken = [true; 2]; + on_path = true; } else { let (adj, ov, axes) = t.snap_rects_axes(&[b + d], cx.snap_tol()); d += adj; @@ -304,7 +328,7 @@ impl MoveSnap { // A ruler guide within reach of the grabbed point wins over lining the bounds up; on an // axis without one that Smart Guides left free, the bounds line up with the ruler guides // (#5746), alongside the Smart Guides. - if let Some(t) = &self.rulers { + if let Some(t) = self.rulers.as_ref().filter(|_| !on_path) { let (adj, ov, held) = t.snap_moved_to_rulers(start + d, self.bounds.map(|b| b + d), cx.snap_tol(), taken); if adj != Vec2::ZERO { d += adj; @@ -681,6 +705,15 @@ impl SelectionTool { }) } + /// The point a press `ev` grabs the selection by ([`Self::hover_point`]), and whether it is an + /// anchor. Nothing for other pointer events. + fn grabbed_at(cx: &ToolContext, ev: &PointerEvent) -> (Option<Point>, bool) { + match ev.kind { + PointerKind::Down => Self::hover_point(cx, ev.pos).map_or((None, false), |(q, label)| (Some(q), label == "anchor")), + _ => (None, false), + } + } + /// On a press, notes the text the pointer is loaded with ([`Self::loaded_at_press`]); a /// release clears it. fn note_loaded_at_press(&mut self, kind: PointerKind) { @@ -913,7 +946,7 @@ impl Tool for SelectionTool { let m = ev.mods; // A press near a centre or an anchor grabs the object by it. self.hover = None; - let grabbed = if matches!(ev.kind, PointerKind::Down) { Self::hover_point(cx, p).map(|(q, _)| q) } else { None }; + let (grabbed, by_anchor) = Self::grabbed_at(cx, ev); let grab = grabbed.unwrap_or(p); if matches!(ev.kind, PointerKind::Move) && matches!(self.state, State::Idle) { self.hover = Self::hover_point(cx, p); @@ -939,7 +972,7 @@ impl Tool for SelectionTool { { let several = cx.selection.objects.len() > 1 || !cx.selection.guides.is_empty(); let (deselect, key) = if m.shift { (Some(id), None) } else { (None, (several && !m.alt).then_some(id)) }; - self.state = State::Moving { start: p, press: p, hold: center, began: false, deselect, key, exclude: None }; + self.state = State::Moving { start: p, press: p, hold: center, by_anchor: false, began: false, deselect, key, exclude: None }; return vec![]; } // 3. Objects: Cmd/Ctrl-click selects the one under the selected one (cycling). @@ -947,7 +980,8 @@ impl Tool for SelectionTool { && cx.select_behind && let Some(behind) = object_behind(cx, p) { - self.state = State::Moving { start: p, press: p, hold: p, began: false, deselect: None, key: None, exclude: None }; + self.state = + State::Moving { start: p, press: p, hold: p, by_anchor: false, began: false, deselect: None, key: None, exclude: None }; return vec![Action::Exec("select.set".into(), json!({ "ids": [behind.0] }))]; } let (hit, scope) = match selected_source_hit(cx, p) { @@ -969,17 +1003,17 @@ impl Tool for SelectionTool { // Grabbed by no anchor or centre, a press on a path's stroke or beside its // edge holds the path there, and that point of it snaps (#3701). let hold = if grabbed.is_some() { grab } else { hold_point(cx, &h, p) }; - self.state = State::Moving { start: grab, press: p, hold, began: false, deselect, key, exclude }; + self.state = State::Moving { start: grab, press: p, hold, by_anchor, began: false, deselect, key, exclude }; out } None => { - self.press_nothing(cx, p, grab, m); + self.press_nothing(cx, p, grab, by_anchor, m); vec![] } } } - (PointerKind::Drag, State::Moving { start, press, hold, began, exclude, .. }) => { - self.drag_moving(cx, p, m, ev.backquote, (start, press, hold, began), exclude) + (PointerKind::Drag, State::Moving { start, press, hold, by_anchor, began, exclude, .. }) => { + self.drag_moving(cx, p, m, ev.backquote, (start, press, hold, by_anchor, began), exclude) } (PointerKind::Drag, State::Scaling { handle, bx, areas }) => { self.last_backquote = ev.backquote; @@ -1679,9 +1713,10 @@ impl SelectionTool { /// A press at `p` that hits no object starts a marquee, except where a clipping mask hides /// the art of a selected object (picked in the Layers panel, say): there, without Shift, it /// grabs the selection by that art (at `grab`), as a press on its visible part does. - fn press_nothing(&mut self, cx: &ToolContext, p: Point, grab: Point, m: Mods) { + /// `by_anchor`: `grab` is an anchor of it. + fn press_nothing(&mut self, cx: &ToolContext, p: Point, grab: Point, by_anchor: bool, m: Mods) { self.state = if !m.shift && selected_hidden_at(cx.doc, p, cx.selection_hit_options(), &cx.selection.objects).is_some() { - State::Moving { start: grab, press: p, hold: grab, began: false, deselect: None, key: None, exclude: None } + State::Moving { start: grab, press: p, hold: grab, by_anchor, began: false, deselect: None, key: None, exclude: None } } else { State::Marquee { start: p, cur: p, toggle: m.shift, enclosed: false, directional_inside: false } }; @@ -1693,7 +1728,7 @@ impl SelectionTool { p: Point, m: Mods, backquote: bool, - (start, press, hold, began): (Point, Point, Point, bool), + (start, press, hold, by_anchor, began): (Point, Point, Point, bool, bool), exclude: Option<(NodeId, NodeId)>, ) -> Vec<Action> { let mut out = vec![]; @@ -1701,6 +1736,7 @@ impl SelectionTool { if p.distance(press) < Self::drag_threshold(cx) { return out; } + let gather = if by_anchor { MoveSnap::by_anchor } else { MoveSnap::new }; // A Shift-drag from a highlighted object of the Global Edit selects it and moves it // with the selection: its snap targets are gathered for the selection with it. self.moving = Some(match exclude { @@ -1708,9 +1744,9 @@ impl SelectionTool { out.push(Action::Exec("select.toggle".into(), json!({ "id": top.0 }))); let mut selection = cx.selection.clone(); selection.add(top); - MoveSnap::new(&ToolContext { selection: &selection, ..*cx }) + gather(&ToolContext { selection: &selection, ..*cx }) } - None => MoveSnap::new(cx), + None => gather(cx), }); out.push(Action::Begin(if m.alt { "Copy".into() } else { "Move".into() })); } @@ -1721,7 +1757,7 @@ impl SelectionTool { } // Shift has already constrained `d`: any change is a snap. self.snapped = (d - unsnapped).hypot() > 1e-9; - self.state = State::Moving { start, press, hold, began: true, deselect: None, key: None, exclude: None }; + self.state = State::Moving { start, press, hold, by_anchor, began: true, deselect: None, key: None, exclude: None }; self.measure = cx.measurement_labels.then(|| (p, cx.offset_label(d.x, d.y))); let mut params = json!({ "matrix": matrix_json(Affine::translate(d)), "copy": m.alt }); if backquote { diff --git a/crates/tools/src/select/tests.rs b/crates/tools/src/select/tests.rs index 63ca697c7d..b7af316571 100644 --- a/crates/tools/src/select/tests.rs +++ b/crates/tools/src/select/tests.rs @@ -171,6 +171,94 @@ fn a_move_grabbed_by_an_anchor_lands_it_on_another_anchor() { assert!((200.0 + x - 350.3).abs() < 1e-9 && (200.0 + y - 250.0).abs() < 1e-9, "the corner lands at ({}, {})", 200.0 + x, 200.0 + y); } +/// A document with the rectangle of [`doc_with_rect`] (100..200 square) and a straight path from +/// `a` to `b` for each pair, and the rectangle's id. +fn doc_with_rect_and_lines(lines: &[(Point, Point)]) -> (vectorcraft_doc::Document, NodeId) { + let (mut d, id) = doc_with_rect(); + let l = d.layers[0].id; + for &(a, b) in lines { + let n = d.alloc_id(); + let path = vectorcraft_geom::PathData::single(vectorcraft_geom::SubPath::polyline(&[a, b], false)); + d.insert(Some(l), 1, vectorcraft_doc::Node::path(n, path, vectorcraft_doc::Appearance::default_art())).unwrap(); + } + (d, id) +} + +/// The rectangle of `d` grabbed at `(gx, gy)` (hovered first, so a press near an anchor grabs it) +/// and dragged to `to`, with Smart Guides on or off (`smart`): the point it was grabbed at after the +/// move, and the label shown. +fn grabbed_and_dragged(d: &vectorcraft_doc::Document, id: NodeId, smart: bool, (gx, gy): (f64, f64), to: (f64, f64)) -> (Point, Option<String>) { + let (none, mut picked, p) = (Selection::default(), Selection::default(), paint()); + picked.add(id); + let (before, after) = (ToolContext { smart_guides: smart, ..cx(d, &none, &p) }, ToolContext { smart_guides: smart, ..cx(d, &picked, &p) }); + let mut t = SelectionTool::default(); + t.pointer(&before, &ev(PointerKind::Move, gx, gy)); + t.pointer(&before, &ev(PointerKind::Down, gx, gy)); + let a = t.pointer(&after, &ev(PointerKind::Drag, to.0, to.1)); + let Some(Action::Preview(_, v)) = a.iter().find(|a| matches!(a, Action::Preview(..))) else { panic!("{a:?}") }; + let start = SelectionTool::hover_point(&before, Point::new(gx, gy)).map_or(Point::new(gx, gy), |(q, _)| q); + let label = t.overlays(&after).iter().find_map(|o| match o { + Overlay::Label { text, .. } => Some(text.clone()), + _ => None, + }); + (start + Vec2::new(v["matrix"][4].as_f64().unwrap(), v["matrix"][5].as_f64().unwrap()), label) +} + +/// #7411: grabbed by an anchor and dropped near a point along another path, away from its anchors +/// and center, the anchor lands on the path ("path") with Smart Guides. A selection grabbed +/// elsewhere, or with Smart Guides off, does not land on the path. +#[test] +fn a_move_grabbed_by_an_anchor_lands_it_on_another_path() { + let (a, b) = (Point::new(300.0, 400.0), Point::new(500.0, 300.0)); + let (d, id) = doc_with_rect_and_lines(&[(a, b)]); + let off_line = |q: Point| ((b - a).cross(q - a) / (b - a).hypot()).abs(); + // Grab the rectangle by its bottom-right corner (200, 200) and drop it half a point beside + // the line, at (430, 335) on it. + let (corner, label) = grabbed_and_dragged(&d, id, true, (201.0, 201.0), (430.0, 335.5)); + assert!(off_line(corner) < 1e-9, "the corner lands at {corner:?}, {} off the line", off_line(corner)); + assert!((corner.x - 430.0).abs() < 0.5, "{corner:?}"); + assert_eq!(label.as_deref(), Some("path")); + // Grabbed by its fill instead, the pointer stays half a point beside the line. + let (grip, _) = grabbed_and_dragged(&d, id, true, (150.0, 170.0), (430.0, 335.5)); + assert!(off_line(grip) > 0.4, "the grip lands at {grip:?}"); + // With Smart Guides off, the corner stays where it was dragged. + let (corner, _) = grabbed_and_dragged(&d, id, false, (201.0, 201.0), (430.0, 335.5)); + assert!(off_line(corner) > 0.4, "the corner lands at {corner:?}"); +} + +/// #7411: a selection grabbed by an anchor lands it where two other paths cross ("intersect"), and +/// on another object's anchor near the path rather than on the path. +#[test] +fn a_move_grabbed_by_an_anchor_lands_it_where_paths_cross() { + let (d, id) = + doc_with_rect_and_lines(&[(Point::new(300.0, 400.0), Point::new(500.0, 300.0)), (Point::new(460.0, 250.0), Point::new(460.0, 420.0))]); + let (corner, label) = grabbed_and_dragged(&d, id, true, (201.0, 201.0), (460.4, 320.5)); + assert!(corner.distance(Point::new(460.0, 320.0)) < 1e-9, "the corner lands at {corner:?}"); + assert_eq!(label.as_deref(), Some("intersect")); + // The end of the upright path (460, 250) is an anchor: the corner lands on it. + let (corner, label) = grabbed_and_dragged(&d, id, true, (201.0, 201.0), (460.5, 251.0)); + assert!(corner.distance(Point::new(460.0, 250.0)) < 1e-9, "the corner lands at {corner:?}"); + assert_eq!(label.as_deref(), Some("anchor")); +} + +/// #7411: a selection grabbed by an anchor lands it where another path crosses a ruler guide +/// ("intersect"), and a ruler guide running past does not pull it off a path it landed on. +#[test] +fn a_move_grabbed_by_an_anchor_lands_it_where_a_path_crosses_a_ruler_guide() { + let (a, b) = (Point::new(300.0, 400.0), Point::new(500.0, 300.0)); + let (mut d, id) = doc_with_rect_and_lines(&[(a, b)]); + d.add_ruler_guide(&vectorcraft_doc::Guide::new(true, 440.0)); + let (corner, label) = grabbed_and_dragged(&d, id, true, (201.0, 201.0), (440.5, 330.5)); + assert!(corner.distance(Point::new(440.0, 330.0)) < 1e-9, "the corner lands at {corner:?}"); + assert_eq!(label.as_deref(), Some("intersect")); + // Beyond reach of the crossing, the corner stays on the path with the guide 3.7 points beside + // it. + let off_line = |q: Point| ((b - a).cross(q - a) / (b - a).hypot()).abs(); + let (corner, label) = grabbed_and_dragged(&d, id, true, (201.0, 201.0), (436.43, 332.12)); + assert!(off_line(corner) < 1e-9, "the corner lands at {corner:?}"); + assert_eq!(label.as_deref(), Some("path")); +} + /// #3716: a press a few pixels from an anchor grabs the object by that anchor, but the drag /// threshold counts from where the pointer went down. A click that wobbles by a pixel selects /// the object without moving it, instead of jumping the anchor onto the pointer. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..7b701bb398 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1201,7 +1201,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur Layer Options for several highlighted rows shows the first row's settings, and OK changes only the settings set in the dialog: each row keeps its own color, Template, Lock, Show, Print, Preview and Dim Images otherwise (`crates/ui-egui/src/dialogs/layer_options.rs` tests). As VectorCraft's own rule, a layer color (`layer.setProps`, `layer.new`, `layer.newSublayer`) or a Live Paint Gap Preview Color (`livePaint.gapOptions`) given as a hex color with an alpha part (`#rrggbbaa` or `#rgba`) is an error and changes nothing, instead of being set without its alpha. Regression tests: `a_layer_color_with_an_alpha_part_is_refused` in `crates/engine/src/tests/layers.rs` and `a_gap_color_with_an_alpha_part_is_refused` in `crates/engine/src/tests/build.rs`. Panel Options › Locate Selected Objects (beyond Illustrator, off by default): when the last selected object changes on the canvas or by a command, the panel opens the layers and groups around it and scrolls to its row, as Locate Object does, without highlighting the row; when Show Layers Only, a search or the filter leaves the object without a row, the panel opens no rows for it and scrolls as with the option off. -- **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges is nearest a gridline on each axis (the center does not snap), #740, #1816; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes. Smart Guides: a point drawn with the Pen or a shape tool, and an anchor dragged with Direct Selection, snaps to where paths and ruler guides cross, labelled "intersect" (#1658, part of #1602; a moved selection's own anchors don't). With Smart Guides › Measurement Labels on, the Line Segment tool labels the segment being drawn with its distance, angle and X and Y offsets (`D`, `Angle`, `dX`, `dY`), and the Pen, Curvature and Smart Pen tools label their rubber band the same way when Enable Rubber Band is on (#2983). +- **Drawing aids:** Smart Guides and snapping (moving, with the Selection, Group Selection or Direct Selection tool, and resizing by the bounding-box handles with the Selection or Free Transform tool, Shift and Alt too: the dragged corner or side lands on the other objects' anchors and centres ("anchor", "center") or lines up with their edges and centres (a line and "align"); with Smart Guides › Spacing Guides, a moved selection that lines up with nothing along an axis lands as far from its neighbour as two other objects of its row or column are apart, or halfway between its two neighbours, the equal gaps marked; with View › Snap to Grid on, a moved selection lands on the grid instead, by whichever of its edges is nearest a gridline on each axis (the center does not snap), #740, #1816; the Rotate, Scale, Shear and Reflect tools drag from the anchor they grab and snap the pointer the same way, so a corner dragged onto another object's anchor scales exactly onto it, #482; anchors dragged with Direct Selection: the one pressed on lands on other anchors, its own path's that stay put among them, on path segments or in line with them, the others following, Shift keeps 45° steps, and with Smart Guides off Snap to Point pulls it onto anchors; the Artboard tool snaps artboards, and their bleed, to other artboards, bleeds and art, the grid or whole pixels while moving, copying and resizing them, and the Transform panel shows and edits the active artboard's X/Y/W/H; drawn points, #506: hovering shows where the press goes, the point lands on the other objects' anchors, centres and paths ("anchor", "center", "path") or lines up with their anchors, edges and centres ("align"), the Pen's on the path being drawn too, near a construction guide through the anchor before it on that guide (Preferences › Smart Guides › Construction Guides and Angles), and with Shift kept to its 45° step or a square's diagonal it slides along that way into line; the targets are gathered once per document state, from the art in the window, and the anchors, centres and lines near the pointer are found by bisection, so hovering never rescans the document), guides dragged out of the rulers (#451: they snap as moved guides do, Shift to the ruler's ticks; with the Artboard tool they are artboard guides, which run across their artboard only and move, copy and delete with it, `guide.add {artboard}`) that the Selection, Direct Selection and Group Selection tools then pick and drag (#414: the selected guides highlight and move together, Alt copies them, Shift snaps the dragged one to the ticks, otherwise it snaps to pixels, the grid or the edges, centres (so the sides' midpoints) and anchors of the art and the artboards, or with Smart Guides off Snap to Point pulls it onto anchors; Shift-clicked they join the selected art, and Shift-added art keeps them, so guides and art are selected together in either order, Delete then deleting both in one step; the arrow keys nudge them, Delete deletes them, dragging one back onto its ruler deletes it, Lock Guides and Hide Guides leave them alone; `guide.list`, `guide.select`, `guide.move` and `guide.remove` reach agents), a right-click on either ruler or the origin box to pick the document's units (the current one checked; `document.setUnits`, one undo step, #528), and Draw Normal / Behind / Inside modes. Smart Guides: a point drawn with the Pen or a shape tool, and an anchor dragged with Direct Selection, snaps to where paths and ruler guides cross, labelled "intersect" (#1658, part of #1602; a moved selection's own anchors don't, except the anchor the Selection tool grabbed it by). A selection the Selection tool grabs by one of its anchors snaps that anchor onto the other objects' paths ("path"), and where a path crosses another path or a ruler guide ("intersect"), in the order Direct Selection uses for a dragged anchor; when the anchor lands on a path, the selection's bounds do not also line up with other objects (#7411). The archived 2007 [user guide](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=55) (page 49) says Smart Guides align the pointer of a moved object to existing paths. Snapping onto paths only when the selection was grabbed by an anchor is VectorCraft's own rule; a selection grabbed anywhere else still lines its bounds up. Tests: `select::tests::a_move_grabbed_by_an_anchor_lands_it_on_another_path`, `a_move_grabbed_by_an_anchor_lands_it_where_paths_cross` and `a_move_grabbed_by_an_anchor_lands_it_where_a_path_crosses_a_ruler_guide`. With Smart Guides › Measurement Labels on, the Line Segment tool labels the segment being drawn with its distance, angle and X and Y offsets (`D`, `Angle`, `dX`, `dY`), and the Pen, Curvature and Smart Pen tools label their rubber band the same way when Enable Rubber Band is on (#2983). A move that Shift keeps level, upright or diagonal stays on that line when it snaps, with the Selection, Group Selection or Direct Selection tool. It slides along the line until the selection lands on the grid or on whole pixels, lines up with the other objects or is spaced evenly with them, or until the line passes an anchor or crosses a ruler guide near the point the selection was grabbed by. A level or upright move snaps along its own axis only. Snap to Last Location: with Smart Guides on and Preferences › Smart Guides › Snap to Last Location on (off by default, VectorCraft's own choice), a selection moved by dragging with the Selection, Group Selection or Direct Selection tool, Shift too, goes back to where the move began while it is within Snapping Tolerance of it, labeled "last location"; an Alt copy is not pulled back onto its original, and with View › Snap to Grid or Snap to Pixel on the move snaps to the grid or to whole pixels instead (`prefs.set` key `snapToLastLocation`). The public [Smart Guides options](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/smart-guides-options.html) page lists the option as snapping objects back to their previous position; the distance, the label, the copy rule and the grid and pixel rule are VectorCraft's own. Tests: `select::tests::snap_to_last_location_puts_a_move_back_where_it_began`, `select::tests::snap_to_pixel_wins_over_snap_to_last_location`, `direct::tests::snap_to_last_location_puts_a_path_moved_by_its_anchor_back`, `direct::tests::snap_to_pixel_wins_over_snap_to_last_location_for_a_path_moved_by_its_anchor`, `tests_prefs::snap_to_last_location_puts_a_dragged_square_back`. Pixel Preview: with View › Pixel Preview on, the tools use no Smart Guides. Nothing snaps to Smart Guides or shows their guides, and Snap to Point acts as it does with Smart Guides off. View › Smart Guides keeps its setting and applies again when Pixel Preview is turned off. [Work with Smart Guides](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/work-with-smart-guides.html) says Smart Guides cannot be used while Pixel Preview is on. Tests: `tests::smartguides::pixel_preview_turns_smart_guides_off`, `canvas::tests::pixel_preview_stops_smart_guides_snapping_a_move`. From 48bbcb115d7eea6344086a1345194631bc86c980 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:43:24 -0800 Subject: [PATCH 085/108] SVG export: masked groups span their region only for effects that are written A fill or stroke that the export leaves out (hidden, unpainted or zero width) no longer adds the hidden rectangle for an effect on it. An instance of a dynamic symbol is checked in its overridden art, so an override that paints a fill or stroke with an effect still adds it. --- crates/svg/src/export/nodes.rs | 27 ++++++++++++++++-------- crates/svg/tests/it/blend_export.rs | 32 ++++++++++++++++++++++++++++- 2 files changed, 49 insertions(+), 10 deletions(-) diff --git a/crates/svg/src/export/nodes.rs b/crates/svg/src/export/nodes.rs index 73135df262..ea1d5ab95b 100644 --- a/crates/svg/src/export/nodes.rs +++ b/crates/svg/src/export/nodes.rs @@ -449,17 +449,24 @@ impl Writer<'_> { /// Do `n`, its fills and strokes, its members at any depth, its symbols' art or the art its /// live objects are written as have a visible raster effect (shadow, glow, blur, feather)? - /// Objects that aren't written (hidden ones, unless the options keep them) are skipped. The - /// walk keeps its own stack, and looks at each symbol's art once. + /// Objects that aren't written (hidden ones, unless the options keep them) are skipped, and so + /// are fills and strokes that [`Self::shape`] doesn't write (hidden, unpainted or zero-width). + /// An instance with overrides is looked at in the art it is written as + /// ([`vectorcraft_brush::instance_art`]). The walk keeps its own stack, and looks at each + /// symbol's art once, and at each instance's overridden art once. fn holds_raster(&self, n: &Node) -> bool { let mut stack: Vec<std::sync::Arc<Node>> = vec![]; - let mut symbols = std::collections::HashSet::new(); + let mut symbols: std::collections::HashSet<(String, Option<vectorcraft_doc::NodeId>)> = std::collections::HashSet::new(); + let paints = |i: &AppearanceItem| match i { + AppearanceItem::Fill(f) => f.visible && !f.paint.is_none(), + AppearanceItem::Stroke(s) => s.visible && !s.paint.is_none() && s.width > 0.0, + }; // Whether `n` itself has one; else its members, symbol art or expanded art go on the stack. let mut visit = |n: &Node, stack: &mut Vec<std::sync::Arc<Node>>| { if !(n.visible || self.opts.hidden_layers) { return false; } - if has_raster(&n.appearance.effects) || n.appearance.items.iter().any(|i| has_raster(i.effects())) { + if has_raster(&n.appearance.effects) || n.appearance.items.iter().any(|i| paints(i) && has_raster(i.effects())) { return true; } // A live object is written as its expanded art ([`Self::node_body`]), which holds no @@ -471,11 +478,13 @@ impl Writer<'_> { return false; } } - if let NodeKind::SymbolInstance { symbol, .. } = &n.kind - && symbols.insert(symbol.clone()) - && let Some(s) = self.doc.symbols.iter().find(|s| s.name == *symbol) - { - stack.push(s.art.clone()); + if let NodeKind::SymbolInstance { symbol, .. } = &n.kind { + let custom = !n.extras().symbol_overrides.is_empty(); + if symbols.insert((symbol.clone(), custom.then_some(n.id))) + && let Some(s) = self.doc.symbols.iter().find(|s| s.name == *symbol) + { + stack.push(if custom { std::sync::Arc::new(vectorcraft_brush::instance_art(&s.art, n)) } else { s.art.clone() }); + } } stack.extend(n.children().into_iter().flatten().cloned()); false diff --git a/crates/svg/tests/it/blend_export.rs b/crates/svg/tests/it/blend_export.rs index 1a46a43a4c..ec947041b0 100644 --- a/crates/svg/tests/it/blend_export.rs +++ b/crates/svg/tests/it/blend_export.rs @@ -261,9 +261,12 @@ fn a_masked_group_spans_its_region_when_its_art_paints_past_its_shapes() { InGroup, InNestedGroup, FillEffect, + HiddenFill, + UnpaintedStroke, HiddenInGroup, Brushed, InSymbol, + OverriddenSymbol, InBlend, } use Case::*; @@ -275,11 +278,17 @@ fn a_masked_group_spans_its_region_when_its_art_paints_past_its_shapes() { (InNestedGroup, true, true), (FillEffect, true, true), (FillEffect, false, false), + // A fill or stroke that isn't written doesn't count. + (HiddenFill, true, false), + (UnpaintedStroke, true, false), (HiddenInGroup, true, false), (Brushed, false, false), (Brushed, true, true), (InSymbol, true, true), (InSymbol, false, false), + // An unpainted fill in a dynamic symbol's art that the instance paints counts. + (OverriddenSymbol, true, true), + (OverriddenSymbol, false, false), (InBlend, true, true), (InBlend, false, false), ] { @@ -290,15 +299,28 @@ fn a_masked_group_spans_its_region_when_its_art_paints_past_its_shapes() { stroke.brush = Some("Bristle Round".into()); red.appearance.items.push(vectorcraft_doc::AppearanceItem::Stroke(stroke)); } + if matches!(case, UnpaintedStroke) { + red.appearance.items.push(vectorcraft_doc::AppearanceItem::Stroke(vectorcraft_doc::StrokeLayer::new(Paint::None, 8.0))); + } if shadowed { match case { - FillEffect => red.appearance.items[0].effects_mut().push(drop_shadow()), + FillEffect | HiddenFill | OverriddenSymbol => red.appearance.items[0].effects_mut().push(drop_shadow()), + UnpaintedStroke => red.appearance.items.last_mut().unwrap().effects_mut().push(drop_shadow()), _ => red.appearance.effects.push(drop_shadow()), } } + if matches!(case, HiddenFill) + && let vectorcraft_doc::AppearanceItem::Fill(f) = &mut red.appearance.items[0] + { + f.visible = false; + } + if matches!(case, OverriddenSymbol) { + red.appearance.set_fill(Paint::None); + } let group = |d: &mut Document, n: Node| Node::group(d.alloc_id(), vec![n.into()]); let mut masked = match case { Alone | FillEffect => red, + HiddenFill | UnpaintedStroke => group(&mut d, red), InGroup | Brushed => group(&mut d, red), InNestedGroup => { let inner = group(&mut d, red); @@ -313,6 +335,14 @@ fn a_masked_group_spans_its_region_when_its_art_paints_past_its_shapes() { let instance = Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: "Square".into(), xf: vectorcraft_geom::Affine::IDENTITY }); group(&mut d, instance) } + OverriddenSymbol => { + d.symbols.push(vectorcraft_doc::Symbol { dynamic: true, name: "Square".into(), art: std::sync::Arc::new(red) }); + let mut instance = + Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: "Square".into(), xf: vectorcraft_geom::Affine::IDENTITY }); + let fill = Some(Paint::solid(Color::rgb8(255, 0, 0))); + instance.extras_mut().symbol_overrides.push(vectorcraft_doc::symbol_overrides::SymbolOverride { fill, ..Default::default() }); + group(&mut d, instance) + } InBlend => { let mut blue = rect(&mut d, Rect::new(60.0, 10.0, 80.0, 30.0), [0, 0, 255]); blue.appearance.effects = red.appearance.effects.clone(); From fe82f68d6ff6c894ae1610734571e1ecc3234044 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:39:50 -0800 Subject: [PATCH 086/108] TIFF: a 16-bit CMYK or gray TIFF with alpha converts at 16 bits Place, Open and relink read a CMYK or grayscale TIFF with an alpha channel through extra_samples_tiff_rgba, which cut every 16-bit sample to its high byte before converting it. A faint ink or a low alpha was lost: cyan 129 at full alpha showed as white, and an alpha of 129 became fully transparent. The samples are now normalized at the depth the file stores them, and only the resulting color and alpha are rounded to 8 bits (a 16-bit alpha to the nearest 8-bit value). Associated alpha is divided out at 16 bits. A pixel whose associated alpha is zero now has no color, instead of keeping its stored color. TIFF 6.0's Associated Alpha Handling section states this arithmetic and the zero-alpha rule for RGB data; applying them to CMYK and gray samples is VectorCraft's own rule. --- crates/doc/src/cmyk.rs | 125 ++++++++++++++++++++++---- crates/engine/src/cmd/fileio/tests.rs | 16 ++++ docs/target-app-parity.md | 1 + 3 files changed, 126 insertions(+), 16 deletions(-) diff --git a/crates/doc/src/cmyk.rs b/crates/doc/src/cmyk.rs index e89d63cb54..ad52eea1a2 100644 --- a/crates/doc/src/cmyk.rs +++ b/crates/doc/src/cmyk.rs @@ -515,9 +515,10 @@ pub fn turned_cmyk(bytes: &[u8], orientation: image::metadata::Orientation, ppi: /// all, as RGBA pixels: CMYK with an alpha channel (5 samples), each colour converted by `rgb` (ink /// amounts 0..1 → sRGB 0..1; the inks can't be kept with the transparency, so they show as RGB), /// and grayscale with extra samples, of which the first is the alpha when the file says so (other -/// channels are left out). Associated (premultiplied) alpha is divided back out. The samples may be -/// stored together or one plane per channel. `None` for other images and ones larger than -/// [`MAX_CMYK_PIXELS`]. +/// channels are left out). Associated (premultiplied) alpha is divided back out, and a pixel with +/// no associated alpha has no color. 16-bit samples are converted at 16 bits, and only the result +/// is rounded to 8 bits. The samples may be stored together or one plane per channel. `None` for +/// other images and ones larger than [`MAX_CMYK_PIXELS`]. pub fn extra_samples_tiff_rgba(bytes: &[u8], rgb: impl Fn([f32; 4]) -> [f32; 3]) -> Option<image::RgbaImage> { use tiff::tags::Tag; let (kind, mut d) = tiff(bytes)?; @@ -535,20 +536,33 @@ pub fn extra_samples_tiff_rgba(bytes: &[u8], rgb: impl Fn([f32; 4]) -> [f32; 3]) _ => return None, }; let n = usize::try_from(pixels(w, h)?).ok()?; - let data = read_samples(&mut d, n, samples)?; - let mut out = Vec::with_capacity(n * 4); - for p in data.chunks_exact(samples) { - let opacity = if alpha { p.get(colour).copied().unwrap_or(u8::MAX) } else { u8::MAX }; - let a = f32::from(opacity) / 255.0; - let level = |v: u8| { - let v = f32::from(v) / 255.0; - if extra == Some(1) && a > 0.0 { (v / a).min(1.0) } else { v } + let data = read_samples_at_depth(&mut d, n, samples)?; + // Sample `i` of the image, 0..1. + let level_at = |i: usize| match &data { + Samples::Eight(v) => v.get(i).map(|&s| f32::from(s) / 255.0), + Samples::Sixteen(v) => v.get(i).map(|&s| f32::from(s) / 65535.0), + }; + // Sample `i` of the image as 8 bits, a 16-bit sample rounded to the nearest. + let byte_at = |i: usize| match &data { + Samples::Eight(v) => v.get(i).copied(), + Samples::Sixteen(v) => v.get(i).map(|&s| u8::try_from((u32::from(s) + 128) / 257).unwrap_or(u8::MAX)), + }; + let mut out = Vec::with_capacity(n.checked_mul(4)?); + for first in (0..n).map(|p| p * samples) { + let (opacity, a) = if alpha { (byte_at(first + colour).unwrap_or(u8::MAX), level_at(first + colour).unwrap_or(1.0)) } else { (u8::MAX, 1.0) }; + let level = |s: usize| { + let v = level_at(first + s).unwrap_or(0.0); + match extra { + Some(1) if a > 0.0 => (v / a).min(1.0), + // No associated alpha: the color is zero (TIFF 6.0, Associated Alpha Handling). + Some(1) if alpha => 0.0, + _ => v, + } }; - let [r, g, b] = match *p { - [c, m, y, k, ..] if colour == 4 => rgb([level(c), level(m), level(y), level(k)]), - [v, ..] if photometric == Some(0) => [1.0 - level(v); 3], - [v, ..] => [level(v); 3], - [] => continue, + let [r, g, b] = match colour { + 4 => rgb([level(0), level(1), level(2), level(3)]), + _ if photometric == Some(0) => [1.0 - level(0); 3], + _ => [level(0); 3], }; out.extend([r, g, b].map(|v| (v.clamp(0.0, 1.0) * 255.0).round() as u8)); out.push(opacity); @@ -767,6 +781,85 @@ mod tests { assert_eq!(gray(0), [255, 255, 255, 255, 51, 51, 51, 255, 0, 0, 0, 255], "a channel that isn't alpha: opaque"); } + /// Five 16-bit samples a pixel: the four inks and one extra sample, which the file's + /// `ExtraSamples` names. + struct Cmyka16; + impl tiff::encoder::colortype::ColorType for Cmyka16 { + type Inner = u16; + const TIFF_VALUE: tiff::tags::PhotometricInterpretation = tiff::tags::PhotometricInterpretation::CMYK; + const BITS_PER_SAMPLE: &'static [u16] = &[16; 5]; + const SAMPLE_FORMAT: &'static [tiff::tags::SampleFormat] = &[tiff::tags::SampleFormat::Uint; 5]; + fn horizontal_predict(row: &[u16], result: &mut Vec<u16>) { + result.extend_from_slice(row); + } + } + + /// Two 16-bit samples a pixel: gray and one extra sample. + struct GrayExtra16; + impl tiff::encoder::colortype::ColorType for GrayExtra16 { + type Inner = u16; + const TIFF_VALUE: tiff::tags::PhotometricInterpretation = tiff::tags::PhotometricInterpretation::BlackIsZero; + const BITS_PER_SAMPLE: &'static [u16] = &[16, 16]; + const SAMPLE_FORMAT: &'static [tiff::tags::SampleFormat] = &[tiff::tags::SampleFormat::Uint; 2]; + fn horizontal_predict(row: &[u16], result: &mut Vec<u16>) { + result.extend_from_slice(row); + } + } + + /// A one-row TIFF of `C`'s pixels `data`, with the ExtraSamples value `extra`. + fn extra_tiff<C: tiff::encoder::colortype::ColorType<Inner = u16>>(extra: u16, data: &[u16]) -> Vec<u8> { + let samples = C::BITS_PER_SAMPLE.len(); + let mut file = Cursor::new(Vec::new()); + let mut enc = tiff::encoder::TiffEncoder::new(&mut file).unwrap(); + let mut img = enc.new_image::<C>(u32::try_from(data.len() / samples).unwrap(), 1).unwrap(); + img.encoder().write_tag(tiff::tags::Tag::ExtraSamples, &[extra][..]).unwrap(); + img.write_data(data).unwrap(); + file.into_inner() + } + + /// 16-bit CMYK with alpha converts its 16-bit inks and alpha, and rounds only the result to 8 + /// bits; the high byte of each sample alone would give other pixels. + #[test] + fn a_16_bit_cmyk_tiff_with_alpha_converts_at_16_bits() { + let naive = |[c, m, y, k]: [f32; 4]| [(1.0 - c) * (1.0 - k), (1.0 - m) * (1.0 - k), (1.0 - y) * (1.0 - k)]; + let read = |extra: u16, data: &[u16]| extra_samples_tiff_rgba(&extra_tiff::<Cmyka16>(extra, data), naive).expect("CMYKA reads").into_raw(); + // Unassociated: 129 of cyan, opaque; no ink at an alpha of 129; no ink at an alpha of 386. + let straight = [129, 0, 0, 0, 65535, 0, 0, 0, 0, 129, 0, 0, 0, 0, 386]; + assert_eq!(read(2, &straight), [254, 255, 255, 255, 255, 255, 255, 1, 255, 255, 255, 2]); + // Associated: cyan 128 at an alpha of 256 (half cyan); K 255 at an alpha of 511 (about half K). + let premultiplied = [128, 0, 0, 0, 256, 0, 0, 0, 255, 511]; + assert_eq!(read(1, &premultiplied), [128, 255, 255, 1, 128, 128, 128, 2], "divided by the 16-bit alpha"); + } + + /// 16-bit gray with alpha converts at 16 bits as well. + #[test] + fn a_16_bit_grayscale_tiff_with_alpha_converts_at_16_bits() { + let read = |extra: u16| { + // A gray of 129, opaque, then 128 at an alpha of 256. + let bytes = extra_tiff::<GrayExtra16>(extra, &[129, 65535, 128, 256]); + extra_samples_tiff_rgba(&bytes, |_| [0.0; 3]).expect("gray with alpha reads").into_raw() + }; + assert_eq!(read(2), [1, 1, 1, 255, 0, 0, 0, 1], "unassociated"); + assert_eq!(read(1), [1, 1, 1, 255, 128, 128, 128, 1], "associated, divided by the 16-bit alpha"); + } + + /// With associated alpha, a pixel whose alpha is zero has no color (TIFF 6.0, Associated + /// Alpha Handling), whatever its color samples hold. + #[test] + fn a_pixel_with_no_associated_alpha_has_no_color() { + use tiff::encoder::{TiffEncoder, colortype::CMYKA8}; + let naive = |[c, m, y, k]: [f32; 4]| [(1.0 - c) * (1.0 - k), (1.0 - m) * (1.0 - k), (1.0 - y) * (1.0 - k)]; + let mut file = Cursor::new(Vec::new()); + let mut enc = TiffEncoder::new(&mut file).unwrap(); + let mut img = enc.new_image::<CMYKA8>(1, 1).unwrap(); + img.encoder().write_tag(tiff::tags::Tag::ExtraSamples, &[1u16][..]).unwrap(); + img.write_data(&[255, 0, 0, 0, 0]).unwrap(); + let cmyk = extra_samples_tiff_rgba(&file.into_inner(), naive).expect("CMYKA reads"); + assert_eq!(cmyk.into_raw(), [255, 255, 255, 0], "no ink"); + let gray = extra_samples_tiff_rgba(&extra_tiff::<GrayExtra16>(1, &[50_000, 0]), |_| [0.0; 3]).expect("gray reads"); + assert_eq!(gray.into_raw(), [0, 0, 0, 0], "a gray of zero"); + } + /// A header claiming more tiles than can be counted: (2^32 − 1)² pixels in tiles of one pixel, /// times 2 planes. #[test] diff --git a/crates/engine/src/cmd/fileio/tests.rs b/crates/engine/src/cmd/fileio/tests.rs index d17af84b66..7374e26e2b 100644 --- a/crates/engine/src/cmd/fileio/tests.rs +++ b/crates/engine/src/cmd/fileio/tests.rs @@ -186,6 +186,22 @@ fn planar_tiffs_read_as_their_chunky_versions() { } } +/// A 16-bit CMYK TIFF with alpha places with its alpha rounded from 16 bits, planar as chunky. +#[test] +fn a_16_bit_cmyk_tiff_with_alpha_places_at_16_bits() { + let none = vec![0u16; 6]; + let cyan = vec![129u16, 0, 300, 0, 128, 65535]; + let alpha = vec![65535u16, 129, 386, 0, 256, 65535]; + for extra in [1u16, 2] { + let channels = [cyan.clone(), none.clone(), none.clone(), none.clone(), alpha.clone()]; + let chunky = kept(&format!("extra samples {extra}, chunky"), &hand_tiff(5, 16, &[extra], false, &channels)); + let planar = kept(&format!("extra samples {extra}, planar"), &hand_tiff(5, 16, &[extra], true, &channels)); + assert_eq!(planar, chunky, "extra samples {extra}: planar reads as chunky"); + let alphas: Vec<u8> = chunky.1.iter().skip(3).step_by(4).copied().collect(); + assert_eq!(alphas, [255, 1, 2, 0, 1, 255], "extra samples {extra}: the alpha, rounded from 16 bits"); + } +} + /// A planar TIFF whose header claims more strips than the decoder can count (here 2^31 + 1 rows /// a strip each, times 5 planes) is refused as too large to draw, without a panic. #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..e030e3db3b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1749,6 +1749,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - HP-GL export's `insideFirst` cuts each pen's paths inside before outside: a path is drawn only after the pen's paths that lie inside it (a letter's counter, a part's holes, rings within rings), touching outlines counted as inside and crossing ones not, in paint order or nearest first with `sortPaths`, within the plot's work budget; these order rules are VectorCraft's own (`crates/cad/src/hpgl/write/nest.rs`, `crates/cad/src/hpgl/write/tests.rs`, `crates/engine/src/cmd/fileio/tests_hpgl.rs`). - EPS and DXF in and out, EMF/WMF in and out; PNG (with PNG-8), JPEG, WebP, GIF, TIFF, BMP, Targa and layered PSD export; grayscale TIFFs with an alpha channel or other extra channels place, relink and open, the alpha as the image's transparency (#1466 in part); PSD and PSB files open and place, linked or embedded, as their merged image in every colour mode and depth (#918). EPS import runs a PostScript Level 3 interpreter written from the PostScript Language Reference: resource categories and `resourceforall`, local and global VM (`currentglobal`/`setglobal`/`gcheck`), `clipsave`/`cliprestore`, subarrays and substrings that share storage, the standard dictionaries in `systemdict`, `dictstack`, `internaldict`, executable filters and strings, `load` by any key, `//name` immediate names, `token`, `execform`, user paths, `cshow`, `rootfont`, `cachestatus`, colour rendering and halftone queries, file `status` and data read with `flushfile`, and `pdfmark` marks dropped (Discord feedback, #466, #469, #474). Masked images (`ImageType 3` in its three interleavings) and reusable streams are read, and an image's several data sources are read in turn, as the reference defines (procedures that read one file get their own rows: such images came in banded, #498). `restore` puts dictionaries back as they were at the `save`, so programs that count their saves in a dictionary read to their end (part of #505). Tiling patterns come in as pattern swatches, uncoloured ones too; Type 3 fonts' glyphs as their outlines, spaced by `ashow`/`widthshow`/`xshow`/`kshow`; mesh and function-based shadings (types 1, 4–7) as gradient meshes; sampled functions (type 0) and Flate/LZW predictors are read. It is tested with programs written from the specification in the ways common generators use these features; Inkscape/cairo EPS files open as vectors. When a file's PostScript still can't be read, it opens as its TIFF preview, its Windows metafile preview (as vectors) or its EPSI preview, and the warning (in the status bar, `document.open`/`app.open`/MCP `open_file` replies and `vectorcraft-cli info`) names the error, the operator that raised it and the procedures it ran in. Legacy PostScript `.ai` files (Illustrator 3–8, written with the prolog that defines their operators) keep their groups and nested groups (`u` … `U`), between and inside clipping groups; EPS and EMF/WMF import nest clips (and groups) at most 128 deep, so a hostile file can't exhaust the stack. DXF TEXT justified Fit or Aligned spans its two points (stretched, or scaled as a whole). PDF export writes type as real, searchable text in embedded subset fonts by default, as Illustrator's PDF presets do (Convert Text to Outlines is an option; printer's marks stay shapes), so text-heavy PDFs stay small (#733). DXF export writes each fill as its outlines followed by its hatch, so laser and cutter software, which skips hatches, gets filled art and type too (#546). - TIFFs that store each channel as its own plane (PlanarConfiguration 2) place, relink and open as the same image stored pixel by pixel does, 8 and 16 bits: grayscale with an alpha channel or other extra channels, and CMYK with or without them. A planar CMYK TIFF keeps its ink amounts and is stored as a CMYK TIFF with each pixel's inks together, at the file's resolution. A TIFF whose header claims more strips or tiles than can be counted is refused as too large to draw (#1466 in part; `crates/engine/src/cmd/fileio/tests.rs`). + - A 16-bit CMYK or grayscale TIFF with an alpha channel is converted from its 16-bit samples, and only the resulting color and alpha are rounded to 8 bits; associated alpha is divided out at 16 bits, and a pixel whose associated alpha is zero has no color. [TIFF 6.0](https://printtechnologies.org/standards/files/tiff-v6.pdf) gives extra samples the depth in BitsPerSample, and its Associated Alpha Handling section states the arithmetic and the zero-alpha rule for RGB data; applying them to CMYK and gray samples is VectorCraft's own rule. Each sample was cut to its high byte first, so a faint ink or a low alpha could be lost (`crates/doc/src/cmyk.rs`, `crates/engine/src/cmd/fileio/tests.rs`). - 1-bit TIFFs compressed with CCITT Group 3 (ITU-T T.4) place, relink and open: Compression 2 (modified Huffman) and Compression 3 with one-dimensional rows or, with T4Options bit 0, two-dimensional ones, with or without fill bits, in strips or tiles, with either FillOrder and either polarity. Rows in T.4's uncompressed mode are not read. A file whose pixels would take more than the decoding allowance as RGBA is refused as too large to draw (#1466 in part; `crates/engine/src/cmd/fileio/tests.rs`). - EPS and PostScript import keeps a CMYK image's ink amounts, as PDF import does: the samples of `image` and `colorimage` in a CMYK color space, and of a CMYK JPEG read through `DCTDecode`, come in as a CMYK TIFF, read through the image's Decode array, and the pixels a `MaskColor` or `ImageType 3` mask hides become a grayscale opacity mask (`crates/eps/src/import/tests_images.rs`). Such images came in as RGB PNGs. - EPS and PostScript import reads image data through `CCITTFaxDecode`: Group 4 (ITU-T T.6) and Group 3 one-dimensional and mixed (ITU-T T.4) data, with the filter's `K`, `Columns`, `Rows`, `EndOfBlock`, `EndOfLine`, `EncodedByteAlign` and `BlackIs1` parameters, decodes to 1-bit rows for `image` and `imagemask`. Damaged data keeps the rows decoded before it (damage in the first row is a PostScript `ioerror`), and parameters out of range or past the 256 MiB limit on decoded data are refused (`crates/eps/src/import/tests_images.rs`). Reading such a file stopped at an error naming the filter, and the file opened from a fallback, such as its preview or the art drawn before the image, or did not open. From 78dd7dd765a1a2c6cadcdaabe4e44a7d7ddb3b1e Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:47:38 -0800 Subject: [PATCH 087/108] SVG import: direction keywords match in any letter case SVG import compared `direction` with `rtl` case-sensitively, so `direction="RTL"` or `style="direction: Rtl"` read as left to right. CSS keywords are ASCII case-insensitive (https://www.w3.org/TR/css-values-3/#keywords), and `unicode-bidi` was already read that way. The `<tspan>` embedding direction, the `<text>` paragraph direction and the anchoring of each chunk now read `direction` through one helper that compares without regard to case. --- crates/svg/src/import/text.rs | 12 +++++++++--- crates/svg/tests/it/import_text.rs | 7 ++++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/crates/svg/src/import/text.rs b/crates/svg/src/import/text.rs index 1a221a69f1..fad8841e99 100644 --- a/crates/svg/src/import/text.rs +++ b/crates/svg/src/import/text.rs @@ -965,6 +965,12 @@ impl Ctx { "normal".into() } + /// Whether the computed `direction` of element `n` is `rtl`, in any letter case (CSS keywords + /// are ASCII case-insensitive, https://www.w3.org/TR/css-values-3/#keywords). + fn is_rtl(&self, n: XNode) -> bool { + self.prop(n, "direction").is_some_and(|d| d.trim().eq_ignore_ascii_case("rtl")) + } + /// The Character Direction of the characters of element `n` inside a `<text>`, and what it /// leaves out (SVG 1.1 §10.7.4, /// https://www.w3.org/TR/SVG11/text.html#RelationshipWithBi-directionality, and CSS Writing @@ -987,7 +993,7 @@ impl Ctx { let inherited = parent.as_ref().and_then(|p| p.style.char_direction); let mut notes = parent.map_or_else(Vec::new, |p| p.bidi_notes.clone()); let rtl = |rtl: bool| Some(if rtl { ParaDirection::RightToLeft } else { ParaDirection::LeftToRight }); - let own = || rtl(self.prop(n, "direction").is_some_and(|d| d.trim() == "rtl")); + let own = || rtl(self.is_rtl(n)); let (dir, note) = match bidi.as_str() { "embed" => (own(), None), "bidi-override" => (own(), Some(BIDI_OVERRIDE)), @@ -1359,7 +1365,7 @@ impl Ctx { // With `unicode-bidi: plaintext`, the text runs in the direction of its first strong // character, and each paragraph in that of its own ([`pin_first_strong`]). let plaintext = self.unicode_bidi(t) == "plaintext"; - let rtl = if plaintext { self.first_strong_rtl(t) == Some(true) } else { self.prop(t, "direction").is_some_and(|d| d.trim() == "rtl") }; + let rtl = if plaintext { self.first_strong_rtl(t) == Some(true) } else { self.is_rtl(t) }; let pin = |obj: &mut TextObject| { pin_direction(obj, rtl); if plaintext { @@ -1386,7 +1392,7 @@ impl Ctx { let chunk: String = cs.chars[i..end].iter().map(|c| c.0).collect(); text_first_strong_rtl(&chunk) == Some(true) }; - let rtl = if plaintext { chunk_rtl() } else { self.prop(el, "direction").is_some_and(|d| d.trim() == "rtl") }; + let rtl = if plaintext { chunk_rtl() } else { self.is_rtl(el) }; if !vertical && rtl { 1.0 - a } else { a } }; let anchor = anchor_of(0); diff --git a/crates/svg/tests/it/import_text.rs b/crates/svg/tests/it/import_text.rs index 472d7517e4..27399ec4ac 100644 --- a/crates/svg/tests/it/import_text.rs +++ b/crates/svg/tests/it/import_text.rs @@ -391,6 +391,9 @@ fn rtl_point_text_start_and_end_use_directional_edges() { (r#"<text x="200" y="60" direction="rtl" font-size="20"><tspan direction="ltr">Wave</tspan></text>"#, 0.0), (r#"<text x="200" y="60" text-anchor="start" font-size="20">Wave</text>"#, 0.0), (r#"<text x="200" y="60" direction="ltr" text-anchor="end" font-size="20">Wave</text>"#, 1.0), + // CSS keywords are case-insensitive. + (r#"<text x="200" y="60" direction="RTL" font-size="20">Wave</text>"#, 1.0), + (r#"<text x="200" y="60" style="direction: Rtl" text-anchor="end" font-size="20">Wave</text>"#, 0.0), // With `unicode-bidi: plaintext`, the direction of the chunk's first strong character. (r#"<text x="200" y="60" unicode-bidi="plaintext" font-size="20">אבג</text>"#, 1.0), (r#"<text x="200" y="60" unicode-bidi="plaintext" text-anchor="end" font-size="20">12 אב</text>"#, 0.0), @@ -494,6 +497,8 @@ fn a_tspan_bidi_embedding_becomes_its_character_direction() { ("ltr", "rtl", "normal", None, false), ("rtl", "ltr", "normal", None, false), ("ltr", "rtl", "EMBED", Some(Rtl), false), + ("ltr", "RTL", "embed", Some(Rtl), false), + ("RTL", "ltr", "embed", Some(Ltr), false), ("ltr", "rtl", "sideways", None, false), ] { let (t, w) = read(&format!( @@ -503,7 +508,7 @@ fn a_tspan_bidi_embedding_becomes_its_character_direction() { assert_eq!(t.plain_text(), "ab 1 2 cd", "{case}: the characters stay in logical order"); assert_eq!(char_direction_of(&t, "1 2"), want, "{case}: {:?}", t.runs); assert_eq!(char_direction_of(&t, "ab"), None, "{case}"); - assert_eq!(t.para_at(0).direction == Some(Rtl), outer == "rtl", "{case}: the paragraph keeps the text's direction"); + assert_eq!(t.para_at(0).direction == Some(Rtl), outer.eq_ignore_ascii_case("rtl"), "{case}: the paragraph keeps the text's direction"); assert_eq!(w.iter().any(|w| w.contains("bidi-override") && w.contains("not supported")), warns, "{case}: {w:?}"); if !warns { assert!(w.is_empty(), "{case}: {w:?}"); From 7e63d4ca0c7d6b130c671d8411157ac085d5945c Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:48:25 -0800 Subject: [PATCH 088/108] Recovery: a recovery copy that finishes later keeps a newer status line MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A recovery copy written in the background set "Saved recovery data for <title>" (or its failure line) when it finished, over any message shown since it started, such as Restore's count with its notes or the "Saving…" line of a copy started after it. The status bar now counts the messages VectorcraftApp::status sets. A copy shows its result only while its own "Saving recovery data for …" line is still the latest message, or right away when it was written without the worker. A failure is still logged, and a failed folder is still recorded for automation replies, when its line is not shown. --- crates/ui-egui/src/app/commands.rs | 1 + crates/ui-egui/src/recovery.rs | 66 ++++++++++++++-------- crates/ui-egui/src/state.rs | 5 ++ crates/ui-egui/src/tests/recovery.rs | 82 ++++++++++++++++++++++++++++ docs/target-app-parity.md | 2 +- 5 files changed, 131 insertions(+), 25 deletions(-) diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index 50c7b1be30..6d40499106 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -457,5 +457,6 @@ impl VectorcraftApp { /// Show a transient status message. pub fn status(&mut self, s: impl Into<String>) { self.ui.status = s.into(); + self.ui.status_sets = self.ui.status_sets.wrapping_add(1); } } diff --git a/crates/ui-egui/src/recovery.rs b/crates/ui-egui/src/recovery.rs index aa0a25e50f..9d787954ea 100644 --- a/crates/ui-egui/src/recovery.rs +++ b/crates/ui-egui/src/recovery.rs @@ -125,24 +125,37 @@ fn write(app: &mut VectorcraftApp, store: &Arc<dyn RecoveryStore>, pick: impl Fn for job in jobs { let (uid, label, title) = (job.uid, format!("Saving recovery data for {}", job.title), job.title.clone()); let (done, at, saving) = (job.clone(), place.clone(), label.clone()); + // The status line before the job starts: on the worker, the job sets one line ("<label>…") + // right after this; written right away, it sets none before `then` runs. + let (sets, started_line) = (app.ui.status_sets, format!("{label}…")); let work = move |_: Writer| job.write(); // A failure is reported here, so the job's result is not an error: that would show as // "<label> failed: <error>" over this line, or as the round's message when it ran here. - let then = move |app: &mut VectorcraftApp, r: Result<Value, String>| match (r, at) { - (Ok(r), _) => { - done.finish(&mut app.session); - app.status(format!("Saved recovery data for {title}")); - Ok(r) - } - (Err(e), Some(at)) => { - copy_failed(app, &title, &at, &e); - Ok(Value::Null) - } - // A store the host installed has no folder to name: the job's own line. - (Err(e), None) => { - app.status(format!("{saving} failed: {e}")); - log::warn!("vectorcraft: {}", app.ui.status); - Ok(Value::Null) + let then = move |app: &mut VectorcraftApp, r: Result<Value, String>| { + // The result goes to the status bar only while it still shows this job's own line: a + // message set since then (another job's, a restore's with its notes) stays. + let show = app.ui.status_sets == sets || (app.ui.status_sets == sets.wrapping_add(1) && app.ui.status == started_line); + match (r, at) { + (Ok(r), _) => { + done.finish(&mut app.session); + if show { + app.status(format!("Saved recovery data for {title}")); + } + Ok(r) + } + (Err(e), Some(at)) => { + copy_failed(app, &title, &at, &e, show); + Ok(Value::Null) + } + // A store the host installed has no folder to name: the job's own line. + (Err(e), None) => { + let line = format!("{saving} failed: {e}"); + log::warn!("vectorcraft: {line}"); + if show { + app.status(line); + } + Ok(Value::Null) + } } }; // Its own store, not the file writer: this only decides whether it runs on the worker. @@ -173,18 +186,23 @@ fn failed(app: &mut VectorcraftApp, place: Option<&(String, bool)>, e: &str) { log::warn!("vectorcraft: {}", app.ui.status); } -/// [`failed`] for the copy of document `title` that couldn't be written to folder `place`. -fn copy_failed(app: &mut VectorcraftApp, title: &str, place: &(String, bool), e: &str) { - match place { - (folder, true) => app.status(format!( +/// [`failed`] for the copy of document `title` that couldn't be written to folder `place`, shown +/// in the status bar only when `show` holds. The log always has it, and the folder is recorded +/// in [`Timer::named`] either way. +fn copy_failed(app: &mut VectorcraftApp, title: &str, place: &(String, bool), e: &str, show: bool) { + let line = match place { + (folder, true) => format!( "Couldn't save recovery data for {title}: {e}. Copies go to {folder}, the folder set in Preferences; to use another folder, set Preferences → File Handling → Data Recovery → Folder (recoveryFolder)" - )), - (folder, false) => app.status(format!( + ), + (folder, false) => format!( "Couldn't save recovery data for {title}: {e}. Copies go to {folder}, the default recovery folder; to use another folder, set Preferences → File Handling → Data Recovery → Folder (recoveryFolder)" - )), - } + ), + }; named(app, &place.0); - log::warn!("vectorcraft: {}", app.ui.status); + log::warn!("vectorcraft: {line}"); + if show { + app.status(line); + } } /// Record that the status text named recovery folder `folder` ([`Timer::named`]). diff --git a/crates/ui-egui/src/state.rs b/crates/ui-egui/src/state.rs index a29ca50e41..d06c0dbcb2 100644 --- a/crates/ui-egui/src/state.rs +++ b/crates/ui-egui/src/state.rs @@ -574,6 +574,10 @@ pub struct UiState { #[serde(skip)] pub touch_drawing_tool: Option<String>, pub status: String, + /// How many times [`crate::VectorcraftApp::status`] has set `status`, so that work finishing + /// later can tell whether the line it started with is still the latest one. Not saved. + #[serde(skip)] + pub status_sets: u64, /// The Replace Font request behind the status bar's warning ([`ReplaceFontWarning`]). Not saved. #[serde(skip)] pub replace_font_warning: Option<ReplaceFontWarning>, @@ -1163,6 +1167,7 @@ impl Default for UiState { group_tool: vectorcraft_tools::TOOL_GROUPS.iter().map(|g| g[0].id.to_string()).collect(), touch_drawing_tool: None, status: String::new(), + status_sets: 0, replace_font_warning: None, status_notes: None, palette_open: false, diff --git a/crates/ui-egui/src/tests/recovery.rs b/crates/ui-egui/src/tests/recovery.rs index 76f56a1fb9..946c535fd4 100644 --- a/crates/ui-egui/src/tests/recovery.rs +++ b/crates/ui-egui/src/tests/recovery.rs @@ -414,6 +414,88 @@ fn a_copy_that_fails_in_a_host_store_names_the_document() { } } +/// Services that write recovery copies on the background worker. +fn on_the_worker() -> Services { + Services { write_shared: Some(Arc::new(|_: &str, _: &[u8]| Ok(()))), ..Default::default() } +} + +/// A copy that finishes after a newer message (a restore's, with its notes) was shown is still +/// written, and the newer message and its notes stay in the status bar. +#[test] +fn a_copy_that_finishes_later_keeps_a_newer_status_and_its_notes() { + let store = Arc::new(MemoryStore::default()); + let mut app = app_with(&store, on_the_worker()); + recovery::tick(&mut app, 0.0); + assert_eq!(recovery::tick(&mut app, 120.0), 1); + assert_eq!(app.background.jobs.len(), 1, "on the worker"); + let newer = "Restored 2 documents with 2 notes: one".to_string(); + crate::io::show_with_notes(&mut app, newer.clone(), vec!["one".into(), "two".into()]); + background::wait_all(&mut app); + assert_eq!(copies(&store), 1); + assert!(app.session.doc().unwrap().recovery.is_some()); + assert_eq!(app.ui.status, newer); + assert_eq!(app.ui.status_notes, Some((newer, vec!["one".into(), "two".into()]))); +} + +/// Of two copies started in one round, the first one to finish leaves the second one's +/// "Saving…" line, and the second one reports. +#[test] +fn a_copy_that_finishes_leaves_the_line_of_a_copy_started_after_it() { + let store = Arc::new(MemoryStore::default()); + let mut app = app_with(&store, on_the_worker()); + app.run("file.new", json!({"width": 200, "height": 100})).unwrap(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 20})).unwrap(); + recovery::tick(&mut app, 0.0); + assert_eq!(recovery::tick(&mut app, 120.0), 2); + let second = app.ui.status.clone(); + let Some(title) = second.strip_prefix("Saving recovery data for ").and_then(|s| s.strip_suffix('…')) else { + panic!("{second}"); + }; + let title = title.to_string(); + background::wait_until(&mut app, |app| app.background.jobs.len() == 1); + assert_eq!(app.ui.status, second); + background::wait_all(&mut app); + assert_eq!(copies(&store), 2); + assert_eq!(app.ui.status, format!("Saved recovery data for {title}")); +} + +/// A copy that fails after a newer message was shown leaves that message in the status bar, in a +/// store the host installed and in a recovery folder; the folder is still recorded. +#[test] +fn a_copy_that_fails_later_keeps_a_newer_status() { + let store: Arc<dyn RecoveryStore> = Arc::new(Refusing(MemoryStore::default())); + let mut app = VectorcraftApp::new(Session::new(), Services { recovery_store: Some(store), ..on_the_worker() }); + app.run("file.new", json!({"width": 200, "height": 100})).unwrap(); + app.run("shape.rectangle", json!({"x": 10, "y": 10, "width": 50, "height": 20})).unwrap(); + app.session.prefs.autosave_interval = 2; + recovery::tick(&mut app, 0.0); + assert_eq!(recovery::tick(&mut app, 120.0), 1); + app.status("Newer"); + background::wait_all(&mut app); + assert_eq!(app.ui.status, "Newer"); + + let dir = scratch("later"); + let folder = dir.join("recovery"); + let shown = folder.to_string_lossy().into_owned(); + let mut app = app_in_folder(&shown, on_the_worker()); + assert_eq!(recovery::tick(&mut app, 120.0), 1); + background::wait_all(&mut app); + // A folder with a file in it takes the copy's place, so the next copy can't be written. + let name = app.session.doc().unwrap().recovery.as_ref().unwrap().file.clone(); + let copy = folder.join(format!("{name}.vectorcraft")); + std::fs::remove_file(©).unwrap(); + std::fs::create_dir(©).unwrap(); + std::fs::write(copy.join("in-the-way"), b"").unwrap(); + app.run("shape.ellipse", json!({"x": 100, "y": 10, "width": 20, "height": 20})).unwrap(); + assert_eq!(recovery::tick(&mut app, 240.0), 1); + app.status("Newer"); + background::wait_all(&mut app); + assert_eq!(app.ui.status, "Newer"); + assert_eq!(app.recovery.named, std::slice::from_ref(&shown)); + drop(app); + let _ = std::fs::remove_dir_all(&dir); +} + /// Issue #367: a tab whose timers were paused (in the background) long enough for another tab to /// take it for gone and discard its copy writes the copy again on its first heartbeat after it /// resumes, even with the timer off (the copy was written by hand). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..894cb730a8 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1640,7 +1640,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - `.vectorcraft` (lossless JSON, compressed, atomic saves, save down to v1), Save As with a format chooser, Save a Copy, Revert, templates, Data Recovery after a crash (browser tabs hold their copies with Web Locks too, so a background tab's copies are never taken for a crash's, and a tab repairs copies another removed when it resumes: #367), background save and export. The desktop app writes its warnings and errors (graphics adapter, a lost graphics device, panics the guard recovered from) to standard error and to `logs/vectorcraft.log` next to the preferences, the two previous runs kept and each file capped at 16 MiB, so a launch without a terminal still leaves something to attach to a bug report (#465). Native documents with a lot of path data (traced or generated art, in layers, symbols or patterns) are saved as compact JSON, about a fifth of the size; small documents stay pretty-printed (#1492). Saving to a network drive on macOS falls back to a plain fsync when the share refuses a full flush (#1625, part of #1620; not confirmed on a real share), and a save still succeeds when a folder refuses the temporary file, the rename over the document or copying permissions: the content is written elsewhere first and copied in, and a failed copy keeps the temporary file and names it (#1649, part of #1620). A document opened by a relative path finds its relatively linked images, and `vectorcraft-cli convert` lists what reading the input left out as `importWarnings` (#1606, fixes #1604). Preferences › File Handling › Data Recovery › Folder has a Choose… button on the desktop that picks the folder Data Recovery keeps its copies in ([Illustrator reference, Set Data Recovery preferences](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf)); a picked folder that Data Recovery cannot create its folders in or list is refused with a status message, and the field keeps its value. OK applies the same check to a folder typed into the field (VectorCraft's own rule): when it fails, the dialog stays open, the status bar says why and no preference changes; an empty field (the default folder) and the folder already saved are not checked. Preferences › Plug-ins & Scratch Disks is where additional plug-ins folders are set ([Illustrator preferences help](https://helpx.adobe.com/illustrator/desktop/get-started/preferences-and-settings/set-app-preferences.html)); its Additional Plug-ins Folder has a Choose… button on the desktop as well, VectorCraft's own, matching Data Recovery's, and VectorCraft's own rule refuses a picked or typed folder whose contents can't be listed. Additional Fonts Folder and Templates Folder stay typed only. `prefs.set` applies the dialog's check to `recoveryFolder` and `pluginsFolder` for every caller (VectorCraft's own rule): a folder that fails returns an error and no preference changes; an empty value and the folder already saved are not checked. - When a Data Recovery copy can't be written, the status bar and the log show the error (with the document's title when one document's copy fails), the folder copies go to, whether that is the default recovery folder or the folder set in Preferences, and the preference that picks another folder (`recoveryFolder`; VectorCraft's own message). + When a Data Recovery copy can't be written, the status bar and the log show the error (with the document's title when one document's copy fails), the folder copies go to, whether that is the default recovery folder or the folder set in Preferences, and the preference that picks another folder (`recoveryFolder`; VectorCraft's own message). A copy written in the background reports its result in the status bar only while the status bar still shows that copy's own "Saving recovery data for …" line, so a message shown since then, such as Restore's count with its notes or another copy's line, stays; a failure is still written to the log (VectorCraft's own rule). After Restore in the dialog Data Recovery shows at launch, the status bar keeps the restored documents' notes (VectorCraft's own rule): it shows the count followed by the first note, and hovering it lists each document's lines about its linked files and its warnings, named with the document's title when more than one was restored. The questions about the documents' missing or modified linked files come one document at a time, with that document made the current one, and a copy that can't be restored shows its error while the hover keeps the count and the restored documents' notes (`tests/recovery.rs`). A name typed in the desktop save panel without the file type's extension gets it, and when a file of that name exists, which the panel did not ask about, Save, Save As, Save a Copy, Save as Template, the exports and every other write through a save panel ask before replacing it (dialog `replaceFile`; Cancel writes nothing). A name returned by the desktop save panel with the extension of a format the save does not write has it replaced with the saved format's: Save As of a new document saves `card.ait` and `card.png` as `card.vectorcraft`, and Save as Template saves `card.pdf` as `card.vctemplate`. An extension that names no format stays part of the name (`notes.v2` is saved as `notes.v2.vectorcraft`). From 25e35ee5b132125421c90c8a3fe70b1bfb9d75b1 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:44:30 -0800 Subject: [PATCH 089/108] 3D: effect validation builds each Extrude and Inflate solid once Checking an Extrude & Bevel (both kinds) or Inflate effect built every shape's profile about the profiles' bounds, then built the fill and stroke solids again about the bounds of the regions they paint. A filled shape's profile is its fill's solid, so that solid was built twice. When a stroke reaches past the shape, the first build also used bounds the effect does not draw it about. The check now builds the profile on its own only where no drawn solid is built from it: every shape for Rotate, and for Extrude & Bevel and Inflate a shape with no fill (strokes only, or no paint). A filled shape's solid is built once, about the bounds the effect draws it about. The shadow check is unchanged. Tests count the solids the check builds: an object with a fill and a stroke, a group of two such members, an effect on the fill and the shadow on; a shape with no fill still has its profile built. --- crates/effects/src/solids.rs | 29 ++++++++++++++++++--- crates/effects/src/solids/tests.rs | 42 ++++++++++++++++++++++++++++++ docs/target-app-parity.md | 1 + 3 files changed, 69 insertions(+), 3 deletions(-) diff --git a/crates/effects/src/solids.rs b/crates/effects/src/solids.rs index ac9de02cad..443459d269 100644 --- a/crates/effects/src/solids.rs +++ b/crates/effects/src/solids.rs @@ -223,6 +223,10 @@ pub(crate) fn solid_paint_sources(n: &Node) -> (Vec<Option<&AppearanceItem>>, Ve } fn facets(id: &str, path: &PathData, rule: FillRule, bounds: Rect, p: &Value) -> Result<Vec<Facet>, String> { + #[cfg(test)] + if !is_plane(id) { + SOLID_GEOMETRY_BUILT.with(|n| n.set(n.get() + 1)); + } let view = view_options(p); match id { EXTRUDE => vectorcraft_three_d::extrude(path, rule, bounds, extrude_options(p), view), @@ -292,7 +296,7 @@ fn validate_solid_for(doc: Option<&Document>, n: &Node, id: &str, p: &Value, at: let mut shapes = members(n, label)?; reshape_members(n, before, &mut shapes); let b = union_bounds(&shapes).ok_or_else(|| format!("{label} requires a group holding a shape with at least two anchors"))?; - shapes.iter().try_for_each(|s| facets(id, &s.path, s.rule, b, p).map(|_| ()))?; + check_profiles(id, p, &shapes, b)?; check_solids(id, p, &shapes)?; return cast_shadow(id, p, &shapes).map(|_| ()); } @@ -309,12 +313,24 @@ fn validate_solid_for(doc: Option<&Document>, n: &Node, id: &str, p: &Value, at: None => (geometry(&path, before, &ctx), solid_paints(n)), }; let b = path.bounds().ok_or_else(anchors)?; - facets(id, &path, rule, b, p)?; let shapes = [Profile { path, rule, items, opacity: 1.0, scopes: vec![] }]; + check_profiles(id, p, &shapes, b)?; check_solids(id, p, &shapes)?; cast_shadow(id, p, &shapes).map(|_| ()) } +/// Do the solids 3D effect `id` with parameters `p` builds from the profiles of `shapes` about `b` +/// build? Only the profiles no solid of [`check_solids`] is built from are built here: every +/// shape's for Rotate, and for Extrude & Bevel and Inflate the profile of a shape with no fill, +/// whose solids are its strokes' outlines or none. A filled shape's profile is its fill's solid, +/// which [`check_solids`] builds once, about the bounds the effect draws it about. +fn check_profiles(id: &str, p: &Value, shapes: &[Profile], b: Rect) -> Result<(), String> { + shapes + .iter() + .filter(|s| is_plane(id) || !s.items.iter().any(|i| matches!(i, AppearanceItem::Fill(_)))) + .try_for_each(|s| facets(id, &s.path, s.rule, b, p).map(|_| ())) +} + /// Do the solids 3D effect `id` with parameters `p` builds from the fills and strokes of `shapes` /// fit, each on its own and all of them together ([`built_solids`])? Rotate's planes are not /// counted. @@ -658,6 +674,9 @@ fn solid_parts(shapes: &[Profile], fallback: Rect) -> (Vec<Part<'_>>, Rect) { thread_local! { /// How many solids [`built_solids`] and [`meshes_for`] have built on this thread, for the tests. static SOLIDS_BUILT: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; + /// How many Extrude & Bevel (Classic included) and Inflate solids [`facets`] and + /// [`built_solids`] have built on this thread, for the tests. + static SOLID_GEOMETRY_BUILT: std::cell::Cell<usize> = const { std::cell::Cell::new(0) }; } /// The solids Extrude & Bevel (Classic included) or Inflate `id` with parameters `p` builds from @@ -687,7 +706,11 @@ fn built_solids<'a>( #[cfg(test)] SOLIDS_BUILT.with(|n| n.set(n.get() + 1)); let built = match inflated.as_mut() { - Some(each) => each.next().unwrap_or_else(|| Ok(vec![])), + Some(each) => { + #[cfg(test)] + SOLID_GEOMETRY_BUILT.with(|n| n.set(n.get() + 1)); + each.next().unwrap_or_else(|| Ok(vec![])) + } None => facets(id, area, *rule, bounds, p), }; let result = match built { diff --git a/crates/effects/src/solids/tests.rs b/crates/effects/src/solids/tests.rs index eb9e81bbc0..8222484c20 100644 --- a/crates/effects/src/solids/tests.rs +++ b/crates/effects/src/solids/tests.rs @@ -953,6 +953,48 @@ fn an_objects_solids_count_their_faces_together() { } } +/// How many Extrude & Bevel and Inflate solids `check` builds, and its result. +fn geometry_builds(check: impl FnOnce() -> Result<(), String>) -> (usize, Result<(), String>) { + SOLID_GEOMETRY_BUILT.with(|b| b.set(0)); + let result = check(); + (SOLID_GEOMETRY_BUILT.with(std::cell::Cell::get), result) +} + +/// The check builds each solid the effect draws once, about the bounds it draws it about: one for +/// a fill and one for each stroke, on an object, on a group's members and on an appearance item, +/// with the shadow on or off. +#[test] +fn the_check_builds_each_drawn_solid_once() { + for id in [EXTRUDE, CLASSIC_EXTRUDE, INFLATE] { + let n = square_node(); + assert_eq!(geometry_builds(|| validate_solid(&n, id, &json!({}))), (2, Ok(())), "{id}: a fill and a stroke"); + let mut other = square_node(); + other.id = NodeId(2); + let g = Node::group(NodeId(9999), vec![Arc::new(square_node()), Arc::new(other)]); + assert_eq!(geometry_builds(|| validate_solid(&g, id, &json!({}))), (4, Ok(())), "{id}: two members' fills and strokes"); + } + for id in [EXTRUDE, INFLATE] { + let n = square_node(); + assert_eq!(geometry_builds(|| validate_three_d_at(&n, id, &json!({}), (Some(0), 0))), (1, Ok(())), "{id}: on the fill"); + let shadow = json!({"shadow": true}); + assert_eq!(geometry_builds(|| validate_solid(&n, id, &shadow)), (2, Ok(())), "{id}: with the shadow on"); + } +} + +/// A shape with no fill draws no solid of its profile, so the check builds the profile on its own +/// as well as the strokes' solids, and an unpainted shape's profile alone. +#[test] +fn the_check_builds_the_profile_of_a_shape_with_no_fill() { + for id in [EXTRUDE, CLASSIC_EXTRUDE, INFLATE] { + let mut stroked = square_node(); + stroked.appearance.items.retain(|i| matches!(i, AppearanceItem::Stroke(_))); + assert_eq!(geometry_builds(|| validate_solid(&stroked, id, &json!({}))), (2, Ok(())), "{id}: a stroke alone"); + let mut bare = square_node(); + bare.appearance.items.clear(); + assert_eq!(geometry_builds(|| validate_solid(&bare, id, &json!({}))), (1, Ok(())), "{id}: no paint"); + } +} + /// A convex polygon of `corners` corners about (20,000, 20,000), filled red, with no stroke. fn polygon_node(id: u64, corners: usize) -> Node { let points: Vec<Point> = (0..corners) diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..2a9c13e665 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1273,6 +1273,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Extrude & Bevel (both kinds) and Rotate keep the art's curves in the faces they draw, export and expand: caps and the edges of walls and bevels where they meet a cap are cubics with smooth anchors where the art's are, fitted within 0.001 pt in perspective and within the sampling tolerance on a bevel's inset. An edge of a twisted wall that is cut into pieces, a piece of curve that does not fit after 8 halvings, and the curves past 1,048,576 for one solid stay straight (VectorCraft's own values; [three-d.md](three-d.md#what-differs-from-the-public-documentation)). Tests `solid::tests::a_cap_keeps_the_curves_of_the_art`, `a_cap_in_perspective_fits_the_projected_curves`, `a_beveled_cap_and_its_walls_share_their_curves`, `twisted_beveled_tiny_and_degenerate_caps_keep_their_curves`. - Export 3D Object (Asset Export's menu): an object with Extrude & Bevel, Revolve, Inflate or Rotate becomes a 3D asset whose Format is USDA (the default), USDZ, glTF or OBJ, and Export writes each of its solids as a mesh with a material in its paint's color (`assets.add3D`, `assets.set3DFormat`, `assets.export3D`; [export 3D vector artwork](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/export-3d-vector-artwork.html)). - Export 3D Object builds each Extrude & Bevel (both kinds) and Inflate solid once: the same build gives the faces that count toward the object's limit and the faces of its mesh, and the meshes match those of a separate build bit for bit. Tests `mesh::tests::a_meshed_solid_is_built_once`, `an_extruded_solid_and_its_mesh_match_the_two_built_apart`, `inflated_solids_and_their_meshes_match_the_two_built_apart`, `solids::tests_mesh::one_build_exports_the_meshes_built_apart`, `a_stroke_past_the_limits_is_left_out_of_the_export`. + - Checking an Extrude & Bevel (both kinds) or Inflate effect builds each solid the effect draws once, about the bounds the effect draws it about; a shape with no fill still has its profile built on its own. Tests `solids::tests::the_check_builds_each_drawn_solid_once`, `the_check_builds_the_profile_of_a_shape_with_no_fill`. - Initial live Revolve (#605, #846): a portable geometry and shading crate (`three-d`), editable path and compound profiles, compact options with artboard rotation and light gizmos, SVG/PDF vector output and Expand Appearance that can trim covered faces. Open ends have continuous caps by default, shading is smooth with one to ten colored lights, and intersecting surfaces' visibility is approximate ([revolve.md](revolve.md)). - Revolve takes graphics on its swept side, shaded with the object's light ([the archived reference, page 185](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=185)). By VectorCraft's own rule a graphic wraps around the axis at its own size at every distance from it, narrows toward the silhouette, follows the profile along its length and is hidden where the side faces away (`threeD.mapGraphic`; `revolve::tests_graphics`, `tests::side_faces_lie_on_the_unrolled_surface_and_caps_do_not`, `map_graphic_puts_a_graphic_on_the_side_of_a_revolve`). - Revolve takes type, as its glyph outlines, and groups or layers, whose members sweep about one axis as [the help page](https://helpx.adobe.com/illustrator/desktop/special-effects-styles/create-3d-graphics/create-3d-objects.html) describes; a surface can have up to 16,384 profile points, and curves take fewer samples when a surface would pass 163,840 faces (#3617). From fb8cf27b9a4677e80b6cc84dcd13e25ac1d0dcf6 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:52:45 -0800 Subject: [PATCH 090/108] Effects: clip regions follow fill effects and compound paths in every case Three cases still clipped differently from what the clipping path draws: - A clip group with an appearance of its own (a Drop Shadow, a geometry effect) was measured for culling by its plain clipping path, so a view showing only the part of the clip that an effect moved drew nothing. The renderer now grows that measure by the clip region in this case too. - The geometry effects on the fills and strokes of an unpainted clipping path applied after the effects of a group around it. They now apply first, as for other members. A clipping path that paints keeps them live, so its fill and stroke still draw. - Export baked a compound clipping path with an effect of its own from its raw paths, dropping the effects on those paths. It now bakes the clipping path as the canvas clips by it, and the pieces it bakes into get ids of their own. --- crates/effects/src/bake.rs | 19 ++++++- crates/effects/src/clip.rs | 38 +++++++------ crates/effects/src/tests/clipfx.rs | 86 ++++++++++++++++++++++++++++++ crates/render/src/fx/bounds.rs | 33 +++++++----- crates/render/src/tests/clip.rs | 37 +++++++++++++ 5 files changed, 182 insertions(+), 31 deletions(-) diff --git a/crates/effects/src/bake.rs b/crates/effects/src/bake.rs index adbdf20b48..27d3194eb3 100644 --- a/crates/effects/src/bake.rs +++ b/crates/effects/src/bake.rs @@ -39,7 +39,7 @@ pub(crate) fn item_effects(item: &AppearanceItem) -> &[vectorcraft_doc::Effect] } } -fn clear_item_effects(item: &mut AppearanceItem) { +pub(crate) fn clear_item_effects(item: &mut AppearanceItem) { match item { AppearanceItem::Fill(f) => f.effects = crate::raster::without_geometry(&f.effects), AppearanceItem::Stroke(s) => s.effects = crate::raster::without_geometry(&s.effects), @@ -202,7 +202,22 @@ fn bake_node(d: &mut Document, n: &Node) -> Option<Node> { return bake_leaf(d, n); } let mut m = n.clone(); - let baked: Vec<Arc<Node>> = ch.iter().map(|c| bake_node(d, c).map(Arc::new).unwrap_or_else(|| c.clone())).collect(); + // A clipping path takes the geometry effects in it as the canvas clips by it, those of a + // compound path's paths before the compound path's own ([`crate::clip::with_clip_effects_applied`]); + // the pieces it is made of then get ids of their own. + let clip = usize::from(n.clips()); + let baked: Vec<Arc<Node>> = ch + .iter() + .enumerate() + .map(|(i, c)| match (i < clip).then(|| crate::clip::with_clip_effects_applied(c)).flatten() { + Some(a) => { + let mut a = bake_node(d, &a).unwrap_or(a); + fresh_ids(d, &mut a, &mut std::collections::HashSet::new()); + Arc::new(a) + } + None => bake_node(d, c).map(Arc::new).unwrap_or_else(|| c.clone()), + }) + .collect(); if let Some(ch) = m.children_mut() { *ch = baked; } diff --git a/crates/effects/src/clip.rs b/crates/effects/src/clip.rs index e39deb32b5..60cc3f2845 100644 --- a/crates/effects/src/clip.rs +++ b/crates/effects/src/clip.rs @@ -24,17 +24,21 @@ pub fn clip_outline(clip: &Node) -> Option<(BezPath, FillRule)> { /// effects, as an export bakes it), the paths of a compound path and the visible members of a group /// are reshaped by their own effects before the effects around them, a group's or layer's own /// effects reshape its members as an export evaluates them, and other objects with effects (type) -/// become a path of their reshaped region. The geometry effects of a path's fills and strokes stay -/// live, for the export to bake. `None` when nothing in it has a geometry effect. Effects on the -/// clip group or around it then reshape the result, after its own. +/// become a path of their reshaped region. A path or compound path whose fills or strokes have +/// geometry effects becomes a group of one path per fill and stroke, reshaped by the path's effects +/// and then by that fill's or stroke's, as an export bakes it; [`clip_outline`] clips by their +/// union. A clipping path that paints ([`Node::clip_paint`], which a group does not) keeps the +/// geometry effects of its own fills and strokes live instead. `None` when nothing in it has a +/// geometry effect. Effects on the clip group or around it then reshape the result, after its own. pub(crate) fn with_clip_effects_applied(n: &Node) -> Option<Node> { - clip_effects_applied(n, false) + let paint = n.clip_paint(); + clip_effects_applied(n, paint.fill.is_none() && paint.stroke.is_none()) } -/// [`with_clip_effects_applied`]; with `region` set, a path or compound path whose fills or strokes -/// have geometry effects becomes a group of one unpainted path per fill and stroke, reshaped by the -/// path's effects and then by that fill's or stroke's, whose union [`clip_outline`] clips by. -fn clip_effects_applied(n: &Node, region: bool) -> Option<Node> { +/// [`with_clip_effects_applied`]; with `items` unset (a clipping path that paints, and the paths of +/// a compound path, which draw with the compound path's fills and strokes), the geometry effects of +/// `n`'s own fills and strokes are left out. +fn clip_effects_applied(n: &Node, items: bool) -> Option<Node> { let mut m: Option<Node> = None; let members: &[std::sync::Arc<Node>] = match &n.kind { NodeKind::Group { children, clip: true } => children.get(..1).unwrap_or_default(), @@ -49,33 +53,35 @@ fn clip_effects_applied(n: &Node, region: bool) -> Option<Node> { // The paths of a compound path draw with the compound path's fills and strokes, and stay paths. let compound = matches!(n.kind, NodeKind::Compound { .. }); for (i, c) in members.iter().enumerate().skip(skip).filter(|(_, c)| all || c.visible) { - if let Some(r) = clip_effects_applied(c, region && !compound) + if let Some(r) = clip_effects_applied(c, items && !compound) && let Some(slot) = m.get_or_insert_with(|| n.clone()).children_mut().and_then(|ch| ch.get_mut(i)) { *slot = std::sync::Arc::new(r); } } - let items = region + let items = items && matches!(n.kind, NodeKind::Path { .. } | NodeKind::Compound { .. }) && n.appearance.items.iter().any(|i| crate::has_geometry(crate::bake::item_effects(i))); - if items && let Some((g, rule, ctx, p)) = crate::bake::leaf_base(m.as_ref().unwrap_or(n)) { + if items && let Some((g, rule, ctx, mut p)) = crate::bake::leaf_base(m.as_ref().unwrap_or(n)) { let children = n .appearance .items .iter() .zip(&p.appearance.items) .map(|(item, carried)| { - let (ig, _) = crate::bake::apply_item(item, carried, &g, &ctx); - let mut piece = Node::path(n.id, ig, Appearance::default()); + let (ig, mut it) = crate::bake::apply_item(item, carried, &g, &ctx); + crate::bake::clear_item_effects(&mut it); + let mut piece = Node::path(n.id, ig, Appearance { items: vec![it], ..Default::default() }); if let NodeKind::Path { rule: r, .. } = &mut piece.kind { *r = rule; } std::sync::Arc::new(piece) }) .collect(); - let mut out = Node::new(n.id, NodeKind::Group { children, clip: false }); - out.visible = n.visible; - return Some(out); + // The path's transparency and raster effects stay on the group of its pieces. + p.appearance.items.clear(); + p.kind = NodeKind::Group { children, clip: false }; + return Some(p); } if !crate::has_geometry(&n.appearance.effects) { return m; diff --git a/crates/effects/src/tests/clipfx.rs b/crates/effects/src/tests/clipfx.rs index c513be72c3..370f32fa81 100644 --- a/crates/effects/src/tests/clipfx.rs +++ b/crates/effects/src/tests/clipfx.rs @@ -131,6 +131,15 @@ fn a_compound_paths_member_keeps_its_effect() { let live = clip_outline(&moved).unwrap(); assert_eq!(live, clip_outline(&baked_clip(&d)).unwrap(), "the canvas clips by the outline the export writes"); assert_ne!(live, clip_outline(&ring(vec![])).unwrap(), "the hole moves"); + // With a Transform of the compound path's own moving the whole ring 10 pt down after it. + let mut both = moved.clone(); + both.appearance.effects.push(fx("distort.transform", json!({"moveV": 10}))); + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + d.insert(Some(layer), 0, clip_group(1, both.clone())).unwrap(); + let live = clip_outline(&both).unwrap(); + assert_eq!(live, clip_outline(&baked_clip(&d)).unwrap(), "the canvas clips by the outline the export writes"); + assert_ne!(live.0.bounding_box(), clip_outline(&moved).unwrap().0.bounding_box(), "the ring moves down"); } #[test] @@ -296,6 +305,83 @@ fn a_fills_geometry_effect_shapes_the_clip_as_an_export_does() { assert_eq!(bounds(&compound), Rect::new(0.0, 0.0, 150.0, 150.0)); } +#[test] +fn a_fills_geometry_effect_shapes_the_clip_before_the_effects_around_it() { + // Offset Path 10 on the fill of an unpainted clipping path, in a group that its Transform + // scales to 50 %: the region is the grown square at half size, 60 pt across, as it is when the + // clipping path is the member of a group that clips by its members. + let clip_with = |fill: Paint| { + let mut clip = clipping_path(3, vec![]); + clip.appearance = Appearance::basic(fill, Paint::None, 0.0).into(); + for item in &mut clip.appearance.items { + if let vectorcraft_doc::AppearanceItem::Fill(f) = item { + f.effects.push(fx("path.offsetPath", json!({"offset": 10}))); + } + } + clip + }; + let scaled = |clip: Node| { + let mut outer = Node::group(NodeId(1), vec![Arc::new(clip_group(2, clip))]); + outer.appearance.effects.push(fx("distort.transform", json!({"scaleH": 50, "scaleV": 50}))); + outer + }; + fn first_clip(n: &Node) -> Option<Arc<Node>> { + match &n.kind { + NodeKind::Group { children, clip: true } => children.first().cloned(), + _ => n.children()?.iter().find_map(|c| first_clip(c)), + } + } + let clip_of = |n: &Node| clip_outline(&first_clip(n).unwrap()).unwrap().0.bounding_box(); + let close = |r: Rect| (r.width() - 60.0).abs() < 0.5 && (r.height() - 60.0).abs() < 0.5; + let nested = clip_of(&crate::evaluate_container(None, &scaled(Node::group(NodeId(4), vec![Arc::new(clip_with(Paint::None))]))).unwrap()); + assert!(close(nested), "nested: {nested:?}"); + let outer = scaled(clip_with(Paint::None)); + let canvas = clip_of(&crate::evaluate_container(None, &outer).unwrap()); + assert!(close(canvas), "canvas: {canvas:?}"); + let mut d = Document::new(400.0, 400.0); + let layer = d.layers[0].id; + d.insert(Some(layer), 0, outer).unwrap(); + let baked = bake_document(&d).unwrap(); + let exported = baked.layers.iter().find_map(|l| first_clip(l)).map(|c| clip_outline(&c).unwrap().0.bounding_box()).unwrap(); + assert!(close(exported), "exported: {exported:?}"); + // A clipping path that paints its fill keeps it, a path with the fill's effect live. + let painted = first_clip(&crate::evaluate_container(None, &scaled(clip_with(Paint::solid(Color::BLACK)))).unwrap()).unwrap(); + assert!(painted.clip_paint().fill.is_some(), "{painted:?}"); +} + +#[test] +fn a_baked_clipping_path_gives_its_pieces_ids_of_their_own() { + // An unpainted clipping path whose fill and stroke have Transform effects, in a clip group + // without effects: the export bakes it into a piece for each, every object with its own id. + let mut d = Document::new(400.0, 400.0); + let (group, path) = (d.alloc_id(), d.alloc_id()); + let mut clip = clipping_path(path.0, vec![]); + clip.appearance = Appearance::basic(Paint::None, Paint::None, 1.0).into(); + for item in &mut clip.appearance.items { + match item { + vectorcraft_doc::AppearanceItem::Fill(f) => f.effects.push(fx("distort.transform", json!({"moveH": 60}))), + vectorcraft_doc::AppearanceItem::Stroke(s) => s.effects.push(fx("distort.transform", json!({"moveV": 60}))), + } + } + let layer = d.layers[0].id; + d.insert(Some(layer), 0, clip_group(group.0, clip)).unwrap(); + let baked = bake_document(&d).unwrap(); + let clip = baked_clip(&d); + assert_eq!(clip.children().map(|c| c.len()), Some(2), "{clip:?}"); + fn ids(n: &Node, out: &mut Vec<NodeId>) { + out.push(n.id); + for c in n.children().into_iter().flatten() { + ids(c, out); + } + } + let mut all = vec![]; + for l in &baked.layers { + ids(l, &mut all); + } + let unique: std::collections::HashSet<_> = all.iter().collect(); + assert_eq!(unique.len(), all.len(), "{all:?}"); +} + #[test] fn a_hidden_member_with_an_effect_adds_nothing() { let shown = Node::path(NodeId(3), shapes::rectangle(Rect::new(50.0, 50.0, 100.0, 100.0)), Appearance::default()); diff --git a/crates/render/src/fx/bounds.rs b/crates/render/src/fx/bounds.rs index 7816d3f187..65ce8a91fd 100644 --- a/crates/render/src/fx/bounds.rs +++ b/crates/render/src/fx/bounds.rs @@ -623,7 +623,7 @@ fn cull_bounds_in(symbols: &SymbolBoxes, n: &Node, after_reshape: bool, brush: b let art = effects::evaluate_container(Some(symbols.document()), n); let art = art.as_ref().unwrap_or(n); let b = if art.clips() { - art.visual_bounds_with(symbols) + art.visual_bounds_with(symbols).map(|b| with_clip_region(symbols, art, b)) } else { art.children()?.iter().fold(None, |acc, c| vectorcraft_geom::union_opt(acc, member(c))) }?; @@ -671,18 +671,7 @@ fn cull_bounds_in(symbols: &SymbolBoxes, n: &Node, after_reshape: bool, brush: b let b = n.visual_bounds_with(symbols)?; let b = match &n.kind { NodeKind::Text(t) => vectorcraft_geom::union_opt(Some(b), glyphs_box(t, n.appearance.outset())).unwrap_or(b), - // The geometry effects in a clipping path move or grow the region it clips to - // ([`effects::clip_outline`]) past its plain shape, and its stroke paints along it. - NodeKind::Group { children, clip: true } | NodeKind::Layer { children, clip: true, .. } => match children.first() { - Some(c) if effects::needs_bake(c) => { - let s = c.appearance.outset(); - let region = effects::clip_outline(c).map(|(bp, _)| bp.bounding_box().inflate(s, s)); - let painted = if has_fx(c) { visual_bounds(symbols, c) } else { None }; - vectorcraft_geom::union_opt(vectorcraft_geom::union_opt(Some(b), region), painted).unwrap_or(b) - } - _ => b, - }, - _ => b, + _ => with_clip_region(symbols, n, b), }; let a = live_content_reach(symbols, n); Some(b.inflate(a, a)) @@ -690,6 +679,24 @@ fn cull_bounds_in(symbols: &SymbolBoxes, n: &Node, after_reshape: bool, brush: b } } +/// `b`, the visual bounds of `n`, grown to the region a clip group's or clipping layer's clipping +/// path clips to when geometry effects in it move or grow that region ([`effects::clip_outline`]) +/// past its plain shape, and to where its stroke paints along it. Other objects keep `b`. +fn with_clip_region(symbols: &SymbolBoxes, n: &Node, b: Rect) -> Rect { + match &n.kind { + NodeKind::Group { children, clip: true } | NodeKind::Layer { children, clip: true, .. } => match children.first() { + Some(c) if effects::needs_bake(c) => { + let s = c.appearance.outset(); + let region = effects::clip_outline(c).map(|(bp, _)| bp.bounding_box().inflate(s, s)); + let painted = if has_fx(c) { visual_bounds(symbols, c) } else { None }; + vectorcraft_geom::union_opt(vectorcraft_geom::union_opt(Some(b), region), painted).unwrap_or(b) + } + _ => b, + }, + _ => b, + } +} + /// The bounds of the art a 3D effect of `n` draws (Revolve, Extrude & Bevel, Inflate, Rotate), /// built now, without `n`'s own raster effects ([`three_d_art_bounds`]): `None` when it draws no /// such art, `Some(None)` when that art paints nothing. The renderer measures the art it keeps diff --git a/crates/render/src/tests/clip.rs b/crates/render/src/tests/clip.rs index cdd2028441..205c2a2583 100644 --- a/crates/render/src/tests/clip.rs +++ b/crates/render/src/tests/clip.rs @@ -131,6 +131,43 @@ fn a_view_of_only_the_moved_clip_draws_the_clipped_art() { } } +#[test] +fn a_view_of_only_the_moved_clip_draws_a_clip_group_with_its_own_appearance() { + // As above, with the Transform effect on the clipping path itself or on its fill, and the clip + // group with an effect of its own: a Drop Shadow, or a Transform that moves nothing. + let moved = || vectorcraft_doc::Effect { id: "distort.transform".into(), params: serde_json::json!({"moveH": 50}), visible: true }; + let shadow = vectorcraft_doc::Effect { + id: "stylize.dropShadow".into(), + params: serde_json::json!({"x": 0, "y": 6, "blur": 0, "opacity": 100}), + visible: true, + }; + let still = vectorcraft_doc::Effect { id: "distort.transform".into(), params: serde_json::json!({"moveV": 0}), visible: true }; + for on_fill in [false, true] { + for own in [shadow.clone(), still.clone()] { + let mut d = Document::new(100.0, 100.0); + let mut clip = Node::path(d.alloc_id(), rect(Rect::new(0.0, 0.0, 50.0, 100.0)), Appearance::basic(Paint::None, Paint::None, 0.0)); + match clip.appearance.items.iter_mut().find_map(|i| match i { + vectorcraft_doc::AppearanceItem::Fill(f) if on_fill => Some(f), + _ => None, + }) { + Some(f) => f.effects.push(moved()), + None => clip.appearance.effects.push(moved()), + } + let art = + Node::path(d.alloc_id(), rect(Rect::new(0.0, 0.0, 100.0, 100.0)), Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 0.0)); + let mut g = Node::new(d.alloc_id(), NodeKind::Group { children: vec![Arc::new(clip), Arc::new(art)], clip: true }); + g.appearance.effects.push(own.clone()); + let l = d.layers[0].id; + d.insert(Some(l), 0, g).unwrap(); + let what = format!("effect on the fill: {on_fill}, group effect {}", own.id); + let whole = Renderer::new().render(&d, 100, 100, Affine::IDENTITY, &RenderOptions::default()); + assert_eq!(whole.pixel(80, 50), BLACK, "the whole canvas ({what})"); + let r = Renderer::new().render(&d, 40, 100, Affine::translate((-60.0, 0.0)), &RenderOptions::default()); + assert_eq!(r.pixel(20, 50), BLACK, "x 80, inside the moved clip ({what})"); + } + } +} + #[test] fn clip_regions_are_cached_per_clipping_path() { let mut d = Document::new(100.0, 100.0); From 4eb1b1cf99ef3c0e409d3f0f3cbd73eb9b8f7b78 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:44:47 -0800 Subject: [PATCH 091/108] SVG import: linked rasters inside a linked SVG file are read An SVG file that an <image> links to was parsed with usvg's from_data_nested, which drops every href to a file, so a PNG or JPEG that the SVG file linked to disappeared without a placeholder or a warning. The files a linked SVG file's own <image> elements link to are now read the way the imported SVG's links are, relative paths from that file's folder: a raster stays linked, an SVG file imports as vector art, and one that can't be read (missing, or refused by the reader) gets the placeholder stretched to its box, its link and a warning. The same href in SVG files of two folders names two files. A link that leads back to an SVG file showing it gets the placeholder and a warning. Reading the links of linked SVG files stops at the element depth cap and at 1,024 reads and 512 MB of text per import, the same limits decoded nested SVG images have, counted separately from them. An SVG data URL still reads no file links, having no folder of its own. SVG 2 tells a viewer to ignore external references in an SVG shown by <image>; reading them on import is VectorCraft's own rule. --- crates/svg/src/import/files.rs | 210 +++++++++++++++++++---- crates/svg/src/import/prepass.rs | 2 +- crates/svg/tests/it/image_orientation.rs | 15 ++ crates/svg/tests/it/import_details.rs | 163 ++++++++++++++++++ docs/target-app-parity.md | 1 + 5 files changed, 355 insertions(+), 36 deletions(-) diff --git a/crates/svg/src/import/files.rs b/crates/svg/src/import/files.rs index bab4246270..605b206717 100644 --- a/crates/svg/src/import/files.rs +++ b/crates/svg/src/import/files.rs @@ -4,6 +4,10 @@ //! (missing, remote, not an image) becomes a placeholder that keeps the link and its place, so it //! can be relinked, and a warning. //! +//! A linked SVG file's own `<image>` links are read the same way, relative paths from that file's +//! folder, within the same limits; an href that leads back to an SVG file showing it gets the +//! placeholder and a warning. +//! //! A raster image, linked or a data URL, whose orientation (EXIF, or a TIFF's Orientation tag) //! turns or flips its pixels is turned before usvg gets it, so it is sized, fitted and stored as //! it is shown. @@ -35,6 +39,9 @@ pub const MAX_NESTED_SVG_TEXT: u64 = 512 << 20; pub(in crate::import) struct Files { /// What usvg gets for each linked href. sources: HashMap<String, Source>, + /// The SVG images usvg is reading, innermost last: a linked SVG file, whose own links an href + /// inside it is looked up in, or `None` for a data URL. + within: Mutex<Vec<Option<Arc<SvgFile>>>>, /// The link of each linked raster or placeholder, by the address of the bytes usvg got. links: HashMap<usize, Linked>, /// An SVG image had text (which isn't imported). @@ -84,8 +91,42 @@ type RasterKind = fn(Arc<Vec<u8>>) -> ImageKind; enum Source { /// A raster file of the kind usvg reads it as. Raster(RasterKind, Arc<Vec<u8>>), - /// An SVG file's text (unpacked when it is SVGZ), parsed by usvg as an image. - Svg(Arc<str>), + /// An SVG file, parsed by usvg as an image. + Svg(Arc<SvgFile>), +} + +/// A linked SVG file as usvg reads it. +struct SvgFile { + /// Its text (unpacked when it is SVGZ), placeholders stretched to their boxes. + text: Arc<str>, + /// What usvg gets for each href its own `<image>` elements link to. + sources: HashMap<String, Source>, +} + +/// The state of [`Files::read`] across the SVG files it reads the links of. +struct Reading<'a, 'w> { + opts: &'a ImportOptions<'a>, + warnings: &'w mut Vec<String>, + /// The placeholder's bytes, made once. + placeholder: Option<Option<Vec<u8>>>, + /// What each file read gave, by the file: hrefs spelled differently (`a.png`, `./a.png`, + /// `%61.png`), and in different SVG files, share one read and one copy of its bytes. An SVG + /// file with a link inside it that led back to an SVG file isn't kept: what it shows depends + /// on where it is. + by_file: HashMap<String, Result<Source, &'static str>>, + /// The SVG files whose links are being read, innermost last, by [`identity`]. + active: Vec<String>, + /// A link led back to one of them while the file being read was read. + led_back: bool, + /// How many linked SVG files were read for their links, and the bytes of their text. + svg_reads: usize, + svg_text: u64, +} + +/// What the link to an SVG file being read is compared by, to find a link back to it: its path +/// with links and `..` resolved, or the path as given when that can't be found. +fn identity(file: &str) -> String { + std::fs::canonicalize(file).map_or_else(|_| file.to_string(), |p| p.to_string_lossy().into_owned()) } /// A linked raster image (or the placeholder of a missing one). @@ -164,54 +205,120 @@ impl Files { /// relinked. pub(in crate::import) fn read(svg: &str, xml: &roxmltree::Document, opts: &ImportOptions, edits: &mut Edits, warnings: &mut Vec<String>) -> Self { let mut files = Files::default(); - let mut placeholder = None; - // What each file read gave, by the file: hrefs spelled differently (`a.png`, `./a.png`, - // `%61.png`) share one read and one copy of its bytes. - let mut by_file: HashMap<String, Result<Source, &str>> = HashMap::new(); + let mut reading = + Reading { opts, warnings, placeholder: None, by_file: HashMap::new(), active: vec![], led_back: false, svg_reads: 0, svg_text: 0 }; + files.sources = files.links_of(svg, xml, opts.folder, None, edits, &mut reading); + files + } + + /// What usvg gets for each href the `<image>` elements of `xml` (the text `svg`) link to, + /// relative paths taken from `folder`. `inside` is how deep the SVG images `xml` shows nest in + /// it and the SVGs around it, measured when an SVG file is read (`None` for `xml` itself). + fn links_of( + &mut self, + svg: &str, + xml: &roxmltree::Document, + folder: Option<&str>, + mut inside: Option<usize>, + edits: &mut Edits, + reading: &mut Reading<'_, '_>, + ) -> HashMap<String, Source> { + let mut sources: HashMap<String, Source> = HashMap::new(); for n in xml.descendants().filter(|n| n.is_element() && n.tag_name().name() == "image") { let Some(h) = href(n).filter(|h| !h.trim_start().starts_with("data:")) else { continue }; - if !files.sources.contains_key(h) { - let (path, file) = target(h, opts.folder); + if !sources.contains_key(h) { + let (path, file) = target(h, folder); // A failed read is cached too, but each href gets its own placeholder: its own link // path (an Arc shared between hrefs would share the first href's link) and warning. - let cached = file.as_ref().and_then(|f| by_file.get(f)).cloned(); + let back = !reading.active.is_empty() && file.as_deref().is_some_and(|f| reading.active.contains(&identity(f))); + let cached = file.as_ref().and_then(|f| reading.by_file.get(f)).cloned(); let source = match cached { + _ if back => { + reading.led_back = true; + Err("leads back to an SVG file that shows it") + } Some(source) => source, None => { - let read = file.clone().and_then(|file| opts.read.and_then(|read| read(&file))); - let source = match read { - Some((bytes, link)) => files.source(bytes, link).ok_or("is not an image VectorCraft reads"), - None => Err("not found"), + let read = file.clone().and_then(|file| reading.opts.read.and_then(|read| read(&file))); + let around = std::mem::replace(&mut reading.led_back, false); + let source = match (read, file.as_deref()) { + (Some((bytes, link)), Some(f)) => match self.source(bytes, link) { + Some(Source::Svg(text)) => { + let inside = *inside.get_or_insert_with(|| depth::height(xml, MAX_ELEMENT_DEPTH).unwrap_or(MAX_ELEMENT_DEPTH)); + // Past what may be read of the SVG files, the image is left out (noted). + let Some(source) = self.svg_file(text, f, inside, reading) else { + reading.led_back = around; + continue; + }; + Ok(source) + } + source => source.ok_or("is not an image VectorCraft reads"), + }, + _ => Err("not found"), }; - if let Some(file) = file { - by_file.insert(file, source.clone()); + // Kept unless a link inside it led back to an SVG file. + let led_back = reading.led_back; + reading.led_back |= around; + if let Some(file) = file + && !led_back + { + reading.by_file.insert(file, source.clone()); } source } }; let source = source.or_else(|why| { - warnings.push(format!("linked image '{h}' {why}: a placeholder keeps its place until it is relinked")); - let bytes = Arc::new(placeholder.get_or_insert_with(missing_placeholder).clone().ok_or(why)?); - files.links.insert(key(&bytes), Linked { link: LinkInfo::new(path), missing: true }); + reading.warnings.push(format!("linked image '{h}' {why}: a placeholder keeps its place until it is relinked")); + let bytes = Arc::new(reading.placeholder.get_or_insert_with(missing_placeholder).clone().ok_or(why)?); + self.links.insert(key(&bytes), Linked { link: LinkInfo::new(path), missing: true }); Ok::<_, &str>(Source::Raster(ImageKind::PNG, bytes)) }); let Ok(source) = source else { continue }; - files.sources.insert(h.to_string(), source); + sources.insert(h.to_string(), source); } - if files.placeholder(h) { + if sources.get(h).is_some_and(|s| self.missing(s)) { edits.set(svg, n, "preserveAspectRatio", "none"); } } - files + sources + } + + /// Linked SVG file `file`, read as `svg`, with the files its own `<image>` elements link to + /// read from its folder; `inside` is how deep it nests in the SVGs around it. Its links aren't + /// read when it nests too deep to be shown, or when it isn't XML. `None`, noted, once the SVG + /// files read for their links pass [`MAX_NESTED_SVG_READS`] or [`MAX_NESTED_SVG_TEXT`]. + fn svg_file(&mut self, svg: Arc<SvgFile>, file: &str, inside: usize, reading: &mut Reading<'_, '_>) -> Option<Source> { + let left = MAX_ELEMENT_DEPTH.saturating_sub(inside); + if !svg.text.contains("image") || depth::xml_deeper_than(&svg.text, left) { + return Some(Source::Svg(svg)); + } + reading.svg_reads += 1; + reading.svg_text = reading.svg_text.saturating_add(svg.text.len() as u64); + if reading.svg_reads > MAX_NESTED_SVG_READS || reading.svg_text > MAX_NESTED_SVG_TEXT { + self.too_much_svg_read.store(true, Ordering::Relaxed); + return None; + } + // Read from its own handle: the text stays borrowed while `svg` may be given back. + let text = svg.text.clone(); + let Ok(xml) = super::parse(&text) else { return Some(Source::Svg(svg)) }; + let Some(height) = depth::height(&xml, left) else { return Some(Source::Svg(svg)) }; + let folder = Path::new(file).parent().map(|p| p.to_string_lossy().into_owned()); + let mut edits = Edits::default(); + reading.active.push(identity(file)); + let sources = self.links_of(&text, &xml, folder.as_deref(), Some(inside + height), &mut edits, reading); + reading.active.pop(); + let text = Arc::from(edits.apply(&text).as_ref()); + Some(Source::Svg(Arc::new(SvgFile { text, sources }))) } /// What usvg gets for a file read (`bytes`, linked by `link`): a raster as [`shown`] gives it - /// (formats usvg doesn't read are stored as PNG) or an SVG; `None` for anything else. + /// (formats usvg doesn't read are stored as PNG) or an SVG, its own links not read yet; `None` + /// for anything else. fn source(&mut self, bytes: Vec<u8>, link: LinkInfo) -> Option<Source> { let Ok(format) = image::guess_format(&bytes) else { // Unpacked once, here, within what the SVGZ images may unpack to. let text = crate::text_within(&bytes, &self.unpacked).ok()?; - return text.contains("<svg").then(|| Source::Svg(Arc::from(text.as_ref()))); + return text.contains("<svg").then(|| Source::Svg(Arc::new(SvgFile { text: Arc::from(text.as_ref()), sources: HashMap::new() }))); }; let (kind, bytes) = self.keep(shown(Arc::new(bytes), format)?); self.links.insert(key(&bytes), Linked { link, missing: false }); @@ -236,9 +343,21 @@ impl Files { self.cmyk.lock().ok()?.get(&key(b)).map(|(_, tiff)| tiff.clone()) } - /// Does href `h` show a placeholder? - fn placeholder(&self, h: &str) -> bool { - matches!(self.sources.get(h), Some(Source::Raster(_, b)) if self.links.get(&key(b)).is_some_and(|l| l.missing)) + /// Is `source` a placeholder? + fn missing(&self, source: &Source) -> bool { + matches!(source, Source::Raster(_, b) if self.links.get(&key(b)).is_some_and(|l| l.missing)) + } + + /// What usvg gets for href `h` where it is read: inside a linked SVG file, from that file's + /// own links; outside any SVG image, from the imported SVG's. Inside an SVG data URL, which + /// has no folder of its own, nothing. + fn find(&self, h: &str) -> Option<Source> { + let within = self.within.lock().ok()?; + let sources = match within.last() { + None => &self.sources, + Some(file) => &file.as_ref()?.sources, + }; + sources.get(h).or_else(|| sources.get(h.trim())).cloned() } /// The link of the image whose data usvg got as `kind`. @@ -308,9 +427,9 @@ impl Files { let (kind, bytes) = self.keep(shown(bytes, format)?); Some(kind(bytes)) }), - resolve_string: Box::new(move |h, opts| match self.sources.get(h).or_else(|| self.sources.get(h.trim()))? { - Source::Raster(kind, bytes) => Some(kind(bytes.clone())), - Source::Svg(text) => self.svg(text, opts), + resolve_string: Box::new(move |h, opts| match self.find(h)? { + Source::Raster(kind, bytes) => Some(kind(bytes)), + Source::Svg(file) => self.svg(&file.text.clone(), Some(file), opts), }), } } @@ -320,7 +439,7 @@ impl Files { /// noted. fn svg_data(&self, bytes: &[u8], opts: &usvg::Options) -> Option<ImageKind> { match crate::text_within(bytes, &self.unpacked) { - Ok(text) => self.svg(&text, opts), + Ok(text) => self.svg(&text, None, opts), Err(e) => leave_out(&self.too_big, matches!(e, SvgError::TooBig(_))), } } @@ -329,8 +448,9 @@ impl Files { /// can't read, when it isn't SVG or when its elements nest deeper than the SVGs around it /// leave: usvg reads it while it reads them, on the same stack. Only a decoded image, with the /// images decoded inside it, counts toward [`MAX_NESTED_SVG_IMAGES`]; every image read counts - /// toward [`MAX_NESTED_SVG_READS`] and [`MAX_NESTED_SVG_TEXT`]. - fn svg(&self, text: &str, opts: &usvg::Options) -> Option<ImageKind> { + /// toward [`MAX_NESTED_SVG_READS`] and [`MAX_NESTED_SVG_TEXT`]. `file` is the linked SVG file + /// the text is, whose own links the hrefs in it are looked up in. + fn svg(&self, text: &str, file: Option<Arc<SvgFile>>, opts: &usvg::Options) -> Option<ImageKind> { let decoded = self.svg_images.load(Ordering::Relaxed); if decoded >= MAX_NESTED_SVG_IMAGES { return leave_out(&self.too_many_svg_images, true); @@ -345,7 +465,7 @@ impl Files { // The image's place is taken while usvg reads it, so the images inside it get what is left. // usvg reads them all on this thread, so no other read comes between these steps. self.svg_images.store(decoded + 1, Ordering::Relaxed); - let tree = self.svg_tree(text, opts); + let tree = self.svg_tree(text, file, opts); if tree.is_none() { self.svg_images.store(decoded, Ordering::Relaxed); } @@ -353,7 +473,7 @@ impl Files { } /// [`Files::svg`]'s image once it is counted. - fn svg_tree(&self, text: &str, opts: &usvg::Options) -> Option<ImageKind> { + fn svg_tree(&self, text: &str, file: Option<Arc<SvgFile>>, opts: &usvg::Options) -> Option<ImageKind> { // Measured as the SVG holding it is (`import`): the text before the XML reader. let used = self.depth.load(Ordering::Relaxed); let left = MAX_ELEMENT_DEPTH.saturating_sub(used); @@ -365,7 +485,27 @@ impl Files { // usvg's parser would overflow on it, as on the SVG holding it (`import`). super::convolve_matrices_ok(&xml).ok()?; self.depth.store(used + height, Ordering::Relaxed); - let tree = usvg::Tree::from_data_nested(text.as_bytes(), opts); + let within = self.within.lock().ok().map(|mut w| w.push(file)).is_some(); + // usvg's `Tree::from_data_nested`, except that hrefs to files go to the resolver. + let nested = usvg::Options { + resources_dir: None, + dpi: opts.dpi, + font_size: opts.font_size, + languages: opts.languages.clone(), + shape_rendering: opts.shape_rendering, + text_rendering: opts.text_rendering, + image_rendering: opts.image_rendering, + default_size: opts.default_size, + image_href_resolver: ImageHrefResolver { + resolve_data: Box::new(|mime, bytes, o| (opts.image_href_resolver.resolve_data)(mime, bytes, o)), + resolve_string: Box::new(|h, o| (opts.image_href_resolver.resolve_string)(h, o)), + }, + ..usvg::Options::default() + }; + let tree = usvg::Tree::from_str(text, &nested); + if within && let Ok(mut w) = self.within.lock() { + w.pop(); + } self.depth.store(used, Ordering::Relaxed); let tree = tree.ok()?; self.note_text(text); diff --git a/crates/svg/src/import/prepass.rs b/crates/svg/src/import/prepass.rs index 95c0d57203..3d1b04ad60 100644 --- a/crates/svg/src/import/prepass.rs +++ b/crates/svg/src/import/prepass.rs @@ -109,7 +109,7 @@ impl Edits { /// `svg` with the edits made; overlapping ones and ranges off character boundaries are /// skipped. - fn apply(mut self, svg: &str) -> Cow<'_, str> { + pub(super) fn apply(mut self, svg: &str) -> Cow<'_, str> { self.list.append(&mut self.id_edits); for (at, has_style, decls) in std::mem::take(&mut self.styles).into_values() { self.insert(at, if has_style { decls } else { format!(" style=\"{}\"", decls.strip_prefix(';').unwrap_or(&decls)) }); diff --git a/crates/svg/tests/it/image_orientation.rs b/crates/svg/tests/it/image_orientation.rs index fbf412a0bb..549a40a3bf 100644 --- a/crates/svg/tests/it/image_orientation.rs +++ b/crates/svg/tests/it/image_orientation.rs @@ -276,3 +276,18 @@ fn a_turned_jpeg_in_an_svg_image_imports_upright() { let px = pixels(&d, &im); assert!(red(px.get_pixel(4, 3)) && !red(px.get_pixel(4, 12))); } + +/// A turned JPEG that a linked SVG file links to is turned too. +#[test] +fn a_turned_jpeg_linked_from_a_linked_svg_file_imports_upright() { + let dir = folder("nested-file"); + std::fs::create_dir_all(dir.join("sub")).unwrap(); + std::fs::write(dir.join("sub").join("photo.jpg"), jpeg(Some(6))).unwrap(); + let inner = r#"<svg xmlns="http://www.w3.org/2000/svg" width="80" height="80"><image href="photo.jpg" width="80" height="80"/></svg>"#; + std::fs::write(dir.join("sub").join("inner.svg"), inner).unwrap(); + let (d, im) = import_one(r#"<image href="sub/inner.svg" width="80" height="80"/>"#, Some(&dir)); + assert_eq!((im.width, im.height), (8, 16)); + assert!(near(placed(&im), Rect::new(20.0, 0.0, 60.0, 80.0)), "{:?}", placed(&im)); + let px = pixels(&d, &im); + assert!(red(px.get_pixel(4, 3)) && !red(px.get_pixel(4, 12))); +} diff --git a/crates/svg/tests/it/import_details.rs b/crates/svg/tests/it/import_details.rs index b043e4d985..cea67c14bc 100644 --- a/crates/svg/tests/it/import_details.rs +++ b/crates/svg/tests/it/import_details.rs @@ -216,6 +216,169 @@ fn svgz_images_import_as_vector_art() { assert!((boxes[1].x0 - 100.0).abs() < 1e-6 && (boxes[1].height() - 20.0).abs() < 1e-6, "{boxes:?}"); } +/// An SVG file of 20 × 20 holding a 5 × 5 rectangle and `images`. +fn svg_file(images: &str) -> String { + format!(r#"<svg xmlns="http://www.w3.org/2000/svg" width="20" height="20"><rect width="5" height="5"/>{images}</svg>"#) +} + +/// Reads as [`read`] does, counting the reads of each file name. +fn counting(reads: &std::sync::Mutex<Vec<String>>) -> impl Fn(&str) -> Option<(Vec<u8>, LinkInfo)> + Sync + '_ { + move |path: &str| { + if let Ok(mut reads) = reads.lock() { + reads.push(Path::new(path).file_name().unwrap().to_string_lossy().into_owned()); + } + read(path) + } +} + +/// A raster an SVG file links to is read from that file's folder and stays linked, in its place in +/// the SVG file's art. +#[test] +fn a_raster_linked_from_a_linked_svg_file_is_read_from_its_folder() { + let dir = folder("nested-link"); + let bytes = png(40, 20); + std::fs::write(dir.join("img").join("photo.png"), &bytes).unwrap(); + std::fs::write(dir.join("img").join("inner.svg"), svg_file(r#"<image href="photo.png" x="2" y="4" width="10" height="5"/>"#)).unwrap(); + let (d, w) = open_in(&dir, r#"<image href="img/inner.svg" x="10" y="10" width="20" height="20"/>"#); + assert!(w.is_empty(), "{w:?}"); + assert_eq!(rects(&d), 1, "the SVG file's art"); + let [(_, im)] = images(&d)[..] else { panic!("{:?}", art(&d)) }; + let link = im.link.as_ref().unwrap(); + assert_eq!(Path::new(&link.path), dir.join("img").join("photo.png")); + assert_eq!(*d.images[&im.key].bytes, bytes, "the file's pixels"); + let b = im.xf.transform_rect_bbox(Rect::new(0.0, 0.0, 40.0, 20.0)); + assert!((b.x0 - 12.0).abs() < 1e-6 && (b.y0 - 14.0).abs() < 1e-6 && (b.width() - 10.0).abs() < 1e-6, "{b:?}"); +} + +/// One href in two SVG files of different folders names two files: each shows its own. +#[test] +fn one_href_in_svg_files_of_different_folders_shows_each_folders_file() { + let dir = folder("nested-same-href"); + let (outer, inner) = (png(4, 4), png(6, 6)); + std::fs::write(dir.join("photo.png"), &outer).unwrap(); + std::fs::write(dir.join("img").join("photo.png"), &inner).unwrap(); + std::fs::write(dir.join("img").join("inner.svg"), svg_file(r#"<image href="photo.png" width="10" height="10"/>"#)).unwrap(); + let (d, w) = open_in(&dir, r#"<image href="photo.png" width="10" height="10"/><image href="img/inner.svg" x="50" width="20" height="20"/>"#); + assert!(w.is_empty(), "{w:?}"); + let [(_, a), (_, b)] = images(&d)[..] else { panic!("{:?}", art(&d)) }; + assert_eq!(Path::new(&a.link.as_ref().unwrap().path), dir.join("photo.png")); + assert_eq!(*d.images[&a.key].bytes, outer); + assert_eq!(Path::new(&b.link.as_ref().unwrap().path), dir.join("img").join("photo.png")); + assert_eq!(*d.images[&b.key].bytes, inner); +} + +/// A raster an SVG file links to that can't be read (missing, or refused by the reader) gets the +/// placeholder, stretched to its box, its link and a warning, as one the imported SVG links to. +#[test] +fn a_missing_raster_linked_from_a_linked_svg_file_keeps_a_placeholder() { + let dir = folder("nested-missing"); + std::fs::write(dir.join("img").join("secret.png"), png(4, 4)).unwrap(); + let links = r#"<image href="gone.png" x="2" y="4" width="10" height="5"/><image href="secret.png" x="2" y="12" width="4" height="4"/>"#; + std::fs::write(dir.join("img").join("inner.svg"), svg_file(links)).unwrap(); + let refusing = |path: &str| if path.ends_with("secret.png") { None } else { read(path) }; + let folder = dir.to_string_lossy(); + let body = r#"<image href="img/inner.svg" x="10" y="10" width="20" height="20"/>"#; + let (d, w) = import_with(&svg(body), &ImportOptions { folder: Some(&folder), read: Some(&refusing) }).unwrap(); + for name in ["gone.png", "secret.png"] { + assert!(w.iter().any(|w| w.contains(&format!("'{name}' not found"))), "{name}: {w:?}"); + } + let [(_, gone), (_, secret)] = images(&d)[..] else { panic!("{:?}", art(&d)) }; + assert_eq!(Path::new(&gone.link.as_ref().unwrap().path), dir.join("img").join("gone.png")); + assert_eq!(Path::new(&secret.link.as_ref().unwrap().path), dir.join("img").join("secret.png")); + assert!(d.images[&gone.key].is_proxy() && d.images[&secret.key].is_proxy(), "placeholders, not the files"); + let b = gone.xf.transform_rect_bbox(Rect::new(0.0, 0.0, gone.width as f64, gone.height as f64)); + assert!((b.x0 - 12.0).abs() < 1e-6 && (b.width() - 10.0).abs() < 1e-6 && (b.height() - 5.0).abs() < 1e-6, "{b:?}"); +} + +/// An SVG file that links to itself, or to an SVG file that links back to it, is read once each +/// time it is shown: the link back gets the placeholder and a warning. +#[test] +fn svg_files_that_link_back_keep_a_placeholder_where_they_lead_back() { + let dir = folder("nested-cycle"); + std::fs::write(dir.join("img").join("self.svg"), svg_file(r#"<image href="self.svg" width="10" height="10"/>"#)).unwrap(); + std::fs::write(dir.join("img").join("a.svg"), svg_file(r#"<image href="b.svg" width="10" height="10"/>"#)).unwrap(); + std::fs::write(dir.join("img").join("b.svg"), svg_file(r#"<image href="./a.svg" width="10" height="10"/>"#)).unwrap(); + let folder = dir.to_string_lossy(); + for (body, files, back) in [("img/self.svg", vec!["self.svg"], "self.svg"), ("img/a.svg", vec!["a.svg", "b.svg"], "./a.svg")] { + let reads = std::sync::Mutex::new(vec![]); + let counted = counting(&reads); + let body = format!(r#"<image href="{body}" width="20" height="20"/><image href="./{body}" x="50" width="20" height="20"/>"#); + let (d, w) = import_with(&svg(&body), &ImportOptions { folder: Some(&folder), read: Some(&counted) }).unwrap(); + assert_eq!(*reads.lock().unwrap(), [files.clone(), files.clone()].concat()); + let warning = format!("linked image '{back}' leads back to an SVG file that shows it: a placeholder keeps its place until it is relinked"); + assert_eq!(w, [warning.clone(), warning]); + assert_eq!(rects(&d), 2 * files.len(), "each file's art once in each place"); + let found = images(&d); + assert_eq!(found.len(), 2); + for (_, im) in found { + assert!(d.images[&im.key].is_proxy()); + assert_eq!(Path::new(&im.link.as_ref().unwrap().path), dir.join("img").join(back.trim_start_matches("./"))); + } + } +} + +/// Two SVG files that link to each other, each shown by the imported SVG, each show the other +/// once, then the placeholder of the link back to themselves. +#[test] +fn svg_files_that_link_to_each_other_each_lead_back_to_themselves() { + let dir = folder("nested-cycle-both"); + std::fs::write(dir.join("img").join("a.svg"), svg_file(r#"<image href="b.svg" width="10" height="10"/>"#)).unwrap(); + std::fs::write(dir.join("img").join("b.svg"), svg_file(r#"<image href="a.svg" width="10" height="10"/>"#)).unwrap(); + let (d, w) = open_in(&dir, r#"<image href="img/a.svg" width="20" height="20"/><image href="img/b.svg" x="50" width="20" height="20"/>"#); + assert_eq!(w.len(), 2, "{w:?}"); + assert_eq!(rects(&d), 4, "each file's art once in each place"); + let [(_, a), (_, b)] = images(&d)[..] else { panic!("{:?}", art(&d)) }; + assert_eq!(Path::new(&a.link.as_ref().unwrap().path), dir.join("img").join("a.svg")); + assert_eq!(Path::new(&b.link.as_ref().unwrap().path), dir.join("img").join("b.svg")); +} + +/// An SVG file shown twice, and a raster that two SVG files link to, are read once. +#[test] +fn a_repeated_linked_svg_file_is_read_once() { + let dir = folder("nested-repeat"); + std::fs::write(dir.join("img").join("photo.png"), png(4, 4)).unwrap(); + std::fs::write(dir.join("img").join("a.svg"), svg_file(r#"<image href="photo.png" width="10" height="10"/>"#)).unwrap(); + std::fs::write( + dir.join("img").join("b.svg"), + svg_file(r#"<image href="a.svg" width="10" height="10"/><image href="photo.png" width="10" height="10"/>"#), + ) + .unwrap(); + let reads = std::sync::Mutex::new(vec![]); + let counted = counting(&reads); + let folder = dir.to_string_lossy(); + let body = r#"<image href="img/a.svg" width="20" height="20"/><image href="./img/a.svg" width="20" height="20"/><image href="img/b.svg" width="20" height="20"/>"#; + let (d, w) = import_with(&svg(body), &ImportOptions { folder: Some(&folder), read: Some(&counted) }).unwrap(); + assert!(w.is_empty(), "{w:?}"); + let mut reads = reads.lock().unwrap().clone(); + reads.sort(); + assert_eq!(reads, ["a.svg", "b.svg", "photo.png"]); + let found = images(&d); + assert_eq!(found.len(), 4); + assert!(found.iter().all(|(_, im)| Path::new(&im.link.as_ref().unwrap().path) == dir.join("img").join("photo.png"))); +} + +/// A chain of SVG files, each linking to the next, is read only as deep as SVG images may nest: +/// past it the images are left out, with a warning. +#[test] +fn a_chain_of_linked_svg_files_stops_at_the_depth_cap() { + let dir = folder("nested-chain"); + let levels = vectorcraft_svg::MAX_ELEMENT_DEPTH; + for i in 0..levels { + std::fs::write(dir.join("img").join(format!("{i}.svg")), svg_file(&format!(r#"<image href="{}.svg" width="10" height="10"/>"#, i + 1))) + .unwrap(); + } + let reads = std::sync::Mutex::new(vec![]); + let counted = counting(&reads); + let folder = dir.to_string_lossy(); + let (d, w) = + import_with(&svg(r#"<image href="img/0.svg" width="20" height="20"/>"#), &ImportOptions { folder: Some(&folder), read: Some(&counted) }) + .unwrap(); + let reads = reads.lock().unwrap().len(); + assert!(reads <= levels / 2 + 4, "{reads} reads"); + assert!(rects(&d) < levels / 2, "{}", rects(&d)); + assert!(w.iter().any(|w| w.contains("nest more than")), "{w:?}"); +} + const SVG_NS: &str = r#"xmlns="http://www.w3.org/2000/svg""#; /// An image showing `svg`, from a base64 data URL of type `mime` (none when empty). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..61a9cb569c 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1785,6 +1785,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - An image that Open and Place store again keeps the ICC profile its file embeds and its 16-bit samples. A turned PNG, JPEG, WebP or TIFF stored as PNG, and a TIFF the image decoder reads, keep their gray or RGB samples at 8 or 16 bits with their gray or RGB profile in the PNG's `iCCP` chunk ([PNG specification, iCCP](https://www.w3.org/TR/png-3/#11iCCP)). A CMYK TIFF stored with one plane per ink and a turned CMYK JPEG or TIFF keep their CMYK profile as TIFF tag 34675, a JPEG's put together from all its APP2 segments ([ICC image-format guide](https://github.com/InternationalColorConsortium/iccDEV/blob/master/iccdev-mcp/docs/icc-format-guide.md)). A profile whose color space differs from the stored samples' is left out. The profile is kept in the stored image; how CMYK inks are drawn and exported to PDF does not change (`crates/engine/src/cmd/fileio/tests.rs`). - SVG import shows a raster `<image>` whose EXIF orientation or TIFF Orientation tag turns or flips it upright, linked or as a data URL, and inside an SVG shown as an image: the pixels are stored turned, the width and height swap, and the `<image>` box fits the turned image under `preserveAspectRatio`, as CSS `image-orientation: from-image` describes (<https://www.w3.org/TR/css-images-3/#the-image-orientation>). A turned CMYK JPEG or TIFF keeps its inks as a CMYK TIFF, as does a CMYK TIFF that is not turned. TIFF data URLs (`image/tiff`, or untyped TIFF bytes) are read, and TIFFs with an alpha or other extra channel, CCITT Group 3 TIFFs and CMYK TIFFs stored one plane per ink are read as Open and Place read them. The pixels are decoded within the decode allowance, and a TIFF claiming more strips or tiles than the decoder can count is refused before it is decoded (`crates/svg/tests/it/image_orientation.rs`). - SVG import leaves out an SVG shown as an image that it can't read (text that isn't XML, an SVG without a size) and goes on with the images after it, as SVG 2's error processing describes (<https://www.w3.org/TR/SVG2/conform.html>). Only images that decode count toward the 256 nested SVG images an SVG may show, so an image after many broken ones is imported. Every nested SVG image read, decoded or not, counts toward VectorCraft's own limits of 1,024 reads and 512 MB of text per import; past them, nested SVG images are left out with a warning (`crates/svg/tests/it/import_details.rs`). + - SVG import reads the files that a linked SVG file's own `<image>` elements link to, relative paths from that file's folder (<https://www.rfc-editor.org/rfc/rfc3986#section-5.1.3>), as it reads the imported SVG's links: a raster stays linked, an SVG file imports as vector art, and one that can't be read gets the placeholder, its link and a warning. SVG 2 tells a viewer not to load these links (<https://www.w3.org/TR/SVG2/conform.html#secure-static-mode>); reading them is VectorCraft's own rule. The same href in SVG files of two folders names two files. A link that leads back to an SVG file showing it gets the placeholder and a warning, and reading the links of linked SVG files stops at the nesting depth cap and at 1,024 reads and 512 MB of text per import, the same limits decoded nested SVG images have, counted separately from them (`crates/svg/tests/it/import_details.rs`). - File › Place and a file dropped on the canvas refuse a PNG, JPEG, GIF or WebP file whose pixels can't be read, such as one cut short by a download or a sync still running, and the status bar shows "Couldn't place <name>: the image's pixels can't be read". Paste and Relink refuse such an image too, and Update Links, or Open when it reads the file again, counts it as missing. A JPEG cut short still places when its pixels can be decoded (`file.place`, `crates/engine/src/tests_place.rs`). - On the desktop, Copy and Cut make the system clipboard's formats (text, SVG, PDF, PNG) from a copy of the clipboard on the thread that writes background saves and exports, and write them when they are ready; while that thread has a save, an export, a print or a recovery copy to finish, they are made and written at once. Until they are written, Paste in VectorCraft takes the internal clipboard, and while a text field or the Type tool has the keyboard the app waits for them. Another Copy or Cut, or a copy of text in VectorCraft, drops them. - In the Linux Flatpak on GNOME, where the clipboard goes through the compositor's core Wayland protocol, one Copy offers the PNG (`image/png`), the SVG (`image/svg+xml`, with Include SVG Code on) and the text, and Paste takes another app's SVG, text or PNG in that order, a picture over blank text or text that only names it; the Paste menu item is enabled by the types offered (`clipboard::wayland` tests in `apps/vectorcraft/src/clipboard.rs`; not yet run in the Flatpak on a GNOME session). From e5a881b05f499c1e780c007d799eabee4ff4dd42 Mon Sep 17 00:00:00 2001 From: ruchirguitar <113586074+ruchirguitar@users.noreply.github.com> Date: Sat, 14 Nov 2026 17:27:09 +0530 Subject: [PATCH 092/108] i18n: French keeps [subpath, anchor] in English --- crates/ui-egui/src/i18n/fr.tsv | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 07209a70dd..2396640141 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7567,7 +7567,7 @@ breakText Glyphs Glyphes @msg `alignOn` must be a string `alignOn` doit être une chaîne @msg `align` is start, center or end `align` vaut start, center ou end @msg `align` must be a string `align` doit être une chaîne -@msg `anchors` must be an array of [subpath, anchor] pairs `anchors` doit être une liste de paires [sous-tracé, point d’ancrage] +@msg `anchors` must be an array of [subpath, anchor] pairs `anchors` doit être une liste de paires [subpath, anchor] @msg `anchors` must list anchor indices (0, 1, 2…), not {k} `anchors` doit lister des indices de points d’ancrage (0, 1, 2…), pas {k} @msg `anchors` must list anchor indices (0, 1, 2…), not {v} `anchors` doit lister des indices de points d’ancrage (0, 1, 2…), pas {v} @msg `answer` for this {kind} dialog must be one of: {_1} `answer` pour cette boîte de dialogue {kind} doit valoir l’une de ces valeurs : {_1} @@ -7631,7 +7631,7 @@ breakText Glyphs Glyphes @msg `fidelity` must be from {lo} to {hi} pt `fidelity` doit être compris entre {lo} et {hi} pt @msg `files` must be 1 to 1000 paths of font files the last text.findFontFiles search found `files` doit contenir de 1 à 1000 chemins de fichiers de police trouvés par la dernière recherche text.findFontFiles @msg `focal` and `radius` cannot be used together `focal` et `radius` ne peuvent pas être utilisés ensemble -@msg `focal` must be an array of [subpath, anchor] pairs `focal` doit être une liste de paires [sous-tracé, point d’ancrage] +@msg `focal` must be an array of [subpath, anchor] pairs `focal` doit être une liste de paires [subpath, anchor] @msg `focal` names [{si}, {ai}], which is not an anchor of the path `focal` désigne [{si}, {ai}], qui n’est pas un point d’ancrage du tracé @msg `folder` must be an absolute folder path `folder` doit être le chemin absolu d’un dossier @msg `fontAxes` must be an object of axis tags and values, such as {"wght"} `fontAxes` doit être un objet de balises d’axe et de valeurs, comme {"wght"} From b3fd92ccdc3c6640147c6524c44493ac02243ae5 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:59:24 -0800 Subject: [PATCH 093/108] PDF export: CMYK images that keep their numbers carry their ICC profile A CMYK TIFF written again, a CMYK JPEG that the Compression settings resample or compress again, and a CMYK image written with its mask as its soft mask lost the CMYK profile the image embeds. Such an image is now written in an ICCBased space holding that profile, byte for byte, when output.profiles is all or taggedSource, and in PDF/A-2b, PDF/X-3 and PDF/X-4 unless profiles is destination. Pixels the Output settings convert are never tagged with it. A CMYK JPEG embedded as it is now follows the same rule instead of always carrying its own ICC_PROFILE segments: with profiles none it is DeviceCMYK, and PDF/X-1a export no longer refuses a CMYK JPEG that carries a profile. A profile tags an image only when it is at most 16 MiB and its declared size, acsp signature, device class, CMYK color space and tag table are well formed. Tagged CMYK documents blend transparency in the document's CMYK profile space, not in an image's own; without that space they blend in DeviceCMYK, or keep their RGB space in PDF/A. --- crates/doc/src/cmyk.rs | 15 ++ crates/engine/src/cmd/fileio/pdf.rs | 2 +- crates/pdf/src/export/images.rs | 12 +- crates/pdf/src/export/writer.rs | 67 +++++++- crates/pdf/src/images.rs | 96 +++++++++--- crates/pdf/src/output.rs | 28 +++- crates/pdf/src/tests/cmykimages.rs | 234 +++++++++++++++++++++++++++- docs/mcp.md | 4 +- docs/target-app-parity.md | 1 + 9 files changed, 417 insertions(+), 42 deletions(-) diff --git a/crates/doc/src/cmyk.rs b/crates/doc/src/cmyk.rs index e89d63cb54..e80b133174 100644 --- a/crates/doc/src/cmyk.rs +++ b/crates/doc/src/cmyk.rs @@ -386,6 +386,21 @@ impl ImageBlob { if bytes.starts_with(&[0xFF, 0xD8]) { jpeg_inks(bytes) } else { tiff_inks(bytes) } } + /// The CMYK ICC profile a CMYK image carries: a four-component JPEG's `ICC_PROFILE` APP2 + /// segments put together, or a CMYK TIFF's tag 34675. `None` for other images, and for a + /// profile that isn't one of CMYK colors. Reads only the file's headers and tags. + pub fn cmyk_icc_profile(&self) -> Option<Vec<u8>> { + let bytes = self.bytes.as_slice(); + if jpeg_components(bytes) == Some(4) { + return cmyk_icc(jpeg_icc(bytes)); + } + let (kind, mut d) = tiff(bytes)?; + if !matches!(kind, tiff::ColorType::CMYK(8 | 16)) { + return None; + } + cmyk_icc(tiff_icc(&mut d)) + } + /// The ink amounts around pixel (`x`, `y`) of a CMYK image, in the pixel space of an image /// object of `object` (width, height) pixels: the average of the `size` × `size` pixels centered /// on it, clipped to the image, as C, M, Y and K bytes. `None` outside the image and for images diff --git a/crates/engine/src/cmd/fileio/pdf.rs b/crates/engine/src/cmd/fileio/pdf.rs index c834e653e4..a891a81ff2 100644 --- a/crates/engine/src/cmd/fileio/pdf.rs +++ b/crates/engine/src/cmd/fileio/pdf.rs @@ -128,7 +128,7 @@ pub fn specs() -> Vec<CommandSpec> { "Export PDF", [], None, - "{path?, preset?: \"VectorCraft Default\" (built-in or saved: pdf.preset.list), artboard? | artboards?: [i…] | range?: \"1-3, 5\" (1-based; default all, one page each), useArtboards?: true (false: one page, the bounds of the visible art, as document.export writes it; artboard, artboards and range are then ignored, Preserve Editing is left out (with a warning when it is on), and a document with no visible art is refused), standard?: none|pdfA2b|pdfX1a (CMYK, grey and spot colours only: colours and images converted to output.destination or the CMYK output intent, untagged; transparency flattened with flattenerPreset; PDF 1.3)|pdfX3 (colours ICC-tagged; transparency flattened; PDF 1.3)|pdfX4 (transparency and layers kept; colours ICC-tagged; PDF 1.6 at most) (PDF/X: a /GTS_PDFX output intent, by default the CMYK profile in effect, embedded; TrimBox, Trapped, GTS_PDFXVersion, title and dates; fonts embedded or outlined), compatibility?: 1.3 (no transparency: it is flattened with flattenerPreset, without the layers the file leaves out; images keep no see-through pixels)|1.4|1.5|1.6|1.7 (default)|2.0 (choosing a standard sets its version: 1.7 for pdfA2b, 1.6 for pdfX4, 1.3 for pdfX1a and pdfX3, which write 1.4 as 1.3 too; pdfA2b refuses 1.3; in pdfA2b files, and with longPagesInPoints: false, a page with a side longer than 14,400 pt keeps its size with a UserUnit from 1.6 on: 1.5 is then written as 1.6, with 1.5's encryption, and so is 1.4 in pdfA2b files, with a warning; PDF/X files and other 1.3 and 1.4 files write it in points, and 1.3 and 1.4 (pdfX1a and pdfX3 too) refuse a page past 32,767 pt whose size or art needs a real number past 32,767; a page whose short side is 3 pt or longer but would be under 3 units at that UserUnit gets a smaller one that keeps the short side at 3 units; a warning gives each such page's size), longPagesInPoints?: true (such a page is written at its size in points, without a UserUnit, at every version, and 1.5 stays 1.5, in files without a standard (PDF/A files keep the UserUnit); apps that keep to the limit cut it to 200 in; false: the UserUnit as above, with a warning that names this option), preserveEditing? (on in VectorCraft Default: the native document as an embedded file, which document.open restores; choosing a standard turns it off, a standard refuses it), thumbnails? (each page drawn as a /Thumb image, 106 px on its long side), fastWebView? (a linearised file: the first page shows while the rest downloads; it stays linearised when encrypted), viewAfterSaving? (the app opens the written file), createLayers? (each layer and sublayer but template layers as a PDF layer, an optional content group listed under its layer's: hidden layers off, non-printing ones /PrintState /OFF, locked ones locked; needs 1.5 or later; they reopen as layers; choosing pdfX1a or pdfX3 turns it off; they refuse it), includeNonPrinting? (keep layers whose Print option is off; left out by default unless createLayers), flattenerPreset?: \"\" (High Resolution) | high | medium | low | a saved preset (flattener.presets.list): what PDF 1.3 files flatten transparency with, flattener?: {object.flattenTransparency options over it}, compression?: {color?, gray?: {downsample: none|average|subsample|bicubic, ppi: 300, abovePpi: 450, compression: none|zip|jpeg|jpeg2000|auto, quality: minimum|low|medium|high|maximum}, mono?: {downsample, ppi: 1200, abovePpi: 1800, compression: none|ccittG3|ccittG4|zip|runLength} (black-and-white images), compressText?: true} (images above abovePpi are resampled to ppi; auto keeps JPEGs JPEG, the others lossless; JPEG needs opaque images; none, jpeg2000, CCITT and runLength are written as ZIP with a warning), marks?: {trim, registration, colorBars, pageInfo, kind: roman|japanese, weight: 0.25 (trim marks and targets), offset: 6 (pt from the artboard, at least the bleed)} (printer's marks in [Registration], every plate: trim marks, registration targets mid-side, CMYK/spot/black-tint colour bars on top, page information (title, artboard, date UTC) below), bleed?: {useDocument (the document's bleed, document.setup), top, bottom, left, right} (pt; art in the bleed is kept; a PDF/X file with no bleed on a side where the document's bleed has one comes back with a warning). Each page: TrimBox = artboard, BleedBox = artboard + bleed, MediaBox = that + the marks' room (art clipped to the BleedBox), output?: {conversion: none (default)|destination (every colour into the destination profile's model, CMYK or RGB, also colours of that model in another profile)|preserveNumbers (only colours of the other model and Lab; those in the destination's model keep their numbers) (grey stays grey; images are converted too, printer's marks are not), destination: profile name (edit.colorSettings lists them; default: the document's profile for its colour mode), profiles: none (device colours)|all|destination|taggedSource (documents assigned a profile: edit.assignProfile) (ICC-based colours: CMYK with the destination or document CMYK profile, RGB as sRGB, grey with the sRGB tone curve; PDF/A, pdfX3 and pdfX4 always, whatever profiles says), outputIntent: profile name (embedded as the catalog's /GTS_PDFX output intent; a name that isn't a profile is only named, which pdfX1a and pdfX3 allow only with a registry and pdfX4 refuses; pdfX1a needs a CMYK one), outputCondition, outputConditionId (default: outputIntent), registry, trapped (/Trapped /True; /False when an output intent is written)} (PDF/A files keep their own output intent), advanced?: {fontSubsetPercent: 100 (below 100 is accepted with a warning: fonts are always embedded as subsets), outlineText: false (type as real, selectable and searchable text in embedded subset fonts with a ToUnicode map; fonts whose licence forbids embedding, or allows only whole fonts, stay outlines with a warning; true: every glyph as an outline), overprint: preserve (overprinting fills and strokes set /OP /op true, /OPM 1; white ones knock out with document.setup discardWhiteOverprint)|discard (they knock out)}, security?: {openPassword, permissionsPassword, printing: none|low|high, changes: none|pages|forms|comments|any, copy, screenReader, plaintextMetadata}, acknowledgeLoss?: bool (write over the file the document was read from although reading it left things out), format?: \"pdf\"} → {path, bytes, warnings}; no path → {dataBase64, bytes, warnings}. The options apply over the preset (null keeps its value); options accepted but not applied yet come back as warnings; a standard with a PDF version it doesn't allow and a password with a standard are refused, and so is a PDF/X file that would still break its standard (transparency the flattener left, RGB in pdfX1a, a font not embedded) or a PDF 1.3 file with transparency left. document.export {format: pdf} takes the same options. A key PDF doesn't take, and an unknown key inside one of the option objects, are refused", + "{path?, preset?: \"VectorCraft Default\" (built-in or saved: pdf.preset.list), artboard? | artboards?: [i…] | range?: \"1-3, 5\" (1-based; default all, one page each), useArtboards?: true (false: one page, the bounds of the visible art, as document.export writes it; artboard, artboards and range are then ignored, Preserve Editing is left out (with a warning when it is on), and a document with no visible art is refused), standard?: none|pdfA2b|pdfX1a (CMYK, grey and spot colours only: colours and images converted to output.destination or the CMYK output intent, untagged; transparency flattened with flattenerPreset; PDF 1.3)|pdfX3 (colours ICC-tagged; transparency flattened; PDF 1.3)|pdfX4 (transparency and layers kept; colours ICC-tagged; PDF 1.6 at most) (PDF/X: a /GTS_PDFX output intent, by default the CMYK profile in effect, embedded; TrimBox, Trapped, GTS_PDFXVersion, title and dates; fonts embedded or outlined), compatibility?: 1.3 (no transparency: it is flattened with flattenerPreset, without the layers the file leaves out; images keep no see-through pixels)|1.4|1.5|1.6|1.7 (default)|2.0 (choosing a standard sets its version: 1.7 for pdfA2b, 1.6 for pdfX4, 1.3 for pdfX1a and pdfX3, which write 1.4 as 1.3 too; pdfA2b refuses 1.3; in pdfA2b files, and with longPagesInPoints: false, a page with a side longer than 14,400 pt keeps its size with a UserUnit from 1.6 on: 1.5 is then written as 1.6, with 1.5's encryption, and so is 1.4 in pdfA2b files, with a warning; PDF/X files and other 1.3 and 1.4 files write it in points, and 1.3 and 1.4 (pdfX1a and pdfX3 too) refuse a page past 32,767 pt whose size or art needs a real number past 32,767; a page whose short side is 3 pt or longer but would be under 3 units at that UserUnit gets a smaller one that keeps the short side at 3 units; a warning gives each such page's size), longPagesInPoints?: true (such a page is written at its size in points, without a UserUnit, at every version, and 1.5 stays 1.5, in files without a standard (PDF/A files keep the UserUnit); apps that keep to the limit cut it to 200 in; false: the UserUnit as above, with a warning that names this option), preserveEditing? (on in VectorCraft Default: the native document as an embedded file, which document.open restores; choosing a standard turns it off, a standard refuses it), thumbnails? (each page drawn as a /Thumb image, 106 px on its long side), fastWebView? (a linearised file: the first page shows while the rest downloads; it stays linearised when encrypted), viewAfterSaving? (the app opens the written file), createLayers? (each layer and sublayer but template layers as a PDF layer, an optional content group listed under its layer's: hidden layers off, non-printing ones /PrintState /OFF, locked ones locked; needs 1.5 or later; they reopen as layers; choosing pdfX1a or pdfX3 turns it off; they refuse it), includeNonPrinting? (keep layers whose Print option is off; left out by default unless createLayers), flattenerPreset?: \"\" (High Resolution) | high | medium | low | a saved preset (flattener.presets.list): what PDF 1.3 files flatten transparency with, flattener?: {object.flattenTransparency options over it}, compression?: {color?, gray?: {downsample: none|average|subsample|bicubic, ppi: 300, abovePpi: 450, compression: none|zip|jpeg|jpeg2000|auto, quality: minimum|low|medium|high|maximum}, mono?: {downsample, ppi: 1200, abovePpi: 1800, compression: none|ccittG3|ccittG4|zip|runLength} (black-and-white images), compressText?: true} (images above abovePpi are resampled to ppi; auto keeps JPEGs JPEG, the others lossless; JPEG needs opaque images; none, jpeg2000, CCITT and runLength are written as ZIP with a warning), marks?: {trim, registration, colorBars, pageInfo, kind: roman|japanese, weight: 0.25 (trim marks and targets), offset: 6 (pt from the artboard, at least the bleed)} (printer's marks in [Registration], every plate: trim marks, registration targets mid-side, CMYK/spot/black-tint colour bars on top, page information (title, artboard, date UTC) below), bleed?: {useDocument (the document's bleed, document.setup), top, bottom, left, right} (pt; art in the bleed is kept; a PDF/X file with no bleed on a side where the document's bleed has one comes back with a warning). Each page: TrimBox = artboard, BleedBox = artboard + bleed, MediaBox = that + the marks' room (art clipped to the BleedBox), output?: {conversion: none (default)|destination (every colour into the destination profile's model, CMYK or RGB, also colours of that model in another profile)|preserveNumbers (only colours of the other model and Lab; those in the destination's model keep their numbers) (grey stays grey; images are converted too, printer's marks are not), destination: profile name (edit.colorSettings lists them; default: the document's profile for its colour mode), profiles: none (device colours)|all|destination|taggedSource (documents assigned a profile: edit.assignProfile) (ICC-based colours: CMYK with the destination or document CMYK profile, RGB as sRGB, grey with the sRGB tone curve; PDF/A, pdfX3 and pdfX4 always, whatever profiles says; a CMYK image that keeps its numbers carries the CMYK profile it embeds with all and taggedSource, and in PDF/A, pdfX3 and pdfX4 unless destination, never in pdfX1a), outputIntent: profile name (embedded as the catalog's /GTS_PDFX output intent; a name that isn't a profile is only named, which pdfX1a and pdfX3 allow only with a registry and pdfX4 refuses; pdfX1a needs a CMYK one), outputCondition, outputConditionId (default: outputIntent), registry, trapped (/Trapped /True; /False when an output intent is written)} (PDF/A files keep their own output intent), advanced?: {fontSubsetPercent: 100 (below 100 is accepted with a warning: fonts are always embedded as subsets), outlineText: false (type as real, selectable and searchable text in embedded subset fonts with a ToUnicode map; fonts whose licence forbids embedding, or allows only whole fonts, stay outlines with a warning; true: every glyph as an outline), overprint: preserve (overprinting fills and strokes set /OP /op true, /OPM 1; white ones knock out with document.setup discardWhiteOverprint)|discard (they knock out)}, security?: {openPassword, permissionsPassword, printing: none|low|high, changes: none|pages|forms|comments|any, copy, screenReader, plaintextMetadata}, acknowledgeLoss?: bool (write over the file the document was read from although reading it left things out), format?: \"pdf\"} → {path, bytes, warnings}; no path → {dataBase64, bytes, warnings}. The options apply over the preset (null keeps its value); options accepted but not applied yet come back as warnings; a standard with a PDF version it doesn't allow and a password with a standard are refused, and so is a PDF/X file that would still break its standard (transparency the flattener left, RGB in pdfX1a, a font not embedded) or a PDF 1.3 file with transparency left. document.export {format: pdf} takes the same options. A key PDF doesn't take, and an unknown key inside one of the option objects, are refused", has_doc, export_pdf ), diff --git a/crates/pdf/src/export/images.rs b/crates/pdf/src/export/images.rs index d0158d8cd2..8110ce2db5 100644 --- a/crates/pdf/src/export/images.rs +++ b/crates/pdf/src/export/images.rs @@ -144,7 +144,8 @@ impl Exporter<'_> { self.rgb_in_cmyk.images.insert(key.to_string()); } let r = if cmyk_image { - crate::images::recode_cmyk(blob, size, c, interpolate, out.cmyk_pixels(), None) + let icc = out.cmyk_image_icc(blob); + crate::images::recode_cmyk(blob, size, c, interpolate, out.cmyk_pixels(), None, icc.as_deref()) } else { crate::images::recode(&blob.bytes, size, c, interpolate, out.pixels()) }; @@ -191,7 +192,8 @@ impl Exporter<'_> { let doc = self.doc; let img = doc.image_blob(im).filter(|b| b.is_cmyk()).and_then(|blob| { let alpha = crate::images::mask_alpha(doc.image_blob(mi)?, im.width, im.height, m.clip)?; - let r = crate::images::recode_cmyk(blob, size, self.compression, interpolate, self.out.cmyk_pixels(), Some(alpha)); + let icc = self.out.cmyk_image_icc(blob); + let r = crate::images::recode_cmyk(blob, size, self.compression, interpolate, self.out.cmyk_pixels(), Some(alpha), icc.as_deref()); if let (Some(w), Some(_)) = (r.warning, &r.image) { self.warn(w); } @@ -313,10 +315,6 @@ pub(super) fn png_8_bit(bytes: &[u8]) -> Option<Vec<u8>> { Some(png) } -/// Most pixels an image may have to be embedded: twice what the app reads (64 million), so every image -/// it holds is still written. -const MAX_EMBED_PIXELS: u64 = 1 << 27; - /// Image `blob` as it is: PNG, JPEG, GIF and WebP through the PDF writer (JPEG data unchanged), /// other formats decoded. Without `sixteen_bit` (a file before PDF 1.5), a PNG of 16 bits a /// sample is written at 8 bits ([`png_8_bit`]). @@ -324,7 +322,7 @@ pub(super) fn embed(blob: &vectorcraft_doc::ImageBlob, interpolate: bool, sixtee // The header's size first: the writer's decoders allocate what it declares, and the encoded // bytes of an image that is far larger than any the app reads may be a few kilobytes. let size = image::ImageReader::new(std::io::Cursor::new(blob.bytes.as_slice())).with_guessed_format().ok()?.into_dimensions(); - if size.is_ok_and(|(w, h)| u64::from(w) * u64::from(h) > MAX_EMBED_PIXELS) { + if size.is_ok_and(|(w, h)| u64::from(w) * u64::from(h) > crate::images::MAX_EMBED_PIXELS) { return None; } let bytes = blob.bytes.as_ref().clone(); diff --git a/crates/pdf/src/export/writer.rs b/crates/pdf/src/export/writer.rs index 9f6d9d6906..ca70ef2695 100644 --- a/crates/pdf/src/export/writer.rs +++ b/crates/pdf/src/export/writer.rs @@ -271,7 +271,8 @@ impl Writer { PdfError::from(e) })?; if self.cmyk { - cmyk_blending(&mut bytes, self.out.tagged); + let profile = self.out.tagged.then(|| vectorcraft_color::cms::icc_bytes(self.out.cmyk_profile()).ok()).flatten(); + cmyk_blending(&mut bytes, self.out.tagged, profile.as_deref(), self.out.standard != Standard::PdfA2b); } let lab = !self.lab_spots.is_empty() && !self.out.standard.cmyk_only(); let bytes = if lab { crate::lab_spot::lab_alternates(bytes, &self.lab_spots) } else { bytes }; @@ -285,12 +286,21 @@ impl Writer { /// its blending space (DeviceRGB, or sRGB when colours are `tagged`), so the group dictionaries /// are rewritten in place to DeviceCMYK (or the CMYK profile's space), keeping their length so the /// cross-reference offsets stay valid. Luminosity masks' groups keep RGB: mask luminance is that -/// of screen colours, as on screen. -fn cmyk_blending(pdf: &mut [u8], tagged: bool) { +/// of screen colours, as on screen. Tagged groups blend in the space of CMYK profile `profile` +/// (the one that tags CMYK colours) when the file has one. When its only CMYK spaces are of other +/// profiles (images' own), they blend in DeviceCMYK where `device` allows it, else they keep RGB; +/// without `profile`, they blend in the first CMYK space. +fn cmyk_blending(pdf: &mut [u8], tagged: bool, profile: Option<&[u8]>, device: bool) { let masks = luminosity_mask_groups(pdf); let mut spaces = vec![("/CS/DeviceRGB".to_string(), "/CS/DeviceCMYK".to_string())]; if tagged { - spaces.extend(icc_spaces(pdf)); + let own = profile.and_then(|icc| crate::output::tagging_stream(pdf, &crate::patch::Xref::read(pdf)?, icc)); + let without = match (profile, device) { + (None, _) => Without::FirstCmyk, + (Some(_), true) => Without::DeviceCmyk, + (Some(_), false) => Without::Rgb, + }; + spaces.extend(icc_spaces(pdf, own, without)); } let mut from = 0; while let Some(at) = find(pdf, b"/Group<<", from).map(|i| i + b"/Group".len()) { @@ -303,11 +313,22 @@ fn cmyk_blending(pdf: &mut [u8], tagged: bool) { } } +/// What tagged groups blend in when the file holds no space of the document's CMYK profile. +#[derive(Clone, Copy, Debug, PartialEq)] +enum Without { + /// The first ICC-based CMYK space of the file. + FirstCmyk, + DeviceCmyk, + /// The RGB space they have. + Rgb, +} + /// The ICC-based RGB colour spaces of `pdf`, each with the ICC-based CMYK one to blend in instead, -/// as group `/CS` entries (`/CS 3 0 R`); none without a CMYK one. -fn icc_spaces(pdf: &[u8]) -> Vec<(String, String)> { +/// as group `/CS` entries (`/CS 3 0 R`): the one whose profile is stream `own`, else as `without` +/// says; none without a CMYK one. +fn icc_spaces(pdf: &[u8], own: Option<u32>, without: Without) -> Vec<(String, String)> { const ICC: &[u8] = b"[/ICCBased "; - let (mut rgb, mut cmyk) = (vec![], None); + let (mut rgb, mut cmyk, mut own_cmyk) = (vec![], None, None); let mut from = 0; while let Some(at) = find(pdf, ICC, from) { from = at + ICC.len(); @@ -319,11 +340,19 @@ fn icc_spaces(pdf: &[u8]) -> Vec<(String, String)> { let Some(head) = find(pdf, format!("\n{stream} 0 obj").as_bytes(), 0) else { continue }; let dict = pdf.get(head..find(pdf, b"stream", head).unwrap_or(pdf.len())).unwrap_or_default(); if find(dict, b"/N 4", 0).is_some() { + if own == Some(stream) { + own_cmyk.get_or_insert(format!("/CS {array} 0 R")); + } cmyk.get_or_insert(format!("/CS {array} 0 R")); } else if find(dict, b"/N 3", 0).is_some() { rgb.push(format!("/CS {array} 0 R")); } } + let cmyk = own_cmyk.or_else(|| match without { + Without::FirstCmyk => cmyk, + Without::DeviceCmyk => cmyk.map(|_| "/CS/DeviceCMYK".to_string()), + Without::Rgb => None, + }); let Some(cmyk) = cmyk else { return vec![] }; rgb.into_iter().map(|r| (r, cmyk.clone())).collect() } @@ -385,3 +414,27 @@ pub(super) fn date_time(t: i64) -> krilla::metadata::DateTime { .utc_offset_hour(0) .utc_offset_minute(0) } + +#[cfg(test)] +mod tests { + use super::{Without, icc_spaces}; + + /// Objects 1 to 3: an RGB ICC-based space (profile 4), then two CMYK ones (profiles 5, 6). + const SPACES: &[u8] = b"%PDF-1.7\n1 0 obj\n[/ICCBased 4 0 R]\nendobj\n2 0 obj\n[/ICCBased 5 0 R]\nendobj\n3 0 obj\n[/ICCBased 6 0 R]\nendobj\n\ + 4 0 obj\n<</N 3/Length 0>>stream\n\nendstream\nendobj\n5 0 obj\n<</N 4/Length 0>>stream\n\nendstream\nendobj\n\ + 6 0 obj\n<</N 4/Length 0>>stream\n\nendstream\nendobj\n"; + + #[test] + fn groups_blend_in_the_documents_cmyk_space_else_device_cmyk() { + let rgb = "/CS 1 0 R".to_string(); + // The space of the document's profile, wherever it is. + for without in [Without::FirstCmyk, Without::DeviceCmyk, Without::Rgb] { + assert_eq!(icc_spaces(SPACES, Some(6), without), [(rgb.clone(), "/CS 3 0 R".to_string())], "{without:?}"); + } + // Without it, DeviceCMYK, or RGB where DeviceCMYK isn't allowed, rather than another + // profile's space; the first CMYK space when the document's profile isn't known. + assert_eq!(icc_spaces(SPACES, None, Without::DeviceCmyk), [(rgb.clone(), "/CS/DeviceCMYK".to_string())]); + assert_eq!(icc_spaces(SPACES, None, Without::Rgb), []); + assert_eq!(icc_spaces(SPACES, None, Without::FirstCmyk), [(rgb, "/CS 2 0 R".to_string())]); + } +} diff --git a/crates/pdf/src/images.rs b/crates/pdf/src/images.rs index 4139259583..d1382449e5 100644 --- a/crates/pdf/src/images.rs +++ b/crates/pdf/src/images.rs @@ -10,7 +10,9 @@ //! CMYK images ([`ImageBlob::cmyk`]) stay CMYK: a CMYK JPEG already as asked is embedded as it is //! when its numbers are kept; the others' ink amounts are resampled, converted when the Output //! settings convert CMYK colours ([`CmykPixels`]) and compressed again. CMYK JPEGs hold Adobe's -//! inverted samples, which the PDF writer's Decode array undoes. +//! inverted samples, which the PDF writer's Decode array undoes. A CMYK image whose numbers are +//! kept carries the CMYK profile it is given ([`cmyk_icc`]), whether it is embedded as it is or +//! written again; without one it is untagged, a JPEG's own `ICC_PROFILE` segments included. use std::io::Cursor; use std::sync::Arc; @@ -26,7 +28,8 @@ use vectorcraft_doc::cmyk::jpeg_components; use crate::output::{CmykPixels, Pixels}; use crate::{CompressionSettings, Downsample, ImageCodec, JpegQuality, MonoCodec}; -/// Raw 8-bit pixels: colour samples (RGB, grey or CMYK) and an optional alpha channel. +/// Raw 8-bit pixels: colour samples (RGB, grey or CMYK) and an optional alpha channel, with the +/// ICC profile the colour samples are in, if any. #[derive(Clone, Hash)] struct Raw { color: Arc<Vec<u8>>, @@ -34,6 +37,7 @@ struct Raw { width: u32, height: u32, space: ImageColorspace, + icc: Option<Arc<Vec<u8>>>, } impl CustomImage for Raw { @@ -54,7 +58,7 @@ impl CustomImage for Raw { } fn icc_profile(&self) -> Option<&[u8]> { - None + self.icc.as_deref().map(Vec::as_slice) } fn color_space(&self) -> ImageColorspace { @@ -79,7 +83,7 @@ fn from_rgba(rgba: &[u8], width: u32, height: u32, interpolate: bool, pixels: Op (px.iter().flat_map(|p| [p[0], p[1], p[2]]).collect(), ImageColorspace::Rgb) }; let alpha = px.iter().any(|p| p[3] < 255).then(|| Arc::new(px.iter().map(|p| p[3]).collect())); - Image::from_custom(Raw { color: Arc::new(color), alpha, width, height, space }, interpolate).ok() + Image::from_custom(Raw { color: Arc::new(color), alpha, width, height, space, icc: None }, interpolate).ok() } /// Are all of the RGBA pixels `rgba` grey? @@ -88,9 +92,57 @@ fn neutral(rgba: &[u8]) -> bool { } /// Colour `samples` (grey, RGB, or CMYK ink amounts, as `space` says) with an optional `alpha` -/// channel, written losslessly. -fn lossless(samples: Vec<u8>, alpha: Option<Vec<u8>>, space: ImageColorspace, width: u32, height: u32, interpolate: bool) -> Option<Image> { - Image::from_custom(Raw { color: Arc::new(samples), alpha: alpha.map(Arc::new), width, height, space }, interpolate).ok() +/// channel, written losslessly, tagged with ICC profile `icc` when given. +fn lossless( + samples: Vec<u8>, + alpha: Option<Vec<u8>>, + space: ImageColorspace, + width: u32, + height: u32, + interpolate: bool, + icc: Option<&[u8]>, +) -> Option<Image> { + let icc = icc.map(|icc| Arc::new(icc.to_vec())); + Image::from_custom(Raw { color: Arc::new(samples), alpha: alpha.map(Arc::new), width, height, space, icc }, interpolate).ok() +} + +/// Most pixels an image may have to be embedded: twice what the app reads (64 million), so every image +/// it holds is still written. +pub(crate) const MAX_EMBED_PIXELS: u64 = 1 << 27; + +/// The most bytes a CMYK profile carried by an image is written with (16 MiB). +const MAX_ICC: usize = 16 << 20; + +/// The CMYK ICC profile image `blob` carries ([`ImageBlob::cmyk_icc_profile`]), when it is one a +/// CMYK image can be tagged with: at most [`MAX_ICC`] bytes, the size its header declares, the +/// `acsp` signature, an input, display, output or colour space profile of CMYK colours, and a tag +/// table whose tags lie within it. `None` for other images and other profiles. +pub(crate) fn cmyk_icc(blob: &ImageBlob) -> Option<Vec<u8>> { + blob.cmyk_icc_profile().filter(|icc| valid_cmyk_icc(icc)) +} + +/// Is `icc` a CMYK profile as [`cmyk_icc`] describes? +fn valid_cmyk_icc(icc: &[u8]) -> bool { + let be = |at: usize| icc.get(at..at + 4).and_then(|b| b.try_into().ok()).map(u32::from_be_bytes); + let fits = |at: u32, len: u32| u64::from(at) + u64::from(len) <= icc.len() as u64; + if icc.len() > MAX_ICC || be(0).and_then(|n| usize::try_from(n).ok()) != Some(icc.len()) { + return false; + } + let class = icc.get(12..16); + if icc.get(36..40) != Some(b"acsp".as_slice()) + || icc.get(16..20) != Some(b"CMYK".as_slice()) + || ![b"scnr", b"mntr", b"prtr", b"spac"].iter().any(|c| class == Some(c.as_slice())) + { + return false; + } + let Some(count) = be(128) else { return false }; + if !fits(132, count.saturating_mul(12)) { + return false; + } + (0..count as usize).all(|i| { + let at = 132 + i * 12; + matches!((be(at + 4), be(at + 8)), (Some(offset), Some(len)) if fits(offset, len)) + }) } /// [`from_rgba`] of pixels converted by `pixels` (when given). @@ -114,7 +166,7 @@ pub(crate) fn from_inks(inks: Vec<u8>, alpha: Vec<u8>, width: u32, height: u32, Some(p) => p.convert(&inks), None => (inks, ImageColorspace::Cmyk), }; - lossless(samples, alpha, space, width, height, interpolate) + lossless(samples, alpha, space, width, height, interpolate, None) } /// The kinds of images the Compression section has settings for. @@ -291,7 +343,7 @@ pub(crate) fn recode(bytes: &[u8], size: (f64, f64), c: &CompressionSettings, in None if grey => (rgba.pixels().map(|p| p[0]).collect(), ImageColorspace::Luma), None => (rgba.pixels().flat_map(|p| [p[0], p[1], p[2]]).collect(), ImageColorspace::Rgb), }; - to_jpeg(&samples, space, width, height, q, interpolate) + to_jpeg(&samples, space, width, height, q, interpolate, None) }); let image = jpeg.or_else(|| from_rgba(rgba.as_raw(), width, height, interpolate, convert)); Recoded { image, warning: rule.instead } @@ -323,7 +375,8 @@ pub(crate) fn coverage_sized(w: u32, h: u32, cover: Vec<u8>, size: (f64, f64), c /// is when its numbers are (`convert` is `None`); otherwise its ink amounts are resampled, /// converted by `convert` and compressed again. With `alpha` (one sample a pixel, see /// [`mask_alpha`]) the image is lossless and carries it as its soft mask; `None` then when its -/// inks can't be read. +/// inks can't be read. When its numbers are kept, the image is tagged with CMYK profile `icc` +/// (see [`cmyk_icc`]), and is untagged without one; converted pixels are never tagged with it. pub(crate) fn recode_cmyk( blob: &ImageBlob, size: (f64, f64), @@ -331,13 +384,20 @@ pub(crate) fn recode_cmyk( interpolate: bool, convert: Option<&CmykPixels>, alpha: Option<Vec<u8>>, + icc: Option<&[u8]>, ) -> Recoded { let rule = rule(c, Kind::Color); let jpeg = jpeg_components(&blob.bytes).is_some(); + let icc = icc.filter(|_| convert.is_none()); if jpeg && convert.is_none() && alpha.is_none() { let dims = ImageReader::new(Cursor::new(blob.bytes.as_slice())).with_guessed_format().ok().and_then(|r| r.into_dimensions().ok()); - if dims.is_some_and(|d| kept(&rule, d, size, true)) { - return Recoded { image: None, warning: rule.instead }; + if let Some((w, h)) = dims.filter(|d| kept(&rule, *d, size, true)) { + // The JPEG data as it is, tagged with `icc` rather than with its own segments; one + // larger than [`MAX_EMBED_PIXELS`] is not written. + let image = (u64::from(w) * u64::from(h) <= MAX_EMBED_PIXELS) + .then(|| Image::from_jpeg_with_icc(blob.bytes.as_ref().clone().into(), icc.map(|i| i.to_vec().into()), interpolate).ok()) + .flatten(); + return Recoded { image, warning: rule.instead }; } } let Some(inks) = blob.cmyk() else { @@ -360,8 +420,8 @@ pub(crate) fn recode_cmyk( None => (inks, ImageColorspace::Cmyk), }; // JPEG needs opaque pixels. - let image = jpeg_quality(&rule, jpeg).filter(|_| alpha.is_none()).and_then(|q| to_jpeg(&samples, space, width, height, q, interpolate)); - let image = image.or_else(|| lossless(samples, alpha, space, width, height, interpolate)); + let image = jpeg_quality(&rule, jpeg).filter(|_| alpha.is_none()).and_then(|q| to_jpeg(&samples, space, width, height, q, interpolate, icc)); + let image = image.or_else(|| lossless(samples, alpha, space, width, height, interpolate, icc)); Recoded { image, warning: rule.instead } } @@ -405,9 +465,9 @@ pub(crate) fn mask_alpha(blob: &ImageBlob, width: u32, height: u32, clip: bool) } /// Opaque colour `samples` (grey, RGB, or CMYK ink amounts, as `space` says) as a JPEG at -/// `quality`. CMYK JPEGs hold Adobe's inverted samples, which the PDF writer's Decode array -/// undoes. -fn to_jpeg(samples: &[u8], space: ImageColorspace, width: u32, height: u32, quality: u8, interpolate: bool) -> Option<Image> { +/// `quality`, tagged with ICC profile `icc` when given. CMYK JPEGs hold Adobe's inverted samples, +/// which the PDF writer's Decode array undoes. +fn to_jpeg(samples: &[u8], space: ImageColorspace, width: u32, height: u32, quality: u8, interpolate: bool, icc: Option<&[u8]>) -> Option<Image> { let mut out = Vec::new(); match space { ImageColorspace::Cmyk => { @@ -420,5 +480,5 @@ fn to_jpeg(samples: &[u8], space: ImageColorspace, width: u32, height: u32, qual } ImageColorspace::DeviceN => return None, } - Image::from_jpeg(out.into(), interpolate).ok() + Image::from_jpeg_with_icc(out.into(), icc.map(|i| i.to_vec().into()), interpolate).ok() } diff --git a/crates/pdf/src/output.rs b/crates/pdf/src/output.rs index 77bc7d1d66..8114931bc4 100644 --- a/crates/pdf/src/output.rs +++ b/crates/pdf/src/output.rs @@ -18,7 +18,9 @@ //! document's), RGB with sRGB (colours of another RGB space as their sRGB equivalents) and grey //! with the sRGB tone curve. Otherwise they are device colours. PDF/A, PDF/X-3 and PDF/X-4 //! always tag them, whatever `profiles` says; PDF/X-1a never does, and always converts to a -//! CMYK destination (see [`crate::pdfx`]). +//! CMYK destination (see [`crate::pdfx`]). A CMYK image that keeps its numbers is tagged with +//! the CMYK profile it carries, if any, with `all` and `taggedSource`, and in PDF/A, PDF/X-3 +//! and PDF/X-4 unless `profiles` is `destination` ([`ColorOut::cmyk_image_icc`]). //! - Output intent: the profile `outputIntent` names, embedded as the `/GTS_PDFX` output intent //! of the catalog with the condition, identifier and registry; Trapped goes in the document //! information (`/False` when an output intent is written untrapped). PDF/A files carry their @@ -59,6 +61,9 @@ pub(crate) struct ColorOut { dest: Option<Dest>, /// Colours are written in ICC-based colour spaces. pub tagged: bool, + /// CMYK images that keep their numbers are tagged with the CMYK profile they carry + /// ([`Self::cmyk_image_icc`]). + image_icc: bool, /// The CMYK profile that tags CMYK colours. cmyk_profile: String, /// Tagged RGB colours are written as their sRGB equivalents: why (a warning), when their RGB @@ -105,6 +110,7 @@ impl Default for ColorOut { profile_notes: vec![], dest: None, tagged: false, + image_icc: false, cmyk_profile, srgb_note: None, pixels: OnceLock::new(), @@ -240,6 +246,14 @@ impl ColorOut { ProfileInclusion::All | ProfileInclusion::Destination => true, ProfileInclusion::TaggedSource => !doc.color_profiles.is_empty(), }); + // Source profiles: with `all` and `taggedSource`, and in the files that tag every colour + // unless only the destination profile is asked for; never in PDF/X-1a. + out.image_icc = !set.standard.cmyk_only() + && match set.output.profiles { + ProfileInclusion::All | ProfileInclusion::TaggedSource => true, + ProfileInclusion::None => matches!(set.standard, Standard::PdfA2b | Standard::PdfX3 | Standard::PdfX4), + ProfileInclusion::Destination => false, + }; let rgb = match &out.dest { Some(d) if d.model == Model::Rgb => (d.srgb, d.cms.settings().rgb.clone()), _ => (source.rgb_is_srgb(), st.rgb.clone()), @@ -324,6 +338,16 @@ impl ColorOut { .as_ref() } + /// The CMYK profile CMYK image `blob` is tagged with ([`crate::images::cmyk_icc`]): the one it + /// carries, when its numbers are kept and the Profiles setting or the standard includes source + /// profiles. `None` otherwise, and in PDF/X-1a, whose images are untagged CMYK. + pub(crate) fn cmyk_image_icc(&self, blob: &vectorcraft_doc::ImageBlob) -> Option<Vec<u8>> { + if !self.image_icc || self.cmyk_pixels().is_some() { + return None; + } + crate::images::cmyk_icc(blob) + } + /// How CMYK images' ink amounts are converted; `None` when they keep their numbers (no /// conversion, or to a CMYK destination that keeps them). pub(crate) fn cmyk_pixels(&self) -> Option<&CmykPixels> { @@ -477,7 +501,7 @@ fn catalog(set: &PdfSettings, cmyk_profile: &str) -> Option<Catalog> { /// The object number of the stream of an ICC-based colour space of `pdf` that holds profile `icc` /// (its data as it is, or Flate-compressed); `None` when no colour space uses that profile. -fn tagging_stream(pdf: &[u8], xref: &Xref, icc: &[u8]) -> Option<u32> { +pub(crate) fn tagging_stream(pdf: &[u8], xref: &Xref, icc: &[u8]) -> Option<u32> { use std::io::Read; const ICC: &[u8] = b"[/ICCBased "; let mut from = 0; diff --git a/crates/pdf/src/tests/cmykimages.rs b/crates/pdf/src/tests/cmykimages.rs index 45222bb04d..4719beec70 100644 --- a/crates/pdf/src/tests/cmykimages.rs +++ b/crates/pdf/src/tests/cmykimages.rs @@ -75,16 +75,18 @@ fn cmyk_dict(w: u32, h: u32, more: &str) -> String { const INVERTED: &str = "/Decode [1 0 1 0 1 0 1 0]"; -/// An image XObject of a written PDF: its colour space and the components of its ICC profile, -/// its Decode array, its filter and its stream data. +/// An image XObject of a written PDF: its colour space and the components and bytes of its ICC +/// profile, its Decode array, its filter, its stream data and whether it has a soft mask. #[derive(Debug)] struct Written { space: String, icc_n: Option<u8>, + icc: Option<Vec<u8>>, decode: Vec<f32>, filter: Option<String>, data: Vec<u8>, width: u32, + smask: bool, } fn written(pdf: &[u8]) -> Vec<Written> { @@ -96,22 +98,26 @@ fn written(pdf: &[u8]) -> Vec<Written> { if d.get::<Name<'_>>(b"Subtype").is_none_or(|n| n.as_ref() != b"Image") { continue; } - let (space, icc_n) = match (d.get::<Name<'_>>(b"ColorSpace"), d.get::<Array<'_>>(b"ColorSpace")) { - (Some(n), _) => (n.as_str().to_string(), None), + let (space, icc_n, icc) = match (d.get::<Name<'_>>(b"ColorSpace"), d.get::<Array<'_>>(b"ColorSpace")) { + (Some(n), _) => (n.as_str().to_string(), None, None), (_, Some(a)) => { let mut it = a.flex_iter(); let name = it.next::<Name<'_>>().unwrap().as_str().to_string(); - (name, it.next::<Stream<'_>>().and_then(|s| s.dict().get::<u8>(b"N"))) + let profile = it.next::<Stream<'_>>(); + let n = profile.as_ref().and_then(|s| s.dict().get::<u8>(b"N")); + (name, n, profile.map(|s| s.decoded().unwrap().into_owned())) } - _ => (String::new(), None), + _ => (String::new(), None, None), }; out.push(Written { space, icc_n, + icc, decode: d.get::<Array<'_>>(b"Decode").map(|a| a.iter::<f32>().collect()).unwrap_or_default(), filter: d.get::<Name<'_>>(b"Filter").map(|n| n.as_str().to_string()), data: s.raw_data().to_vec(), width: d.get::<u32>(b"Width").unwrap_or(0), + smask: d.get::<Stream<'_>>(b"SMask").is_some(), }); } out @@ -447,6 +453,222 @@ fn the_output_settings_convert_cmyk_images_and_compression_recompresses_them_in_ assert_eq!(blob.cmyk().unwrap().data, flat(ink, 16)); } +/// A version 2.1 output profile of CMYK colors with a one-tag table (`cprt`), its header and table +/// consistent with its size; `edit` changes it after it is made. +fn cmyk_profile(edit: impl FnOnce(&mut Vec<u8>)) -> Vec<u8> { + let mut icc = vec![0u8; 156]; + icc[0..4].copy_from_slice(&156u32.to_be_bytes()); + icc[8..12].copy_from_slice(&[2, 0x10, 0, 0]); + icc[12..16].copy_from_slice(b"prtr"); + icc[16..20].copy_from_slice(b"CMYK"); + icc[20..24].copy_from_slice(b"Lab "); + icc[36..40].copy_from_slice(b"acsp"); + icc[128..132].copy_from_slice(&1u32.to_be_bytes()); + icc[132..136].copy_from_slice(b"cprt"); + icc[136..140].copy_from_slice(&144u32.to_be_bytes()); + icc[140..144].copy_from_slice(&12u32.to_be_bytes()); + icc[144..156].copy_from_slice(b"text\0\0\0\0VC\0\0"); + edit(&mut icc); + icc +} + +/// `inks` (four bytes a pixel) as a CMYK JPEG carrying `icc` in its `ICC_PROFILE` segments. +fn cmyk_jpeg_with(inks: &[u8], w: u16, h: u16, icc: &[u8]) -> Vec<u8> { + let mut out = Vec::new(); + let mut e = jpeg_encoder::Encoder::new(&mut out, 100); + e.add_icc_profile(icc).unwrap(); + e.encode(inks, w, h, jpeg_encoder::ColorType::Cmyk).unwrap(); + out +} + +/// A CMYK TIFF of `w` × `h` pixels of `ink` carrying `icc` as its tag 34675 (written as Open +/// stores a CMYK JPEG that carries one). +fn cmyk_tiff_with(ink: [u8; 4], w: u16, h: u16, icc: &[u8]) -> ImageBlob { + let jpg = cmyk_jpeg_with(&flat(ink, usize::from(w) * usize::from(h)), w, h, icc); + let (tiff, _) = vectorcraft_doc::cmyk::turned_cmyk(&jpg, image::metadata::Orientation::NoTransforms, None).unwrap(); + let blob = ImageBlob::new("image/tiff", tiff); + assert_eq!(blob.cmyk_icc_profile().as_deref(), Some(icc), "the TIFF carries the profile"); + blob +} + +/// A CMYK image whose numbers are kept is written in an ICC-based space of the CMYK profile it +/// carries, byte for byte, when the Profiles setting or the standard includes source profiles: +/// a TIFF written again, a JPEG kept as it is or compressed again, and an image with its mask as +/// its soft mask. Its inks are those it had. Without source profiles it is DeviceCMYK, and a +/// converted image never carries the profile its old numbers were in. +#[test] +fn a_cmyk_image_that_keeps_its_numbers_carries_its_cmyk_profile() { + let ink = [0u8, 102, 255, 0]; + let icc = cmyk_profile(|_| {}); + let tiff = cmyk_tiff_with(ink, 4, 4, &icc); + let tiff_inks = tiff.cmyk().unwrap().data; + let d = image_doc(tiff, 4, 4); + let export = |d: &Document, s: serde_json::Value| { + let out = export_with_report(d, &opts(s.clone())).unwrap_or_else(|e| panic!("{s}: {e}")); + let w: Vec<Written> = written(&out.bytes).into_iter().filter(|w| w.space != "DeviceGray").collect(); + assert_eq!(w.len(), 1, "{s}: {w:?}"); + (w.into_iter().next().unwrap(), out.bytes) + }; + let tagged = |w: &Written, s: &serde_json::Value| { + assert_eq!((w.space.as_str(), w.icc_n), ("ICCBased", Some(4)), "{s}"); + assert!(w.icc.as_deref() == Some(icc.as_slice()), "{s}: the image's own profile, byte for byte"); + }; + for s in [ + json!({"output": {"profiles": "all"}}), + json!({"output": {"profiles": "taggedSource"}}), + json!({"standard": "pdfX4"}), + json!({"standard": "pdfX3"}), + json!({"output": {"profiles": "all", "conversion": "preserveNumbers", "destination": DEVICE_CMYK}}), + ] { + let (w, bytes) = export(&d, s.clone()); + tagged(&w, &s); + assert_eq!(blobs(&import(&bytes).unwrap())[0].cmyk().unwrap().data, tiff_inks, "{s}: the inks as they were"); + } + // Without source profiles, untagged; PDF/X-1a images are always DeviceCMYK. + for s in [json!({}), json!({"output": {"profiles": "destination"}}), json!({"standard": "pdfX1a", "output": {"profiles": "all"}})] { + let (w, _) = export(&d, s.clone()); + assert!(w.icc.as_deref() != Some(icc.as_slice()), "{s}: {w:?}"); + } + let (w, _) = export(&d, json!({"standard": "pdfX1a", "output": {"profiles": "all"}})); + assert_eq!(w.space, "DeviceCMYK"); + // Converted to another CMYK profile: its new numbers aren't in the old profile. + let (w, _) = export(&d, json!({"output": {"profiles": "all", "conversion": "destination", "destination": DEVICE_CMYK}})); + assert!(w.icc.as_deref() != Some(icc.as_slice()), "{w:?}"); + + // A CMYK JPEG kept as it is carries the profile only when source profiles are included, and + // PDF/X-1a writes it untagged. + let jpg = cmyk_jpeg_with(&flat(ink, 64 * 64), 64, 64, &icc); + let d = image_doc(ImageBlob::new("image/jpeg", jpg.clone()), 64, 64); + let s = json!({"output": {"profiles": "all"}}); + let (w, _) = export(&d, s.clone()); + tagged(&w, &s); + assert!(w.data == jpg, "the JPEG data unchanged"); + for s in [json!({"standard": "pdfX1a"}), json!({})] { + let (w, _) = export(&d, s.clone()); + assert_eq!((w.space.as_str(), w.filter.as_deref()), ("DeviceCMYK", Some("DCTDecode")), "{s}"); + assert!(w.data == jpg, "{s}: the JPEG data unchanged"); + } + // Resampled and compressed again, it keeps the profile. + let s = json!({"output": {"profiles": "all"}, "compression": {"color": {"downsample": "bicubic", "ppi": 72.0, "abovePpi": 100.0}}}); + let (w, bytes) = export(&d, s.clone()); + tagged(&w, &s); + assert_eq!((w.width, w.filter.as_deref()), (40, Some("DCTDecode")), "{s}"); + assert!(blobs(&import(&bytes).unwrap())[0].cmyk().unwrap().data.as_chunks::<4>().0.iter().all(|p| close(p, &ink, 3))); + + // With its mask as its soft mask. + let mut d = masked_doc(png(image::GrayImage::from_raw(2, 2, vec![255, 128, 0, 64]).unwrap()), true, false); + d.images.insert("img".into(), cmyk_tiff_with(ink, 2, 2, &icc)); + let s = json!({"output": {"profiles": "all"}}); + let (w, bytes) = export(&d, s.clone()); + tagged(&w, &s); + assert!(w.smask, "{w:?}"); + assert!(!String::from_utf8_lossy(&bytes).contains("/S/Luminosity"), "no luminosity soft mask"); +} + +/// A CMYK JPEG kept as it is whose header declares far more pixels than the app reads is left out +/// with a warning, as other images that large are. +#[test] +fn a_kept_cmyk_jpeg_declaring_too_many_pixels_is_left_out() { + let mut jpg = cmyk_jpeg_with(&flat([0, 102, 255, 0], 4), 2, 2, &cmyk_profile(|_| {})); + // Height and width of the SOF0 segment (after its marker, length and precision): 16384 × 16384. + let sof = jpg.windows(2).position(|w| w == [0xFF, 0xC0]).unwrap(); + jpg[sof + 5..sof + 9].copy_from_slice(&[0x40, 0, 0x40, 0]); + assert_eq!(ImageBlob::new("image/jpeg", jpg.clone()).header_size(), Some((16384, 16384))); + let d = image_doc(ImageBlob::new("image/jpeg", jpg), 2, 2); + for s in [ + json!({"compression": {"color": {"downsample": "none"}}}), + json!({"output": {"profiles": "all"}, "compression": {"color": {"downsample": "none"}}}), + ] { + let out = export_with_report(&d, &opts(s.clone())).unwrap(); + assert!(written(&out.bytes).is_empty(), "{s}"); + assert!(out.warnings.iter().any(|w| w.contains("couldn't be decoded")), "{s}: {:?}", out.warnings); + } +} + +/// The profile each transparency group of written PDF `bytes` blends in: its ICC-based space's +/// profile, or `None` for DeviceCMYK. +fn group_profiles(bytes: &[u8]) -> Vec<Option<Vec<u8>>> { + let text = String::from_utf8_lossy(bytes); + let file = Pdf::new(Arc::new(bytes.to_vec())).unwrap(); + let groups: Vec<&str> = text.split("/Group<<").skip(1).filter(|g| g.contains("/S/Transparency")).collect(); + assert!(!groups.is_empty(), "{text}"); + groups + .into_iter() + .map(|group| { + let cs = group.split("/CS").nth(1).unwrap(); + if cs.starts_with("/DeviceCMYK") { + return None; + } + let cs: i32 = cs.trim_start().split(' ').next().unwrap().parse().unwrap(); + let space = text.split(&format!("\n{cs} 0 obj\n")).nth(1).unwrap(); + let stream: i32 = space.strip_prefix("[/ICCBased ").unwrap().split(' ').next().unwrap().parse().unwrap(); + let profile = file.xref().get::<Stream<'_>>(craft_pdf::syntax::object::ObjectIdentifier::new(stream, 0)).unwrap(); + Some(profile.decoded().unwrap().into_owned()) + }) + .collect() +} + +/// Transparency in a tagged CMYK document blends in the document's CMYK profile space, not in the +/// space of the profile a CMYK image carries, whichever the file holds first. +#[test] +fn tagged_cmyk_documents_blend_in_their_own_profile_beside_an_image_profile() { + let icc = cmyk_profile(|_| {}); + let document = cms::icc_bytes(&cms::active_settings().cmyk).unwrap().to_vec(); + // A transparent CMYK rectangle over the image, and the image itself transparent. + let mut d = image_doc(cmyk_tiff_with([0, 102, 255, 0], 4, 4, &icc), 4, 4); + let mut n = Node::path( + d.alloc_id(), + shapes::rectangle(Rect::new(20.0, 20.0, 60.0, 60.0)), + Appearance::basic(Paint::solid(Color::cmyk(0.0, 1.0, 0.0, 0.0)), Paint::None, 0.0), + ); + n.opacity = 0.5; + let l = d.layers[0].id; + d.insert(Some(l), 1, n).unwrap(); + let mut alone = Document::new_with_mode(100.0, 100.0, ColorMode::Cmyk); + alone.images.insert("img".into(), cmyk_tiff_with([0, 102, 255, 0], 4, 4, &icc)); + let image = + ImageObject { key: "img".into(), width: 4, height: 4, xf: Affine::scale(10.0), link: None, placement: Default::default(), pixels: None }; + let mut n = Node::new(alone.alloc_id(), NodeKind::Image(Box::new(image))); + n.opacity = 0.5; + let l = alone.layers[0].id; + alone.insert(Some(l), 0, n).unwrap(); + for d in [d, alone] { + let out = export_with_report(&d, &opts(json!({"output": {"profiles": "all"}}))).unwrap(); + let w = written(&out.bytes); + assert!(w.iter().any(|w| w.icc.as_deref() == Some(icc.as_slice())), "the image's own profile: {w:?}"); + for profile in group_profiles(&out.bytes) { + assert!(profile.as_ref().is_none_or(|p| *p == document), "the group blends in the document's CMYK profile or DeviceCMYK"); + } + } +} + +/// Only a well-formed CMYK profile tags an image: one whose size, signature, class, colour space +/// or tag table is wrong leaves it untagged. +#[test] +fn a_cmyk_image_with_a_malformed_profile_is_written_untagged() { + let tag = |icc: Vec<u8>| crate::images::cmyk_icc(&ImageBlob::new("image/jpeg", cmyk_jpeg_with(&flat([0, 102, 255, 0], 4), 2, 2, &icc))); + let good = cmyk_profile(|_| {}); + assert_eq!(tag(good.clone()), Some(good)); + let bad: [(&str, Vec<u8>); 7] = [ + ("declared size", cmyk_profile(|i| i[0..4].copy_from_slice(&200u32.to_be_bytes()))), + ("signature", cmyk_profile(|i| i[36..40].copy_from_slice(b"xxxx"))), + ("device link class", cmyk_profile(|i| i[12..16].copy_from_slice(b"link"))), + ("RGB colour space", cmyk_profile(|i| i[16..20].copy_from_slice(b"RGB "))), + ("tag beyond the end", cmyk_profile(|i| i[136..140].copy_from_slice(&150u32.to_be_bytes()))), + ("table beyond the end", cmyk_profile(|i| i[128..132].copy_from_slice(&3u32.to_be_bytes()))), + ("header only", cmyk_profile(|i| i.truncate(100))), + ]; + for (what, icc) in bad { + assert_eq!(tag(icc), None, "{what}"); + } + // And the image is written untagged. + let icc = cmyk_profile(|i| i[36..40].copy_from_slice(b"xxxx")); + let d = image_doc(cmyk_tiff_with([0, 102, 255, 0], 4, 4, &icc), 4, 4); + let out = export_with_report(&d, &opts(json!({"output": {"profiles": "taggedSource"}}))).unwrap(); + let w = written(&out.bytes); + assert_eq!((w.len(), w[0].space.as_str()), (1, "DeviceCMYK"), "{w:?}"); +} + /// A Press Quality export of a 2 × 2 CMYK image masked by PNG `mask` on its own pixel grid /// (`clip`, `invert`): the file, and the decoded soft mask of each CMYK image (`None`: it has none). fn export_masked(mask: Vec<u8>, clip: bool, invert: bool) -> (Vec<u8>, Vec<Option<Vec<u8>>>) { diff --git a/docs/mcp.md b/docs/mcp.md index ca77311c58..e0bd37015c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -5418,7 +5418,9 @@ too and printer's marks are not. The destination is any profile `edit.colorSetti for its colour mode). `profiles` (`all`, `destination`, or `taggedSource` for a document assigned profiles with `edit.assignProfile`) writes colours in ICC-based spaces with their profiles embedded: CMYK with the destination's or the document's CMYK profile, RGB as sRGB, grey with the sRGB tone curve (PDF/A, PDF/X-3 and PDF/X-4 files are -always tagged, whatever `profiles` says). `outputIntent` embeds a profile as the file's +always tagged, whatever `profiles` says). A CMYK image that keeps its numbers carries the CMYK profile it embeds +with `all` and `taggedSource`, and in PDF/A, PDF/X-3 and PDF/X-4 unless `profiles` is `destination`; PDF/X-1a +images are always untagged CMYK. `outputIntent` embeds a profile as the file's `/GTS_PDFX` output intent with `outputCondition`, `outputConditionId` and `registry`, and `trapped` sets `/Trapped` (PDF/A files keep their own output intent). Type is written as selectable, searchable text in embedded subset fonts with a ToUnicode map (fonts whose licence forbids embedding stay outlines, with a warning); `advanced: {outlineText: diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..f6e2d18969 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1782,6 +1782,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - File › Revert also drops what was started for the content it discards: a file being read for Place, for the place cursor or dropped on the canvas, a bitmap being read for Paste, and a paste waiting at its Swatch Conflict dialog are not placed or pasted in the reverted document, and the status bar says the document was reverted. Edits made while a file is read, a Revert that fails or that a batch rolls back, and a Revert of another document leave the read to finish as before (`crates/ui-egui/src/placing/tests.rs`). - The pixels of a PNG, JPEG, GIF or WebP file that Place decodes to check them are kept in the image store the renderers share, so the canvas's first frame with the placed image draws them without decoding the file again on the UI thread: File › Place, a file dropped on the canvas, a click or drag of the place cursor, `file.place`, and Paste of such an image. A CMYK JPEG is still decoded when it is first drawn (`crates/ui-egui/src/placing.rs`, `crates/render/src/tests.rs`). - A photo whose EXIF orientation turns or flips it (a camera held upright or upside down) is placed and opened upright, as it was taken; the image is stored as it is seen (#4284). A quarter turn swaps the resolution's axes, so the image keeps its physical size. TIFFs read without the image decoder (grayscale with extra channels, CCITT Group 3, CMYK with one plane per ink) follow their Orientation tag too, and a turned CMYK JPEG or TIFF keeps its inks, at the 8 or 16 bits the file has, as a CMYK TIFF. + - PDF export writes a CMYK image that keeps its numbers in an `ICCBased` color space holding, byte for byte, the CMYK profile the image carries (a CMYK TIFF's tag 34675, or a CMYK JPEG's `ICC_PROFILE` APP2 segments) when `output.profiles` is `all` or `taggedSource`, and in PDF/A-2b, PDF/X-3 and PDF/X-4 unless it is `destination` ([the help page](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/pdf-marks-bleeds-and-color-output-options.html)). This covers a CMYK JPEG embedded as it is, one the Compression settings resample or compress again, a TIFF written again, and an image written with its mask as its soft mask. With `none`, and in PDF/X-1a, the image is DeviceCMYK and a JPEG's own profile is left out, so PDF/X-1a export writes a CMYK JPEG that carries a profile. Pixels the Output settings convert are never tagged with the profile of their old numbers. A profile tags an image only when its size, signature, class, CMYK color space and tag table are well formed and it is at most 16 MiB (VectorCraft's own limit). Transparency in a tagged CMYK document blends in the document's CMYK profile; when the file holds no space of that profile it blends in DeviceCMYK, or keeps its RGB space in PDF/A, and never in an image's own profile (`crates/pdf/src/tests/cmykimages.rs`, `export::writer::tests`). - An image that Open and Place store again keeps the ICC profile its file embeds and its 16-bit samples. A turned PNG, JPEG, WebP or TIFF stored as PNG, and a TIFF the image decoder reads, keep their gray or RGB samples at 8 or 16 bits with their gray or RGB profile in the PNG's `iCCP` chunk ([PNG specification, iCCP](https://www.w3.org/TR/png-3/#11iCCP)). A CMYK TIFF stored with one plane per ink and a turned CMYK JPEG or TIFF keep their CMYK profile as TIFF tag 34675, a JPEG's put together from all its APP2 segments ([ICC image-format guide](https://github.com/InternationalColorConsortium/iccDEV/blob/master/iccdev-mcp/docs/icc-format-guide.md)). A profile whose color space differs from the stored samples' is left out. The profile is kept in the stored image; how CMYK inks are drawn and exported to PDF does not change (`crates/engine/src/cmd/fileio/tests.rs`). - SVG import shows a raster `<image>` whose EXIF orientation or TIFF Orientation tag turns or flips it upright, linked or as a data URL, and inside an SVG shown as an image: the pixels are stored turned, the width and height swap, and the `<image>` box fits the turned image under `preserveAspectRatio`, as CSS `image-orientation: from-image` describes (<https://www.w3.org/TR/css-images-3/#the-image-orientation>). A turned CMYK JPEG or TIFF keeps its inks as a CMYK TIFF, as does a CMYK TIFF that is not turned. TIFF data URLs (`image/tiff`, or untyped TIFF bytes) are read, and TIFFs with an alpha or other extra channel, CCITT Group 3 TIFFs and CMYK TIFFs stored one plane per ink are read as Open and Place read them. The pixels are decoded within the decode allowance, and a TIFF claiming more strips or tiles than the decoder can count is refused before it is decoded (`crates/svg/tests/it/image_orientation.rs`). - SVG import leaves out an SVG shown as an image that it can't read (text that isn't XML, an SVG without a size) and goes on with the images after it, as SVG 2's error processing describes (<https://www.w3.org/TR/SVG2/conform.html>). Only images that decode count toward the 256 nested SVG images an SVG may show, so an image after many broken ones is imported. Every nested SVG image read, decoded or not, counts toward VectorCraft's own limits of 1,024 reads and 512 MB of text per import; past them, nested SVG images are left out with a warning (`crates/svg/tests/it/import_details.rs`). From 490c8030804cd89e9ce4113b32815d2dc69c1816 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:47:27 -0800 Subject: [PATCH 094/108] SVG import: type on a closed path wraps around past the path's start Text on a path of one closed subpath that is anchored to start before the path's start point (text-anchor end or middle, right-to-left start, or a negative startOffset) started at the start point, and text offset past the path's end started at its end. It now wraps around the path, as SVG 2's startOffset attribute describes for a single closed subpath (https://www.w3.org/TR/SVG2/text.html#TextPathElementStartOffsetAttribute): text-anchor end at startOffset 0 ends at the start point. Open paths and paths of several subpaths still start the text at the path's start or end. --- crates/svg/src/import/text.rs | 16 ++++-- crates/svg/tests/it/import_text.rs | 78 ++++++++++++++++++++++++++++++ docs/target-app-parity.md | 1 + 3 files changed, 91 insertions(+), 4 deletions(-) diff --git a/crates/svg/src/import/text.rs b/crates/svg/src/import/text.rs index 1a221a69f1..b8aa55373c 100644 --- a/crates/svg/src/import/text.rs +++ b/crates/svg/src/import/text.rs @@ -1408,10 +1408,18 @@ impl Ctx { let em = self.font_size(tp); let offset = tp.attribute("startOffset").and_then(|v| self.length(v, em, len)).unwrap_or(0.0) + dx[0]; let width = if anchor > 0.0 { advance(&point_text(&cells)) } else { 0.0 }; - // Text that would start before the path's beginning starts at it, with all its glyphs - // on the path (SVG does not draw the glyphs that fall off it). - let start = Some((offset - anchor * width) / len).filter(|s| s.is_finite()).map_or(0.0, |s| s.clamp(0.0, 1.0)); - obj.kind = TextKind::OnPath { path: PathData::from_bezpath(&bp), start, end: None }; + // On a path of one closed subpath, text that starts before the path's start or past its + // end wraps around the path. Otherwise it starts at the path's start or end. + let path = PathData::from_bezpath(&bp); + let wraps = path.subpaths.len() == 1 && path.is_closed(); + let wrap = |s: f64| { + // `rem_euclid` can round a tiny negative value up to 1. + let s = s.rem_euclid(1.0); + if s < 1.0 { s } else { 0.0 } + }; + let start = + Some((offset - anchor * width) / len).filter(|s| s.is_finite()).map_or(0.0, |s| if wraps { wrap(s) } else { s.clamp(0.0, 1.0) }); + obj.kind = TextKind::OnPath { path, start, end: None }; obj.xf = Affine::IDENTITY; } else if vertical { // Type on a vertical path: dy is extra advance, dx shifts across the column. diff --git a/crates/svg/tests/it/import_text.rs b/crates/svg/tests/it/import_text.rs index 472d7517e4..fdba7e41cb 100644 --- a/crates/svg/tests/it/import_text.rs +++ b/crates/svg/tests/it/import_text.rs @@ -299,6 +299,84 @@ fn text_path_becomes_type_on_a_path() { assert_eq!(t[2].para.justify, Justify::Left); } +#[test] +fn text_on_a_closed_path_wraps_past_the_path_start() { + // A closed path 400 long: text anchored before its start, or offset past its end, wraps + // around the path instead of stopping at its start or end. + let d = open( + r##"<path id="p" d="M50 50 H150 V150 H50 Z" fill="none" stroke="black"/> + <text font-size="20" text-anchor="end"><textPath href="#p">Wave</textPath></text> + <text font-size="20"><textPath href="#p" startOffset="440">Wave</textPath></text> + <text font-size="20" direction="rtl"><textPath href="#p">Wave</textPath></text> + <text font-size="20" text-anchor="middle"><textPath href="#p">Wave</textPath></text> + <text font-size="20"><textPath href="#p" startOffset="-40">Wave</textPath></text> + <text font-size="20"><textPath href="#p" startOffset="-10%">Wave</textPath></text> + <path id="q" d="M50 50 H150 V150 H50 Z M200 50 H300 V150 H200 Z" fill="none" stroke="black"/> + <text font-size="20" text-anchor="end"><textPath href="#q">Wave</textPath></text> + <path id="o" d="M50 50 H150 V150 H50" fill="none" stroke="black"/> + <text font-size="20" text-anchor="end"><textPath href="#o">Wave</textPath></text> + <text font-size="20"><textPath href="#o" startOffset="440">Wave</textPath></text>"##, + ); + let t = texts(&d); + assert_eq!(t.len(), 9); + let start_of = |t: &TextObject| match t.kind { + TextKind::OnPath { start, .. } => start, + _ => panic!("{:?}", t.kind), + }; + let width: f64 = layout(FontDb::global(), t[0]).glyphs.iter().map(|g| g.advance).sum(); + assert!(width > 0.0); + // Ending at the path's start: the text starts its width before the end of the loop. + assert!(close(start_of(t[0]), 1.0 - width / 400.0, 1e-6), "{} {width}", start_of(t[0])); + assert!(close(start_of(t[1]), 0.1, 1e-9), "{}", start_of(t[1])); + // Right-to-left text starts at its edge toward the path's end, here the path's start. + assert!(close(start_of(t[2]), 1.0 - width / 400.0, 1e-6), "{} {width}", start_of(t[2])); + // Centered on the path's start: half the text before it, half after. + assert!(close(start_of(t[3]), 1.0 - width / 800.0, 1e-6), "{} {width}", start_of(t[3])); + // A negative startOffset, in user units or as a percentage, counts back from the path's end. + assert!(close(start_of(t[4]), 0.9, 1e-9), "{}", start_of(t[4])); + assert!(close(start_of(t[5]), 0.9, 1e-9), "{}", start_of(t[5])); + // A path of two closed subpaths, and an open path, do not wrap: the text starts at the path's + // start or end. + assert_eq!(start_of(t[6]), 0.0); + assert_eq!(start_of(t[7]), 0.0); + assert_eq!(start_of(t[8]), 1.0); + + // Laid out, the end-anchored text draws every glyph up the left side and ends at the start + // point; the centered text crosses the start point from the left side onto the top. + let lay = layout(FontDb::global(), t[0]); + assert!(!lay.overflow); + assert_eq!(lay.glyphs.len(), 4); + for g in &lay.glyphs { + let o = t[0].xf * g.origin; + assert!(close(o.x, 50.0, 0.05) && o.y > 50.0 && o.y < 150.0, "{o:?}"); + } + let last = lay.glyphs.last().map(|g| t[0].xf * (g.origin + baseline_dir(g.angle) * g.advance)); + assert!(last.is_some_and(|p| close(p.x, 50.0, 0.05) && close(p.y, 50.0, 0.05)), "{last:?}"); + let lay = layout(FontDb::global(), t[3]); + assert!(!lay.overflow); + assert_eq!(lay.glyphs.len(), 4); + let first = t[3].xf * lay.glyphs[0].origin; + assert!(close(first.x, 50.0, 0.05) && first.y > 50.0, "{first:?}"); + let last = t[3].xf * lay.glyphs[3].origin; + assert!(close(last.y, 50.0, 0.05) && last.x > 50.0, "{last:?}"); + + // Text longer than the loop draws its first characters, whatever its anchor. + let d = open( + r##"<path id="s" d="M0 0 H20 V20 H0 Z" fill="none" stroke="black"/> + <text font-size="20" text-anchor="end"><textPath href="#s">Wave Wave Wave</textPath></text>"##, + ); + let t = only_text(&d); + let lay = layout(FontDb::global(), t); + assert!(lay.overflow); + assert!(!lay.glyphs.is_empty() && lay.glyphs.len() < 14, "{}", lay.glyphs.len()); + assert!(lay.glyphs.iter().enumerate().all(|(i, g)| g.byte == i), "{:?}", lay.glyphs.iter().map(|g| g.byte).collect::<Vec<_>>()); +} + +/// The unit vector along a glyph's baseline. +fn baseline_dir(angle: f64) -> vectorcraft_geom::Vec2 { + vectorcraft_geom::Vec2::new(angle.cos(), angle.sin()) +} + #[test] fn per_character_positions_rotation_and_shifts() { let d = open(r#"<text x="10 30 60" y="50" rotate="15 -30" dy="0 -4" font-size="12">abcd</text>"#); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..1d924927e7 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1658,6 +1658,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A gap between glyphs of two sizes is measured against the smaller one, so a word set beside a much larger one with no space glyph between them (a browser's margin between two sizes, as in `≤ 4` and a small `hours`) keeps its word space (#3623). SVG import's style cascade, used for hidden objects, non-scaling strokes and type, tests each element only against the `<style>` rules for its id, its classes and its element name, and the rules whose selector ends in none of these (`*`, `[x]`). SVG import places right-to-left point type and type on a path as [SVG 2's `text-anchor`](https://www.w3.org/TR/SVG2/text.html#TextAnchoringProperties) says: with `direction: rtl`, `start` puts the right edge of the text at its position (on a path, the text ends at `startOffset`) and `end` puts the left edge there. Each line and each absolutely placed chunk is anchored by the `text-anchor` and `direction` of the element holding its first character, a `<tspan>`'s own included, and each line starts at its own `x`. An absolutely placed chunk is anchored by the left and right edges of its glyphs as they are drawn, so a chunk of several right-to-left characters, whose first character is drawn at its right, sits on its anchor too. A letter-spaced right-to-left line keeps the tracking of all its letters inside the advance it anchors (`rtl_point_text_start_and_end_use_directional_edges`, `rtl_type_on_a_path_starts_at_its_directional_edge`, `rtl_letter_spaced_lines_stay_on_their_anchor`, `rtl_lines_use_each_chunk_first_character_direction_and_anchor`, `each_line_starts_at_its_own_x`, `absolutely_placed_chunks_use_their_own_rtl_anchor` and `absolutely_placed_rtl_chunks_of_several_characters_anchor_by_their_visual_edges` in `crates/svg/tests/it/import_text.rs`). + SVG import places type on a path of one closed subpath as [SVG 2's `startOffset` attribute](https://www.w3.org/TR/SVG2/text.html#TextPathElementStartOffsetAttribute) describes: text anchored to start before the path's start point, or offset past its end, wraps around the path, so text with `text-anchor="end"` at `startOffset` 0 ends at the start point, and a negative `startOffset` counts back from the end. Text longer than the loop draws its first characters whatever its anchor. A path of several subpaths, and an open path, still start the text at the path's start or end (`text_on_a_closed_path_wraps_past_the_path_start` in `crates/svg/tests/it/import_text.rs`). SVG import reads the bidi embedding of a `<tspan>`, `<textPath>` or `<a>` inside a `<text>` as [SVG 1.1's bidi section](https://www.w3.org/TR/SVG11/text.html#RelationshipWithBi-directionality) describes: with `unicode-bidi: embed` its characters take its `direction` as their Character Direction, an element with `normal` stays in its parent's embedding, and the `<text>` keeps its own paragraph direction, so a run that SVG export writes with `direction` and `unicode-bidi="embed"` opens with its Character Direction again. Character Direction holds one level of embedding, so `bidi-override`, `isolate` and `isolate-override` are imported as embeddings in their `direction`, `plaintext` as an embedding in the direction of its first strong character, and an embedding inside another as an embedding of its own, each with an import warning. With `unicode-bidi: plaintext` on the `<text>`, each of its paragraphs runs, and each chunk is anchored, in the direction of its first strong character (`a_tspan_bidi_embedding_becomes_its_character_direction`, `unicode_bidi_is_not_inherited_and_reads_from_the_cascade` and `unicode_bidi_values_the_text_model_cannot_hold_are_reported` in `crates/svg/tests/it/import_text.rs`; `character_direction_reads_back` in `crates/svg/tests/it/text_layout.rs`). A `.svgz` file copied in a file manager pastes as its art, as a copied `.svg` file does. SVG export (Save As, Export As, Export for Screens, Asset Export and the clipboard share the writer) writes simple shapes as SVG basic shapes, as the reference app does (an ellipse is an `ellipse` tag until an anchor is added, [forum](https://community.adobe.com/t5/illustrator-discussions/trouble-exporting-shape-with-points-to-svg/td-p/10720325); rectangles come out as `<rect>` and `<polygon>`, [forum](https://community.adobe.com/t5/illustrator-discussions/force-svg-export-using-all-lt-rect-gt/td-p/11282378)): an axis-aligned rectangle as `<rect>`, a circle or ellipse drawn with four standard arcs as `<circle>`/`<ellipse>`, a straight line as `<line>`, and other straight-segment paths as `<polygon>`/`<polyline>`, at the written precision (#4652). A rectangle or ellipse with a dashed stroke, whose dashes would start elsewhere, a turned ellipse, curves and compound paths stay `<path>`. `crates/svg/tests/it/basic_shapes.rs` checks each element, that the picture renders as the canvas does and that the geometry reimports. From efb31aa51a28c9149a8c27643eda4e6f17a21578 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:06:15 -0800 Subject: [PATCH 095/108] PDF and EPS export: gradients name only the spot inks of stops that color something A gradient's Separation or DeviceN space, and EPS's %%DocumentCustomColors, named the spot ink of every linked stop. A stop out of order whose neighboring stretches have no width, a stop at a tint of 0 without process plates, and in PDF a stop whose stretches are fully transparent print no ink, but their spot inks were still declared, so separations got an empty plate. - vectorcraft-color: Gradient::drawn_stops (the rule Document Info uses, moved here) and Gradient::reached_stops (every stop taken as opaque). - PDF: Separation and DeviceN shadings, the Perceptual spot shadings and the spot-image warning name only inks of drawn stops at a tint above 0 or with process plates; other stops are written with no ink, so their process inks and RGB or Lab colors no longer shape the space either. - EPS: the same with reached stops, since EPS writes stops opaque; a transparent spot stop keeps its ink. Output is unchanged when every stop colors part of the gradient and every spot stop has a tint above 0 or process plates. --- crates/color/src/gradient.rs | 43 ++++++++++++++ crates/color/src/gradient/tests.rs | 63 ++++++++++++++++++++ crates/engine/src/cmd/docinfo.rs | 74 +----------------------- crates/eps/src/scene.rs | 21 ++++--- crates/eps/src/tests.rs | 60 +++++++++++++++++++ crates/pdf/src/export/paint.rs | 92 +++++++++++++++++++++--------- crates/pdf/src/tests/output.rs | 54 ++++++++++++++++++ docs/target-app-parity.md | 1 + 8 files changed, 302 insertions(+), 106 deletions(-) diff --git a/crates/color/src/gradient.rs b/crates/color/src/gradient.rs index 54cb50c197..05b7f4839c 100644 --- a/crates/color/src/gradient.rs +++ b/crates/color/src/gradient.rs @@ -547,6 +547,49 @@ impl Gradient { None => (Color::BLACK, 1.0), } } + /// Which of its stops color some part of it that draws, by the stretches [`Self::sample`] + /// mixes in, for stops in any order: the pair of stop `k` and stop `k + 1` covers the offsets + /// above every offset of stops `0..=k` up to stop `k + 1`'s, and both its stops count when that + /// stretch has positive width and either stop is above opacity 0. The first stop also counts + /// when it is above opacity 0, since it colors the offsets up to its own, and so does the last + /// stop, since it colors the offsets above every stop's. Any other stop, opaque or not, counts + /// only through a pair: a stop out of order whose pairs have no width (another stop before it + /// reaches past both ends) colors nothing. A freeform gradient draws from its points, so each of + /// its stops counts while any stop is above opacity 0. + pub fn drawn_stops(&self) -> Vec<bool> { + self.stops_with_color(|s| s.opacity > 0.0) + } + /// [`Self::drawn_stops`] with every stop taken as opaque, for output that leaves stop opacity + /// out: the stops that color a stretch of positive width, and the first and last stops. + pub fn reached_stops(&self) -> Vec<bool> { + self.stops_with_color(|_| true) + } + /// [`Self::drawn_stops`] with `shows` telling whether a stop's opacity shows its color. + fn stops_with_color(&self, shows: impl Fn(&GradientStop) -> bool) -> Vec<bool> { + let stops = &self.stops; + if self.kind == GradientKind::Freeform { + let any = stops.iter().any(&shows); + return vec![any; stops.len()]; + } + let mut drawn = vec![false; stops.len()]; + if let (Some(first), Some(d)) = (stops.first(), drawn.first_mut()) { + *d = shows(first); + } + if let (Some(last), Some(d)) = (stops.last(), drawn.last_mut()) { + *d |= shows(last); + } + // `f32::max` skips a NaN offset, which the sampler never picks either. + let mut reach = f32::NEG_INFINITY; + for k in 0..stops.len().saturating_sub(1) { + reach = reach.max(stops[k].offset); + let (a, b) = (&stops[k], &stops[k + 1]); + if b.offset > reach && (shows(a) || shows(b)) { + drawn[k] = true; + drawn[k + 1] = true; + } + } + drawn + } /// [`Self::sample_with`] at each of `ts`, which must not decrease. Each search starts where /// the one before it stopped, so the work is the samples plus the stops, not their product. pub fn sample_increasing_with(&self, ts: impl IntoIterator<Item = f32>, mix: impl Fn(&Color, &Color, f32) -> Color) -> Vec<(Color, f32)> { diff --git a/crates/color/src/gradient/tests.rs b/crates/color/src/gradient/tests.rs index cd25753a05..16d8005786 100644 --- a/crates/color/src/gradient/tests.rs +++ b/crates/color/src/gradient/tests.rs @@ -66,6 +66,69 @@ fn stop_reach_matches_scanning_the_stops() { } } +/// A gradient's stops color what draws where they color a stretch that draws, for stops in any +/// order: the sampler mixes stop `k` with stop `k + 1` above every offset of the stops before it, +/// so an out-of-order stop's pair can have no width. +#[test] +fn drawn_stops_follow_the_sampled_stretches() { + let stop = |offset: f32, opacity: f32| GradientStop { opacity, ..GradientStop::new(offset, Color::BLACK) }; + let g = |stops: Vec<GradientStop>| Gradient::new(GradientKind::Linear, stops); + // In order: the clear stop next to the opaque one, not the one after it. + assert_eq!(g(vec![stop(0.0, 1.0), stop(0.5, 0.0), stop(1.0, 0.0)]).drawn_stops(), vec![true, true, false]); + // Out of order: the pair (0.8, 0.3) has no width, so the clear stop at 0.3 mixes only with + // the clear stop at 0.8 before it, and the pair (0.3, 1.0) is sampled above 0.8. + assert_eq!(g(vec![stop(0.0, 0.0), stop(0.8, 0.0), stop(0.3, 0.0), stop(1.0, 1.0)]).drawn_stops(), vec![false, false, true, true]); + // An opaque stop out of order: the pairs (0, 0.8) and (0.7, 1) cover every offset, so the + // pairs next to the stop at 0.3 have no width and it colors nothing. + let out_of_order = |o: f32| g(vec![stop(0.0, 0.0), stop(0.8, o), stop(0.3, 1.0), stop(0.7, 0.0), stop(1.0, 0.0)]); + assert_eq!(out_of_order(0.0).drawn_stops(), vec![false; 5]); + // With the stop at 0.8 opaque, the pairs next to it with width are drawn. + assert_eq!(out_of_order(1.0).drawn_stops(), vec![true, true, false, false, false]); + // The last stop colors the offsets above every stop's, even when it is out of order. + assert_eq!(g(vec![stop(0.0, 0.0), stop(0.6, 0.0), stop(0.5, 1.0)]).drawn_stops(), vec![false, false, true]); + // The first stop colors the offsets up to its own. + assert_eq!(g(vec![stop(0.0, 1.0), stop(0.0, 0.0), stop(1.0, 0.0)]).drawn_stops(), vec![true, false, false]); + // One stop, every stop clear, and no stops at all. + assert_eq!(g(vec![stop(0.5, 1.0)]).drawn_stops(), vec![true]); + assert_eq!(g(vec![stop(0.0, 0.0), stop(1.0, 0.0)]).drawn_stops(), vec![false, false]); + assert!(g(vec![]).drawn_stops().is_empty()); + // A freeform gradient draws from its points: its stops count while any is above opacity 0. + let mut free = g(vec![stop(0.0, 1.0), stop(0.5, 0.0), stop(1.0, 0.0)]); + free.kind = GradientKind::Freeform; + assert_eq!(free.drawn_stops(), vec![true, true, true]); + free.stops.iter_mut().for_each(|s| s.opacity = 0.0); + assert_eq!(free.drawn_stops(), vec![false; 3]); +} + +/// Taken as opaque, every stop that colors a stretch of positive width counts, and the first and +/// last stops, whatever their opacity; an out-of-order stop whose pairs have no width does not. +#[test] +fn reached_stops_leave_out_only_stops_without_width() { + let stop = |offset: f32, opacity: f32| GradientStop { opacity, ..GradientStop::new(offset, Color::BLACK) }; + let g = |stops: Vec<GradientStop>| Gradient::new(GradientKind::Linear, stops); + // Clear stops in order color their stretches once opaque. + assert_eq!(g(vec![stop(0.0, 1.0), stop(0.5, 0.0), stop(1.0, 0.0)]).reached_stops(), vec![true; 3]); + assert_eq!(g(vec![stop(0.0, 0.0), stop(1.0, 0.0)]).reached_stops(), vec![true, true]); + // The stop at 0.3 sits inside the stretch the stops at 0 and 0.8 cover. + let out_of_order = g(vec![stop(0.0, 0.0), stop(0.8, 0.0), stop(0.3, 1.0), stop(0.7, 0.0), stop(1.0, 0.0)]); + assert_eq!(out_of_order.reached_stops(), vec![true, true, false, true, true]); + // A stop at the offset of the stop before it: its pair has no width, the next one does. + assert_eq!(g(vec![stop(0.0, 1.0), stop(0.0, 1.0), stop(1.0, 1.0)]).reached_stops(), vec![true, true, true]); + assert_eq!( + g(vec![stop(0.0, 1.0), stop(0.6, 1.0), stop(0.6, 1.0), stop(0.2, 1.0), stop(1.0, 1.0)]).reached_stops(), + vec![true, true, false, true, true] + ); + assert!(g(vec![]).reached_stops().is_empty()); + // Every pair the sampler picks between the ends has both its stops counted. + let stops: Vec<GradientStop> = [0.1, 0.4, 0.4, 0.2, 0.9, 0.5].iter().map(|&o| stop(o, 1.0)).collect(); + let g = g(stops); + let (reached, reach) = (g.reached_stops(), StopReach::new(&g.stops)); + for t in (5..=95).map(|k| k as f32 / 100.0).filter(|&t| t > 0.1 && t <= 0.9) { + let k = reach.0.partition_point(|r| *r < t); + assert!(reached[k] && reached[k + 1], "pair {k} at {t}: {reached:?}"); + } +} + /// Repeated offsets turn off the direct midpoint mix, and the midpoints still come out as /// `sample` gives them, with work that stays near linear in the stops (thousands of stops at one /// offset used to scan them all for each midpoint). diff --git a/crates/engine/src/cmd/docinfo.rs b/crates/engine/src/cmd/docinfo.rs index 4068c2506c..b5ac1c13e5 100644 --- a/crates/engine/src/cmd/docinfo.rs +++ b/crates/engine/src/cmd/docinfo.rs @@ -344,44 +344,9 @@ fn spot_swatches(d: &Document) -> HashSet<&str> { first.into_iter().filter(|&(name, spot)| spot && name != vectorcraft_color::swatch::REGISTRATION).map(|(name, _)| name).collect() } -/// Which of gradient `g`'s stops color some part of it that draws, by the stretches -/// [`vectorcraft_color::Gradient::sample`] mixes in, for stops in any order: the pair of stop `k` -/// and stop `k + 1` covers the offsets above every offset of stops `0..=k` up to stop `k + 1`'s, -/// and both its stops count when that stretch has positive width and either stop is above opacity -/// 0. The first stop also counts when it is above opacity 0, since it colors the offsets up to its -/// own, and so does the last stop, since it colors the offsets above every stop's. Any other stop, -/// opaque or not, counts only through a pair: a stop out of order whose pairs have no width -/// (another stop before it reaches past both ends) colors nothing. A freeform gradient draws from -/// its points, so each of its stops counts while any stop is above opacity 0. -fn drawn_stops(g: &vectorcraft_color::Gradient) -> Vec<bool> { - let stops = &g.stops; - if g.kind == vectorcraft_color::GradientKind::Freeform { - let any = stops.iter().any(|s| s.opacity > 0.0); - return vec![any; stops.len()]; - } - let mut drawn = vec![false; stops.len()]; - if let (Some(first), Some(d)) = (stops.first(), drawn.first_mut()) { - *d = first.opacity > 0.0; - } - if let (Some(last), Some(d)) = (stops.last(), drawn.last_mut()) { - *d |= last.opacity > 0.0; - } - // `f32::max` skips a NaN offset, which the sampler never picks either. - let mut reach = f32::NEG_INFINITY; - for k in 0..stops.len().saturating_sub(1) { - reach = reach.max(stops[k].offset); - let (a, b) = (&stops[k], &stops[k + 1]); - if b.offset > reach && (a.opacity > 0.0 || b.opacity > 0.0) { - drawn[k] = true; - drawn[k + 1] = true; - } - } - drawn -} - /// The spot colors paint `p` prints (`spots`: [`spot_swatches`]): the spot swatch a solid color is -/// linked to, or those a gradient's drawn stops ([`drawn_stops`]) are linked to, each once, in the -/// order of the stops. A link at a tint of 0 prints no ink, a stop that colors only parts of a +/// linked to, or those a gradient's drawn stops ([`vectorcraft_color::Gradient::drawn_stops`]) are +/// linked to, each once, in the order of the stops. A link at a tint of 0 prints no ink, a stop that colors only parts of a /// gradient at an opacity of 0 prints none, and a color that only looks like a spot color is not /// linked to one. fn spot_labels(spots: &HashSet<&str>, p: &Paint) -> Vec<String> { @@ -398,7 +363,7 @@ fn spot_labels(spots: &HashSet<&str>, p: &Paint) -> Vec<String> { match p { Paint::Solid { swatch, tint, .. } => add(swatch, *tint), Paint::Gradient(g) => { - let drawn = drawn_stops(&g.gradient); + let drawn = g.gradient.drawn_stops(); g.gradient.stops.iter().zip(drawn).filter(|&(_, d)| d).for_each(|(s, _)| add(&s.swatch, s.tint)); } _ => {} @@ -1662,39 +1627,6 @@ mod tests { assert!(!["Far", "Edge", "Seam"].iter().any(|n| text.contains(n)), "{text}"); } - /// A gradient's stops print where they color a stretch that draws, for stops in any order: the - /// sampler mixes stop `k` with stop `k + 1` above every offset of the stops before it, so an - /// out-of-order stop's pair can have no width. - #[test] - fn drawn_stops_follow_the_sampled_stretches() { - use vectorcraft_color::{Color, Gradient, GradientKind, GradientStop}; - let stop = |offset: f32, opacity: f32| GradientStop { opacity, ..GradientStop::new(offset, Color::BLACK) }; - let g = |stops: Vec<GradientStop>| Gradient::new(GradientKind::Linear, stops); - // In order: the clear stop next to the opaque one, not the one after it. - assert_eq!(drawn_stops(&g(vec![stop(0.0, 1.0), stop(0.5, 0.0), stop(1.0, 0.0)])), vec![true, true, false]); - // Out of order: the pair (0.8, 0.3) has no width, so the clear stop at 0.3 mixes only with - // the clear stop at 0.8 before it, and the pair (0.3, 1.0) is sampled above 0.8. - assert_eq!(drawn_stops(&g(vec![stop(0.0, 0.0), stop(0.8, 0.0), stop(0.3, 0.0), stop(1.0, 1.0)])), vec![false, false, true, true]); - // An opaque stop out of order: the pairs (0, 0.8) and (0.7, 1) cover every offset, so the - // pairs next to the stop at 0.3 have no width and it colors nothing. - let out_of_order = |o: f32| g(vec![stop(0.0, 0.0), stop(0.8, o), stop(0.3, 1.0), stop(0.7, 0.0), stop(1.0, 0.0)]); - assert_eq!(drawn_stops(&out_of_order(0.0)), vec![false; 5]); - // With the stop at 0.8 opaque, the pairs next to it with width are drawn. - assert_eq!(drawn_stops(&out_of_order(1.0)), vec![true, true, false, false, false]); - // The last stop colors the offsets above every stop's, even when it is out of order. - assert_eq!(drawn_stops(&g(vec![stop(0.0, 0.0), stop(0.6, 0.0), stop(0.5, 1.0)])), vec![false, false, true]); - // The first stop colors the offsets up to its own. - assert_eq!(drawn_stops(&g(vec![stop(0.0, 1.0), stop(0.0, 0.0), stop(1.0, 0.0)])), vec![true, false, false]); - // One stop, every stop clear, and no stops at all. - assert_eq!(drawn_stops(&g(vec![stop(0.5, 1.0)])), vec![true]); - assert_eq!(drawn_stops(&g(vec![stop(0.0, 0.0), stop(1.0, 0.0)])), vec![false, false]); - assert!(drawn_stops(&g(vec![])).is_empty()); - // A freeform gradient draws from its points: its stops count while any is above opacity 0. - let mut free = g(vec![stop(0.0, 1.0), stop(0.5, 0.0), stop(1.0, 0.0)]); - free.kind = GradientKind::Freeform; - assert_eq!(drawn_stops(&free), vec![true, true, true]); - } - /// Brushes, Spot Color Objects, Pattern Objects and Gradient Objects leave out a hidden object, /// an object at an opacity of 0 and the objects inside a hidden layer or a group at an opacity of /// 0, with Selection Only too: their fills, strokes, characters and colorized pixels paint no diff --git a/crates/eps/src/scene.rs b/crates/eps/src/scene.rs index 023dbdcbe1..299d130f7d 100644 --- a/crates/eps/src/scene.rs +++ b/crates/eps/src/scene.rs @@ -931,18 +931,21 @@ impl<'a> Scene<'a> { /// process inks the stops use, in CMYK order, and the spot inks, in the order the stops name /// them. Paper white adds no ink, a gray stop is black ink, and a spot stop's process plates /// print with its ink. An off-center midpoint is a stop - /// with the inks halfway between its two stops. `None` for a gradient without a spot ink, and, - /// with a warning, for one whose inks can't be kept or that is mixed by the Perceptual method - /// or around the hue wheel; it is then written in process colors. + /// with the inks halfway between its two stops. Stop opacity is left out, so the stops that + /// color a stretch ([`vectorcraft_color::Gradient::reached_stops`]) name the inks, a spot ink + /// only above a tint of 0 or with process plates; the others are written with no ink. `None` for a gradient without a + /// spot ink, and, with a warning, for one whose inks can't be kept or that is mixed by the + /// Perceptual method or around the hue wheel; it is then written in process colors. fn ink_stops(&mut self, g: &vectorcraft_color::Gradient) -> Option<(GradientSpace, RawStops)> { let doc = self.doc; let spot_of = |s: &vectorcraft_color::GradientStop| -> Option<String> { s.swatch.as_deref().filter(|n| doc.swatch(n).is_some_and(|w| w.spot)).map(str::to_string) }; + let reached = g.reached_stops(); // The spot inks, collected up to one more than a DeviceN space can hold. let mut names: Vec<String> = vec![]; - for s in &g.stops { - if let Some(n) = spot_of(s) + for (s, &r) in g.stops.iter().zip(&reached) { + if let Some(n) = spot_of(s).filter(|_| r && (s.tint > 0.0 || s.plates.is_some())) && !names.contains(&n) { names.push(n); @@ -971,9 +974,10 @@ impl<'a> Scene<'a> { }; // Each stop's ink coverage: the four process inks, then one tint per spot ink. let mut inks: Vec<Vec<f32>> = Vec::with_capacity(g.stops.len()); - for s in &g.stops { + for (s, &r) in g.stops.iter().zip(&reached) { let mut v = vec![0.0; 4 + names.len()]; match spot_of(s) { + _ if !r => {} Some(n) => { if let Some(i) = names.iter().position(|m| *m == n) { v[4 + i] = unit(s.tint); @@ -1116,7 +1120,10 @@ impl<'a> Scene<'a> { // keep no swatch links: the warning [`Self::ink_stops`] gives the others. if g.gradient.method.is_hue() && g.gradient.is_spread() && g.gradient.spread == vectorcraft_color::GradientSpread::Reflect { let doc = self.doc; - if g.gradient.stops.iter().any(|s| s.swatch.as_deref().is_some_and(|n| doc.swatch(n).is_some_and(|w| w.spot))) { + let spot = |s: &vectorcraft_color::GradientStop| { + (s.tint > 0.0 || s.plates.is_some()) && s.swatch.as_deref().is_some_and(|n| doc.swatch(n).is_some_and(|w| w.spot)) + }; + if g.gradient.stops.iter().zip(g.gradient.reached_stops()).any(|(s, r)| r && spot(s)) { self.warn(SPOT_GRADIENTS_HUE); } } diff --git a/crates/eps/src/tests.rs b/crates/eps/src/tests.rs index e9d6f79521..8547c4d015 100644 --- a/crates/eps/src/tests.rs +++ b/crates/eps/src/tests.rs @@ -532,6 +532,66 @@ fn a_gradient_mixing_a_spot_ink_with_rgb_is_written_without_the_ink() { assert!(!out.warnings.iter().any(|w| w.contains("spot")), "{:?}", out.warnings); } +#[test] +fn gradients_name_only_the_spot_inks_of_stops_that_color_a_stretch() { + let black = |offset: f32| GradientStop::new(offset, Color::cmyk(0.0, 0.0, 0.0, 1.0)); + let paper = |offset: f32| GradientStop::new(offset, Color::cmyk(0.0, 0.0, 0.0, 0.0)); + let no_spot_space = |ps: &str| !ps.contains("(Gold Ink) cvn") && !ps.contains("/DeviceN") && !ps.contains("/Separation"); + for level in [Level::Two, Level::Three] { + // Gold Ink out of order: the stops at 0 and 0.8 cover the stretches next to it, so it + // colors nothing and has no plate. + let d = spot_gradient_doc(vec![black(0.0), black(0.8), spot_stop(0.2, "Gold Ink", GOLD, 1.0), black(0.4), black(1.0)]); + let out = export(&d, &EpsOptions { level, ..opts(&d) }, None, None).unwrap(); + let ps = text(&out); + assert_eq!(dsc(&ps, "DocumentCustomColors"), None, "{level:?}: {ps}"); + assert!(no_spot_space(&ps), "{level:?}: {ps}"); + assert!(!out.warnings.iter().any(|w| w.contains("spot")), "{level:?}: {:?}", out.warnings); + checked_page(&ps); + // Without it, Leaf Ink's tints over paper are a Separation shading. + let d = spot_gradient_doc(vec![ + spot_stop(0.0, "Leaf Ink", LEAF, 1.0), + spot_stop(0.8, "Leaf Ink", LEAF, 0.5), + spot_stop(0.2, "Gold Ink", GOLD, 1.0), + paper(0.4), + paper(1.0), + ]); + let ps = text(&export(&d, &EpsOptions { level, ..opts(&d) }, None, None).unwrap()); + assert_eq!(dsc(&ps, "DocumentCustomColors").as_deref(), Some("(Leaf Ink)"), "{level:?}: {ps}"); + assert!(ps.contains("/VCsp0 [/Separation (Leaf Ink) cvn /DeviceCMYK") && !ps.contains("(Gold Ink) cvn"), "{level:?}: {ps}"); + checked_page(&ps); + // An RGB stop out of order colors nothing either, so it keeps no ink out. + let d = spot_gradient_doc(vec![ + spot_stop(0.0, "Gold Ink", GOLD, 1.0), + spot_stop(0.8, "Gold Ink", GOLD, 0.5), + GradientStop::new(0.2, Color::rgb(0.0, 1.0, 0.0)), + paper(0.4), + paper(1.0), + ]); + let out = export(&d, &EpsOptions { level, ..opts(&d) }, None, None).unwrap(); + let ps = text(&out); + assert!(ps.contains("/VCsp0 [/Separation (Gold Ink) cvn /DeviceCMYK"), "{level:?}: {ps}"); + assert!(!out.warnings.iter().any(|w| w.contains("spot")), "{level:?}: {:?}", out.warnings); + // Gold Ink at a tint of 0 prints no ink. + let d = spot_gradient_doc(vec![spot_stop(0.0, "Gold Ink", GOLD, 0.0), black(1.0)]); + let ps = text(&export(&d, &EpsOptions { level, ..opts(&d) }, None, None).unwrap()); + assert_eq!(dsc(&ps, "DocumentCustomColors"), None, "{level:?}: {ps}"); + assert!(no_spot_space(&ps), "{level:?}: {ps}"); + } + // Gold Ink at a tint of 0 over a 30% cyan plate (a DeviceN gradient read from a PDF) keeps + // its process plate in the same space. + let plated = GradientStop { plates: Some([0.3, 0.0, 0.0, 0.0]), ..spot_stop(1.0, "Gold Ink", GOLD, 0.0) }; + let d = spot_gradient_doc(vec![GradientStop::new(0.0, Color::cmyk(0.3, 0.0, 0.0, 0.0)), plated]); + let ps = text(&export(&d, &opts(&d), None, None).unwrap()); + assert!(ps.contains("/VCdn0 [/DeviceN [/Cyan (Gold Ink) cvn ] /DeviceCMYK") && checked_page(&ps).contains("/C0 [0.3 0] /C1 [0.3 0]"), "{ps}"); + // EPS leaves stop opacity out, so a clear Gold Ink stop between clear stops is written opaque + // and keeps its plate. + let clear = |s: GradientStop| GradientStop { opacity: 0.0, ..s }; + let d = spot_gradient_doc(vec![black(0.0), clear(black(0.2)), clear(spot_stop(0.4, "Gold Ink", GOLD, 1.0)), clear(black(0.6)), black(1.0)]); + let ps = text(&export(&d, &opts(&d), None, None).unwrap()); + assert_eq!(dsc(&ps, "DocumentCustomColors").as_deref(), Some("(Gold Ink)"), "{ps}"); + assert!(ps.contains("/VCdn0 [/DeviceN [/Black (Gold Ink) cvn ] /DeviceCMYK"), "{ps}"); +} + #[test] fn spot_inks_named_all_or_none_are_written_under_names_of_their_own() { let rect = |d: &mut Document, fill: &str, stroke: &str| { diff --git a/crates/pdf/src/export/paint.rs b/crates/pdf/src/export/paint.rs index 77815f93b3..6baffa48a8 100644 --- a/crates/pdf/src/export/paint.rs +++ b/crates/pdf/src/export/paint.rs @@ -90,16 +90,20 @@ impl Exporter<'_> { /// The stops of a gradient whose every stop is a tint of one spot ink (or paper white, 0% of /// it) as tints of that ink — a Separation shading — with midpoints as explicit stops (the /// tint and opacity there are halfway). A gradient that mixes a spot ink with other colors - /// gets [`Self::device_n_stops`]. `None` for gradients without a spot ink. + /// gets [`Self::device_n_stops`]. `None` for gradients without a spot ink that prints + /// ([`Self::printed_spot`]). fn spot_stops(&mut self, g: &vectorcraft_color::Gradient) -> Option<Vec<(f32, krilla::color::Color, f32)>> { - let ink = g.stops.iter().find_map(|s| s.swatch.as_deref().filter(|n| self.doc.swatch(n).is_some_and(|w| w.spot)))?; + let drawn = g.drawn_stops(); + let ink = g.stops.iter().zip(&drawn).find_map(|(s, &d)| self.printed_spot(s, d))?; let tints: Option<Vec<f32>> = g .stops .iter() - .map(|s| match s.swatch.as_deref() { + .zip(&drawn) + .map(|(s, &d)| match s.swatch.as_deref() { + _ if !d => Some(0.0), // A stop that also prints process plates needs a DeviceN space. Some(n) if n == ink && s.plates.is_none() => Some(s.tint), - _ if self.paper_stop(s) => Some(0.0), + _ if self.inkless_stop(s) => Some(0.0), _ => None, }) .collect(); @@ -126,19 +130,22 @@ impl Exporter<'_> { /// the order the stops name them), with midpoints as explicit stops (the tints and opacity /// there are halfway), or for a Perceptual gradient the stops on its curve /// ([`vectorcraft_color::Gradient::ink_mixes`]). Paper white adds no ink; a spot stop with - /// process plates ([`vectorcraft_color::GradientStop::plates`]) prints them too. `None`, with a - /// warning, when a stop is written in RGB or Lab or the spot inks can't share a DeviceN space; - /// the gradient is then written in the colors of its stops. + /// process plates ([`vectorcraft_color::GradientStop::plates`]) prints them too. Only the stops + /// that color something that draws ([`vectorcraft_color::Gradient::drawn_stops`]) name inks: + /// the others are written with no ink. `None`, with a warning, when a stop is written in RGB or + /// Lab or the spot inks can't share a DeviceN space; the gradient is then written in the colors + /// of its stops. fn device_n_stops(&mut self, g: &vectorcraft_color::Gradient) -> Option<Vec<(f32, krilla::color::Color, f32)>> { use krilla::color::device_n::{Color as DnColor, Colorant, DeviceNSpace, Process}; let doc = self.doc; fn spot_of<'s>(doc: &vectorcraft_doc::Document, s: &'s vectorcraft_color::GradientStop) -> Option<&'s str> { s.swatch.as_deref().filter(|n| doc.swatch(n).is_some_and(|w| w.spot)) } + let drawn = g.drawn_stops(); // Each spot ink: its swatch's name, then its colorant name and CMYK equivalent. let mut spots: Vec<(&str, (String, [f32; 4]))> = Vec::new(); - for s in &g.stops { - if let Some(n) = spot_of(doc, s) + for (s, &d) in g.stops.iter().zip(&drawn) { + if let Some(n) = self.printed_spot(s, d) && !spots.iter().any(|(m, _)| *m == n) { spots.push((n, self.spot_ink(n)?)); @@ -146,12 +153,15 @@ impl Exporter<'_> { } // Each stop's ink coverage: the four process inks, then one tint per spot ink. let mut inks: Vec<Vec<f32>> = Vec::with_capacity(g.stops.len()); - for s in &g.stops { + for (s, &d) in g.stops.iter().zip(&drawn) { let mut v = vec![0.0; 4 + spots.len()]; match spot_of(doc, s) { + _ if !d => {} Some(n) => { - let i = spots.iter().position(|(m, _)| *m == n)?; - v[4 + i] = s.tint; + // A spot ink that no drawn stop prints ([`Self::printed_spot`]) has no colorant. + if let Some(i) = spots.iter().position(|(m, _)| *m == n) { + v[4 + i] = s.tint; + } if let Some(p) = s.plates { v[..4].copy_from_slice(&p.map(|t| t.clamp(0.0, 1.0))); } @@ -434,18 +444,38 @@ impl Exporter<'_> { !s.swatch.as_deref().is_some_and(|n| self.doc.swatch(n).is_some_and(|w| w.spot)) && paper(&s.color) } - /// The spot swatch whose tints are every stop of `g` that isn't paper white - /// ([`Self::paper_stop`]); `None` when no stop is linked to a spot swatch or a stop has - /// another color. - fn one_spot_ink<'g>(&self, g: &'g vectorcraft_color::Gradient) -> Option<&'g str> { - let spot = |s: &'g vectorcraft_color::GradientStop| s.swatch.as_deref().filter(|n| self.doc.swatch(n).is_some_and(|w| w.spot)); - let ink = g.stops.iter().find_map(spot)?; - g.stops.iter().all(|s| (spot(s) == Some(ink) && s.plates.is_none()) || self.paper_stop(s)).then_some(ink) + /// The spot swatch stop `s` prints: the one it is linked to, when the stop colors something + /// that draws (`drawn`, [`vectorcraft_color::Gradient::drawn_stops`]) at a tint above 0 or + /// with process plates ([`vectorcraft_color::GradientStop::plates`]), which print in the same + /// DeviceN space. + fn printed_spot<'s>(&self, s: &'s vectorcraft_color::GradientStop, drawn: bool) -> Option<&'s str> { + s.swatch.as_deref().filter(|n| drawn && (s.tint > 0.0 || s.plates.is_some()) && self.doc.swatch(n).is_some_and(|w| w.spot)) } - /// Can every stop of `g` be inks of a DeviceN space ([`Self::device_n_stops`]): is a stop - /// linked to a spot swatch, and is every other stop paper white ([`Self::paper_stop`]) or - /// written in CMYK or gray? + /// Does stop `s` add no ink to a Separation or DeviceN shading: is it paper white + /// ([`Self::paper_stop`]) or linked to a spot swatch at a tint of 0 without process plates? + fn inkless_stop(&self, s: &vectorcraft_color::GradientStop) -> bool { + let spot = s.swatch.as_deref().is_some_and(|n| self.doc.swatch(n).is_some_and(|w| w.spot)); + self.paper_stop(s) || (spot && self.printed_spot(s, true).is_none()) + } + + /// The spot swatch whose tints are every stop of `g` that colors something that draws + /// ([`vectorcraft_color::Gradient::drawn_stops`]) and adds ink ([`Self::inkless_stop`]); `None` + /// when no such stop prints a spot swatch ([`Self::printed_spot`]) or one has another color. + fn one_spot_ink<'g>(&self, g: &'g vectorcraft_color::Gradient) -> Option<&'g str> { + let drawn = g.drawn_stops(); + let ink = g.stops.iter().zip(&drawn).find_map(|(s, &d)| self.printed_spot(s, d))?; + g.stops + .iter() + .zip(&drawn) + .all(|(s, &d)| !d || (s.swatch.as_deref() == Some(ink) && s.plates.is_none()) || self.inkless_stop(s)) + .then_some(ink) + } + + /// Can every stop of `g` be inks of a DeviceN space ([`Self::device_n_stops`]): does a stop + /// print a spot swatch ([`Self::printed_spot`]), and is every other stop that colors something + /// that draws linked to a spot swatch, paper white ([`Self::paper_stop`]) or written in CMYK or + /// gray? fn device_n_inks_only(&self, g: &vectorcraft_color::Gradient) -> bool { let doc = self.doc; let cmyk_doc = doc.color_mode == vectorcraft_doc::ColorMode::Cmyk; @@ -453,7 +483,9 @@ impl Exporter<'_> { let inks = |s: &vectorcraft_color::GradientStop| { self.paper_stop(s) || matches!(self.out.color(&s.color, self.intent, cmyk_doc, self.convert), Color::Cmyk { .. } | Color::Gray { .. }) }; - g.stops.iter().any(spot) && g.stops.iter().all(|s| spot(s) || inks(s)) + let drawn = g.drawn_stops(); + let mut stops = g.stops.iter().zip(&drawn); + stops.clone().any(|(s, &d)| self.printed_spot(s, d).is_some()) && stops.all(|(s, &d)| !d || spot(s) || inks(s)) } /// Is `g` a Perceptual linear or radial gradient of spot inks, alone or mixed with process @@ -485,16 +517,20 @@ impl Exporter<'_> { let doc = self.doc; let full = doc.linked_color(doc.swatch(ink)?.paint.color()?, true); let space = self.separation(ink)?; - // The stops keep their own tints; paper white is 0% of the ink. - let own: Vec<f32> = g.stops.iter().map(|s| if s.swatch.as_deref() == Some(ink) { s.tint } else { 0.0 }).collect(); + // The stops keep their own tints; paper white, and a stop that colors nothing that draws, + // is 0% of the ink. + let own: Vec<f32> = + g.stops.iter().zip(g.drawn_stops()).map(|(s, d)| if d && s.swatch.as_deref() == Some(ink) { s.tint } else { 0.0 }).collect(); Some(g.ink_tints(&full, &own)?.into_iter().map(|(o, t, a)| (o, SepColor::new_f32(t, space.clone()).into(), a)).collect()) } - /// Warn when gradient `g`, drawn as an image, has stops linked to a spot swatch: the image is - /// in process colors, so the spot inks have no plate of their own. + /// Warn when gradient `g`, drawn as an image, has stops that print a spot swatch + /// ([`Self::printed_spot`]): the image is in process colors, so the spot inks have no plate of + /// their own. fn warn_spot_image(&mut self, g: &vectorcraft_color::GradientPaint) { let from_stops = g.gradient.kind != GradientKind::Freeform || !g.has_freeform_points(); - if from_stops && self.has_spot_stop(&g.gradient) { + let prints_spot = || g.gradient.stops.iter().zip(g.gradient.drawn_stops()).any(|(s, d)| self.printed_spot(s, d).is_some()); + if from_stops && prints_spot() { self.warn( "spot colors in gradients exported as images (freeform or dithered gradients, ones mixed around the hue wheel, and Perceptual ones with RGB or Lab stops or too many stops) are written in process colors", ); diff --git a/crates/pdf/src/tests/output.rs b/crates/pdf/src/tests/output.rs index 0ab4d58c18..a15c2aa429 100644 --- a/crates/pdf/src/tests/output.rs +++ b/crates/pdf/src/tests/output.rs @@ -278,6 +278,60 @@ fn spot_gradients_keep_a_trace_of_process_ink_at_a_light_stop() { } } +/// [`gold_gradient_pdf`] with spot swatch "Leaf" (C100 Y100) in the document too. +fn gold_and_leaf_gradient_pdf(stops: Vec<GradientStop>, perceptual: bool) -> String { + let mut d = doc(ColorMode::Cmyk, &[]); + d.swatches.push(Swatch { name: "Gold".into(), paint: Paint::solid(Color::cmyk(0.0, 0.2, 0.8, 0.1)), global: true, spot: true }); + d.swatches.push(Swatch { name: "Leaf".into(), paint: Paint::solid(Color::cmyk(1.0, 0.0, 1.0, 0.0)), global: true, spot: true }); + let mut g = Gradient::new(GradientKind::Linear, stops); + if perceptual { + g.method = GradientMethod::Perceptual; + } + let paint = Paint::Gradient(Box::new(GradientPaint::new(g))); + let l = d.layers[0].id; + let n = Node::path(d.alloc_id(), shapes::rectangle(Rect::new(10.0, 10.0, 110.0, 30.0)), Appearance::basic(paint, Paint::None, 0.0)); + d.insert(Some(l), 0, n).unwrap(); + String::from_utf8_lossy(&export(&d, &PdfOptions::uncompressed()).unwrap()).into_owned() +} + +#[test] +fn gradients_name_only_the_spot_inks_of_stops_that_color_what_draws() { + let black = |offset: f32, opacity: f32| GradientStop { opacity, ..GradientStop::new(offset, Color::cmyk(0.0, 0.0, 0.0, 1.0)) }; + let paper = |offset: f32| GradientStop::new(offset, Color::cmyk(0.0, 0.0, 0.0, 0.0)); + let leaf = |offset: f32, tint: f32| { + let mut s = GradientStop::new(offset, Color::cmyk(1.0, 0.0, 1.0, 0.0).tinted(tint)); + s.swatch = Some("Leaf".into()); + s.tint = tint; + s + }; + let clear_gold = GradientStop { opacity: 0.0, ..gold_stop(0.4, 1.0) }; + for perceptual in [false, true] { + // Gold in a stretch where every stop is clear, and Gold out of order, where the stops at 0 + // and 0.8 cover the stretches next to it: Gold colors nothing, so no Gold plate. + let clear = vec![black(0.0, 1.0), black(0.2, 0.0), clear_gold.clone(), black(0.6, 0.0), black(1.0, 1.0)]; + let out_of_order = vec![black(0.0, 1.0), black(0.8, 1.0), gold_stop(0.2, 1.0), black(0.4, 1.0), black(1.0, 1.0)]; + // Gold at a tint of 0 prints no Gold ink. + let no_tint = vec![gold_stop(0.0, 0.0), black(1.0, 1.0)]; + for (what, stops) in [("clear", clear), ("out of order", out_of_order), ("tint 0", no_tint)] { + let text = gold_gradient_pdf(stops, perceptual); + assert!(!text.contains("/Gold"), "{what}, perceptual {perceptual}: {text}"); + assert!(!text.contains("/DeviceN") && !text.contains("/Separation"), "{what}, perceptual {perceptual}: {text}"); + } + // Without the Gold stop out of order, Leaf's tints over paper are a Separation shading. + let leaf_only = vec![leaf(0.0, 1.0), leaf(0.8, 0.5), gold_stop(0.2, 1.0), paper(0.4), paper(1.0)]; + let text = gold_and_leaf_gradient_pdf(leaf_only, perceptual); + assert!(text.contains("[/Separation/Leaf/") && !text.contains("/Gold") && !text.contains("/DeviceN"), "perceptual {perceptual}: {text}"); + // A clear Gold stop next to an opaque one colors the stretch between them. + let text = gold_gradient_pdf(vec![black(0.0, 1.0), clear_gold.clone(), black(1.0, 1.0)], perceptual); + assert!(text.contains("[/DeviceN[/Black/Gold]"), "perceptual {perceptual}: {text}"); + } + // Gold at a tint of 0 over a 30% cyan plate (a DeviceN gradient read from a PDF) keeps its + // process plate in the same space. + let plated = GradientStop { plates: Some([0.3, 0.0, 0.0, 0.0]), ..gold_stop(1.0, 0.0) }; + let text = gold_gradient_pdf(vec![GradientStop::new(0.0, Color::cmyk(0.3, 0.0, 0.0, 0.0)), plated], false); + assert!(text.contains("[/DeviceN[/Cyan/Gold]"), "{text}"); +} + #[test] fn converting_to_rgb_turns_cmyk_into_rg() { let ink = Color::cmyk(0.0, 1.0, 1.0, 0.0); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..fb208f37aa 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1636,6 +1636,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A PDF, or a `.ai` read through its PDF part, whose spot inks have the same values but different names opens with a spot swatch for each ink. The solid fills and strokes of paths and type, and the stops of gradients on paths, link to the swatch of the ink they are painted in, the points of a gradient mesh in one of these inks keep the ink's color, and PDF export writes each of these inks as its own separation (`pdf/src/tests/import_color.rs`). Paint in these inks inside pattern cells, soft masks and type 3 glyphs, and gradients on type in these inks, still import as RGB. Type in one of these inks can also import as RGB when type in another Separation or DeviceN ink is shown with no path drawn between them. The stops of an axial or radial shading in a DeviceN space that mixes one spot ink with process plates (a spot ink over a constant cyan, for example) link to the ink's swatch at its tint and keep the process plates, and PDF and EPS (Level 3) export write those stops in a DeviceN space of the ink and those plates, so the spot plate is not lost (#3235, `import_color::a_device_n_gradient_of_a_spot_ink_over_a_process_plate_keeps_both_inks`). Solid fills that mix a spot ink with process plates, and stops that mix several spot inks, still import as RGB, with the spot inks kept as swatches. A `.ai` or EPS opened from its editing data keeps both swatches when a pattern's name, or a named color's, is also another swatch's: a pattern's swatch named as a default swatch, a named color or a palette color becomes "Name 2", and a named color named as a gradient or pattern swatch of the palette becomes "Name 2", with the fills, strokes and gradient stops linked to it following it (`ai::tests::a_pattern_swatch_named_as_another_swatch_is_numbered`, `ai::tests::a_color_named_as_a_palette_gradient_or_pattern_is_numbered`). PDF export writes a linear or radial gradient that mixes a spot color with process colors, or two spot colors, as a DeviceN shading of the spot inks and the process inks its stops use, so each spot ink prints on its own plate; an off-center midpoint is written as a stop with the inks halfway between its two stops. A gradient that mixes a spot color with RGB or Lab colors is still written without the spot ink, with a warning. A CMYK document, or an export that converts colors to a CMYK destination profile, writes RGB and Lab stops in CMYK first (unless the export converts colors to an RGB destination profile), so there such a gradient, Classic or Perceptual, is written as a DeviceN shading that keeps the spot ink. A Perceptual gradient of spot inks is written as a Separation or DeviceN shading of the stops on its curve; a dithered gradient fill, and a Perceptual gradient with RGB or Lab stops other than white or more than 4,096 stops on its curve, are written as images in process colors, with a warning. A Lab spot color in such a shading is named by the same Separation space, with the Lab alternate, as its flat fills (`engine/src/tests/linked_stops.rs`, `engine/src/tests/labspots.rs`). + PDF and EPS export name a spot ink in a gradient's Separation or DeviceN space, and EPS in `%%DocumentCustomColors`, only when a stop linked to it at a tint above 0, or with process plates, colors part of the gradient (VectorCraft's own rule): a stop out of order whose neighboring stretches have no width, and in PDF a stop whose stretches are fully transparent, adds no ink and no empty plate. EPS writes every stop opaque, so there a transparent spot stop keeps its ink (`crates/pdf/src/tests/output.rs`, `crates/eps/src/tests.rs`). PDF export writes a spot color named All or None (in a Separation space, the names of every plate and of no plate: [ISO 32000-1:2008](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf), 8.6.6.4) as the ink All Spot or None Spot (All Spot 2 and on when a spot swatch already has that name) in its fills, strokes, gradients, colorized images and Lab alternates; Registration still prints on every plate (`pdf/src/tests/output.rs`). - `.vectorcraft` (lossless JSON, compressed, atomic saves, save down to v1), Save As with a format chooser, Save a Copy, Revert, templates, Data Recovery after a crash (browser tabs hold their copies with Web Locks too, so a background tab's copies are never taken for a crash's, and a tab repairs copies another removed when it resumes: #367), background save and export. The desktop app writes its warnings and errors (graphics adapter, a lost graphics device, panics the guard recovered from) to standard error and to `logs/vectorcraft.log` next to the preferences, the two previous runs kept and each file capped at 16 MiB, so a launch without a terminal still leaves something to attach to a bug report (#465). Native documents with a lot of path data (traced or generated art, in layers, symbols or patterns) are saved as compact JSON, about a fifth of the size; small documents stay pretty-printed (#1492). Saving to a network drive on macOS falls back to a plain fsync when the share refuses a full flush (#1625, part of #1620; not confirmed on a real share), and a save still succeeds when a folder refuses the temporary file, the rename over the document or copying permissions: the content is written elsewhere first and copied in, and a failed copy keeps the temporary file and names it (#1649, part of #1620). A document opened by a relative path finds its relatively linked images, and `vectorcraft-cli convert` lists what reading the input left out as `importWarnings` (#1606, fixes #1604). Preferences › File Handling › Data Recovery › Folder has a Choose… button on the desktop that picks the folder Data Recovery keeps its copies in ([Illustrator reference, Set Data Recovery preferences](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf)); a picked folder that Data Recovery cannot create its folders in or list is refused with a status message, and the field keeps its value. OK applies the same check to a folder typed into the field (VectorCraft's own rule): when it fails, the dialog stays open, the status bar says why and no preference changes; an empty field (the default folder) and the folder already saved are not checked. Preferences › Plug-ins & Scratch Disks is where additional plug-ins folders are set ([Illustrator preferences help](https://helpx.adobe.com/illustrator/desktop/get-started/preferences-and-settings/set-app-preferences.html)); its Additional Plug-ins Folder has a Choose… button on the desktop as well, VectorCraft's own, matching Data Recovery's, and VectorCraft's own rule refuses a picked or typed folder whose contents can't be listed. Additional Fonts Folder and Templates Folder stay typed only. From 3a6b016253cc3910c12824fdfb942753c1999bec Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:25:55 -0800 Subject: [PATCH 096/108] Blend: steps between gradients linked to the same spot swatch keep its process plates A blend between two gradients whose matching stops are tints of one spot swatch kept the link and interpolated the tint, but every step's stop lost the process inks (C, M, Y, K) printed with the spot ink, so PDF export wrote the steps as the spot ink alone. - Matching stops linked to one swatch interpolate each process ink with the tint; a stop without process inks counts as none of each, and the ends keep their own. - Gradients with different stop counts keep the inks at every resampled stop, interpolated with the midpoint-adjusted fraction between two stops of one swatch. - A solid blended with a gradient brings no process inks of its own: its stand-in gradient no longer copies the other gradient's. Stops of different swatches, or linked and unlinked stops, still blend into unlinked process colors without plates. --- crates/doc/src/blend.rs | 157 +++++++++++++++++++++++++++++---- crates/pdf/src/tests/output.rs | 30 +++++++ docs/target-app-parity.md | 1 + 3 files changed, 173 insertions(+), 15 deletions(-) diff --git a/crates/doc/src/blend.rs b/crates/doc/src/blend.rs index b84de1cac3..f36993a18c 100644 --- a/crates/doc/src/blend.rs +++ b/crates/doc/src/blend.rs @@ -45,7 +45,24 @@ fn lerp_f64(x: f64, y: f64, t: f64) -> f64 { x + (y - x) * t } -/// `like` with every stop painting `c`, linked as the solid is (`swatch` at `tint`). +/// The process plates between two stops linked to one spot swatch: each of C, M, Y and K in turn, +/// a stop without plates counting as none of each. The ends keep their own plates. +fn lerp_plates(a: Option<[f32; 4]>, b: Option<[f32; 4]>, t: f32) -> Option<[f32; 4]> { + if t <= 0.0 { + return a; + } + if t >= 1.0 { + return b; + } + if a.is_none() && b.is_none() { + return None; + } + let (a, b) = (a.unwrap_or_default(), b.unwrap_or_default()); + Some(std::array::from_fn(|i| lerp_f32(a[i], b[i], t))) +} + +/// `like` with every stop painting `c`, linked as the solid is (`swatch` at `tint`), with no +/// process plates (a solid has none). fn solid_gradient(c: Color, swatch: Option<&str>, tint: f32, like: &Gradient) -> Gradient { let mut g = like.clone(); for s in &mut g.stops { @@ -53,16 +70,18 @@ fn solid_gradient(c: Color, swatch: Option<&str>, tint: f32, like: &Gradient) -> s.opacity = 1.0; s.swatch = swatch.map(str::to_string); s.tint = tint; + s.plates = None; } g } -/// The swatch and tint `g` paints at `t`: a stop's own link, or the shared swatch of the two stops -/// around `t` at the tint between theirs (unlinked when they differ), as [`Gradient::sample_with`] walks. -fn link_at(g: &Gradient, t: f32) -> (Option<String>, f32) { +/// The swatch, tint and process plates `g` paints at `t`: a stop's own link, or the shared swatch +/// of the two stops around `t` at the tint and plates between theirs (unlinked when they differ), +/// as [`Gradient::sample_with`] walks. +fn link_at(g: &Gradient, t: f32) -> (Option<String>, f32, Option<[f32; 4]>) { let stops = &g.stops; - let link = |s: &GradientStop| (s.swatch.clone(), s.tint); - let Some(first) = stops.first() else { return (None, 1.0) }; + let link = |s: &GradientStop| (s.swatch.clone(), s.tint, s.plates); + let Some(first) = stops.first() else { return (None, 1.0, None) }; if t <= first.offset { return link(first); } @@ -74,14 +93,14 @@ fn link_at(g: &Gradient, t: f32) -> (Option<String>, f32) { let m = a.midpoint.clamp(0.01, 0.99); let v = if u < m { 0.5 * u / m } else { 0.5 + 0.5 * (u - m) / (1.0 - m) }; return match (&a.swatch, &b.swatch) { - (Some(x), Some(y)) if x == y => (Some(x.clone()), lerp_f32(a.tint, b.tint, v)), _ if v <= 0.0 => link(a), _ if v >= 1.0 => link(b), - _ => (None, 1.0), + (Some(x), Some(y)) if x == y => (Some(x.clone()), lerp_f32(a.tint, b.tint, v), lerp_plates(a.plates, b.plates, v)), + _ => (None, 1.0, None), }; } } - stops.last().map_or((None, 1.0), link) + stops.last().map_or((None, 1.0, None), link) } /// `g` with its stops at `offsets`, each painting what `g` paints there (midpoints centred). @@ -91,8 +110,8 @@ fn resample_stops(g: &Gradient, offsets: &[f32]) -> Gradient { .iter() .map(|&o| { let (color, opacity) = g.sample_keep_model(o); - let (swatch, tint) = link_at(g, o); - GradientStop { opacity, swatch, tint, ..GradientStop::new(o, color) } + let (swatch, tint, plates) = link_at(g, o); + GradientStop { opacity, swatch, tint, plates, ..GradientStop::new(o, color) } }) .collect(); out @@ -139,16 +158,18 @@ fn lerp_gradient(a: &GradientPaint, b: &GradientPaint, t: f32) -> Option<Gradien .iter() .zip(&gb.stops) .map(|(sa, sb)| { - // Stops on two tints of one swatch stay linked to it, as solids do (#3234). - let (swatch, tint) = match (&sa.swatch, &sb.swatch) { - (Some(x), Some(y)) if x == y => (Some(x.clone()), lerp_f32(sa.tint, sb.tint, t)), - _ => (None, 1.0), + // Stops on two tints of one swatch stay linked to it, as solids do (#3234), and keep + // the process plates printed with it. + let (swatch, tint, plates) = match (&sa.swatch, &sb.swatch) { + (Some(x), Some(y)) if x == y => (Some(x.clone()), lerp_f32(sa.tint, sb.tint, t), lerp_plates(sa.plates, sb.plates, t)), + _ => (None, 1.0, None), }; GradientStop { opacity: lerp_f32(sa.opacity, sb.opacity, t), midpoint: lerp_f32(sa.midpoint, sb.midpoint, t), swatch, tint, + plates, ..GradientStop::new(lerp_f32(sa.offset, sb.offset, t), lerp_color(&sa.color, &sb.color, t)) } }) @@ -2462,6 +2483,112 @@ mod tests { assert!(m.gradient.stops.iter().any(|s| s.swatch.is_none()), "{:?}", m.gradient.stops); } + /// A stop linked to the spot swatch "Spot" at `tint`, printed with process `plates`. + fn spot_stop(offset: f32, tint: f32, plates: Option<[f32; 4]>) -> GradientStop { + let mut stop = GradientStop::new(offset, Color::cmyk(1.0, 0.7, 0.0, 0.4).tinted(tint)); + stop.swatch = Some("Spot".into()); + stop.tint = tint; + stop.plates = plates; + stop + } + + fn gradient_paint(stops: Vec<GradientStop>) -> Paint { + Paint::Gradient(Box::new(GradientPaint::new(Gradient { stops, ..Gradient::default() }))) + } + + fn assert_plates(got: Option<[f32; 4]>, want: [f32; 4]) { + let got = got.unwrap_or_else(|| panic!("plates {want:?}, not none")); + assert!(got.iter().zip(&want).all(|(g, w)| (g - w).abs() < 1e-5), "{got:?} != {want:?}"); + } + + #[test] + fn blend_gradient_spot_process_plates_interpolate() { + let (p, q) = ([0.2, 0.4, 0.0, 0.0], [0.6, 0.0, 0.8, 1.0]); + let a = gradient_paint(vec![spot_stop(0.0, 0.2, Some(p)), spot_stop(1.0, 0.2, Some(p))]); + let b = gradient_paint(vec![spot_stop(0.0, 1.0, Some(q)), spot_stop(1.0, 1.0, Some(q))]); + let Paint::Gradient(m) = lerp_paint(&a, &b, 0.25) else { panic!() }; + for s in &m.gradient.stops { + assert_eq!(s.swatch.as_deref(), Some("Spot")); + assert!((s.tint - 0.4).abs() < 1e-6, "{}", s.tint); + assert_plates(s.plates, [0.3, 0.3, 0.2, 0.25]); + } + // Without plates on either side the steps print the spot ink alone, as before. + let bare = |tint| gradient_paint(vec![spot_stop(0.0, tint, None), spot_stop(1.0, tint, None)]); + let Paint::Gradient(m) = lerp_paint(&bare(0.2), &bare(1.0), 0.5) else { panic!() }; + assert!(m.gradient.stops.iter().all(|s| s.plates.is_none()), "{:?}", m.gradient.stops); + } + + #[test] + fn resampled_gradient_spot_process_plates_interpolate() { + let (p, q, r) = ([0.0, 0.4, 0.0, 0.0], [0.6, 0.4, 0.3, 0.0], [0.2, 0.2, 0.2, 0.2]); + let mut first = spot_stop(0.0, 0.2, Some(p)); + first.midpoint = 0.25; + let two = Gradient { stops: vec![first, spot_stop(1.0, 0.8, Some(q))], ..Gradient::default() }; + let three = + Gradient { stops: vec![spot_stop(0.0, 1.0, Some(r)), spot_stop(0.5, 1.0, Some(r)), spot_stop(1.0, 1.0, Some(r))], ..Gradient::default() }; + let Some((ra, rb)) = common_stops(&two, &three) else { panic!() }; + let offsets: Vec<f32> = ra.stops.iter().map(|s| s.offset).collect(); + assert_eq!(offsets, [0.0, 0.25, 0.5, 1.0]); + // The original stops keep their plates; between them, the midpoint at 0.25 puts 0.5 two + // thirds of the way along the inks. + assert_eq!((ra.stops[0].plates, ra.stops[3].plates), (Some(p), Some(q))); + assert_plates(ra.stops[1].plates, [0.3, 0.4, 0.15, 0.0]); + assert_plates(ra.stops[2].plates, [0.4, 0.4, 0.2, 0.0]); + assert!((ra.stops[2].tint - 0.6).abs() < 1e-5, "{}", ra.stops[2].tint); + assert!(rb.stops.iter().all(|s| s.plates == Some(r)), "{:?}", rb.stops); + + let Paint::Gradient(m) = lerp_paint(&gradient_paint(two.stops), &gradient_paint(three.stops), 0.5) else { panic!() }; + assert_eq!(m.gradient.stops.len(), 4); + assert!(m.gradient.stops.iter().all(|s| s.swatch.as_deref() == Some("Spot")), "{:?}", m.gradient.stops); + assert_plates(m.gradient.stops[2].plates, [0.3, 0.3, 0.2, 0.1]); + } + + #[test] + fn blend_gradient_missing_plates_mean_zero() { + let p = [0.4, 0.8, 0.0, 0.2]; + let with = gradient_paint(vec![spot_stop(0.0, 1.0, Some(p)), spot_stop(1.0, 1.0, Some(p))]); + let without = gradient_paint(vec![spot_stop(0.0, 1.0, None), spot_stop(1.0, 1.0, None)]); + let Paint::Gradient(m) = lerp_paint(&without, &with, 0.25) else { panic!() }; + assert!(m.gradient.stops.iter().all(|s| s.swatch.as_deref() == Some("Spot")), "{:?}", m.gradient.stops); + m.gradient.stops.iter().for_each(|s| assert_plates(s.plates, [0.1, 0.2, 0.0, 0.05])); + // The ends keep their own plates. + let Paint::Gradient(m) = lerp_paint(&without, &with, 0.0) else { panic!() }; + assert!(m.gradient.stops.iter().all(|s| s.plates.is_none()), "{:?}", m.gradient.stops); + + // Another swatch, or an unlinked stop: process steps with no plates, as before. + let mut other = spot_stop(0.0, 1.0, Some(p)); + other.swatch = Some("Other".into()); + let other = gradient_paint(vec![other.clone(), GradientStop { offset: 1.0, ..other }]); + let mut plain = spot_stop(0.0, 1.0, None); + plain.swatch = None; + let plain = gradient_paint(vec![plain.clone(), GradientStop { offset: 1.0, ..plain }]); + for b in [&other, &plain] { + let Paint::Gradient(m) = lerp_paint(&with, b, 0.5) else { panic!() }; + assert!(m.gradient.stops.iter().all(|s| s.swatch.is_none() && s.plates.is_none()), "{:?}", m.gradient.stops); + } + } + + #[test] + fn blend_solid_to_spot_gradient_does_not_copy_plates() { + let p = [0.4, 0.8, 0.0, 0.2]; + let gradient = gradient_paint(vec![spot_stop(0.0, 1.0, Some(p)), spot_stop(1.0, 1.0, Some(p))]); + let Paint::Gradient(g) = &gradient else { panic!() }; + assert!(solid_gradient(Color::BLACK, Some("Spot"), 0.2, &g.gradient).stops.iter().all(|s| s.plates.is_none())); + let solid = Paint::Solid { color: Color::cmyk(1.0, 0.7, 0.0, 0.4).tinted(0.2), swatch: Some("Spot".into()), tint: 0.2 }; + // The solid's end has no plates: they grow from none toward the gradient's, both ways round. + for (a, b, t) in [(&solid, &gradient, 0.25), (&gradient, &solid, 0.75)] { + let Paint::Gradient(m) = lerp_paint(a, b, t) else { panic!() }; + for s in &m.gradient.stops { + assert_eq!(s.swatch.as_deref(), Some("Spot")); + assert!((s.tint - 0.4).abs() < 1e-6, "{}", s.tint); + assert_plates(s.plates, [0.1, 0.2, 0.0, 0.05]); + } + } + // A process solid unlinks the steps, and they take no plates. + let Paint::Gradient(m) = lerp_paint(&Paint::solid(Color::BLACK), &gradient, 0.5) else { panic!() }; + assert!(m.gradient.stops.iter().all(|s| s.swatch.is_none() && s.plates.is_none()), "{:?}", m.gradient.stops); + } + #[test] fn gradients_with_different_stop_counts_interpolate() { let g = |stops: &[(f32, Color)]| { diff --git a/crates/pdf/src/tests/output.rs b/crates/pdf/src/tests/output.rs index 0ab4d58c18..3a45475c32 100644 --- a/crates/pdf/src/tests/output.rs +++ b/crates/pdf/src/tests/output.rs @@ -161,6 +161,36 @@ fn spot_alternates_and_device_n_gradient_inks_are_written_as_the_document_holds_ assert!(text.contains("/C0[0 0 0.75]/C1[0.75 0.04 0]"), "the stops' C75, K4 and 75% Gold are written as they are"); } +#[test] +fn blend_steps_between_spot_gradients_with_process_plates_print_both_inks() { + let stop = |offset: f32, tint: f32, plates: Option<[f32; 4]>| { + let mut s = GradientStop::new(offset, Color::cmyk(0.0, 0.2, 0.8, 0.1).tinted(tint)); + s.swatch = Some("Gold".into()); + s.tint = tint; + s.plates = plates; + s + }; + let gradient = |tint: f32, plates: Option<[f32; 4]>| { + Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(GradientKind::Linear, vec![stop(0.0, tint, plates), stop(1.0, tint, plates)])))) + }; + let step_pdf = |a: &Paint, b: &Paint| { + let mut d = doc(ColorMode::Cmyk, &[]); + d.swatches.push(Swatch { name: "Gold".into(), paint: Paint::solid(Color::cmyk(0.0, 0.2, 0.8, 0.1)), global: true, spot: true }); + let step = vectorcraft_doc::blend::lerp_paint(a, b, 0.5); + let l = d.layers[0].id; + let n = Node::path(d.alloc_id(), shapes::rectangle(Rect::new(10.0, 10.0, 110.0, 30.0)), Appearance::basic(step, Paint::None, 0.0)); + d.insert(Some(l), 0, n).unwrap(); + String::from_utf8_lossy(&export(&d, &PdfOptions::uncompressed()).unwrap()).into_owned() + }; + // The middle step prints 60% Gold over 30% Cyan, in one DeviceN shading of both inks. + let text = step_pdf(&gradient(0.2, Some([0.2, 0.0, 0.0, 0.0])), &gradient(1.0, Some([0.4, 0.0, 0.0, 0.0]))); + assert!(text.contains("[/DeviceN[/Cyan/Gold]"), "{text}"); + assert!(text.contains("/C0[0.3 0.6]/C1[0.3 0.6]"), "{text}"); + // Without plates the step is a Separation shading of Gold alone. + let text = step_pdf(&gradient(0.2, None), &gradient(1.0, None)); + assert!(!text.contains("/DeviceN") && text.contains("[/Separation/Gold/"), "{text}"); +} + /// A spot swatch's Separation space with alternate C0 M20 Y80 K10 under `colorant` (a PDF name). fn gold_separation(colorant: &str) -> String { format!("[/Separation{colorant}/DeviceCMYK<</FunctionType 2/Domain[0 1]/Range[0 1 0 1 0 1 0 1]/C0[0 0 0 0]/C1[0 0.2 0.8 0.1]/N 1>>]") diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..7172c00bab 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1131,6 +1131,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur View › Hide Edges hides the Live Corners widgets, the bounding box and the type widget, and the selection tools then do not answer a press on them or change the cursor over them. - **Blend spine Anchor Point tool (#2544):** on a selected blend, dragging a spine corner makes symmetric Smooth handles; the tool displays and picks existing spine handles when switched to, drags one independently or retracts it on click, and clicking a point with handles retracts both. The spine is edited live without moving its key objects. Windows native canvas checks and screenshots reviewed: symmetric and independent handles, corner/retraction, Shift constraints and perpendicular reshaping, tool switching, key preservation, Undo/Redo, save/reopen, hidden handles and overlapping Path/Blend priority (PR #2643). Behaviour reference: [public path-editing documentation](https://helpx.adobe.com/illustrator/using/adjust-path-segments.html). - **Blend steps of brushed strokes:** the steps interpolate the pen pressure, tilt, bearing and rotation recorded with the Paintbrush, so a Calligraphic, Scatter or Art brush that varies with the pen changes gradually from one key to the next. A key without a recording counts as half pressure, half tilt and 0°, as brushes read it, and angles turn the shorter way round. When the blend starts a key's path at another anchor (an open path run from its end, a closed one turned to another start), the key's recordings, width profile and arrowheads turn with the path. Different brushes still switch halfway (VectorCraft's own rule; strokes blend their options, as [Blended objects overview](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blended-objects-overview.html) describes; `crates/doc/src/blend.rs`, `pen_pressure_tilt_and_angles_interpolate_for_brushes`, `stroke_profiles_turn_with_a_key_path_started_elsewhere`). + - **Blend steps of spot gradients with process plates:** when the matching stops of two gradients, or of a gradient and a solid, are tints of one spot swatch, each step's stop stays linked to it at a tint between the two and keeps the process inks printed with it, each of C, M, Y and K between the two stops' amounts; a stop or solid without process inks counts as none of each. Gradients with different stop counts keep the inks at every resampled stop. PDF export writes such a step as one DeviceN shading of the spot and process inks. Tints of one spot color blend into tints of it, as [the help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/blended-objects-overview.html) describes; the process-ink interpolation is VectorCraft's own rule (`crates/doc/src/blend.rs`, `blend_gradient_spot_process_plates_interpolate`, `resampled_gradient_spot_process_plates_interpolate`, `blend_gradient_missing_plates_mean_zero`, `blend_solid_to_spot_gradient_does_not_copy_plates`; `crates/pdf/src/tests/output.rs`, `blend_steps_between_spot_gradients_with_process_plates_print_both_inks`). - **Path editing (#494):** the handles shown are the handles that drag: Direct Selection drags those of a path selected as a whole (as the Pen leaves it), the Anchor Point tool and Pen+Alt no longer grab handles that Show handles when multiple anchors are selected hides, a handle shorter than the tolerance leaves its anchor to be picked, and the anchor tools pick within Selection & Anchor Display › Tolerance. A dragged segment keeps a smooth anchor at either end smooth. With Direct Selection, the Pen, the Curvature and the anchor tools, a path selected as a whole shows all its anchors selected, and the Control bar and the Properties panel offer Convert (corner, smooth) for them too; Remove and Cut wait for anchors direct-selected (#504). A handle drag gathers its snap targets once per drag (it took 21 ms per pointer move on a 20,000-path document, now 1 ms; `vectorcraft-cli perf` measures handle and segment drags on a 5,000-anchor path). Join merges the selected anchor points that lie on one another, as after Average, into one anchor (#1582, fixes #1533), and removes the merged anchors in one pass over the path, so a long run of them no longer moves the anchors after it once per merge (`cmd::path::tests::a_long_run_before_many_other_anchors_merges_in_one_pass`); Object › Path › Average & Join… (`path.averageJoin`, Cmd+Alt+Shift+J, the "Create corner or smooth join" shortcut of [Default keyboard shortcuts](https://helpx.adobe.com/illustrator/using/default-keyboard-shortcuts.html)) moves two open path ends to their midpoint and joins them there, a corner or smooth point as its dialog's Points choice asks, in one undo step. - **Graphs:** Column, Stacked Column, Bar, Stacked Bar, Line, Area, Scatter, Pie and Radar graph tools with Graph Data and Graph Type. A series starts in greyscale; Group Selection's fill and stroke, the paint, weight, opacity and blend mode of a mark's top visible fill or stroke row after an Appearance command or a graphic style (each given a mark or its series picked with Group Selection), the Eyedropper, Default Fill and Stroke or Swap Fill and Stroke, the paint or stroke weight a stroke weight, gradient or recolor command changes there, and a mark's object opacity and blend mode, are kept separately on the graph and reapplied when its data, type or size changes, and through save, open and undo; a kept gradient takes the same place on each mark's own box. A series that draws Filled Lines bands keeps no stroke paint or weight: its bands are drawn again with their 0.25 pt black outline. Graph Type's Override Calculated Values (both `axisMin` and `axisMax`) uses exactly that value-axis range, split into the tick count (5 when automatic). Line graphs take Edge-to-Edge Lines (off by default: the points sit at the centres of their categories; graphs saved before the option keep their edge-to-edge lines), and radar graphs follow Mark Data Points and Connect Data Points. Blank cells (an empty CSV cell or `null`) are values left out, not zeros: columns, bars and stacked segments skip them, lines and scatter lines break around them and the value axis ignores them, while area, pie and radar draw them as 0; a number in straight quotes is a label, and the data window writes it back quoted. Graph types combine: Graph Type on series picked with Group Selection (or `series` indexes) draws them as their own type, with column, stacked column, line and area mixing on the vertical value axis and bar and stacked bar on the horizontal one; stacked columns take one slot of the cluster, lines draw in front of columns and areas behind. The value axis goes on the left, the right or both sides (column, stacked column, line, area and scatter graphs; bar graphs keep theirs along the bottom), and Separate Scales gives the series assigned to the right axis a scale of their own with its own tick values. Each value axis takes tick marks of no, short or full (across the plot) length and a count per division, and a prefix and suffix for its numbers; the category axis takes tick marks too (none by default), at or between its labels. Graph designs: Object › Graph › Design lists the designs with a preview of the selected one, and New Design (the selected art), Rename, Delete Design, Paste Design (a copy back to edit) and Select Unused, and Marker draws the data points and legend swatches of line, scatter and radar series with a design, scaled so its backmost object fills the default marker's square. The Appearance, effect and graphic style commands do not edit a design's art inside a series, which the graph draws again from the design. Graph Data transposes rows and columns and switches a scatter graph's x and y, and a `|` in a category or series label starts a new line. Pie graphs take Legends in Wedges, Position (Even, Ratio sized by area, Stacked on one centre) and Sort (None, All, First). Graph Type takes column and cluster widths up to 1000% (overlapping past 100%) with First Row and First Column in Front (First Row orders each series' categories; across series the series order decides, so series stay one group each for Group Selection), draws filled lines, adds drop shadows behind columns, bars, lines and wedges, and puts the legend in rows across the top. Text formatted with the Character, Paragraph, Appearance, Transparency or Graphic Styles controls or the Eyedropper, on the whole graph or on labels picked with Group Selection, is kept per kind of label (value axis numbers, category labels, legend labels) through the graph being drawn again, the paint, weight, opacity and blend mode of a label's topmost visible fill and stroke rows and its object opacity and blend mode included. Object › Graph › Data opens a worksheet: cells picked with a click and edited above the sheet (Tab moves right, Enter down, the arrows between cells), Import Data from a tab-separated text file, Transpose, Switch x/y, Cell Style (decimals shown, column width), Revert and Apply. `graph.setData` returns and takes the data as CSV with each value written exactly, not rounded to two decimals, so applying the returned CSV changes nothing (#1485). An Eyedropper pick that includes transparency and leaves a mark's top fill or stroke row without paint, or removes that row when the source has no row of that kind, where that row had paint before, also replaces the opacity and blend mode the graph keeps for that kind of row in the series; a row that had no paint before the pick leaves them as they are. From 0e6151011df6f638112c99bd8b6ec39c8fba71d6 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:30:45 -0800 Subject: [PATCH 097/108] Export: clipping type with geometry effects clips where the canvas does Type used as a clip group's clipping path, with a geometry effect on the object, on one of its fills or strokes, or a perspective, was baked into its outlined pieces with the effects applied, so SVG, PDF and the other exports clipped by all of them while the canvas clips by the plain glyph outlines. The baked clipping path was also a group, so the type's fills and strokes were not painted. bake_node now bakes such a clip group as the canvas draws it: the clipping path is a path of the region effects::clip_outline gives, the type's fills (effects baked) paint behind the clipped art inside the clip, and its strokes paint over it outside the clip, in a group that keeps the clip group's id and transparency. --- crates/effects/src/bake.rs | 59 ++++++++++++++++++++++++++++++++ crates/effects/src/bake/tests.rs | 52 +++++++++++++++++++++++++++- 2 files changed, 110 insertions(+), 1 deletion(-) diff --git a/crates/effects/src/bake.rs b/crates/effects/src/bake.rs index 2cffad6581..fe83d129bd 100644 --- a/crates/effects/src/bake.rs +++ b/crates/effects/src/bake.rs @@ -201,6 +201,9 @@ fn bake_node(d: &mut Document, n: &Node) -> Option<Node> { { return bake_leaf(d, n); } + if let Some(m) = clip_group_with_type_clip(d, n) { + return Some(m); + } let mut m = n.clone(); let baked: Vec<Arc<Node>> = ch.iter().map(|c| bake_node(d, c).map(Arc::new).unwrap_or_else(|| c.clone())).collect(); if let Some(ch) = m.children_mut() { @@ -211,6 +214,62 @@ fn bake_node(d: &mut Document, n: &Node) -> Option<Node> { bake_leaf(d, n) } +/// Clip group or clipping layer `n` whose clipping path is type with geometry effects (its own, its +/// fills' or strokes', or a perspective), baked as the canvas draws it: the type becomes a +/// clipping path of the region the canvas clips to ([`crate::clip_outline`]), its fills (with their +/// effects baked) paint behind the clipped art inside the clip, and its strokes paint over it +/// outside the clip, in a group that `n` becomes with its clip group inside ([`Node::clip_paint`]). +/// The other members are baked as usual. `None` for other objects and when the type has nothing to +/// clip by. +fn clip_group_with_type_clip(d: &mut Document, n: &Node) -> Option<Node> { + let (first, rest) = n.children()?.split_first()?; + if !n.clips() + || !matches!(first.kind, NodeKind::Text(_)) + || !(has_geometry(&first.appearance.effects) || first.projection().is_some() || has_item_geometry(first)) + { + return None; + } + let (bp, rule) = crate::clip_outline(first)?; + let mut clip = Node::path(first.id, PathData::from_bezpath(&bp), Appearance::default()); + if let NodeKind::Path { rule: r, clipping, .. } = &mut clip.kind { + (*r, *clipping) = (rule, true); + } + clip.name = first.name.clone(); + clip.visible = first.visible; + let paint = first.clip_paint(); + // The type's fills and strokes as art: baked with the type's id, as the renderer draws them, + // then given ids of their own. + let mut seen = std::collections::HashSet::from([n.id, first.id]); + let mut art = |d: &mut Document, part: Option<Node>| { + part.map(|p| { + let mut a = bake_node(d, &p).unwrap_or(p); + fresh_ids(d, &mut a, &mut seen); + Arc::new(a) + }) + }; + let fill = art(d, paint.fill); + let stroke = art(d, paint.stroke); + let members: Vec<Arc<Node>> = + std::iter::once(Arc::new(clip)).chain(fill).chain(rest.iter().map(|c| bake_node(d, c).map(Arc::new).unwrap_or_else(|| c.clone()))).collect(); + let mut m = n.clone(); + let Some(stroke) = stroke else { + if let Some(ch) = m.children_mut() { + *ch = members; + } + return Some(m); + }; + // `n` keeps its id, name and transparency, and holds the clip group and the strokes over it. + let inner = Node::new(d.alloc_id(), NodeKind::Group { children: members, clip: true }); + match &mut m.kind { + NodeKind::Group { children, clip } | NodeKind::Layer { children, clip, .. } => { + *children = vec![Arc::new(inner), stroke]; + *clip = false; + } + _ => return None, + } + Some(m) +} + /// `m`, art evaluated from an object, with its children baked and then given ids of their own (the /// pieces copied from the source keep the source's ids until then). The pieces are baked with the /// ids the renderer draws them with: Random in a Transform effect takes its seed from the id. diff --git a/crates/effects/src/bake/tests.rs b/crates/effects/src/bake/tests.rs index f3855f57ca..3334dd8704 100644 --- a/crates/effects/src/bake/tests.rs +++ b/crates/effects/src/bake/tests.rs @@ -2,7 +2,7 @@ use super::*; use serde_json::json; use vectorcraft_color::{Color, Paint}; use vectorcraft_doc::{CharStyle, Effect, NodeId, TextObject}; -use vectorcraft_geom::{Point, Rect, shapes}; +use vectorcraft_geom::{Point, Rect, Shape, shapes}; /// Type tests need glyph outlines, which only the optional craft-fonts build input provides. fn skip_without_craft_fonts() -> bool { @@ -813,6 +813,56 @@ fn type_in_a_clipping_group_with_a_fill_of_its_own_is_outlined_plain() { assert!(b.y0 > 30.0 && b.y1 < 70.0, "{b:?}"); } +#[test] +fn clipping_type_whose_fill_has_a_geometry_effect_clips_by_its_plain_outlines() { + if skip_without_craft_fonts() { + return; + } + let near = |a: Rect, b: Rect, tol: f64| [a.x0 - b.x0, a.y0 - b.y0, a.x1 - b.x1, a.y1 - b.y1].iter().all(|v| v.abs() < tol); + for stroke in [Paint::None, Paint::solid(Color::rgb(1.0, 0.0, 0.0))] { + // Type that clips a square, with a Transform effect on its own fill. + let mut t = type_node(60); + t.appearance = Appearance::basic(Paint::solid(Color::BLACK), stroke.clone(), 1.0).into(); + for item in &mut t.appearance.items { + if let AppearanceItem::Fill(f) = item { + f.effects.push(fx("distort.transform", json!({"moveH": 300}))); + } + } + let square = Node::path(NodeId(61), shapes::rectangle(Rect::new(0.0, 0.0, 100.0, 100.0)), Appearance::default_art()); + let clip = Node::new(NodeId(62), NodeKind::Group { children: vec![Arc::new(t.clone()), Arc::new(square)], clip: true }); + let canvas = crate::clip_outline(&t).map(|(bp, _)| bp.bounding_box()).unwrap(); + assert!(canvas.x1 < 100.0, "the canvas clips by the plain outlines: {canvas:?}"); + let d = bake_document(&doc_with(clip)).unwrap(); + let baked = d.node(NodeId(62)).unwrap(); + // With a stroke, the clip group sits in a group with the stroke over it, outside the clip. + let group = match baked.kind { + NodeKind::Group { clip: true, .. } => { + assert!(stroke.is_none(), "{baked:?}"); + baked + } + _ => { + let ch = baked.children().unwrap(); + assert_eq!(ch.len(), 2, "{baked:?}"); + let strokes = ch[1].appearance.items.iter().all(|i| matches!(i, AppearanceItem::Stroke(_))); + assert!(matches!(ch[1].kind, NodeKind::Text(_)) && strokes, "the type with only its stroke: {:?}", ch[1]); + &ch[0] + } + }; + let ch = group.children().unwrap(); + assert!(matches!(group.kind, NodeKind::Group { clip: true, .. }) && ch.len() == 3, "{group:?}"); + // The export clips by the outlines the canvas clips by. + assert!(matches!(ch[0].kind, NodeKind::Path { clipping: true, .. }), "{:?}", ch[0]); + let b = crate::clip_outline(&ch[0]).map(|(bp, _)| bp.bounding_box()).unwrap(); + assert!(near(b, canvas, 1e-6), "canvas {canvas:?}, export {b:?}"); + // The fills (the characters' and the moved one) paint behind the square, inside the clip. + let fill = ch[1].geometric_bounds().unwrap(); + assert!((fill.x0 - canvas.x0).abs() < 1e-6 && fill.x1 > canvas.x1 + 250.0, "{fill:?}"); + assert_eq!(ch[2].id, NodeId(61)); + let mut ids = std::collections::HashSet::new(); + baked.walk(&mut |n| assert!(ids.insert(n.id), "duplicate id {}", n.id)); + } +} + #[test] fn type_with_its_own_transform_effect_copies_stays_type() { if skip_without_craft_fonts() { From bfa0c8e15e5fe9810f57e566fee1b817d6117492 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:31:29 -0800 Subject: [PATCH 098/108] Dimensions: an opened file redraws its labels in its own composite fonts When a document opens or is reverted with dimensions whose art is not in its color mode, the dimensions are drawn again before the document's composite fonts are registered. A label whose font names a composite font that another open document defines differently was measured in that other definition, so it was centered off its anchor. The redraw now measures the labels in the document's own composite fonts, in front and in the back. --- crates/engine/src/cmd/compositefonts/tests.rs | 103 ++++++++++++++++++ crates/engine/src/cmd/dimension.rs | 7 +- docs/target-app-parity.md | 1 + 3 files changed, 110 insertions(+), 1 deletion(-) diff --git a/crates/engine/src/cmd/compositefonts/tests.rs b/crates/engine/src/cmd/compositefonts/tests.rs index 434f2e383a..cac6f4bdcb 100644 --- a/crates/engine/src/cmd/compositefonts/tests.rs +++ b/crates/engine/src/cmd/compositefonts/tests.rs @@ -478,6 +478,75 @@ fn an_opened_file_measures_its_type_in_its_own_composite_fonts() { assert_eq!(actual.cached_bounds, Some(expected)); } +/// The label of dimension `id` in `doc`. +fn label(doc: &vectorcraft_doc::Document, id: u64) -> vectorcraft_doc::TextObject { + let node = doc.node(NodeId(id)).unwrap(); + node.children().unwrap().iter().find_map(|n| if let NodeKind::Text(t) = &n.kind { Some((**t).clone()) } else { None }).unwrap() +} + +/// The center of label `t`'s measured box on the page. +fn label_center(t: &vectorcraft_doc::TextObject) -> vectorcraft_geom::Point { + t.xf * t.cached_bounds.unwrap().center() +} + +/// Whether every character of label `t` is filled in CMYK. +fn label_in_cmyk(t: &vectorcraft_doc::TextObject) -> bool { + !t.runs.is_empty() && t.runs.iter().all(|r| matches!(r.style.fill.color(), Some(vectorcraft_color::Color::Cmyk { .. }))) +} + +/// The native file of a CMYK document whose composite font `name` sets Roman at full size, with a +/// dimension whose label is set in it and whose label's characters are saved in RGB, so opening +/// the file draws the dimension again → (the file, the dimension's id, the center of its label as +/// drawn in the document's own composite font). +fn dimension_file(name: &str) -> (Vec<u8>, u64, vectorcraft_geom::Point) { + let mut s = Session::new(); + s.execute("file.new", &json!({"width": 400, "height": 400, "colorMode": "cmyk"})).unwrap(); + let mut full = font(name); + full["parts"]["roman"]["size"] = json!(100); + s.execute("type.compositeFonts.set", &json!({"fonts": [full]})).unwrap(); + let line = s.execute("shape.line", &json!({"x1": 100, "y1": 100, "x2": 172, "y2": 100})).unwrap()["id"].as_u64().unwrap(); + let id = s + .execute( + "dimension.create", + &json!({"source": {"kind": "segment", "edge": {"node": line, "subpath": 0, "segment": 0}}, + "options": {"units": "in", "precision": 2, "fontFamily": name, "fontSize": 20}}), + ) + .unwrap()["id"] + .as_u64() + .unwrap(); + let mut doc = (*s.doc().unwrap().doc).clone(); + let drawn = label(&doc, id); + assert!(label_in_cmyk(&drawn)); + let center = label_center(&drawn); + let mut label_id = None; + doc.node(NodeId(id)).unwrap().walk(&mut |n| { + if matches!(n.kind, NodeKind::Text(_)) { + label_id = Some(n.id); + } + }); + if let Some(NodeKind::Text(t)) = doc.node_mut(label_id.unwrap()).map(|n| &mut n.kind) { + for r in &mut t.runs { + r.style.fill = vectorcraft_color::Paint::solid(vectorcraft_color::Color::rgb8(0, 0, 0)); + } + } + (vectorcraft_format::save_file(&doc), id, center) +} + +/// A file whose dimensions are drawn again when it opens (their art is not in the document's color +/// mode) draws their labels in its own composite fonts, not in those of the front document, which +/// defines the label's font name with Roman at half size: each label stays centered on its anchor. +#[test] +fn an_opened_file_draws_its_dimension_labels_in_its_own_composite_fonts() { + let (bytes, id, center) = dimension_file("CF Dimension"); + let mut s = session(); + s.execute("type.compositeFonts.set", &json!({"fonts": [font("CF Dimension")]})).unwrap(); + let file = crate::cmd::fileio::read_for_open("dimension.vectorcraft", &bytes, None, &json!({}), false, false).unwrap(); + crate::cmd::fileio::open_read(&mut s, file).unwrap(); + let opened = label(&s.doc().unwrap().doc, id); + assert!(label_in_cmyk(&opened)); + assert!((label_center(&opened) - center).hypot() < 1e-6, "{:?} vs {center:?}", label_center(&opened)); +} + /// Threaded type read from a file flows through its frames in the file's own composite fonts, when /// no open document defines them. #[test] @@ -536,6 +605,40 @@ fn a_document_replaced_in_the_back_is_measured_when_the_front_one_closes() { assert_eq!(actual.cached_bounds, Some(expected)); } +/// A document replaced in front (File › Revert) whose dimensions are drawn again draws their labels +/// in its new composite fonts, not in those it had before. +#[test] +fn a_document_replaced_in_front_draws_its_dimension_labels_in_its_own_composite_fonts() { + let (bytes, id, center) = dimension_file("CF Reverted"); + let mut s = session(); + s.execute("type.compositeFonts.set", &json!({"fonts": [font("CF Reverted")]})).unwrap(); + assert!(s.replace_document(0, vectorcraft_format::load(&bytes).unwrap())); + let replaced = label(&s.doc().unwrap().doc, id); + assert!(label_in_cmyk(&replaced)); + assert!((label_center(&replaced) - center).hypot() < 1e-6, "{:?} vs {center:?}", label_center(&replaced)); +} + +/// A document replaced in the back draws its dimension labels in its own composite fonts, while the +/// front document keeps its definition of the same name registered; the labels stay where they are +/// when the document comes to the front. +#[test] +fn a_document_replaced_in_the_back_draws_its_dimension_labels_in_its_own_composite_fonts() { + let (bytes, id, center) = dimension_file("CF Back Dimension"); + let mut s = session(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + s.execute("type.compositeFonts.set", &json!({"fonts": [font("CF Back Dimension")]})).unwrap(); + assert!(s.replace_document(0, vectorcraft_format::load(&bytes).unwrap())); + assert_eq!(s.active_index(), Some(1)); + let front = vectorcraft_text::FontDb::global().composite_font("CF Back Dimension").unwrap(); + assert_eq!(front.parts.get(vectorcraft_doc::CharClass::Roman).size, 50.0); + let replaced = label(&s.documents()[0].doc, id); + assert!(label_in_cmyk(&replaced)); + assert!((label_center(&replaced) - center).hypot() < 1e-6, "{:?} vs {center:?}", label_center(&replaced)); + assert!(s.set_active(0)); + let shown = label(&s.doc().unwrap().doc, id); + assert!((label_center(&shown) - center).hypot() < 1e-6, "{:?} vs {center:?}", label_center(&shown)); +} + /// The type of document `index` with id `id`, wherever its tab is. fn text_in(s: &Session, index: usize, id: u64) -> vectorcraft_doc::TextObject { match &s.documents()[index].doc.node(NodeId(id)).unwrap().kind { diff --git a/crates/engine/src/cmd/dimension.rs b/crates/engine/src/cmd/dimension.rs index 44ac08d7ad..183cbd3746 100644 --- a/crates/engine/src/cmd/dimension.rs +++ b/crates/engine/src/cmd/dimension.rs @@ -495,7 +495,8 @@ pub(crate) fn refresh(before: &Document, doc: &mut Document) -> Result<bool> { /// Redraw the dimensions of an opened document whose art isn't in its colour mode: files saved /// before dimensions followed the colour mode have RGB dimensions in CMYK documents. A dimension -/// that can't be redrawn keeps the art it has. +/// that can't be redrawn keeps the art it has. The labels are measured in the document's own +/// composite fonts, also when another document's definitions of the same names are registered. pub(crate) fn conform(doc: &mut Document) { if !doc.dimensions { return; @@ -521,6 +522,10 @@ pub(crate) fn conform(doc: &mut Document) { } } }); + if stale.is_empty() { + return; + } + let _lent = vectorcraft_text::FontDb::global().lend_composite_fonts(&doc.composite_fonts); for (id, d) in stale { // An error leaves this dimension as it was; the others are still redrawn. let _ = replace(doc, id, d); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..eb9d3978d9 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -723,6 +723,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Reordering document tabs (G7, #5663):** a document tab dragged along the tab strip moves its document among the others ([public source](https://helpx.adobe.com/illustrator/using/customizing-workspace.html)); a line marks the gap it goes in. The current document stays current, each document keeps its own zoom, centre and artboard, the views Window › New Window opened move with their document, and Window › Next/Previous Document follow the new order. `document.move` (`{from?, to}`) does the same from MCP, the control channel and recordings. `crates/ui-egui/src/tests/tab_reorder.rs`, `crates/engine/src/tests/document_move.rs`. - **Closing a background document tab:** closing a tab other than the current one (`file.close {index}`) keeps the current document current, and its tool keeps its state; closing the current tab still makes its neighbor current. `crates/engine/src/tests/document_close.rs`. - **Replacing a background document's content:** `Session::replace_document` on a tab other than the current one (the replacement File › Revert makes for the current tab) measures the new content's type in that document's own composite fonts at once, so that type has its measured bounds while the document is in the back. When that document becomes the current one unchanged, its type in those fonts is not measured again. `crates/engine/src/cmd/compositefonts/tests.rs`. +- **Dimension labels in an opened document's composite fonts:** when a document opens or is replaced (File › Revert) with dimensions that are drawn again because their art is not in the document's color mode, each label is measured and centered on its anchor in the document's own composite fonts, also when another open document defines the label's font name differently. `crates/engine/src/cmd/compositefonts/tests.rs` (`an_opened_file_draws_its_dimension_labels_in_its_own_composite_fonts`, `a_document_replaced_in_front_draws_its_dimension_labels_in_its_own_composite_fonts`, `a_document_replaced_in_the_back_draws_its_dimension_labels_in_its_own_composite_fonts`). - **Export and Import Preferences (#6435):** an optional VectorCraft feature. The Preferences dialog's Export Preferences… saves the applied preferences to a JSON file (`prefs.export`; the web build downloads it), and Import Preferences… applies such a file (`prefs.import`). The file leaves out the folder preferences. The import checks every value first and changes nothing on an error; it keeps the open document's units and records no undo step. The file format is VectorCraft's own. Tests: `crates/engine/src/tests/prefs_file.rs`, `crates/ui-egui/src/prefs_dialog/tests.rs`. - **Preferences › User Interface › Open Documents As Tabs (G7, #394):** checked by default, documents open under tabs in one document window ([public source](https://helpx.adobe.com/illustrator/desktop/get-started/learn-the-basics/workspace-overview.html)). With the box cleared, each document opened or created afterwards opens in a floating window of its own, at the next cascade place, as Float in Window floats it; documents already open stay where they are, and checking the box again leaves floating documents in their windows. Tests: `crates/ui-egui/src/doc_windows/tests.rs`. - **Preferences search:** a Search Preferences field above the category list has the keyboard focus when the dialog opens, and Cmd/Ctrl+F gives it back; typing lists the settings it finds, and choosing one shows its category, as the [help page](https://helpx.adobe.com/illustrator/desktop/get-started/preferences-and-settings/set-app-preferences.html) describes. VectorCraft's own rules: the field matches a setting's label, section or category, ignoring case, in the interface language or in English; the list replaces the categories while the field has text and shows every match, or "No settings found"; the chosen setting's row is highlighted and scrolled into view; Escape in the field with text clears it, and Escape in the empty field closes the dialog. The dialog's `__search` field (`ui.dialog.set`) holds the text. Tests: `crates/ui-egui/src/prefs_dialog/tests.rs`. From 7f1764973146e3b6a0e62ee8e95130c41a32d394 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:34:05 -0800 Subject: [PATCH 099/108] Guides: document and layer guide edits share one set of one-pass helpers Document::guides_to_saved, remove_edit_layer, retain_guides and the artboard guide moves now call the layer helpers in node/ops.rs (held_guides, strip_held, map_held), which Node::strip_ruler_guides and Node::map_ruler_guide_positions already use. The copies in document_guides.rs (picked_in_layers, drop_picked, edit_picked) are removed. Picked stays for the walks through objects and opacity-mask art. Results, guide order, copies kept for undo and the number of nodes each walk looks at are unchanged. --- crates/doc/src/document_guides.rs | 76 ++++++------------------------- crates/doc/src/node.rs | 1 + crates/doc/src/node/ops.rs | 8 ++-- 3 files changed, 18 insertions(+), 67 deletions(-) diff --git a/crates/doc/src/document_guides.rs b/crates/doc/src/document_guides.rs index df336fe09e..ba6e4dc428 100644 --- a/crates/doc/src/document_guides.rs +++ b/crates/doc/src/document_guides.rs @@ -1,6 +1,7 @@ use super::document_ext::free_id; use super::guides::Guide; use super::limits::MAX_NEXT_ID; +use super::node::{held_guides, map_held, strip_held}; use super::{Affine, Arc, Document, Node, NodeId, NodeKind, PatternDef, Point, Rect, Selection, SymbolBoxes, Vec2, artboard_holds}; use std::collections::{BTreeMap, HashSet}; @@ -272,8 +273,8 @@ impl Document { return; } for l in &mut self.layers { - if let Some(held) = picked_in_layers(l, &Node::is_ruler_guide) { - drop_picked(l, held); + if let Some(held) = held_guides(l, &Node::is_ruler_guide) { + strip_held(Arc::make_mut(l), held); } } self.saved_guides.extend(guides); @@ -347,14 +348,14 @@ impl Document { /// saved guide whose layer is gone opens. Returns the removed node, without the guides. pub fn remove_edit_layer(&mut self, id: NodeId) -> Result<Arc<Node>, crate::DocError> { let mut layer = self.remove(id)?; - let Some(held) = picked_in_layers(&layer, &Node::is_ruler_guide) else { return Ok(layer) }; + let Some(held) = held_guides(&layer, &Node::is_ruler_guide) else { return Ok(layer) }; let mut guides = vec![]; layer.walk(&mut |c| { if c.is_ruler_guide() { guides.push(Arc::new(c.clone())); } }); - drop_picked(&mut layer, held); + strip_held(Arc::make_mut(&mut layer), held); let home = self.default_layer().unwrap_or_else(|| self.add_layer(None)); self.children_mut(Some(home))?.extend(guides); Ok(layer) @@ -418,8 +419,8 @@ impl Document { } let pick = |n: &Node| n.is_ruler_guide() && gone.contains(&n.id); for l in &mut self.layers { - if let Some(held) = picked_in_layers(l, &pick) { - drop_picked(l, held); + if let Some(held) = held_guides(l, &pick) { + strip_held(Arc::make_mut(l), held); } } sel.guides.retain(|id| !gone.contains(id)); @@ -434,8 +435,8 @@ impl Document { fn edit_artboard_guides(&mut self, id: u32, f: &mut impl FnMut(bool, &mut f64)) { let pick = |n: &Node| matches!(n.kind, NodeKind::RulerGuide { artboard: Some(a), .. } if a == id); for l in &mut self.layers { - if let Some(held) = picked_in_layers(l, &pick) { - edit_picked(l, held, f); + if let Some(held) = held_guides(l, &pick) { + map_held(Arc::make_mut(l), held, f); } } } @@ -569,57 +570,6 @@ impl Picked { } } -/// The children of `n`, if it is a layer, that `pick` picks (with nothing inside), and its -/// sublayers holding one (with what they hold), or `None` when it holds none. `pick` looks at -/// each child of the layers once. -fn picked_in_layers(n: &Node, pick: &impl Fn(&Node) -> bool) -> Option<Picked> { - if !n.is_layer() { - return None; - } - let children = n - .children() - .into_iter() - .flatten() - .enumerate() - .filter_map(|(i, c)| if pick(c) { Some((i, Picked::default())) } else { picked_in_layers(c, pick).map(|p| (i, p)) }) - .collect(); - Picked { children, mask: None }.some() -} - -/// Remove the children of `layer` and of its sublayers that [`picked_in_layers`] picked (`held`). -/// Only the layers holding one are copied, and only those are visited. -fn drop_picked(layer: &mut Arc<Node>, held: Picked) { - let Some(ch) = Arc::make_mut(layer).children_mut() else { return }; - let mut held = held.children.into_iter().peekable(); - let mut next = 0; - ch.retain_mut(|c| { - let at = next; - next += 1; - let Some((_, inner)) = held.next_if(|(i, _)| *i == at) else { return true }; - // A sublayer holds something; a child picked itself has nothing inside. - if inner.is_empty() { - return false; - } - drop_picked(c, inner); - true - }); -} - -/// Change with `f` (whether it is vertical, its position) the line of each ruler guide of `layer` -/// and of its sublayers that [`picked_in_layers`] picked (`held`), in the order they lie in. Only -/// the layers holding one, and the guides, are copied, and only those layers are visited. -fn edit_picked(layer: &mut Arc<Node>, held: Picked, f: &mut impl FnMut(bool, &mut f64)) { - let Some(ch) = Arc::make_mut(layer).children_mut() else { return }; - for (i, inner) in held.children { - let Some(c) = ch.get_mut(i) else { continue }; - if !inner.is_empty() { - edit_picked(c, inner, f); - } else if let NodeKind::RulerGuide { vertical, pos, .. } = &mut Arc::make_mut(c).kind { - f(*vertical, pos); - } - } -} - /// `n` picked itself when it is a ruler guide by `is_guide`, else the ruler guides below it /// ([`guides_below`]). fn guide_or_below(n: &Node, is_guide: &impl Fn(&Node) -> bool) -> Option<Picked> { @@ -872,9 +822,9 @@ mod tests { looked.set(looked.get() + 1); on_artboard_7(n) }; - let held = picked_in_layers(&d.layers[0], &pick).unwrap(); + let held = held_guides(&d.layers[0], &pick).unwrap(); assert_eq!(looked.get(), NESTED_CHILDREN, "each child of the layers is looked at once"); - drop_picked(&mut d.layers[0], held); + strip_held(Arc::make_mut(&mut d.layers[0]), held); assert_eq!(looked.get(), NESTED_CHILDREN, "removing looks at nothing again"); assert!(d.layers[0].children().is_some_and(|c| Arc::ptr_eq(&c[1], &still)), "a sublayer with nothing to remove is not copied"); @@ -932,10 +882,10 @@ mod tests { looked.set(looked.get() + 1); on_artboard_7(n) }; - let held = picked_in_layers(&d.layers[0], &pick).unwrap(); + let held = held_guides(&d.layers[0], &pick).unwrap(); assert_eq!(looked.get(), NESTED_CHILDREN, "each child of the layers is looked at once"); let mut seen = vec![]; - edit_picked(&mut d.layers[0], held, &mut |vertical, pos: &mut f64| { + map_held(Arc::make_mut(&mut d.layers[0]), held, &mut |vertical, pos: &mut f64| { seen.push((vertical, *pos)); *pos += 9.0; }); diff --git a/crates/doc/src/node.rs b/crates/doc/src/node.rs index eeec6ab162..79ce594212 100644 --- a/crates/doc/src/node.rs +++ b/crates/doc/src/node.rs @@ -32,6 +32,7 @@ pub use kind::{ImageObject, MAX_BUFFERED_VALUES, NodeKind, with_buffered_value_b pub use live_shape::{LiveShape, Scaling}; pub use opacity::{Knockout, OpacityMask, whiten}; pub use ops::{flattens, keeps_gradient_fit}; +pub(crate) use ops::{held_guides, map_held, strip_held}; use wire::NodeWire; pub(crate) use wire::counted_list; pub use wire::{MAX_READ_NODES, with_node_budget}; diff --git a/crates/doc/src/node/ops.rs b/crates/doc/src/node/ops.rs index fb6e8de8d9..efb006afed 100644 --- a/crates/doc/src/node/ops.rs +++ b/crates/doc/src/node/ops.rs @@ -823,11 +823,11 @@ impl Node { /// The ruler guides a layer holds: its children that are one, by index in order (each with /// nothing inside), and its sublayers holding one (with what they hold). #[derive(Debug, Default)] -pub(super) struct HeldGuides(Vec<(usize, HeldGuides)>); +pub(crate) struct HeldGuides(Vec<(usize, HeldGuides)>); /// The ruler guides, by `is_guide`, that `n` holds if it is a layer, or `None` when it holds /// none. `is_guide` looks at each child of `n` and of its sublayers once. -pub(super) fn held_guides(n: &Node, is_guide: &impl Fn(&Node) -> bool) -> Option<HeldGuides> { +pub(crate) fn held_guides(n: &Node, is_guide: &impl Fn(&Node) -> bool) -> Option<HeldGuides> { if !n.is_layer() { return None; } @@ -843,7 +843,7 @@ pub(super) fn held_guides(n: &Node, is_guide: &impl Fn(&Node) -> bool) -> Option /// Remove the ruler guides of `layer` and of its sublayers that [`held_guides`] found (`held`). /// Only the sublayers holding one are copied, and only those are visited. -pub(super) fn strip_held(layer: &mut Node, held: HeldGuides) { +pub(crate) fn strip_held(layer: &mut Node, held: HeldGuides) { let Some(ch) = layer.children_mut() else { return }; let mut held = held.0.into_iter().peekable(); let mut next = 0; @@ -863,7 +863,7 @@ pub(super) fn strip_held(layer: &mut Node, held: HeldGuides) { /// Call `f` (whether it is vertical, its position) on each ruler guide of `layer` and of its /// sublayers that [`held_guides`] found (`held`), in the order they lie in. Only the sublayers /// holding one, and the guides, are copied, and only those sublayers are visited. -pub(super) fn map_held(layer: &mut Node, held: HeldGuides, f: &mut impl FnMut(bool, &mut f64)) { +pub(crate) fn map_held(layer: &mut Node, held: HeldGuides, f: &mut impl FnMut(bool, &mut f64)) { let Some(ch) = layer.children_mut() else { return }; for (i, inner) in held.0 { let Some(c) = ch.get_mut(i) else { continue }; From 65b221192e531794ab49371b3042f372b7db686d Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:27:47 -0800 Subject: [PATCH 100/108] Effects: a layer's effects gather its sublayers' ruler guides in one pass Evaluating a layer's Pathfinder or geometry effects asked each member whether a sublayer below it held a ruler guide, then asked the members of every selected sublayer or group the same question again on the way down. A sublayer nested N deep was scanned once per layer or group above it, so a chain of N sublayers cost N(N+1)/2 scans. One read walk now looks at each member once at most and records which members hold or lead to a sublayer's guides, and the move visits and copies only those. As before, the groups inside a sublayer that holds no guide are not looked into. The guides taken, their order, their hidden and locked state, the art left behind and the sharing of untouched members are the same as before. --- crates/effects/src/group.rs | 112 +++++++++++++++++++++++------- crates/effects/src/group/tests.rs | 85 +++++++++++++++++++++++ 2 files changed, 170 insertions(+), 27 deletions(-) diff --git a/crates/effects/src/group.rs b/crates/effects/src/group.rs index bb2f605a91..f8b2c00713 100644 --- a/crates/effects/src/group.rs +++ b/crates/effects/src/group.rs @@ -734,35 +734,93 @@ fn item_art(id: NodeId, item: &AppearanceItem, shapes: &[(PathData, FillRule)], Some(g) } -/// Whether a sublayer among the members of `n`, or among its groups' members, holds a ruler guide. -fn sublayer_guides(n: &Node) -> bool { - n.children().is_some_and(|ch| ch.iter().any(|c| c.holds_ruler_guides() || (!c.is_layer() && sublayer_guides(c)))) +/// The members of a container that [`take_held_guides`] visits, by index, each with the same for +/// its own members. A ruler guide's entry is empty; a container's is not. +#[derive(Default)] +struct HeldGuides(Vec<(usize, HeldGuides)>); + +/// The members of `n` holding or leading to the ruler guides of sublayers, found by looking at each +/// member at every depth once: the ruler guides (`is_guide`) of `n` when it is a layer, each +/// sublayer holding one directly or in its sublayers, and each member of another kind with such a +/// sublayer among its members or its groups' members. With them, whether `n` is a layer holding a +/// ruler guide directly or in its sublayers. The other members of a layer holding none are not +/// looked into, unless the layer is the one whose sublayers are gathered (`top`). +fn held_guides(n: &Node, top: bool, is_guide: &impl Fn(&Node) -> bool) -> (bool, HeldGuides) { + let layer = n.is_layer(); + let (mut holds, mut held, mut other) = (false, vec![], vec![]); + for (i, c) in n.children().into_iter().flatten().enumerate() { + if is_guide(c) { + if layer { + holds = true; + held.push((i, HeldGuides::default())); + } + } else if c.is_layer() { + let (sub_holds, inner) = held_guides(c, false, is_guide); + if sub_holds { + holds = true; + held.push((i, inner)); + } + } else { + other.push((i, c)); + } + } + if !layer || holds || top { + for (i, c) in other { + let (_, inner) = held_guides(c, false, is_guide); + if !inner.0.is_empty() { + held.push((i, inner)); + } + } + held.sort_unstable_by_key(|(i, _)| *i); + } + (layer && holds, HeldGuides(held)) +} + +/// Move the ruler guides of `n` and of its members that [`held_guides`] found (`held`) to `out`: +/// those of `n` first, in order, then those of each member in turn. A guide taken from a hidden or +/// locked container, or from one inside such a container, is hidden or locked itself. Only the +/// containers in `held` are copied, and only those are visited. +fn take_held_guides(n: &mut Node, held: HeldGuides, out: &mut Vec<Arc<Node>>, hidden: bool, locked: bool) { + let Some(ch) = n.children_mut() else { return }; + let (mut own, mut deeper) = (vec![], vec![]); + for (i, inner) in held.0 { + if inner.0.is_empty() { + own.push(i); + continue; + } + let Some(c) = ch.get_mut(i) else { continue }; + let c = Arc::make_mut(c); + let (hidden, locked) = (hidden || !c.visible, locked || c.locked); + take_held_guides(c, inner, &mut deeper, hidden, locked); + } + if !own.is_empty() { + let mut own = own.into_iter().peekable(); + for (i, mut c) in std::mem::take(ch).into_iter().enumerate() { + if own.next_if_eq(&i).is_none() { + ch.push(c); + continue; + } + if hidden || locked { + let g = Arc::make_mut(&mut c); + g.visible &= !hidden; + g.locked |= locked; + } + out.push(c); + } + } + out.append(&mut deeper); } /// Move the ruler guides of the sublayers among the members of `n`, and among its groups' -/// members, to `out`, in order. A guide taken from a hidden or locked sublayer, or from one inside -/// such a sublayer or group, is hidden or locked itself. Only containers holding one are copied. -fn take_sublayer_guides(n: &mut Node, out: &mut Vec<Arc<Node>>, hidden: bool, locked: bool) { - let Some(ch) = n.children_mut() else { return }; - for c in ch.iter_mut().filter(|c| c.holds_ruler_guides() || (!c.is_layer() && sublayer_guides(c))) { - let c = Arc::make_mut(c); - let (hidden, locked) = (hidden || !c.visible, locked || c.locked); - if c.is_layer() - && let Some(lc) = c.children_mut() - { - let (taken, art): (Vec<_>, Vec<_>) = std::mem::take(lc).into_iter().partition(|g| g.is_ruler_guide()); - *lc = art; - out.extend(taken.into_iter().map(|mut g| { - if hidden || locked { - let g = Arc::make_mut(&mut g); - g.visible &= !hidden; - g.locked |= locked; - } - g - })); - } - take_sublayer_guides(c, out, hidden, locked); - } +/// members, to `out`, in order: a sublayer's own guides, then those of its members. A guide taken +/// from a hidden or locked sublayer, or from one inside such a sublayer or group, is hidden or +/// locked itself. Each member at every depth is looked at once at most (`is_guide`), and only +/// containers holding one are copied. +fn take_sublayer_guides(n: &mut Node, out: &mut Vec<Arc<Node>>, is_guide: &impl Fn(&Node) -> bool) { + let (_, mut held) = held_guides(n, true, is_guide); + // The ruler guides of `n` itself stay where they are. + held.0.retain(|(_, inner)| !inner.0.is_empty()); + take_held_guides(n, held, out, false, false); } /// `n`, a group or layer, as plain art: its Pathfinder effects evaluated, its geometry effects @@ -790,7 +848,7 @@ pub fn evaluate_container(doc: Option<&Document>, n: &Node) -> Option<Node> { // So do its sublayers' guides, which would otherwise go with the art the effects replace or // copy: they stay on this layer, hidden and locked as their sublayers were. if m.is_layer() && (pathfinder || !fx.is_empty()) { - take_sublayer_guides(&mut m, &mut guides, false, false); + take_sublayer_guides(&mut m, &mut guides, &Node::is_ruler_guide); } if pathfinder { let hook = |c: &Node| crate::outline_object(doc, c); diff --git a/crates/effects/src/group/tests.rs b/crates/effects/src/group/tests.rs index c6e2a78c73..340ca9d4bc 100644 --- a/crates/effects/src/group/tests.rs +++ b/crates/effects/src/group/tests.rs @@ -1757,3 +1757,88 @@ fn a_sublayers_ruler_guide_in_a_hidden_or_locked_group_stays_hidden_or_locked() assert_eq!(guides, [(NodeId(20), !hidden, locked)], "hidden {hidden}, locked {locked}"); } } + +/// Gathering the ruler guides of nested sublayers, and of a sublayer inside nested groups, looks +/// at each member at every depth once at most, and takes the same guides, in the same order and state, as +/// a layer's effects keep. +#[test] +fn gathering_sublayer_ruler_guides_looks_at_each_member_once() { + use std::cell::Cell; + use vectorcraft_doc::LayerColor; + const CHAIN: u64 = 6; + let guide = |id| Arc::new(Node::new(NodeId(id), NodeKind::RulerGuide { vertical: true, pos: id as f64, artboard: None })); + let layer = |id, children: Vec<Arc<Node>>| { + let mut l = Node::layer(NodeId(id), "Sub", LayerColor::Preset(1)); + if let Some(ch) = l.children_mut() { + *ch = children; + } + l + }; + // Sublayers nested CHAIN deep, each holding the next before its own art and guide. The second + // is hidden and the fourth locked. + let first_guide = guide(201); + let mut chain = layer(100 + CHAIN, vec![sq(300 + CHAIN, 0.0, Color::BLACK), guide(200 + CHAIN)]); + for depth in (1..CHAIN).rev() { + let own = if depth == 1 { first_guide.clone() } else { guide(200 + depth) }; + chain = layer(100 + depth, vec![Arc::new(chain), sq(300 + depth, 0.0, Color::BLACK), own]); + (chain.visible, chain.locked) = (depth != 2, depth == 4); + } + let second_guide = chain.children().and_then(|c| c[0].children()).map(|c| c[2].clone()).unwrap(); + // A sublayer inside five nested groups, the third of them locked. + let mut groups = layer(450, vec![guide(250), sq(350, 0.0, Color::BLACK)]); + for depth in (1..=5).rev() { + groups = Node::group(NodeId(400 + depth), vec![Arc::new(groups)]); + groups.locked = depth == 3; + } + let free = Arc::new(Node::group(NodeId(500), vec![sq(501, 0.0, Color::BLACK), sq(502, 5.0, Color::BLACK)])); + // A sublayer with no guide: the art in its group is not looked at. + let quiet = Node::group(NodeId(601), vec![sq(602, 0.0, Color::BLACK), sq(603, 5.0, Color::BLACK)]); + let quiet = Arc::new(layer(600, vec![Arc::new(quiet)])); + let mut root = layer(10, vec![sq(1, 0.0, Color::rgb(1.0, 0.0, 0.0)), Arc::new(chain), Arc::new(groups), free.clone(), quiet.clone(), guide(20)]); + fn members(n: &Node) -> usize { + n.children().into_iter().flatten().map(|c| 1 + members(c)).sum() + } + let expected: Vec<_> = (1..=CHAIN).map(|depth| (NodeId(200 + depth), depth < 2, depth >= 4)).chain([(NodeId(250), true, true)]).collect(); + let state = |g: &[Arc<Node>]| g.iter().map(|g| (g.id, g.visible, g.locked)).collect::<Vec<_>>(); + + let mut m = root.clone(); + let looked = Cell::new(0_usize); + let is_guide = |n: &Node| { + looked.set(looked.get() + 1); + n.is_ruler_guide() + }; + let mut taken = vec![]; + take_sublayer_guides(&mut m, &mut taken, &is_guide); + assert_eq!(looked.get(), members(&root) - 2, "each member is looked at once, none in the quiet sublayer's group"); + assert_eq!(state(&taken), expected, "a sublayer's own guides, then its sublayers', each once"); + assert!(Arc::ptr_eq(&taken[0], &first_guide), "a guide with nothing to change is not copied"); + assert!(!Arc::ptr_eq(&taken[1], &second_guide), "a guide made hidden is copied"); + assert!(second_guide.visible, "the guide as it was stays as it was"); + let ch = m.children().unwrap(); + assert!(Arc::ptr_eq(&ch[3], &free), "a member with no sublayer guide is not copied"); + assert!(Arc::ptr_eq(&ch[4], &quiet), "a sublayer with no guide is not copied"); + assert!(ch[5].is_ruler_guide(), "the layer's own guide stays where it is"); + let ids = |n: &Node| n.children().into_iter().flatten().map(|c| c.id).collect::<Vec<_>>(); + assert_eq!(ids(&ch[1]), [NodeId(102), NodeId(301)], "the sublayer's art stays, in order"); + assert_eq!(ids(&root.children().unwrap()[1]), [NodeId(102), NodeId(301), NodeId(201)], "the source keeps its guides"); + + fn found(n: &Node, out: &mut Vec<NodeId>) { + for c in n.children().into_iter().flatten() { + if c.is_ruler_guide() { + out.push(c.id); + } + found(c, out); + } + } + for (effect, params) in [("pathfinder.add", serde_json::json!({})), ("distort.transform", serde_json::json!({"moveH": 30, "copies": 2}))] { + root.appearance.effects = vec![Effect { id: effect.into(), params, visible: true }]; + let art = evaluate_container(None, &root).unwrap(); + let ch = art.children().unwrap(); + let tail = &ch[ch.len() - expected.len() - 1..]; + assert_eq!(tail[0].id, NodeId(20), "{effect}: the layer's own guide comes first"); + assert_eq!(state(&tail[1..]), expected, "{effect}: then the sublayers' guides"); + let mut all = vec![]; + found(&art, &mut all); + assert_eq!(all.len(), expected.len() + 1, "{effect}: each guide once"); + } +} From f37c5c293e6f9058de8faec616334e1c9a6b36f9 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:41:02 -0800 Subject: [PATCH 101/108] Brushes: brush.freehand refuses a brush or style it cannot use brush.freehand drew the plain path when `brush` named no brush in the document or was not a string, and drew a pencil stroke for any `style` other than "brush". It now refuses an unknown name with "no brush named `<name>`", as brush.apply and brush.setCurrent do, a `brush` that is not a string, and a `style` other than "pencil" or "brush". The document does not change and no undo step is recorded. A `brush` left out or null still draws the plain path. The Paintbrush skips a tool brush or current brush that has been deleted and paints with the other, or draws the plain path when neither is in the document, so a stroke after a brush is deleted is not refused. --- crates/engine/src/cmd/brushsym.rs | 2 +- crates/engine/src/cmd/brushsym/brushes.rs | 15 +++++- crates/engine/src/tests/brushsym.rs | 63 +++++++++++++++++++++++ crates/tools/src/symbolism.rs | 26 +++++++++- docs/mcp.md | 7 ++- docs/target-app-parity.md | 1 + 6 files changed, 110 insertions(+), 4 deletions(-) diff --git a/crates/engine/src/cmd/brushsym.rs b/crates/engine/src/cmd/brushsym.rs index 32b0f9fcd0..1046cada1c 100644 --- a/crates/engine/src/cmd/brushsym.rs +++ b/crates/engine/src/cmd/brushsym.rs @@ -180,7 +180,7 @@ pub fn specs() -> Vec<CommandSpec> { "Paintbrush", [], None, - "{…params as path.freehand, brush} paint a freehand stroke with a brush → {id}", + "{…params as path.freehand, brush?: name} paint a freehand stroke with a brush; without `brush` (or with null) the plain path is drawn; a `brush` that names no brush in the document, or a `style` other than \"pencil\" or \"brush\", is an error and nothing is drawn → {id}", has_doc, brush_freehand ), diff --git a/crates/engine/src/cmd/brushsym/brushes.rs b/crates/engine/src/cmd/brushsym/brushes.rs index 1f63076cfd..7fd8c9aa9a 100644 --- a/crates/engine/src/cmd/brushsym/brushes.rs +++ b/crates/engine/src/cmd/brushsym/brushes.rs @@ -729,8 +729,21 @@ pub(super) fn expand_brush(s: &mut Session, p: &Value) -> Result<Value> { Ok(json!({ "ids": ids_json(&out) })) } +/// Paints a `path.freehand` stroke with the brush `brush` names. A `brush` left out or null draws +/// the plain path; a `brush` that is not a string or names no brush in the document, and a `style` +/// other than "pencil" or "brush", is an error before anything is drawn. pub(super) fn brush_freehand(s: &mut Session, p: &Value) -> Result<Value> { - let name = str_param(p, "brush").map(str::to_string).filter(|n| s.doc().is_ok_and(|st| brush::find(&st.doc, n).is_some())); + const C: &str = "brush.freehand"; + let name = match crate::cmd::text_param(p, "brush", C)? { + None => None, + Some(n) if brush::find(&s.doc()?.doc, n).is_some() => Some(n.to_string()), + Some(n) => return Err(bad(C, format!("no brush named `{n}`"))), + }; + match p.get("style") { + None | Some(Value::Null) => {} + Some(v) if matches!(v.as_str(), Some("pencil" | "brush")) => {} + Some(v) => return Err(bad(C, format!("`style` must be \"pencil\" or \"brush\", not {v}"))), + } let spec = find_command("path.freehand").ok_or_else(|| EngineError::UnknownCommand("path.freehand".into()))?; let r = crate::cmd::run_checked(s, spec, p)?; let (Some(name), Some(id)) = (name, id_param(&r, "id")) else { return Ok(r) }; diff --git a/crates/engine/src/tests/brushsym.rs b/crates/engine/src/tests/brushsym.rs index e961a59e81..bc4ce76c83 100644 --- a/crates/engine/src/tests/brushsym.rs +++ b/crates/engine/src/tests/brushsym.rs @@ -963,6 +963,69 @@ fn brush_freehand_paints_with_a_brush_in_one_step() { assert_eq!(brush_of(&s, id).as_deref(), Some("Charcoal")); } +/// `brush.freehand` refuses a `brush` that is not a string or names no brush in the document, +/// and a `style` other than "pencil" or "brush", before it draws: the document, the selection +/// and the undo history stay as they were. A `brush` left out or null draws the plain path. +#[test] +fn brush_freehand_refuses_a_brush_or_style_it_cannot_use() { + let mut s = session(); + let a = rect(&mut s, 0.0, 0.0, 10.0, 10.0); + select(&mut s, &[a]); + let points = json!([[10, 10], [60, 40], [120, 10]]); + for (extra, words) in [ + (json!({"brush": "Nope"}), "no brush named `Nope`"), + (json!({"brush": ""}), "no brush named ``"), + (json!({"brush": 5}), "`brush` must be a string"), + (json!({"brush": {"name": "Charcoal"}}), "`brush` must be a string"), + (json!({"brush": true}), "`brush` must be a string"), + (json!({"brush": "Charcoal", "style": "marker"}), "`style` must be \"pencil\" or \"brush\", not \"marker\""), + (json!({"brush": "Charcoal", "style": 1}), "`style` must be \"pencil\" or \"brush\", not 1"), + ] { + let mut p = extra.clone(); + p["points"] = points.clone(); + let (before, undo) = (s.doc().unwrap().doc.clone(), s.doc().unwrap().history.undo.len()); + let e = s.execute("brush.freehand", &p).expect_err(&format!("{extra} is refused")); + assert!(e.to_string().contains(words), "{extra}: {e}"); + assert!(*s.doc().unwrap().doc == *before, "{extra} leaves the document"); + assert_eq!(s.doc().unwrap().selection.objects, [a], "{extra} leaves the selection"); + assert_eq!(s.doc().unwrap().history.undo.len(), undo, "{extra} records no undo step"); + } + for extra in [json!({}), json!({"brush": null, "style": null})] { + let mut p = extra.clone(); + p["points"] = points.clone(); + let id = NodeId(s.execute("brush.freehand", &p).unwrap()["id"].as_u64().unwrap()); + assert_eq!(brush_of(&s, id), None, "{extra} draws the plain path"); + } + for style in ["pencil", "brush"] { + let r = s.execute("brush.freehand", &json!({"points": points, "style": style, "brush": "Charcoal"})).unwrap(); + assert!(r["id"].is_u64(), "{style}: {r}"); + } +} + +/// The Paintbrush skips a brush deleted after it was chosen: a deleted tool brush gives way to +/// the document's current brush, and with neither the stroke is drawn without a brush. +#[test] +fn paintbrush_tool_skips_a_deleted_brush() { + let mut s = session(); + s.execute("brush.setCurrent", &json!({"name": "Arrow"})).unwrap(); + let v = ViewInfo::default(); + s.select_tool("paintbrush", v).unwrap(); + s.set_tool_option("brush", &json!("Dots")); + s.execute("brush.delete", &json!({"name": "Dots"})).unwrap(); + let stroke = |s: &mut Session, y: f64| { + for (k, x) in [(PointerKind::Down, 10.0), (PointerKind::Drag, 50.0), (PointerKind::Drag, 90.0), (PointerKind::Up, 130.0)] { + s.pointer(&PointerEvent::new(k, x, y), v).unwrap(); + } + s.doc().unwrap().selection.objects[0] + }; + let id = stroke(&mut s, 10.0); + assert_eq!(brush_of(&s, id).as_deref(), Some("Arrow")); + s.execute("brush.delete", &json!({"name": "Arrow"})).unwrap(); + assert_eq!(s.doc().unwrap().doc.unknown.get("currentBrush"), None); + let id = stroke(&mut s, 110.0); + assert_eq!(brush_of(&s, id), None); +} + #[test] fn paintbrush_tool_uses_the_current_brush() { let mut s = session(); diff --git a/crates/tools/src/symbolism.rs b/crates/tools/src/symbolism.rs index 1618d6e7d6..580e61d4fd 100644 --- a/crates/tools/src/symbolism.rs +++ b/crates/tools/src/symbolism.rs @@ -238,10 +238,15 @@ impl Default for BrushPaintTool { } impl BrushPaintTool { + /// The tool's brush, else the document's current brush, skipping a name the document's brush + /// library no longer has (a deleted brush), so the stroke is drawn without it. fn brush_name(&self, cx: &ToolContext) -> Option<String> { - self.brush.clone().or_else(|| cx.doc.unknown.get("currentBrush").and_then(Value::as_str).map(str::to_string)) + [self.brush.clone(), vectorcraft_brush::current(cx.doc)].into_iter().flatten().find(|n| vectorcraft_brush::find(cx.doc, n).is_some()) } fn map(&self, cx: &ToolContext, acts: Vec<Action>) -> Vec<Action> { + if !acts.iter().any(|a| matches!(a, Action::Preview(c, _) if c == "path.freehand")) { + return acts; + } let Some(b) = self.brush_name(cx) else { return acts }; acts.into_iter() .map(|a| match a { @@ -403,4 +408,23 @@ mod tests { t.set_option("brush", &json!("Dots")); assert_eq!(t.options()["brush"], "Dots"); } + + #[test] + fn paintbrush_skips_a_brush_the_document_does_not_have() { + let (mut d, _) = doc_with_rect(); + let (s, p) = (Selection::default(), paint()); + let drag = |d: &vectorcraft_doc::Document, t: &mut BrushPaintTool| { + let cx = cx(d, &s, &p); + t.pointer(&cx, &PointerEvent::new(PointerKind::Down, 0.0, 0.0)); + t.pointer(&cx, &PointerEvent::new(PointerKind::Drag, 30.0, 0.0)).swap_remove(1) + }; + d.unknown.insert("currentBrush".into(), json!("Charcoal")); + let mut t = BrushPaintTool::default(); + t.set_option("brush", &json!("Deleted")); + let a = drag(&d, &mut t); + assert!(matches!(&a, Action::Preview(c, v) if c == "brush.freehand" && v["brush"] == "Charcoal"), "the current brush: {a:?}"); + d.unknown.insert("currentBrush".into(), json!("Also deleted")); + let a = drag(&d, &mut BrushPaintTool::default()); + assert!(matches!(&a, Action::Preview(c, v) if c == "path.freehand" && v.get("brush").is_none()), "no brush: {a:?}"); + } } diff --git a/docs/mcp.md b/docs/mcp.md index ca77311c58..1817d09c4e 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3126,7 +3126,12 @@ already walks Image Trace. Short agent entry points: is unused, and offers Remove Strokes or Cancel when one of them is in use. - Brushes: `brush.list`, `brush.get {name}`, `brush.apply {name, ids?}`, `brush.new {type, name?, params?, ids?}`, `brush.setCurrent {name}`, `brush.options {name, params?, newName?}`, `brush.delete {name} | {names}`, - `brush.duplicate {name, newName?} | {names}`, `brush.freehand`, `object.expandBrush {ids?}`. A document or brush + `brush.duplicate {name, newName?} | {names}`, `brush.freehand {…path.freehand params, brush?}`, + `object.expandBrush {ids?}`. `brush.freehand` draws the plain path when `brush` is left out or null. It refuses a + `brush` that is not a string with "`brush` must be a string", a name that no brush in the document has (an empty + name included) with "no brush named `<name>`", and a `style` other than "pencil" or "brush"; the document does not + change and no undo step is recorded. The Paintbrush skips a tool brush or current brush that has been deleted and + paints with the other, or draws the plain path when neither is in the document. A document or brush library file whose brushes repeat a name is read with the first brush of that name as stored and each later one numbered with the first "`<name>` 2", "`<name>` 3"… the file does not have; strokes of the name keep the first brush. `brush.new`, diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..6cd8c13b9e 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1165,6 +1165,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur In the Pencil and Paintbrush Tool Options, Edit selected paths within 0 px turns editing off, so a stroke that starts exactly on an end of a selected open path draws a new path; Close paths when ends are within 0 px turns closing off, so a stroke that ends exactly where it started stays open. The Pencil's and the Paintbrush's Fidelity is in screen pixels, the same at any zoom: their Tool Options give it in px, from 0.01 px on the logarithmic slider to 20 px and up to 100 px in the field, and the tool sends `path.freehand` the value in points at the current zoom (#5729). The Smooth tool's and the Blob Brush's Fidelity stays in points. `path.freehand` and `brush.freehand` take a Fidelity of up to 100 / 0.0313 pt (about 3194.89 pt), the 100 px field maximum at the lowest zoom (3.13 %), and reject a value outside their range with an error, so a Pencil or Paintbrush stroke drawn zoomed out keeps the Fidelity set in pixels (engine tests `pencil_fit_keeps_its_anchors_on_a_stroke_drawn_zoomed_out` and `pencil_takes_fidelity_within_its_range_and_rejects_the_rest`). + `brush.freehand` refuses a `brush` that names no brush in the document, or is not a string, and a `style` other than "pencil" or "brush", with an error and no change or undo step, instead of drawing the plain path; the Paintbrush skips a chosen brush that has since been deleted (engine tests `brush_freehand_refuses_a_brush_or_style_it_cannot_use` and `paintbrush_tool_skips_a_deleted_brush`). Each drag of the Smooth tool smooths the stretch of a selected path in its reach along its length before refitting it within Fidelity, so a wobble wider than Fidelity is smoothed out and another drag over the same place smooths it further, as [the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/smooth-tool.html) describes (`path.smoothRegion`). The smoothing spread (a third of the reach) and the rule that each refit stays within twice the distance the smoothing moved the path, so repeated drags do not drift from it, are VectorCraft's own. A drag over the whole of a closed path smooths it across its first anchor too, so a bump there is smoothed like any other and no corner is left; Object › Path › Smooth smooths a closed path across its first anchor the same way. The Smooth tool shows the Not Allowed cursor while no path is selected that it can act on (an editable path, not a guide, with three or more anchors on one of its subpaths or two anchors joined by a curve), and the release of a drag then sends no command and changes nothing; [the help page](https://helpx.adobe.com/illustrator/using/tool-techniques/smooth-tool.html) has the path selected first. A selected path anywhere on the canvas gives the Smooth cursor wherever the pointer is. The Pencil with Alt key toggles to Smooth Tool on and the Blob Brush show Not Allowed the same way when Alt gives them the Smooth tool; the Paintbrush keeps its closing cursor, since its release with Alt closes the stroke. Use Precise Cursors leaves Not Allowed as it is. This cursor rule is VectorCraft's own (tools `smooth_shows_not_allowed_without_a_selected_path_to_smooth`, `borrowed_smooth_shows_not_allowed_without_a_selected_path_to_smooth`, `smoothing_release_sends_nothing_without_a_selected_path_to_smooth`; engine `use_precise_cursors_keeps_the_smooth_tools_not_allowed_pointer`). When a Smooth tool drag reaches the first or last anchor of an open path, that anchor stays where it is and the curve there leaves or arrives along the smoothed path within the reach, so a jagged first or last segment no longer sets the end's direction; an end where the smoothed path turns back by 90° or more keeps its segment's direction, and where the refitted stretch ends inside the path the curve keeps the direction of the part outside the drag. This rule is VectorCraft's own (`tests/draw2.rs`, `smoothing_an_open_path_turns_its_jagged_ends_with_the_path` and `a_smooth_drag_turns_only_the_end_it_reaches`). From be9be8c1bda4614bd1c6cb7bff8e5f5901a108e1 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 03:59:02 -0800 Subject: [PATCH 102/108] Swatches: a replacement gradient or pattern is stored as a new swatch stores it swatch.edit stored a replacement gradient without its placement, so a radial gradient with an aspect, Alt-dropped on a gradient swatch or given as `paint`, lost that aspect, while swatch.new keeps it and applies the swatch with it. A gradient given an aspect without `start` and `end` lost the aspect in both commands. A replacement pattern kept the tile transform of the swatch it came from, while swatch.new stores a pattern untransformed, and `paint: {pattern: name}`, which an Alt-drop of a pattern fill sends, was refused. swatch.edit and swatch.new now store a gradient or pattern through one helper: a gradient keeps its aspect, with or without a vector, and holds no swatch link, and a pattern is untransformed. swatch.edit takes a pattern by name, as swatch.new does. --- crates/engine/src/cmd/swatch.rs | 48 +++++++++--- crates/engine/src/tests/swatchlib.rs | 108 +++++++++++++++++++++++++++ docs/mcp.md | 10 ++- 3 files changed, 151 insertions(+), 15 deletions(-) diff --git a/crates/engine/src/cmd/swatch.rs b/crates/engine/src/cmd/swatch.rs index 3b98cbd9a6..3388b8344b 100644 --- a/crates/engine/src/cmd/swatch.rs +++ b/crates/engine/src/cmd/swatch.rs @@ -19,7 +19,7 @@ pub fn specs() -> Vec<CommandSpec> { "New Swatch", ["Window", "Swatches"], None, - "{name?, color? | colors?: [colour] (one swatch each, in one undo step; #rrggbbaa and #rgba are refused) | swatch? | gradient? | pattern?: name (default: the current fill), tint?: 0..100 (% of the global or spot `swatch`, or of the one the current fill links to), mode?: \"gray\"|\"rgb\"|\"hsb\"|\"lab\"|\"cmyk\"|\"web\" (convert the colour; lab: CIE L*a*b*, how spot colours are usually defined), global?, spot? (a spot colour, always global), group?: colour group name (solid colours only; default: ungrouped), none?: true (the None paint), paint?: paint.setFill params, keepModel?: bool (as paint.setFill)} save a colour, gradient or pattern as a swatch. A tint of a global or spot colour (below 100%, without mode, global or spot) becomes a tint swatch, \"Name 40%\", linked to its base: it follows edits to the base and applies as that tint of it. A gradient swatch holds no link to the swatch its gradient came from, and a pattern swatch holds the pattern untransformed. Names are unique (\"Sky 2\"); a colour's default name is its values (\"C=10 M=20 Y=30 K=0\", \"R=255 G=128 B=0\", \"Gray K=40\", \"L=55 a=60 b=40\") → {name, names: [every new swatch]}", + "{name?, color? | colors?: [colour] (one swatch each, in one undo step; #rrggbbaa and #rgba are refused) | swatch? | gradient? | pattern?: name (default: the current fill), tint?: 0..100 (% of the global or spot `swatch`, or of the one the current fill links to), mode?: \"gray\"|\"rgb\"|\"hsb\"|\"lab\"|\"cmyk\"|\"web\" (convert the colour; lab: CIE L*a*b*, how spot colours are usually defined), global?, spot? (a spot colour, always global), group?: colour group name (solid colours only; default: ungrouped), none?: true (the None paint), paint?: paint.setFill params, keepModel?: bool (as paint.setFill)} save a colour, gradient or pattern as a swatch. A tint of a global or spot colour (below 100%, without mode, global or spot) becomes a tint swatch, \"Name 40%\", linked to its base: it follows edits to the base and applies as that tint of it. A gradient swatch keeps the gradient's aspect (with or without start/end) and holds no link to the swatch its gradient came from, and a pattern swatch holds the pattern untransformed. Names are unique (\"Sky 2\"); a colour's default name is its values (\"C=10 M=20 Y=30 K=0\", \"R=255 G=128 B=0\", \"Gray K=40\", \"L=55 a=60 b=40\") → {name, names: [every new swatch]}", has_doc, swatch_new ), @@ -48,7 +48,7 @@ pub fn specs() -> Vec<CommandSpec> { "Swatch Options", ["Window", "Swatches"], None, - "{name, newName?, color? (e.g. {l, a, b} for a Lab colour; #rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill; the swatch's own color and a color given with mode keep their model), mode?: \"gray\"|\"rgb\"|\"hsb\"|\"lab\"|\"cmyk\"|\"web\" (convert the colour), global?, spot? (spot colours are always global), paint?: paint.setFill params ({color}, {gradient}, {swatch} or {pattern}) replacing the swatch's colour; gradient or pattern with one of the same kind} edit a swatch in any colour group, as one undo step. Fills, strokes, text, gradient stops and tint swatches linked to a global swatch take its new colour (at their own tint) and name; turning Global off unlinks them (they keep their colour). Colour, mode and spot apply to solid colours only; a tint swatch only takes a new name (edit its base) → {name, relinked: paints changed}", + "{name, newName?, color? (e.g. {l, a, b} for a Lab colour; #rrggbbaa and #rgba are refused), keepModel?: bool (as paint.setFill; the swatch's own color and a color given with mode keep their model), mode?: \"gray\"|\"rgb\"|\"hsb\"|\"lab\"|\"cmyk\"|\"web\" (convert the colour), global?, spot? (spot colours are always global), paint?: paint.setFill params ({color}, {gradient} or {swatch}) or {pattern: name} replacing the swatch's colour; gradient or pattern with one of the same kind (stored as swatch.new stores it: a gradient keeps its aspect with or without start/end and holds no swatch link; a pattern is untransformed)} edit a swatch in any colour group, as one undo step. Fills, strokes, text, gradient stops and tint swatches linked to a global swatch take its new colour (at their own tint) and name; turning Global off unlinks them (they keep their colour). Colour, mode and spot apply to solid colours only; a tint swatch only takes a new name (edit its base) → {name, relinked: paints changed}", has_doc, swatch_edit ), @@ -187,11 +187,7 @@ fn swatch_new(s: &mut Session, p: &Value) -> Result<Value> { })), Paint::None => Err(bad(C, "a swatch needs a colour, gradient or pattern")), _ if spot || mode.is_some() || group.is_some() => Err(bad(C, "spot, mode and group apply to solid colours only")), - // The swatch holds the gradient itself, not a link to the swatch it may have come from. - // It keeps `geom`, which holds the aspect the swatch is applied with. - Paint::Gradient(g) => Ok(Paint::Gradient(Box::new(vectorcraft_color::GradientPaint { swatch: None, ..*g }))), - // The swatch holds the pattern untransformed, not the placement of the art it came from. - Paint::Pattern { pattern, .. } => Ok(pattern_paint(&pattern)), + paint @ (Paint::Gradient(_) | Paint::Pattern { .. }) => Ok(stored_paint(paint, p)), }) .collect::<Result<Vec<_>>>()?; // A name applies to a single new swatch. @@ -220,6 +216,27 @@ fn swatch_new(s: &mut Session, p: &Value) -> Result<Value> { Ok(json!({ "name": names[0], "names": names })) } +/// A gradient or pattern `paint`, parsed from the paint params `p`, as a new or edited swatch +/// stores it. +fn stored_paint(paint: Paint, p: &Value) -> Paint { + match paint { + // A gradient given an `aspect` but no vector is placed on a box so that the swatch keeps + // the aspect, as `paint.setFill` places it on each object. + Paint::Gradient(ref g) if g.geom.is_none() && g.freeform.is_none() => { + match super::gradient::place_paint(&paint, p, Some(vectorcraft_geom::Rect::new(0.0, 0.0, 100.0, 100.0))) { + Paint::Gradient(g) => Paint::Gradient(Box::new(vectorcraft_color::GradientPaint { swatch: None, ..*g })), + other => other, + } + } + // The swatch holds the gradient itself, not a link to the swatch it may have come from. + // It keeps `geom`, which holds the aspect the swatch is applied with. + Paint::Gradient(g) => Paint::Gradient(Box::new(vectorcraft_color::GradientPaint { swatch: None, ..*g })), + // The swatch holds the pattern untransformed, not the placement of the art it came from. + Paint::Pattern { pattern, .. } => pattern_paint(&pattern), + other => other, + } +} + /// The `names` list and `name` parameters, without repeats; at least one is required. pub(super) fn names_param(p: &Value, cmd: &str) -> Result<Vec<String>> { let mut seen: HashSet<String> = HashSet::new(); @@ -866,12 +883,21 @@ fn swatch_edit(s: &mut Session, p: &Value) -> Result<Value> { } // A replacement paint of the swatch's kind (a dropped colour or edited gradient). let paint = match p.get("paint").filter(|v| !v.is_null()) { - Some(v) => match (if given("mode") { paint_from(s, &keeping_model(v))? } else { paint_from(s, v)? }, &sw.paint) { + Some(v) => match ( + // A pattern by name, as `swatch.new` takes it. + match str_param(v, "pattern") { + Some(pat) if d.pattern(pat).is_some() => Some(pattern_paint(pat)), + Some(pat) => return Err(bad(C, format!("no pattern `{pat}`"))), + None if given("mode") => paint_from(s, &keeping_model(v))?, + None => paint_from(s, v)?, + }, + &sw.paint, + ) { (Some(Paint::Solid { color, .. }), Paint::Solid { .. }) => Some(Paint::solid(color)), - (Some(Paint::Gradient(g)), Paint::Gradient(_)) => { - Some(Paint::Gradient(Box::new(vectorcraft_color::GradientPaint { geom: None, swatch: None, ..*g }))) + // Stored as `swatch.new` stores it. + (Some(new @ Paint::Gradient(_)), Paint::Gradient(_)) | (Some(new @ Paint::Pattern { .. }), Paint::Pattern { .. }) => { + Some(stored_paint(new, v)) } - (Some(new @ Paint::Pattern { .. }), Paint::Pattern { .. }) => Some(new), _ => return Err(bad(C, format!("`{name}` takes a paint of its own kind (colour, gradient or pattern)"))), }, None => None, diff --git a/crates/engine/src/tests/swatchlib.rs b/crates/engine/src/tests/swatchlib.rs index 445ce38ea7..dbf32eba7c 100644 --- a/crates/engine/src/tests/swatchlib.rs +++ b/crates/engine/src/tests/swatchlib.rs @@ -636,6 +636,114 @@ fn gradient_libraries_are_listed_and_gradient_swatches_rename_and_take_new_gradi assert_eq!(doc(&s).swatch("Red").unwrap().paint.color().map(|c| c.to_hex()), Some("#00ff00".into())); } +/// A radial gradient from red to blue, with `extra` keys. +fn radial_gradient(extra: Value) -> Value { + let mut g = json!({"kind": "radial", "stops": [{"offset": 0, "color": "#ff0000"}, {"offset": 1, "color": "#0000ff"}]}); + if let (Some(g), Some(extra)) = (g.as_object_mut(), extra.as_object()) { + g.extend(extra.clone()); + } + g +} + +/// The gradient swatch `name` keeps an aspect of 50%, holds no swatch link, and applies with that +/// aspect, fitted to the object it is applied to. +fn assert_swatch_applies_with_half_aspect(s: &mut Session, name: &str) { + let Paint::Gradient(sw) = &doc(s).swatch(name).unwrap().paint else { panic!("{name}: a gradient swatch") }; + assert!(sw.geom.is_some_and(|g| (g.aspect - 0.5).abs() < 1e-9), "{name} keeps the aspect: {:?}", sw.geom); + assert_eq!(sw.swatch, None, "{name} holds no link to the swatch its gradient came from"); + let r = run(s, "shape.rectangle", json!({"x": 100, "y": 0, "width": 100, "height": 60})); + let id = r["id"].as_u64().unwrap(); + run(s, "paint.setFill", json!({"ids": [id], "swatch": name})); + let fill = doc(s).node(vectorcraft_doc::NodeId(id)).unwrap().appearance.fill_paint(); + let Paint::Gradient(g) = fill else { panic!("{name}: a gradient fill") }; + let geom = g.geom.unwrap(); + assert!( + geom.start.distance(vectorcraft_geom::Point::new(150.0, 30.0)) < 1e-9 && (geom.aspect - 0.5).abs() < 1e-9, + "{name} fits the object with its aspect: {geom:?}" + ); +} + +/// An edited gradient with a vector and an aspect that replaces a gradient swatch keeps its aspect, +/// as a new swatch made from it does. +#[test] +fn a_gradient_swatch_takes_an_edited_gradient_with_its_aspect() { + let mut s = session(); + run(&mut s, "swatch.new", json!({"name": "Edited", "gradient": radial_gradient(json!({}))})); + let placed = radial_gradient(json!({"start": [25, 25], "end": [50, 25], "aspect": 50})); + run(&mut s, "swatch.edit", json!({"name": "Edited", "paint": {"gradient": placed}})); + assert_swatch_applies_with_half_aspect(&mut s, "Edited"); +} + +/// A gradient swatch Alt-dropped on another gradient swatch gives it its gradient with its aspect. +#[test] +fn a_gradient_swatch_takes_a_dropped_swatch_with_its_aspect() { + let mut s = session(); + run(&mut s, "swatch.new", json!({"name": "Dropped", "gradient": radial_gradient(json!({}))})); + let placed = radial_gradient(json!({"start": [25, 25], "end": [50, 25], "aspect": 50})); + run(&mut s, "swatch.new", json!({"name": "Oval", "gradient": placed})); + run(&mut s, "swatch.edit", json!({"name": "Dropped", "paint": {"swatch": "Oval"}})); + assert_swatch_applies_with_half_aspect(&mut s, "Dropped"); +} + +/// A gradient given an aspect but no vector keeps the aspect in a new swatch and in a replacement, +/// as `paint.setFill` keeps it on the object. +#[test] +fn a_gradient_without_a_vector_keeps_its_aspect_in_a_swatch() { + let mut s = session(); + let oval = radial_gradient(json!({"aspect": 50})); + run(&mut s, "swatch.new", json!({"name": "New", "gradient": oval})); + assert_swatch_applies_with_half_aspect(&mut s, "New"); + run(&mut s, "swatch.new", json!({"name": "Edited", "gradient": radial_gradient(json!({}))})); + run(&mut s, "swatch.edit", json!({"name": "Edited", "paint": {"gradient": oval}})); + assert_swatch_applies_with_half_aspect(&mut s, "Edited"); + // Without an aspect the swatch stays unplaced. + run(&mut s, "swatch.new", json!({"name": "Round", "gradient": radial_gradient(json!({}))})); + let Paint::Gradient(round) = &doc(&s).swatch("Round").unwrap().paint else { panic!("a gradient swatch") }; + assert_eq!(round.geom, None); +} + +/// A pattern that replaces a pattern swatch is stored untransformed, as a new swatch stores it, so +/// art the swatch is applied to keeps its own tile placement. +#[test] +fn a_pattern_swatch_takes_a_new_pattern_untransformed() { + let mut s = session(); + for (name, color) in [("Dots", "#ff0000"), ("Bars", "#0000ff")] { + let r = run(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})); + run(&mut s, "paint.setFill", json!({"ids": [r["id"]], "color": color})); + run(&mut s, "select.set", json!({"ids": [r["id"]]})); + run(&mut s, "object.pattern.make", json!({"name": name, "width": 20, "height": 20})); + run(&mut s, "object.pattern.done", json!({})); + } + // A pattern swatch holding a tile transform, as documents saved by older versions can. + let moved = vectorcraft_geom::Affine::new([2.0, 0.0, 0.0, 2.0, 15.0, 10.0]); + let st = s.doc_mut().unwrap(); + let Some(Paint::Pattern { xf, .. }) = std::sync::Arc::make_mut(&mut st.doc).swatch_mut("Bars").map(|w| &mut w.paint) else { + panic!("the Bars pattern swatch") + }; + *xf = moved; + run(&mut s, "swatch.edit", json!({"name": "Dots", "paint": {"swatch": "Bars"}})); + assert_eq!(doc(&s).swatch("Dots").unwrap().paint, vectorcraft_doc::pattern::pattern_paint("Bars")); +} + +/// A pattern swatch takes a pattern given by name, as an Alt-drop of a pattern fill sends it, and +/// an unknown pattern is an error that leaves the swatch as it was. +#[test] +fn a_pattern_swatch_takes_a_pattern_by_name() { + let mut s = session(); + for (name, color) in [("Dots", "#ff0000"), ("Bars", "#0000ff")] { + let r = run(&mut s, "shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})); + run(&mut s, "paint.setFill", json!({"ids": [r["id"]], "color": color})); + run(&mut s, "select.set", json!({"ids": [r["id"]]})); + run(&mut s, "object.pattern.make", json!({"name": name, "width": 20, "height": 20})); + run(&mut s, "object.pattern.done", json!({})); + } + run(&mut s, "swatch.edit", json!({"name": "Dots", "paint": {"pattern": "Bars"}})); + assert_eq!(doc(&s).swatch("Dots").unwrap().paint, vectorcraft_doc::pattern::pattern_paint("Bars")); + let before = doc(&s).swatch("Dots").unwrap().paint.clone(); + assert!(s.execute("swatch.edit", &json!({"name": "Dots", "paint": {"pattern": "Nope"}})).is_err()); + assert_eq!(doc(&s).swatch("Dots").unwrap().paint, before); +} + #[test] fn organic_fades_add_with_their_method_midpoints_and_opacities_in_rgb_and_cmyk() { let lib = vectorcraft_color::libraries::builtin_library("organic-fades").unwrap(); diff --git a/docs/mcp.md b/docs/mcp.md index ca77311c58..fd6f17526c 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -876,13 +876,15 @@ Errors (unknown tool, bad arguments, a disabled or failing command) come back as `isError: true` and a message. The model can read the message and retry. Swatches go through `run_command`: `swatch.list` lists every swatch with its colour group, kind and colour; -`swatch.edit {name, newName?, color?, mode?, global?, spot?}` edits one (fills, strokes and text linked to a +`swatch.edit {name, newName?, color?, mode?, global?, spot?, paint?}` edits one (fills, strokes and text linked to a global or spot swatch follow its colour and name, as one undo step, in the art, opacity masks, symbols, graph -designs, pattern tiles, graphic styles and the art of brushes); `swatch.delete {names, unlink?}` deletes +designs, pattern tiles, graphic styles and the art of brushes). A replacement colour, gradient or pattern given as +`paint` (`{color}`, `{gradient}`, `{swatch}` or `{pattern: name}`) is stored as `swatch.new` stores it; +`swatch.delete {names, unlink?}` deletes swatches and colour groups in one undo step (art using a deleted global swatch keeps its colour, unlinked). `swatch.new {color?, mode?, spot?, global?, group?}` saves a colour (into a colour group with `group`), gradient -or pattern (a gradient swatch holds no link to the swatch its gradient came from, and a pattern swatch holds the -pattern untransformed); `swatch.newGroup {fromArtwork: true, toGlobal?, includeTints?}` makes a colour group of the selected +or pattern (a gradient swatch keeps the gradient's aspect, with or without `start` and `end`, and holds no link to +the swatch its gradient came from, and a pattern swatch holds the pattern untransformed); `swatch.newGroup {fromArtwork: true, toGlobal?, includeTints?}` makes a colour group of the selected art's colours (by default as global swatches the art links to). `swatch.move {names, to?, group?}` reorders swatches or moves them into or out of a colour group (as dragging them in the Swatches panel does); give colour group names instead to reorder the groups. Dropping a swatch on art From 6ab46b5fd8542986c2d58eab759e10a846a09b6d Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:46:10 -0800 Subject: [PATCH 103/108] Print: a spot gradient stop prints its process plates on the separations A gradient stop linked to a spot ink that also carries process plates (a DeviceN stop opened from a PDF) printed only its spot tint: print separations and Separations Preview left its Cyan, Magenta, Yellow and Black plates blank. They now print the stop's plates beside the tint. With spots printed as process, each process plate prints the stop's plate layered with the spot tint's process equivalent, as a separated image's spot plates layer. Plates beside no spot link, or beside Registration, still print nothing of their own. The color visitor also skipped a freeform gradient's points, so print plates kept their display colors and Document Color Mode left them unconverted. The points are now visited as unlinked colors. --- crates/doc/src/inks.rs | 113 ++++++++++++++++++++++++--- crates/engine/src/tests/colormgmt.rs | 20 +++++ crates/pdf/src/print/plates.rs | 29 ++++++- crates/pdf/src/tests/print.rs | 66 +++++++++++++++- crates/render/src/proof.rs | 10 ++- crates/render/src/tests/colorize.rs | 29 +++++++ docs/target-app-parity.md | 1 + 7 files changed, 246 insertions(+), 22 deletions(-) diff --git a/crates/doc/src/inks.rs b/crates/doc/src/inks.rs index e10c424ee9..a9fa5f3f80 100644 --- a/crates/doc/src/inks.rs +++ b/crates/doc/src/inks.rs @@ -94,25 +94,45 @@ pub fn inks(doc: &Document, c: &Cms, color: &Color, link: Link, intent: Intent) Inks { cmyk: c.to_cmyk(color, intent), spot: None, registration: false } } -/// Visits one colour: the colour, its swatch link and its tint, all of which it may change. -pub type ColorVisitor<'a> = dyn FnMut(&mut Color, &mut Option<String>, &mut f32) + 'a; +/// Process plates a colour prints together with its spot tint (C, M, Y, K, 0..1): a gradient +/// stop's [`vectorcraft_color::GradientStop::plates`]; `None` for every other colour. +pub type StopPlates = Option<[f32; 4]>; + +/// [`inks`] of a colour that may print process plates `plates` with its spot tint. The plates +/// print only beside a spot ink: a colour without a valid spot link, or linked to Registration, +/// prints as [`inks`] separates it. A plate amount that is not a finite number prints no ink. +pub fn stop_inks(doc: &Document, c: &Cms, color: &Color, link: Link, plates: StopPlates, intent: Intent) -> Inks { + let mut ink = inks(doc, c, color, link, intent); + if let (Some(p), Some(_)) = (plates, &ink.spot) { + ink.cmyk = p.map(|v| if v.is_finite() { v.clamp(0.0, 1.0) } else { 0.0 }); + } + ink +} + +/// Visits one colour: the colour, its swatch link, its tint and its process plates +/// ([`StopPlates`]), all of which it may change. +pub type ColorVisitor<'a> = dyn FnMut(&mut Color, &mut Option<String>, &mut f32, &mut StopPlates) + 'a; fn visit_paint(p: &mut Paint, f: &mut ColorVisitor) { match p { - Paint::Solid { color, swatch, tint } => f(color, swatch, tint), + Paint::Solid { color, swatch, tint } => f(color, swatch, tint, &mut None), Paint::Gradient(g) => { for s in &mut g.gradient.stops { - f(&mut s.color, &mut s.swatch, &mut s.tint); + f(&mut s.color, &mut s.swatch, &mut s.tint, &mut s.plates); + } + for p in g.freeform.iter_mut().flat_map(|ff| ff.points.iter_mut()) { + f(&mut p.color, &mut None, &mut 1.0, &mut None); } } _ => {} } } -/// Visit every colour of a node tree (fills, strokes, gradient stops, text runs, mesh points, an -/// image's colorize color, the fills and strokes a dynamic symbol instance keeps for objects of its -/// art, not opacity masks) with its swatch link and tint. Mesh points have no link: changes to it -/// are dropped. +/// Visit every colour of a node tree (fills, strokes, gradient stops, a freeform gradient's +/// points, text runs, mesh points, an image's colorize color, the fills and strokes a dynamic +/// symbol instance keeps for objects of its art, not opacity masks) with its swatch link, tint and +/// process plates. Freeform and mesh points have no link or plates: a link or plates `f` gives +/// them are dropped. pub fn visit_node_colors(n: &mut Node, f: &mut ColorVisitor) { for it in &mut n.appearance.items { match it { @@ -137,7 +157,7 @@ pub fn visit_node_colors(n: &mut Node, f: &mut ColorVisitor) { } NodeKind::Mesh(m) => { for p in &mut m.points { - f(&mut p.color, &mut None, &mut 1.0); + f(&mut p.color, &mut None, &mut 1.0, &mut None); } } _ => {} @@ -149,11 +169,16 @@ pub fn visit_node_colors(n: &mut Node, f: &mut ColorVisitor) { } } -/// Apply `f` to every colour of a node tree (fills, strokes, gradient stops, text runs, mesh -/// points, a dynamic symbol instance's own fills and strokes) given its swatch link and tint, -/// keeping the links. +/// Apply `f` to every colour of a node tree (fills, strokes, gradient stops, a freeform +/// gradient's points, text runs, mesh points, a dynamic symbol instance's own fills and strokes) +/// given its swatch link and tint, keeping the links and process plates. pub fn map_node_colors(n: &mut Node, f: &mut dyn FnMut(&Color, Link) -> Color) { - visit_node_colors(n, &mut |c, swatch, tint| *c = f(c, swatch.as_deref().map(|s| (s, *tint)))); + map_node_inks(n, &mut |c, link, _| f(c, link)); +} + +/// [`map_node_colors`], with each colour's process plates ([`StopPlates`]) passed to `f` too. +pub fn map_node_inks(n: &mut Node, f: &mut dyn FnMut(&Color, Link, StopPlates) -> Color) { + visit_node_colors(n, &mut |c, swatch, tint, plates| *c = f(c, swatch.as_deref().map(|s| (s, *tint)), *plates)); } /// Apply `f` to every colour in the document's art and symbol definitions. @@ -170,8 +195,70 @@ pub fn map_document_colors(doc: &mut Document, f: &mut dyn FnMut(&Color, Link) - mod tests { use super::*; use crate::{NodeId, SymbolOverride}; + use vectorcraft_color::{Freeform, FreeformPoint, Gradient, GradientKind, GradientPaint, GradientStop, Swatch}; use vectorcraft_geom::Affine; + /// A document with spot swatch `Gold` and process swatch `Teal`. + fn gold_doc() -> Document { + let mut d = Document::new(100.0, 100.0); + d.swatches.push(Swatch { name: "Gold".into(), paint: Paint::solid(Color::cmyk(0.0, 0.2, 0.8, 0.1)), global: true, spot: true }); + d.swatches.push(Swatch { name: "Teal".into(), paint: Paint::solid(Color::cmyk(0.8, 0.0, 0.3, 0.0)), global: true, spot: false }); + d + } + + #[test] + fn a_spot_stops_process_plates_print_with_its_tint() { + let d = gold_doc(); + let c = vectorcraft_color::cms::active(); + let look = Color::cmyk(0.25, 0.1, 0.8, 0.05); + let ink = |link: Link, plates: StopPlates| stop_inks(&d, &c, &look, link, plates, Intent::RelativeColorimetric); + let mixed = ink(Some(("Gold", 0.5)), Some([0.25, 0.0, 0.4, 0.0])); + assert_eq!(mixed, Inks { cmyk: [0.25, 0.0, 0.4, 0.0], spot: Some(("Gold".into(), 0.5)), registration: false }); + assert_eq!((mixed.on_plate("Cyan"), mixed.on_plate("Gold")), (0.25, 0.5)); + // Amounts outside 0..1 are clamped; one that is not a number prints no ink. + let odd = ink(Some(("Gold", 1.0)), Some([f32::NAN, 2.0, -1.0, f32::INFINITY])); + assert_eq!(odd.cmyk, [0.0, 1.0, 0.0, 0.0]); + // Without plates the spot ink prints alone, as `inks` separates it. + assert_eq!(ink(Some(("Gold", 0.5)), None), inks(&d, &c, &look, Some(("Gold", 0.5)), Intent::RelativeColorimetric)); + // Plates beside no spot ink print nothing of their own: a process swatch, an unknown + // swatch, no link and Registration separate as `inks` does. + for link in [Some(("Teal", 1.0)), Some(("Missing", 1.0)), None, Some((REGISTRATION, 0.5))] { + assert_eq!(ink(link, Some([0.25, 0.0, 0.4, 0.0])), inks(&d, &c, &look, link, Intent::RelativeColorimetric), "{link:?}"); + } + } + + #[test] + fn gradient_stops_pass_their_plates_and_freeform_points_are_visited() { + let mut stop = GradientStop::new(0.0, Color::cmyk(0.25, 0.1, 0.8, 0.05)); + (stop.swatch, stop.tint, stop.plates) = (Some("Gold".into()), 0.5, Some([0.25, 0.0, 0.4, 0.0])); + let mut g = GradientPaint::new(Gradient::new(GradientKind::Linear, vec![stop, GradientStop::new(1.0, Color::rgb(1.0, 1.0, 1.0))])); + let point = FreeformPoint::new(kurbo::Point::new(10.0, 10.0), Color::rgb(0.0, 1.0, 0.0)); + g.freeform = Some(Freeform { points: vec![point], ..Default::default() }); + let mut n = Node::path( + NodeId(1), + vectorcraft_geom::shapes::rectangle(vectorcraft_geom::Rect::new(0.0, 0.0, 10.0, 10.0)), + crate::Appearance::basic(Paint::Gradient(Box::new(g)), Paint::None, 0.0), + ); + let mut seen = vec![]; + let gray = Color::Gray { k: 0.5 }; + map_node_inks(&mut n, &mut |c, link, plates| { + seen.push((*c, link.map(|(s, t)| (s.to_string(), t)), plates)); + gray + }); + assert_eq!( + seen, + vec![ + (Color::cmyk(0.25, 0.1, 0.8, 0.05), Some(("Gold".to_string(), 0.5)), Some([0.25, 0.0, 0.4, 0.0])), + (Color::rgb(1.0, 1.0, 1.0), None, None), + (Color::rgb(0.0, 1.0, 0.0), None, None), + ] + ); + let Some(Paint::Gradient(g)) = n.appearance.fill().map(|f| f.paint.clone()) else { panic!("no gradient fill") }; + assert_eq!(g.gradient.stops[0].plates, Some([0.25, 0.0, 0.4, 0.0]), "mapping a colour keeps its plates"); + assert!(g.gradient.stops.iter().all(|s| s.color == gray)); + assert_eq!(g.freeform.map(|f| f.points[0].color), Some(gray), "the freeform point is mapped too"); + } + #[test] fn a_dynamic_instances_own_fills_and_strokes_are_visited() { let red = Color::rgb(1.0, 0.0, 0.0); diff --git a/crates/engine/src/tests/colormgmt.rs b/crates/engine/src/tests/colormgmt.rs index 493f569805..99d099f68d 100644 --- a/crates/engine/src/tests/colormgmt.rs +++ b/crates/engine/src/tests/colormgmt.rs @@ -184,6 +184,26 @@ fn rgb_cmyk_converts_each_gradient_stop() { } } +/// Each point of a freeform gradient converts on its own, as gradient stops do. +#[test] +fn rgb_cmyk_converts_each_freeform_point() { + let _g = GLOBAL.lock().unwrap_or_else(|e| e.into_inner()); + let mut s = session(); + let id = rect(&mut s, 10.0, 10.0, 50.0, 50.0, json!("#000000")); + let stops = json!([{"offset": 0, "color": Color::rgb(0.912_345, 0.1, 0.2)}, {"offset": 1, "color": Color::rgb(0.3, 0.4, 0.654_321)}]); + let points = json!([{"at": [20, 20], "color": Color::rgb(0.2, 0.876_543, 0.3)}, {"at": [50, 50], "color": Color::rgb(0.6, 0.111_111, 0.9)}]); + let gradient = json!({"kind": "freeform", "stops": stops, "freeform": {"points": points}}); + s.execute("paint.setFill", &json!({"ids": [id.0], "gradient": gradient})).unwrap(); + let points = |s: &Session| match fill_of(s, id) { + Paint::Gradient(g) => g.freeform.map(|f| f.points.iter().map(|p| p.color).collect::<Vec<_>>()).unwrap_or_default(), + p => panic!("not a gradient: {p:?}"), + }; + let old = points(&s); + assert!(!old.is_empty(), "the freeform fill has points"); + s.execute("object.convertDocumentColorMode", &json!({"mode": "cmyk"})).unwrap(); + assert_eq!(points(&s), old.into_iter().map(to_cmyk).collect::<Vec<_>>()); +} + /// A pattern's tile art converts, and the art filled with the pattern keeps it. #[test] fn rgb_cmyk_converts_a_pattern_tile() { diff --git a/crates/pdf/src/print/plates.rs b/crates/pdf/src/print/plates.rs index ce6c5b336e..8b0876d9f3 100644 --- a/crates/pdf/src/print/plates.rs +++ b/crates/pdf/src/print/plates.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use vectorcraft_color::Color; use vectorcraft_color::cms::{self, Cms, Model, ProfileKind}; use vectorcraft_color::swatch::REGISTRATION; -use vectorcraft_doc::inks::{Link, inks, plates, visit_node_colors}; +use vectorcraft_doc::inks::{Link, StopPlates, inks, plates, spot_color, stop_inks, visit_node_colors}; use vectorcraft_doc::overprint::darken_overprints; use vectorcraft_doc::{ColorMode, Document, ImageBlob, Node, NodeKind}; @@ -101,12 +101,33 @@ impl<'a> Separator<'a> { inks(self.doc, &self.cms, c, link, color.intent).on_plate(plate) } - /// Recolour `n`'s subtree as plate `plate`: the grey of each colour's coverage, unlinked. + /// [`Self::ink`] of a colour that prints process plates `plates` with its spot tint + /// ([`stop_inks`]): the spot plate prints the tint and the process plates print `plates`. With + /// spots as process, each process plate prints `plates` layered with the spot tint's process + /// equivalent, as a separated image's plates layer ([`vectorcraft_doc::separated::Separated::coverage_as`]). + fn stop_ink(&self, plate: &str, c: &Color, link: Link, plates: StopPlates) -> f32 { + let own = stop_inks(self.doc, &self.cms, c, link, plates, self.set.color.intent); + let (Some(_), Some((name, tint))) = (plates, own.spot.as_ref()) else { + return self.ink(plate, c, link); + }; + if !self.set.output.spots_to_process { + return own.on_plate(plate); + } + let Some(i) = cms::PROCESS_PLATES.iter().position(|p| *p == plate) else { + return 0.0; + }; + let spot = spot_color(self.doc, name).map_or(0.0, |s| self.ink(plate, &s.tinted(*tint), None)); + 1.0 - (1.0 - own.cmyk[i]) * (1.0 - spot) + } + + /// Recolour `n`'s subtree as plate `plate`: the grey of each colour's coverage, unlinked and + /// without process plates. pub fn node(&self, plate: &str, n: &mut Node) { - visit_node_colors(n, &mut |c, swatch, tint| { - *c = Color::Gray { k: self.ink(plate, c, swatch.as_deref().map(|s| (s, *tint))) }; + visit_node_colors(n, &mut |c, swatch, tint, plates| { + *c = Color::Gray { k: self.stop_ink(plate, c, swatch.as_deref().map(|s| (s, *tint)), *plates) }; *swatch = None; *tint = 1.0; + *plates = None; }); } diff --git a/crates/pdf/src/tests/print.rs b/crates/pdf/src/tests/print.rs index 5c5e1eb2c0..155912c124 100644 --- a/crates/pdf/src/tests/print.rs +++ b/crates/pdf/src/tests/print.rs @@ -4,7 +4,7 @@ use std::sync::Arc; use serde_json::json; -use vectorcraft_color::{Color, Paint, Swatch}; +use vectorcraft_color::{Color, Freeform, FreeformPoint, Gradient, GradientKind, GradientPaint, GradientStop, Paint, Swatch}; use vectorcraft_doc::{Appearance, Artboard, Document, LayerColor, Node, NodeKind}; use vectorcraft_geom::{Rect, shapes}; use vectorcraft_testkit::raster::render_region; @@ -536,6 +536,70 @@ fn cmyk_and_a_spot_separate_into_five_plates() { assert_eq!(inks(&p[2]), [0.0, 40.0], "the gold's yellow"); } +/// A 100 pt CMYK document with spot swatch `Gold` and a square filled with gradient `g`. +fn gold_gradient_doc(g: GradientPaint) -> Document { + let mut d = doc(100.0, 100.0, &[(Rect::new(0.0, 0.0, 50.0, 50.0), Paint::Gradient(Box::new(g)))]); + d.color_mode = vectorcraft_doc::ColorMode::Cmyk; + d.swatches.push(Swatch { name: "Gold".into(), paint: Paint::solid(Color::cmyk(0.0, 0.2, 0.8, 0.1)), global: true, spot: true }); + d +} + +/// The grey of each plate of a separation of `d` (job options `v`), in percent: of the first +/// gradient stop, and of the first freeform point when there is one. No plate keeps a link or +/// process plates. +fn gradient_plates(d: &Document, v: serde_json::Value) -> Vec<(f32, Option<f32>)> { + let opts = PrintOptions { settings: settings(v), ..Default::default() }; + let gray = |c: &Color| match c { + Color::Gray { k } => (k * 100.0).round(), + c => panic!("{c:?}"), + }; + let plan = plan(d, &opts).unwrap(); + plan.plates + .iter() + .map(|p| { + let mut found = vec![]; + p.walk(|n| { + if let Some(Paint::Gradient(g)) = n.appearance.fill().map(|f| &f.paint) { + let s = &g.gradient.stops[0]; + assert_eq!((s.swatch.as_deref(), s.tint, s.plates), (None, 1.0, None), "the stop is unlinked"); + found.push((gray(&s.color), g.freeform.as_ref().and_then(|f| f.points.first()).map(|q| gray(&q.color)))); + } + }); + assert_eq!(found.len(), 1); + found[0] + }) + .collect() +} + +#[test] +fn a_spot_gradient_stop_prints_its_process_plates() { + let mut mixed = GradientStop::new(0.0, Color::cmyk(0.25, 0.1, 0.8, 0.05)); + (mixed.swatch, mixed.tint, mixed.plates) = (Some("Gold".into()), 0.5, Some([0.25, 0.0, 0.4, 0.0])); + let g = GradientPaint::new(Gradient::new(GradientKind::Linear, vec![mixed, GradientStop::new(1.0, Color::cmyk(0.0, 0.0, 0.0, 0.0))])); + let d = gold_gradient_doc(g); + let first = |v| gradient_plates(&d, v).into_iter().map(|(s, _)| s).collect::<Vec<_>>(); + assert_eq!(first(json!({"output": {"mode": "separations"}})), [25.0, 0.0, 40.0, 0.0, 50.0], "Cyan, Magenta, Yellow, Black, Gold"); + // Spots as process: the plates layered with the gold tint's process inks (0, 10, 40, 5). + assert_eq!(first(json!({"output": {"mode": "separations", "spotsToProcess": true}})), [25.0, 10.0, 64.0, 5.0]); +} + +#[test] +fn a_freeform_gradients_points_separate_into_plates() { + let mut g = GradientPaint::new(Gradient::new(GradientKind::Freeform, vec![GradientStop::new(0.0, Color::cmyk(0.0, 0.0, 0.0, 1.0))])); + let point = FreeformPoint::new(vectorcraft_geom::Point::new(25.0, 25.0), Color::cmyk(0.0, 0.6, 0.0, 0.0)); + g.freeform = Some(Freeform { points: vec![point], ..Default::default() }); + let d = gold_gradient_doc(g); + let set = json!({"output": {"mode": "separations"}}); + let points = gradient_plates(&d, set.clone()).into_iter().map(|(_, p)| p).collect::<Vec<_>>(); + assert_eq!(points, [Some(0.0), Some(60.0), Some(0.0), Some(0.0), Some(0.0)], "the point's magenta, on its plate only"); + // Each plate draws the square in the grey of the point's ink on it. + let plan = plan(&d, &PrintOptions { settings: settings(set), ..Default::default() }).unwrap(); + let drawn: Vec<u8> = plan.plates.iter().map(|p| render_region(p, Rect::new(0.0, 0.0, 50.0, 50.0), 1.0).over_white(25, 25)[0]).collect(); + for (plate, (v, ink)) in drawn.iter().zip([0.0, 0.6, 0.0, 0.0, 0.0]).enumerate() { + assert!((f32::from(*v) - 255.0 * (1.0 - ink)).abs() <= 3.0, "plate {plate}: {drawn:?}"); + } +} + #[test] fn trim_marks_surround_the_artboard_on_the_paper() { let d = doc(200.0, 100.0, &[(Rect::new(0.0, 0.0, 200.0, 100.0), rgb(1.0, 0.0, 0.0))]); diff --git a/crates/render/src/proof.rs b/crates/render/src/proof.rs index a6736b022d..284ad8ce5d 100644 --- a/crates/render/src/proof.rs +++ b/crates/render/src/proof.rs @@ -4,7 +4,8 @@ //! space (CMYK press or RGB/colour-blindness simulation) → display, through a cached 17³ LUT. //! * **Separations Preview** recolours the *document* before rendering: each paint colour is split //! into process inks (colour-managed), or a spot ink at the colour's tint when it's linked to a -//! spot swatch (solid colours and gradient stops alike). With one plate visible the plate +//! spot swatch (solid colours and gradient stops alike), with the process plates a gradient stop +//! prints beside its spot ink ([`vectorcraft_color::GradientStop::plates`]). With one plate visible the plate //! renders as greyscale ink coverage (black = 100%); with several, the visible inks are //! composited through the proof profile, spots multiplied on top. Colours linked to the //! Registration swatch print their tint on every plate, spot plates included. @@ -29,6 +30,7 @@ use vectorcraft_color::cms::{self, Cms, CmykLut, PROCESS_PLATES, ProofLut, lab}; pub use vectorcraft_color::cms::{Intent, ProofSetup, ProofTarget}; use vectorcraft_color::{Color, Swatch, SwatchGroup}; pub use vectorcraft_doc::inks::{Inks, Link, Plate, inks, map_document_colors, map_node_colors, plates, spot_color}; +use vectorcraft_doc::inks::{StopPlates, map_node_inks, stop_inks}; use vectorcraft_doc::overprint::darken_overprints; use vectorcraft_doc::{Document, ImageBlob, Node, NodeId, Shared}; use vello_cpu::Pixmap; @@ -59,8 +61,8 @@ fn plate_rgb(c: &Cms, proof: &ProofSetup, visible: &[String], ink: &Inks) -> [f3 c.proof_cmyk_to_srgb(cmyk, proof) } -fn plate_color(doc: &Document, c: &Cms, proof: &ProofSetup, visible: &[String], color: &Color, link: Link) -> Color { - let ink = inks(doc, c, color, link, proof.intent); +fn plate_color(doc: &Document, c: &Cms, proof: &ProofSetup, visible: &[String], color: &Color, link: Link, plates: StopPlates) -> Color { + let ink = stop_inks(doc, c, color, link, plates, proof.intent); let mut rgb = plate_rgb(c, proof, visible, &ink); // Over several plates the visible spot inks print on top. for name in visible.iter().filter(|v| visible.len() != 1 && !PROCESS_PLATES.contains(&v.as_str())) { @@ -355,7 +357,7 @@ impl How<'_> { fn apply(&self, a: &mut Arc<Node>) { darken_overprints(a, self.discard_white); if let Some((c, proof, visible)) = self.plates { - map_node_colors(Arc::make_mut(a), &mut |col, sw| plate_color(self.doc, c, proof, visible, col, sw)); + map_node_inks(Arc::make_mut(a), &mut |col, sw, plates| plate_color(self.doc, c, proof, visible, col, sw, plates)); } } } diff --git a/crates/render/src/tests/colorize.rs b/crates/render/src/tests/colorize.rs index 721707502d..8a8891c7da 100644 --- a/crates/render/src/tests/colorize.rs +++ b/crates/render/src/tests/colorize.rs @@ -289,6 +289,35 @@ fn separations_preview_keeps_a_reduced_dcs_plates_coverage() { assert!(p[..3].iter().all(|v| (100..=160).contains(v)), "half the ink, got {p:?}"); } +/// A gradient stop linked to a spot ink that prints process plates with it shows them on those +/// plates, and its tint on the spot plate. +#[test] +fn separations_preview_shows_a_spot_gradient_stops_process_plates() { + use vectorcraft_color::{Gradient, GradientKind, GradientPaint, GradientStop}; + let mut d = Document::new_with_mode(20.0, 20.0, vectorcraft_doc::ColorMode::Cmyk); + d.swatches.push(vectorcraft_color::Swatch { + name: "Gold".into(), + paint: Paint::solid(Color::cmyk(0.0, 0.2, 0.8, 0.1)), + global: true, + spot: true, + }); + let stop = |offset| { + let mut s = GradientStop::new(offset, Color::cmyk(0.25, 0.1, 0.8, 0.05)); + (s.swatch, s.tint, s.plates) = (Some("Gold".into()), 0.5, Some([0.25, 0.0, 0.4, 0.0])); + s + }; + let g = Paint::Gradient(Box::new(GradientPaint::new(Gradient::new(GradientKind::Linear, vec![stop(0.0), stop(1.0)])))); + let (layer, id) = (d.layers[0].id, d.alloc_id()); + let square = Node::path(id, shapes::rectangle(Rect::new(0.0, 0.0, 20.0, 20.0)), Appearance::basic(g, Paint::None, 0.0)); + d.insert(Some(layer), 0, square).unwrap(); + let gray = |plate: &str| Renderer::new().render(&d, 20, 20, Affine::IDENTITY, &separations(&[plate])).pixel(10, 10)[0]; + let near = |v: u8, ink: f32| (f32::from(v) - 255.0 * (1.0 - ink)).abs() <= 3.0; + for (plate, ink) in [("Cyan", 0.25), ("Magenta", 0.0), ("Yellow", 0.4), ("Black", 0.0), ("Gold", 0.5)] { + let v = gray(plate); + assert!(near(v, ink), "{plate}: {ink} of the ink, got {v}"); + } +} + /// Separations Preview showing `plates`, as the canvas draws it. fn separations(plates: &[&str]) -> RenderOptions { let proof = proof::ProofSetup { separations: Some(plates.iter().map(|p| p.to_string()).collect()), ..Default::default() }; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..42150a9f6f 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1634,6 +1634,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur PDF export measures each member of a plain group or layer once to leave out what is off the page: the group or layer is measured through its members (`Node::visual_of_members`), and each member uses that box when it is written. The elements of a knockout group are measured twice, once for the group's box and once to choose the elements on the page (`pdf/src/tests/measuring.rs` counts the measures). A local byte comparison with the previous build found identical output on one open path of 200,000 anchors, 20,000 rectangles in 200 groups of 100, 5,000 point type objects and a document of plain, see-through, clipping and knockout groups. The walk that writes link annotations measures only an object with a URL that opens and a clipping group (`links.rs`), and its output on a document of linked objects in plain and clipping groups is the same byte for byte as when it measured every object. Invisible text in a PDF (rendering mode 3, which carries a scanned page's recognized text over the scan) opens as type with no fill or stroke, a run of its own beside visible text on the same line; text that can't come in as type (opened as outlines, Type 3 fonts) is left out with a warning. PDF export, and printing, write characters with no fill or stroke as real text in rendering mode 3, so they draw nothing but stay selectable and searchable, also in PDF/X-1a and PDF/A-2b (#2675, `pdf/src/tests/import_fidelity.rs`, `pdf/src/tests/realtext.rs`). A PDF, or a `.ai` read through its PDF part, whose spot inks have the same values but different names opens with a spot swatch for each ink. The solid fills and strokes of paths and type, and the stops of gradients on paths, link to the swatch of the ink they are painted in, the points of a gradient mesh in one of these inks keep the ink's color, and PDF export writes each of these inks as its own separation (`pdf/src/tests/import_color.rs`). Paint in these inks inside pattern cells, soft masks and type 3 glyphs, and gradients on type in these inks, still import as RGB. Type in one of these inks can also import as RGB when type in another Separation or DeviceN ink is shown with no path drawn between them. The stops of an axial or radial shading in a DeviceN space that mixes one spot ink with process plates (a spot ink over a constant cyan, for example) link to the ink's swatch at its tint and keep the process plates, and PDF and EPS (Level 3) export write those stops in a DeviceN space of the ink and those plates, so the spot plate is not lost (#3235, `import_color::a_device_n_gradient_of_a_spot_ink_over_a_process_plate_keeps_both_inks`). Solid fills that mix a spot ink with process plates, and stops that mix several spot inks, still import as RGB, with the spot inks kept as swatches. + Print separations and Separations Preview print such a stop's process plates on the Cyan, Magenta, Yellow and Black plates beside its tint on the spot plate; with spots printed as process, each process plate prints the stop's plate layered with the spot tint's process equivalent. A freeform gradient's points separate into plates as its stops do, and converting the document's color mode converts them (`print::a_spot_gradient_stop_prints_its_process_plates`, `print::a_freeform_gradients_points_separate_into_plates`, `colorize::separations_preview_shows_a_spot_gradient_stops_process_plates`, `colormgmt::rgb_cmyk_converts_each_freeform_point`). A `.ai` or EPS opened from its editing data keeps both swatches when a pattern's name, or a named color's, is also another swatch's: a pattern's swatch named as a default swatch, a named color or a palette color becomes "Name 2", and a named color named as a gradient or pattern swatch of the palette becomes "Name 2", with the fills, strokes and gradient stops linked to it following it (`ai::tests::a_pattern_swatch_named_as_another_swatch_is_numbered`, `ai::tests::a_color_named_as_a_palette_gradient_or_pattern_is_numbered`). PDF export writes a linear or radial gradient that mixes a spot color with process colors, or two spot colors, as a DeviceN shading of the spot inks and the process inks its stops use, so each spot ink prints on its own plate; an off-center midpoint is written as a stop with the inks halfway between its two stops. A gradient that mixes a spot color with RGB or Lab colors is still written without the spot ink, with a warning. A CMYK document, or an export that converts colors to a CMYK destination profile, writes RGB and Lab stops in CMYK first (unless the export converts colors to an RGB destination profile), so there such a gradient, Classic or Perceptual, is written as a DeviceN shading that keeps the spot ink. A Perceptual gradient of spot inks is written as a Separation or DeviceN shading of the stops on its curve; a dithered gradient fill, and a Perceptual gradient with RGB or Lab stops other than white or more than 4,096 stops on its curve, are written as images in process colors, with a warning. A Lab spot color in such a shading is named by the same Separation space, with the Lab alternate, as its flat fills (`engine/src/tests/linked_stops.rs`, `engine/src/tests/labspots.rs`). PDF export writes a spot color named All or None (in a Separation space, the names of every plate and of no plate: [ISO 32000-1:2008](https://opensource.adobe.com/dc-acrobat-sdk-docs/pdfstandards/PDF32000_2008.pdf), 8.6.6.4) as the ink All Spot or None Spot (All Spot 2 and on when a spot swatch already has that name) in its fills, strokes, gradients, colorized images and Lab alternates; Registration still prints on every plate (`pdf/src/tests/output.rs`). From 3474f7d123659cc9ffde32f9882c3c1ca00ed839 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 04:54:25 -0800 Subject: [PATCH 104/108] Swatches: test Spot Colors options and Default Swatches replace in a batch swatch.spotOptions and swatch.resetDefaults {replace: true} rewrite the fill and stroke for new art through map_default_paints, which also runs for command.batch steps. Two tests now run each command on its own and as a batch step followed by a rectangle, and check that the default paints and the rectangles match: a Lab spot link keeps its tint and takes the Lab values or their CMYK equivalent in both directions, and a link to a swatch the replace removes is dropped while the color stays. Both tests fail when map_default_paints skips every interaction. The progress line for swatch steps in a batch names the two commands and the new tests. --- crates/engine/src/tests/swatches.rs | 46 +++++++++++++++++++++++++++-- docs/target-app-parity.md | 2 +- 2 files changed, 45 insertions(+), 3 deletions(-) diff --git a/crates/engine/src/tests/swatches.rs b/crates/engine/src/tests/swatches.rs index 8abaec348c..e59e9a90b1 100644 --- a/crates/engine/src/tests/swatches.rs +++ b/crates/engine/src/tests/swatches.rs @@ -1099,13 +1099,18 @@ fn fill_and_stroke(s: &Session, id: NodeId) -> (Paint, Paint) { /// in the batch, and one drawn after it, the same fill and stroke. Returns the batch's rectangle's /// fill and stroke. fn batch_matches_steps(steps: &[(&str, Value)]) -> (Paint, Paint) { + batch_matches_steps_from(brand_defaults_session, steps) +} + +/// [`batch_matches_steps`] with both sessions made by `setup`. +fn batch_matches_steps_from(setup: impl Fn() -> Session, steps: &[(&str, Value)]) -> (Paint, Paint) { let shape = ("shape.rectangle", json!({"x": 0, "y": 0, "width": 10, "height": 10})); - let mut one_by_one = brand_defaults_session(); + let mut one_by_one = setup(); for (id, p) in steps { run(&mut one_by_one, id, p.clone()); } let single = rect(&mut one_by_one); - let mut batched = brand_defaults_session(); + let mut batched = setup(); let commands: Vec<Value> = steps.iter().chain([&shape]).map(|(id, p)| json!({"command": id, "params": p})).collect(); let r = run(&mut batched, "command.batch", json!({ "commands": commands })); let in_batch = NodeId(r["results"][steps.len()]["id"].as_u64().unwrap()); @@ -1133,6 +1138,43 @@ fn swatch_steps_in_a_batch_change_the_new_art_paints_as_commands_do() { assert_eq!(batch_matches_steps(&[("swatch.editGroup", json!({"group": "G", "colors": ["#ababab"]}))]), (gray.clone(), gray)); } +#[test] +fn spot_colors_options_in_a_batch_change_the_new_art_paints_as_the_command_does() { + let _g = crate::tests_colormgmt::GLOBAL.lock().unwrap_or_else(|e| e.into_inner()); + let lab = Color::Lab { l: 55.0, a: 60.0, b: 40.0 }; + let cms = vectorcraft_color::cms::active(); + let cmyk = cms.convert(&lab, vectorcraft_color::cms::Model::Cmyk, cms.settings().intent); + assert!(matches!(cmyk, Color::Cmyk { .. })); + // The default fill and stroke for new art are linked to 40 % of the Lab spot swatch "Lab Ink". + let lab_ink_defaults = |use_lab: bool| { + let mut s = session(); + run(&mut s, "swatch.new", json!({"name": "Lab Ink", "color": {"l": 55, "a": 60, "b": 40}, "spot": true})); + run(&mut s, "swatch.spotOptions", json!({ "useLab": use_lab })); + run(&mut s, "select.set", json!({"ids": []})); + run(&mut s, "paint.setFill", json!({"swatch": "Lab Ink", "tint": 40})); + run(&mut s, "paint.setStroke", json!({"swatch": "Lab Ink", "tint": 40})); + s + }; + let ink = |color: Color| Paint::Solid { color: color.tinted(0.4), swatch: Some("Lab Ink".into()), tint: 0.4 }; + assert_eq!(lab_ink_defaults(true).paint.fill, ink(lab)); + let to_cmyk = [("swatch.spotOptions", json!({"useLab": false}))]; + assert_eq!(batch_matches_steps_from(|| lab_ink_defaults(true), &to_cmyk), (ink(cmyk), ink(cmyk))); + assert_eq!(lab_ink_defaults(false).paint.fill, ink(cmyk)); + let to_lab = [("swatch.spotOptions", json!({"useLab": true}))]; + assert_eq!(batch_matches_steps_from(|| lab_ink_defaults(false), &to_lab), (ink(lab), ink(lab))); +} + +#[test] +fn default_swatches_replace_in_a_batch_unlinks_the_new_art_paints_as_the_command_does() { + // Brand and Other are not default swatches, so replacing the swatches drops the links to them. + let blue = Paint::solid(Color::from_hex("#2a6fb0").unwrap()); + let replace = [("swatch.resetDefaults", json!({"replace": true}))]; + assert_eq!(batch_matches_steps(&replace), (blue.clone(), blue)); + // Without replace the swatches stay, and so do the links. + let link = linked("#2a6fb0", "Brand"); + assert_eq!(batch_matches_steps(&[("swatch.resetDefaults", json!({}))]), (link.clone(), link)); +} + #[test] fn undo_and_redo_of_a_swatch_edit_put_back_the_new_art_paints() { let edit = json!({"name": "Brand", "newName": "Signal", "color": "#00ff00"}); diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 7e36c7f318..df7e2a15c2 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1492,7 +1492,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **CSS swatch libraries:** fractional linear and radial gradient stop positions are preserved, so nearby stops such as 12.5% and 12.890625% remain distinct instead of collapsing to 13%. Reference: [CSS Images 3 color stops](https://www.w3.org/TR/css-images-3/#color-stop-syntax). The original synthetic regression is `palette_io::tests::css_preserves_fractional_gradient_stop_positions` in `crates/color/src/palette_io.rs`. Scores and hours are unchanged. - **Swatches:** names follow the colour model and are unique; Swatch Options (process/spot, Global, Gray/RGB/HSB/CMYK/Web, live preview); editing a global or spot swatch recolours every linked fill, stroke and text run in one undo step; multi-select and delete with confirmation; New Swatch and New Color Group dialogs (a group from the selected artwork's colours); swatches in colour groups convert, separate and count like any other. The Swatches panel selects ranges and whole groups, has a find field, and drags swatches to reorder, regroup or paint art; Add Used Colors, Select All Unused, Merge, Ungroup and Sort by Kind; a CMYK document keeps applied colours in CMYK. Swatch libraries: nine generated colour libraries, seven gradient libraries (among them Organic Fades, soft perceptually mixed multi-stop fades that thin out to transparent, and Holographic, seven opaque linear foils of narrow pastel and pearl bands and seven radial glows that fade out to a clear edge) and three pattern libraries (Geometric Patterns; Grit Textures with eight seamless grain, speckle, stipple, scratch and fleck tiles; and Optical Effects with eight of VectorCraft's own seamless wave, ring, warped-check, stripe, chevron and lens tiles; their swatches bring their patterns) in a library panel, saved as `.vcswatches`, `.gpl`, swatch exchange (`.ase`) or CSS, and loaded from `.vcswatches`, `.gpl` and `.ase` files (`.ase` both ways: RGB, CMYK, Lab and Gray; global, spot and process; groups) and from color books (`.acb`, read only: the RGB, CMYK or Lab colors of a book such as a Pantone book a user owns, named with its prefix and suffix, spot unless it says process, #831); `swatch.library.copyToUser` copies a loaded library into the User Defined folder without replacing a file, and a file with the same extension and bytes as a User Defined library opens as that library. Tints of global and spot colours ("Name 40%") stay linked and separate as a percentage of their plate. Spot colours can be defined in Lab (Spot Colors options). A built-in [Registration] swatch prints on every plate. Editing, renaming, deleting or merging a global swatch also changes the colors linked to it in graph designs, the art of brushes and the tile that pattern editing's Cancel puts back, in the same undo step as the rest of the art; Default Swatches with replace unlinks them there too. - A swatch step in `command.batch` (Delete, Swatch Options, Merge, Edit Color Group) changes the fill and stroke for new art as the command run on its own does, so art drawn later in the batch or after it takes the same paint; a batch that fails, and a canceled batch preview, put back the paints it started with, and a canceled Swatch Options preview leaves them as they were. These swatch commands also change the fills and strokes of the appearance new art takes, and Undo and Redo of the command or the batch put the paints for new art back with the swatches. Evidence: `swatch_steps_in_a_batch_change_the_new_art_paints_as_commands_do`, `undo_and_redo_of_a_swatch_edit_put_back_the_new_art_paints`, `swatch_edits_reach_the_paints_of_the_new_art_template`, `a_failed_batch_puts_back_the_new_art_paints_a_swatch_step_changed` and `canceling_a_swatch_options_preview_keeps_the_new_art_paints` in `crates/engine/src/tests/swatches.rs`. + A swatch step in `command.batch` (Delete, Swatch Options, Merge, Edit Color Group) changes the fill and stroke for new art as the command run on its own does, so art drawn later in the batch or after it takes the same paint; a batch that fails, and a canceled batch preview, put back the paints it started with, and a canceled Swatch Options preview leaves them as they were. These swatch commands also change the fills and strokes of the appearance new art takes, and Undo and Redo of the command or the batch put the paints for new art back with the swatches. Spot Colors options (`swatch.spotOptions`) and Default Swatches with replace (`swatch.resetDefaults {replace: true}`) as `command.batch` steps also change the fill and stroke for new art as each command run on its own does: a fill or stroke linked to a Lab spot swatch keeps its link and tint and takes the Lab values or their CMYK equivalent, and one linked to a swatch the replace removes keeps its color and loses the link. Evidence: `swatch_steps_in_a_batch_change_the_new_art_paints_as_commands_do`, `spot_colors_options_in_a_batch_change_the_new_art_paints_as_the_command_does`, `default_swatches_replace_in_a_batch_unlinks_the_new_art_paints_as_the_command_does`, `undo_and_redo_of_a_swatch_edit_put_back_the_new_art_paints`, `swatch_edits_reach_the_paints_of_the_new_art_template`, `a_failed_batch_puts_back_the_new_art_paints_a_swatch_step_changed` and `canceling_a_swatch_options_preview_keeps_the_new_art_paints` in `crates/engine/src/tests/swatches.rs`. Add Used Colors (`swatch.addUsedColors`) and Select All Unused (`swatch.unused`) look colors, swatch names, links, tints and gradients up in hash sets instead of searching every swatch and color for each color or linked paint (New Color Group from artwork too), and New Swatch with several colors (`swatch.new`), New Color Group (`swatch.newGroup`) and Edit Color Group (`swatch.editGroup`) name their new swatches from one set of the names already taken. The new swatches keep their names, order and links, and Select All Unused lists the same swatches. Evidence: `add_used_colors_adds_each_new_color_once_with_free_names`, `add_used_colors_global_links_every_paint_of_a_new_color`, `unused_matches_links_tints_colors_gradients_and_patterns_exactly`, `new_swatches_from_colors_are_numbered_after_names_already_taken`, `new_color_group_numbers_its_colors_after_the_group_and_its_moved_swatches`, `new_color_group_from_artwork_lists_each_color_once_with_free_names` and `edit_color_group_numbers_extra_colors_after_the_names_it_keeps` in `crates/engine/src/tests/swatchcmds.rs`; `free_swatch_names_match_naming_each_swatch_as_it_is_added` and `free_swatch_names_match_new_swatch_names_as_swatches_are_added` in `crates/doc/src/swatches.rs`. - **Colorized images (#1466):** a fill color applied to a selected grayscale or 1-bit image (`paint.setFill`) colorizes it with black, white, a process color or a spot color, and refuses a process color when the image has an alpha channel ([Convert color modes](https://web.archive.org/web/20251220223850/https://helpx.adobe.com/illustrator/desktop/manage-colors/select-and-adjust-colors/convert-color-modes.html), "Colorize Grayscale or 1-bit images"); black and white are accepted there too. The canvas draws each pixel in the color as far as the pixel is dark, with white pixels transparent; PDF export writes the image in the color (a spot color as its ink, Registration in every ink) with the image as its soft mask; Separations Preview and printed separations show it on its color's plates; native files keep the color. SVG writes the fill color through a coverage mask (or a colorized PNG in Tiny 1.2); EPS writes binary coverage as an image mask in the color's ink, and a grayscale image as ink samples scaled by coverage, with white pixels left out at Level 3 and gray midtones written over white. The prompt for deleting several swatches and groups uses the interface language's plural form for the count. Evidence: `deleting_several_swatches_uses_each_count_form` in `crates/ui-egui/src/panels/swatches/tests.rs`. From bc24ad5352c42d4f70a40e60cc498633d3e83bf4 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 05:10:41 -0800 Subject: [PATCH 105/108] Symbols: a symbol nested in symbol art is measured by its own art Document::symbol_art_bounds measured a symbol's art without the document, so an instance of another symbol in that art counted as the 20 x 20 square. It now measures the art through SymbolBoxes, so a nested instance takes its own symbol's art, and an inline graphic of the outer symbol is sized by it and follows it when that symbol changes. - The inline resolve order also follows the instances that size a symbol's art, so a symbol is measured after the type in the art of the symbols it holds is laid out again. - A symbol whose art reaches itself through an instance and an inline graphic is an empty slot. Only instances that the measurement uses count, so one a clipping path hides adds no dependency. - A missing symbol, a symbol without art, a symbol that holds an instance of itself, and nesting 32 deep still measure as the square. - SymbolBoxes finds symbols through a name index built once, and the inline resolve pass and inline_art_bounds share one index, instead of scanning the symbol list for each lookup. --- crates/doc/src/inline.rs | 213 +++++++++++++++++++++++++----- crates/doc/src/symbols.rs | 113 ++++++++++++---- crates/engine/src/tests/inline.rs | 141 ++++++++++++++++++++ docs/target-app-parity.md | 1 + 4 files changed, 405 insertions(+), 63 deletions(-) diff --git a/crates/doc/src/inline.rs b/crates/doc/src/inline.rs index a8e3955015..86c26e14f4 100644 --- a/crates/doc/src/inline.rs +++ b/crates/doc/src/inline.rs @@ -8,13 +8,20 @@ use std::sync::{Arc, RwLock, Weak}; use vectorcraft_geom::{Affine, Rect}; -use crate::{Document, Node, NodeId, NodeKind, Symbol, TextObject}; +use crate::symbols::SymbolNames; +use crate::{Document, Node, NodeId, NodeKind, Symbol, SymbolBoxes, TextObject}; /// The document key under which the app records each symbol's natural size (`{name: [w, h]}`). pub const SYMBOL_SIZES: &str = "symbolSizes"; /// Half the side of the square symbol art is normalised to. pub const SYMBOL_HALF: f64 = 10.0; +/// The box symbol art `art` is measured by in [`Document::symbol_art_bounds`]: its visual bounds, +/// or its geometric bounds when it has no visual bounds. +fn art_extent(art: &Node, boxes: &SymbolBoxes) -> Option<Rect> { + art.visual_bounds_with(boxes).or_else(|| art.geometric_bounds_with(boxes)) +} + /// Usable art bounds: finite, non-degenerate. fn usable(r: Option<Rect>) -> Option<Rect> { r.filter(|r| [r.x0, r.y0, r.x1, r.y1].iter().all(|v| v.is_finite()) && r.width() >= 0.0 && r.height() > 1e-9) @@ -35,27 +42,38 @@ impl Document { } /// Visual bounds of the art of the symbol named `name` at its natural size (see - /// [`Self::symbol_natural_xf`]), if it exists and has a usable extent. + /// [`Self::symbol_natural_xf`]), if it exists and has a usable extent. The symbol instances in + /// the art are measured by their own symbols' art ([`Node::visual_bounds_with`]), or by the + /// 20 × 20 square where [`crate::SymbolBoxes`] measures them by it. pub fn symbol_art_bounds(&self, name: &str) -> Option<Rect> { - let s = self.symbols.iter().find(|s| s.name == name)?; - let b = usable(s.art.visual_bounds().or_else(|| s.art.geometric_bounds()))?; + self.symbol_art_bounds_in(name, &self.symbol_boxes()) + } + + /// [`Self::symbol_art_bounds`], with the symbols found and the instances measured by `boxes` + /// (new boxes of this document). + fn symbol_art_bounds_in(&self, name: &str, boxes: &SymbolBoxes) -> Option<Rect> { + let b = usable(art_extent(boxes.symbol_art(name)?, boxes))?; usable(Some(self.symbol_natural_xf(name).transform_rect_bbox(b))) } /// The art bounds an inline graphic of the symbol named `name` takes: [`Self::symbol_art_bounds`], /// or `None` (an empty slot) when the symbol's art shows the symbol itself inline, directly or - /// through the inline graphics in other symbols' art, so that its size would depend on itself. + /// through the inline graphics and symbol instances in other symbols' art, so that its size + /// would depend on itself. pub fn inline_art_bounds(&self, name: &str) -> Option<Rect> { - if self.inline_cycles().contains(name) { None } else { self.symbol_art_bounds(name) } + let (cyclic, names) = self.inline_cycles(); + if cyclic.contains(name) { None } else { self.symbol_art_bounds_in(name, &self.symbol_boxes().with_names(&names)) } } - /// The names of the symbols that reach themselves through the inline graphics in symbol art, - /// found once while the symbols stay as they are. - fn inline_cycles(&self) -> Arc<HashSet<String>> { + /// The names of the symbols that reach themselves through the inline graphics in symbol art + /// ([`InlineGraph`]), with each symbol name → the index of the first symbol of that name, found + /// once while the symbols stay as they are. + fn inline_cycles(&self) -> (Arc<HashSet<String>>, Arc<SymbolNames>) { if let Some(found) = self.inline_cycles.get(&self.symbols) { return found; } - let found = Arc::new(InlineGraph::of(self).cyclic); + let graph = InlineGraph::of(self); + let found = (Arc::new(graph.cyclic), graph.names); self.inline_cycles.set(&self.symbols, &found); found } @@ -94,7 +112,8 @@ impl Document { /// of symbols, graph designs and pattern tiles, and the opacity masks and live objects in /// them. Each text whose inline graphics changed has its cached layout cleared and is passed /// to `layout` to be laid out again. The symbols are resolved first, each after the symbols its - /// inline graphics show, so a symbol's art is measured with its type already laid out; a + /// inline graphics and symbol instances show, so a symbol's art is measured with its type, and + /// the type in the art of the symbols its instances show, already laid out; a /// symbol that shows itself inline ([`Self::inline_art_bounds`]) is shown as an empty slot. /// Returns the ids of the texts in the layers that changed. pub fn resolve_inline_art_with(&mut self, layout: &mut dyn FnMut(&mut TextObject)) -> Vec<NodeId> { @@ -241,34 +260,48 @@ fn inline_symbols(n: &Node) -> Vec<String> { out } -/// Each symbol name of `d` → the index of the first symbol of that name (the one a name finds). -fn symbol_index(d: &Document) -> HashMap<&str, usize> { - let mut index = HashMap::with_capacity(d.symbols.len()); - for (i, s) in d.symbols.iter().enumerate() { - index.entry(s.name.as_str()).or_insert(i); - } - index -} - -/// The symbols of a document as their inline graphics depend on each other. +/// The symbols of a document as their sizes depend on each other: a symbol's art depends on the +/// symbols its type shows inline, and on the symbols its instances show when those instances are +/// measured by their symbols' art ([`crate::SymbolBoxes`]). struct InlineGraph { - /// Every symbol index, each after the symbols its art shows inline (except along a cycle). + /// Every symbol index, each after the symbols its art depends on (except along a cycle). order: Vec<usize>, - /// The names of the symbols that reach themselves through inline graphics. + /// The names of the symbols that reach themselves through inline graphics. Instances alone make + /// no cycle: an instance of a symbol that holds an instance of itself is measured by the + /// 20 × 20 square, so every cycle passes through an inline graphic. cyclic: HashSet<String>, + /// Each symbol name → the index of the first symbol of that name, which stay the same while + /// [`Document::resolve_inline_art_with`] changes the symbols' art. + names: Arc<SymbolNames>, } impl InlineGraph { - /// The graph of `d`'s symbols: each symbol's art is walked once, and the order and cycles are - /// found in time linear in the symbols and their inline references (Tarjan's strongly - /// connected components, without recursion). + /// The graph of `d`'s symbols: each symbol's art is walked once, and, when the art of any + /// symbol holds an inline graphic, measured once with the art boxes of the symbols its + /// instances show measured once in all ([`SymbolBoxes::consulted`]: an instance that does not + /// size the art, such as one a clipping path hides, adds nothing). The order and cycles are + /// found in time linear in the symbols and their inline references and instances (Tarjan's + /// strongly connected components, without recursion). fn of(d: &Document) -> Self { - let index = symbol_index(d); + let names = Arc::new(d.symbol_names()); + let boxes = d.symbol_boxes().quick().with_names(&names); + let inline: Vec<Vec<String>> = d.symbols.iter().map(|s| inline_symbols(&s.art)).collect(); + // Without inline graphics in symbol art, no symbol's type depends on another symbol. + let any_inline = inline.iter().any(|v| !v.is_empty()); let edges: Vec<Vec<usize>> = d .symbols .iter() - .map(|s| { - let mut e: Vec<usize> = inline_symbols(&s.art).iter().filter_map(|n| index.get(n.as_str()).copied()).collect(); + .zip(inline) + .map(|(s, inline)| { + let measured = if any_inline { + boxes.consulted(|| { + art_extent(&s.art, &boxes); + }) + } else { + HashSet::new() + }; + let shows = inline.into_iter().chain(measured); + let mut e: Vec<usize> = shows.filter_map(|n| names.get(n.as_str()).copied()).collect(); e.sort_unstable(); e.dedup(); e @@ -276,12 +309,13 @@ impl InlineGraph { .collect(); let (order, cyclic) = components(&edges); let cyclic = order.iter().filter(|&&i| cyclic[i]).map(|&i| d.symbols[i].name.clone()).collect(); - Self { order, cyclic } + Self { order, cyclic, names } } - /// [`Document::inline_art_bounds`] with the cycles found in this graph. + /// [`Document::inline_art_bounds`] with the cycles found in this graph, for `d` with the + /// symbols' names and order the graph was made with. fn bounds(&self, d: &Document, name: &str) -> Option<Rect> { - if self.cyclic.contains(name) { None } else { d.symbol_art_bounds(name) } + if self.cyclic.contains(name) { None } else { d.symbol_art_bounds_in(name, &d.symbol_boxes().with_names(&self.names)) } } } @@ -354,12 +388,16 @@ fn components(edges: &[Vec<usize>]) -> (Vec<usize>, Vec<bool>) { #[derive(Default)] pub(crate) struct InlineCycles(RwLock<Option<Arc<Found>>>); -/// The name and art of each symbol the cycles were found in, and the names of the symbols on one. -type Found = (Vec<(String, Weak<Node>)>, Arc<HashSet<String>>); +/// The names of the symbols on a cycle, and each symbol name → the index of the first symbol of that +/// name. +type Cycles = (Arc<HashSet<String>>, Arc<SymbolNames>); + +/// The name and art of each symbol the cycles were found in, and what was found. +type Found = (Vec<(String, Weak<Node>)>, Cycles); impl InlineCycles { /// The cached names, when they were found in `symbols`. - fn get(&self, symbols: &[Symbol]) -> Option<Arc<HashSet<String>>> { + fn get(&self, symbols: &[Symbol]) -> Option<Cycles> { let g = self.0.read().ok()?; let (from, found) = &**g.as_ref()?; let same = from.len() == symbols.len() @@ -368,7 +406,7 @@ impl InlineCycles { } /// Keep `found`, found in `symbols`. - fn set(&self, symbols: &[Symbol], found: &Arc<HashSet<String>>) { + fn set(&self, symbols: &[Symbol], found: &Cycles) { if let Ok(mut g) = self.0.write() { *g = Some(Arc::new((symbols.iter().map(|s| (s.name.clone(), Arc::downgrade(&s.art))).collect(), found.clone()))); } @@ -485,6 +523,109 @@ mod tests { assert_eq!(count.get(), 2); } + /// A rectangle `r` filled black, with a 2 pt black stroke. + fn stroked(d: &mut Document, r: Rect) -> Arc<Node> { + use vectorcraft_color::{Color, Paint}; + let look = crate::Appearance::basic(Paint::solid(Color::BLACK), Paint::solid(Color::BLACK), 2.0); + Arc::new(Node::path(d.alloc_id(), vectorcraft_geom::shapes::rectangle(r), look)) + } + + fn instance(d: &mut Document, symbol: &str, xf: Affine) -> Arc<Node> { + Arc::new(Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: symbol.into(), xf })) + } + + /// Symbol `name` holding `art` in a group. + fn symbol(d: &mut Document, name: &str, art: Vec<Arc<Node>>) { + let group = Node::group(d.alloc_id(), art); + d.symbols.push(Symbol { dynamic: false, name: name.into(), art: Arc::new(group) }); + } + + #[test] + fn a_symbol_nested_in_symbol_art_is_measured_by_its_own_art() { + // `Far` is a rectangle from (200, 100) to (240, 130) with a 2 pt stroke, far from the + // 20 × 20 square around the origin. + let mut d = Document::new(500.0, 500.0); + let far = stroked(&mut d, Rect::new(200.0, 100.0, 240.0, 130.0)); + symbol(&mut d, "Far", vec![far]); + let moved = instance(&mut d, "Far", Affine::translate((-100.0, 0.0))); + symbol(&mut d, "Moved", vec![moved.clone()]); + let scaled = instance(&mut d, "Far", Affine::scale(2.0)); + symbol(&mut d, "Scaled", vec![scaled]); + symbol(&mut d, "Sized", vec![moved]); + d.unknown.insert(SYMBOL_SIZES.into(), serde_json::json!({ "Sized": [40.0, 20.0] })); + assert_eq!(d.symbol_art_bounds("Far"), Some(Rect::new(199.0, 99.0, 241.0, 131.0))); + // The stroke paints 1 pt around the moved rectangle. + assert_eq!(d.symbol_art_bounds("Moved"), Some(Rect::new(99.0, 99.0, 141.0, 131.0))); + // Scaled 2 times, the stroke keeps its weight. + assert_eq!(d.symbol_art_bounds("Scaled"), Some(Rect::new(399.0, 199.0, 481.0, 261.0))); + // At its natural size, 40 × 20 for the 20 × 20 square: 2 times across. + assert_eq!(d.symbol_art_bounds("Sized"), Some(Rect::new(198.0, 99.0, 282.0, 131.0))); + assert_eq!(d.inline_art_bounds("Moved"), d.symbol_art_bounds("Moved")); + } + + #[test] + fn nested_instances_without_art_of_their_own_are_measured_by_the_square() { + let mut d = Document::new(500.0, 500.0); + let r = Rect::new(0.0, 0.0, 10.0, 10.0); + // An instance of a missing symbol and one of a symbol with no art, beside a rectangle. + symbol(&mut d, "Empty", vec![]); + let pieces = vec![stroked(&mut d, r), instance(&mut d, "Nowhere", Affine::translate((100.0, 0.0)))]; + symbol(&mut d, "Missing", pieces); + let pieces = vec![stroked(&mut d, r), instance(&mut d, "Empty", Affine::translate((100.0, 0.0)))]; + symbol(&mut d, "Holds empty", pieces); + let with_square = Some(Rect::new(-1.0, -10.0, 110.0, 11.0)); + assert_eq!(d.symbol_art_bounds("Empty"), None); + assert_eq!(d.symbol_art_bounds("Missing"), with_square); + assert_eq!(d.symbol_art_bounds("Holds empty"), with_square); + // A symbol that holds an instance of itself: the instance is measured by the square, and + // an inline graphic of it is not an empty slot. + let pieces = vec![stroked(&mut d, r), instance(&mut d, "Loop", Affine::translate((100.0, 0.0)))]; + symbol(&mut d, "Loop", pieces); + assert_eq!(d.symbol_art_bounds("Loop"), with_square); + assert_eq!(d.inline_art_bounds("Loop"), with_square); + // A chain of 40 symbols, each holding a rectangle and an instance of the next one 1 pt to + // the right: symbols nest 39 deep in Link 0's art, past the limit of 32, so its instance of + // Link 1 is measured by the square. + for i in 0..40 { + let unit = stroked(&mut d, Rect::new(0.0, 0.0, 1.0, 1.0)); + let next = instance(&mut d, &format!("Link {}", i + 1), Affine::translate((1.0, 0.0))); + symbol(&mut d, &format!("Link {i}"), if i < 39 { vec![unit, next] } else { vec![unit] }); + } + assert_eq!(d.symbol_art_bounds("Link 0"), Some(Rect::new(-9.0, -10.0, 11.0, 10.0))); + // Link 8's art nests 31 deep: measured by the art of the links after it. + assert_eq!(d.symbol_art_bounds("Link 8"), Some(Rect::new(-1.0, -1.0, 33.0, 2.0))); + } + + /// Type showing the symbol named `symbol` inline. + fn showing(d: &mut Document, symbol: &str) -> Arc<Node> { + let style = crate::CharStyle::default(); + let mut t = TextObject::point(vectorcraft_geom::Point::ZERO, "Type", style.clone()); + t.runs.push(crate::TextRun::new("", style)); + t.runs[1].inline = Some(crate::InlineArt { symbol: symbol.into(), scale: 1.0, baseline_shift: 0.0, bounds: None }); + Arc::new(Node::new(d.alloc_id(), NodeKind::Text(Box::new(t)))) + } + + #[test] + fn only_instances_that_size_a_symbols_art_make_it_depend_on_their_symbol() { + // B's type shows A inline. A's art is a clip group: a clipping rectangle, then an instance + // of B that the rectangle clips, so A's size does not depend on B's. + let mut d = Document::new(500.0, 500.0); + let text = showing(&mut d, "A"); + symbol(&mut d, "B", vec![text]); + let clip = stroked(&mut d, Rect::new(0.0, 0.0, 10.0, 10.0)); + let inner = instance(&mut d, "B", Affine::IDENTITY); + let group = Arc::new(Node::new(d.alloc_id(), NodeKind::Group { children: vec![clip, inner.clone()], clip: true })); + symbol(&mut d, "A", vec![group]); + assert_eq!(d.inline_art_bounds("A"), Some(Rect::new(-1.0, -1.0, 11.0, 11.0))); + // Without the clip, A's size depends on B's and B's on A's: both are empty slots. + let art = Arc::new(Node::group(d.alloc_id(), vec![inner])); + if let Some(a) = d.symbols.iter_mut().find(|s| s.name == "A") { + a.art = art; + } + assert_eq!(d.inline_art_bounds("A"), None); + assert_eq!(d.inline_art_bounds("B"), None); + } + #[test] fn components_handle_a_long_chain_without_recursion() { let n = 200_000; diff --git a/crates/doc/src/symbols.rs b/crates/doc/src/symbols.rs index dde6621993..822dce49ea 100644 --- a/crates/doc/src/symbols.rs +++ b/crates/doc/src/symbols.rs @@ -2,7 +2,7 @@ //! the document and measures it once, and an instance's bounds are its art's box placed by the //! instance's transform ([`Node::geometric_bounds_with`]). -use std::cell::{Cell, RefCell}; +use std::cell::{Cell, OnceCell, RefCell}; use std::collections::{HashMap, HashSet}; use std::sync::Arc; @@ -26,6 +26,9 @@ const MAX_REACHES: usize = 4096; /// A symbol's name and the bits of the linear part of a transform that places its art. type Placing = (String, [u64; 4]); +/// Each symbol name of a document → the index of the first symbol of that name. +pub(crate) type SymbolNames = HashMap<String, usize>; + /// A symbol's art measured in symbol space. #[derive(Clone, Copy, Debug, PartialEq)] pub(crate) struct ArtBox { @@ -51,6 +54,10 @@ pub(crate) struct ArtBox { /// symbols change. pub struct SymbolBoxes<'a> { doc: &'a Document, + /// Each symbol name of the document → the index of the first symbol of that name (the one a + /// name finds), made the first time a name is looked up ([`Self::symbol_art`]) or given by + /// [`Self::with_names`]. + names: OnceCell<Arc<SymbolNames>>, /// The art boxes measured so far, by symbol name (`None` for a symbol whose instances are /// measured by [`SYMBOL_SQUARE`]). measured: RefCell<HashMap<String, Option<ArtBox>>>, @@ -89,6 +96,9 @@ pub struct SymbolBoxes<'a> { sliced_most: u64, /// The widths [`Self::measured_width`] has measured, by kind and symbol name. widths: RefCell<HashMap<(&'static str, String), Option<f64>>>, + /// While [`Self::consulted`] runs: the symbols whose art boxes [`Self::art`] has given outside + /// the measuring of symbol art. + consulted: RefCell<Option<HashSet<String>>>, } impl Document { @@ -96,6 +106,7 @@ impl Document { pub fn symbol_boxes(&self) -> SymbolBoxes<'_> { SymbolBoxes { doc: self, + names: OnceCell::new(), measured: RefCell::default(), depths: RefCell::default(), quick: Cell::new(false), @@ -110,8 +121,19 @@ impl Document { sliced_placed: Cell::new(0), sliced_most: MAX_SYMBOL_NODES, widths: RefCell::default(), + consulted: RefCell::default(), } } + + /// Each symbol name of this document → the index of the first symbol of that name (the one a + /// name finds). + pub(crate) fn symbol_names(&self) -> SymbolNames { + let mut names = HashMap::with_capacity(self.symbols.len()); + for (i, s) in self.symbols.iter().enumerate() { + names.entry(s.name.clone()).or_insert(i); + } + names + } } impl<'a> SymbolBoxes<'a> { @@ -120,6 +142,26 @@ impl<'a> SymbolBoxes<'a> { self.doc } + /// Makes these boxes find symbols by `names` ([`Document::symbol_names`]), made from the + /// document's symbols while they had the names and order they have now. + pub(crate) fn with_names(self, names: &Arc<SymbolNames>) -> Self { + let _ = self.names.set(names.clone()); + self + } + + /// The art of the first symbol of the document named `name`, found in time independent of the + /// number of symbols after the first lookup. + pub(crate) fn symbol_art(&self, name: &str) -> Option<&'a Arc<Node>> { + let doc: &'a Document = self.doc; + let names = self.names.get_or_init(|| Arc::new(doc.symbol_names())); + let i = *names.get(name)?; + match doc.symbols.get(i) { + Some(s) if s.name == name => Some(&s.art), + // Names that no longer match the symbols: the first symbol of that name. + _ => doc.symbols.iter().find(|s| s.name == name).map(|s| &s.art), + } + } + /// Makes these boxes measure every symbol instance as [`Node::reach_bounds_with`] does, by its /// art box alone. An instance that scales or turns stroked art then measures a little larger /// than with [`Node::visual_bounds_with`], and its art is not transformed to measure it. The @@ -160,21 +202,37 @@ impl<'a> SymbolBoxes<'a> { /// art boxes. Returns `None` when [`Self::depth`] is `None` and when the art has no finite /// bounds: instances of the symbol are then measured by [`SYMBOL_SQUARE`]. pub(crate) fn art(&self, name: &str) -> Option<ArtBox> { - if let Some(b) = self.measured.borrow().get(name) { - return *b; + let cached = self.measured.borrow().get(name).copied(); + let b = cached.unwrap_or_else(|| { + let b = self.measure_art(name, |art| self.in_art(|| art_box(art, self))).flatten(); + self.measured.borrow_mut().insert(name.to_string(), b); + b + }); + if b.is_some() + && let Some(seen) = self.consulted.borrow_mut().as_mut() + && !seen.contains(name) + { + seen.insert(name.to_string()); } - let b = self.measure_art(name, |art| self.in_art(|| art_box(art, self))).flatten(); - self.measured.borrow_mut().insert(name.to_string(), b); b } + /// Runs `measure`, and returns the names of the symbols whose art boxes it took from these + /// boxes, the art of symbols it measured left out: the symbols whose art the instances it + /// measured are measured by. + pub(crate) fn consulted(&self, measure: impl FnOnce()) -> HashSet<String> { + let was = self.consulted.replace(Some(HashSet::new())); + measure(); + self.consulted.replace(was).unwrap_or_default() + } + /// Runs `measure` on the art of the symbol named `name`. Returns `None` when [`Self::depth`] /// is `None`, without running it. pub fn measure_art<R>(&self, name: &str, measure: impl FnOnce(&Arc<Node>) -> R) -> Option<R> { self.depth(name)?; - let sym = self.doc.symbols.iter().find(|s| s.name == name)?; + let art = self.symbol_art(name)?; self.runs.set(self.runs.get() + 1); - Some(measure(&sym.art)) + Some(measure(art)) } /// How many times [`Self::measure_art`] has run a measure on symbol art for these boxes, the @@ -297,10 +355,9 @@ impl<'a> SymbolBoxes<'a> { /// other symbols it reaches: the depth of each one it walks to the end, and `None` for those on /// the way down to a symbol that holds an instance of itself or nests too deep. fn find_depth(&self, name: &str, learned: &mut HashMap<String, Option<usize>>) -> Option<usize> { - let art = |n: &str| self.doc.symbols.iter().find(|s| s.name == n).map(|s| &s.art); // The symbols on the way down from `name`: each with the symbols its art shows that are // still to be walked, and the deepest nesting found under it so far. - let mut path: Vec<(String, Vec<String>, usize)> = vec![(name.to_string(), shown(self.doc, art(name)?), 0)]; + let mut path: Vec<(String, Vec<String>, usize)> = vec![(name.to_string(), self.shown(self.symbol_art(name)?), 0)]; loop { let (_, todo, _) = path.last_mut()?; let Some(next) = todo.pop() else { @@ -330,8 +387,8 @@ impl<'a> SymbolBoxes<'a> { // Symbols nested MAX_DEPTH deep under `name`. None if path.len() >= MAX_DEPTH => return None, None => { - if let Some(a) = art(&next) { - let todo = shown(self.doc, a); + if let Some(a) = self.symbol_art(&next) { + let todo = self.shown(a); path.push((next, todo, 0)); } } @@ -379,7 +436,7 @@ impl<'a> SymbolBoxes<'a> { None => { // The most objects placing makes, the art of opacity masks included, is set aside // while the art is placed and measured, and what placing did not make is given back. - let art = &self.doc.symbols.iter().find(|s| s.name == name)?.art; + let art = self.symbol_art(name)?; let most = match self.doc.symbol_slice_map(name, linear) { Some(m) => m.most_placed(art, self.doc), None => art.count_with_masks() as u64, @@ -431,11 +488,28 @@ impl<'a> SymbolBoxes<'a> { fn in_art<R>(&self, f: impl FnOnce() -> R) -> R { let pad = self.brush_art.replace(false); let strokes = self.art_strokes.replace(true); + let consulted = self.consulted.take(); let r = self.quickly(f); self.brush_art.set(pad); self.art_strokes.set(strokes); + *self.consulted.borrow_mut() = consulted; r } + + /// The names of the symbols of the document that the instances in `art` show, each once. + fn shown(&self, art: &Node) -> Vec<String> { + let mut seen = HashSet::new(); + let mut names = vec![]; + art.walk(&mut |n| { + if let NodeKind::SymbolInstance { symbol, .. } = &n.kind + && seen.insert(symbol.as_str()) + && self.symbol_art(symbol).is_some() + { + names.push(symbol.clone()); + } + }); + names + } } /// Records every symbol on `path` in `learned` as one whose instances are measured by @@ -447,21 +521,6 @@ fn give_up(path: &[(String, Vec<String>, usize)], learned: &mut HashMap<String, None } -/// The names of the symbols of `doc` that the instances in `art` show, each once. -fn shown(doc: &Document, art: &Node) -> Vec<String> { - let mut seen = HashSet::new(); - let mut names = vec![]; - art.walk(&mut |n| { - if let NodeKind::SymbolInstance { symbol, .. } = &n.kind - && seen.insert(symbol.as_str()) - && doc.symbols.iter().any(|s| s.name == *symbol) - { - names.push(symbol.clone()); - } - }); - names -} - /// Measures symbol art `art`, with the instances in it measured by `symbols`. fn art_box(art: &Arc<Node>, symbols: &SymbolBoxes) -> Option<ArtBox> { let finite = |r: &Rect| [r.x0, r.y0, r.x1, r.y1].iter().all(|v| v.is_finite()); diff --git a/crates/engine/src/tests/inline.rs b/crates/engine/src/tests/inline.rs index f7c72956ad..71caf14bf8 100644 --- a/crates/engine/src/tests/inline.rs +++ b/crates/engine/src/tests/inline.rs @@ -1,8 +1,12 @@ //! Inline graphics in text: `text.insertInline`, editing over them, undo, following their symbol. +use std::sync::Arc; + use serde_json::json; +use vectorcraft_color::{Color, Paint}; use vectorcraft_doc::text::INLINE_CHAR; use vectorcraft_doc::{Node, NodeId, NodeKind, TextObject}; +use vectorcraft_geom::{Affine, Rect}; use vectorcraft_tools::{Mods, PointerEvent, PointerKind, ToolKey}; use crate::*; @@ -325,6 +329,143 @@ fn a_symbol_that_shows_itself_inline_is_an_empty_slot() { assert_eq!(d.inline_art_bounds("Loop"), None); } +/// A rectangle `r` filled black, without a stroke. +fn filled_rect(d: &mut vectorcraft_doc::Document, r: Rect) -> Arc<Node> { + let look = vectorcraft_doc::Appearance::basic(Paint::solid(Color::BLACK), Paint::None, 0.0); + Arc::new(Node::path(d.alloc_id(), vectorcraft_geom::shapes::rectangle(r), look)) +} + +/// An instance of symbol `name` placed by `xf`. +fn symbol_instance(d: &mut vectorcraft_doc::Document, name: &str, xf: Affine) -> Arc<Node> { + Arc::new(Node::new(d.alloc_id(), NodeKind::SymbolInstance { symbol: name.into(), xf })) +} + +/// Gives symbol `name` the art `art` in a group, adding the symbol when there is none of that name. +fn set_symbol_art(d: &mut vectorcraft_doc::Document, name: &str, art: Vec<Arc<Node>>) { + let art = Arc::new(Node::group(d.alloc_id(), art)); + match d.symbols.iter_mut().find(|x| x.name == name) { + Some(x) => x.art = art, + None => d.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: name.into(), art }), + } +} + +/// An inline graphic of a symbol whose art holds an instance of another symbol is sized by that +/// symbol's art, and follows it when it changes, through undo, redo and a saved copy. +#[test] +fn an_inline_graphic_follows_the_art_of_a_symbol_nested_in_its_symbol() { + let mut s = session(); + s.edit("Symbols", |d, _| { + let far = filled_rect(d, Rect::new(100.0, 0.0, 160.0, 20.0)); + set_symbol_art(d, "Far", vec![far]); + let inner = symbol_instance(d, "Far", Affine::IDENTITY); + set_symbol_art(d, "Holder", vec![inner]); + Ok(()) + }) + .unwrap(); + let id = text(&mut s, "ab"); + let w0 = obj(&s, id).bounds().unwrap().width(); + s.execute("text.insertInline", &json!({"id": id.0, "at": 1, "symbol": "Holder", "scale": 1})).unwrap(); + let wide = Some(Rect::new(100.0, 0.0, 160.0, 20.0)); + let t = obj(&s, id); + assert_eq!(inline_bounds(&t), wide); + // 20 pt tall at 20 pt type and 3 times as wide: the text grows by 60 pt. + let w1 = t.bounds().unwrap().width(); + assert!((w1 - w0 - 60.0).abs() < 1.5, "{w0} → {w1}"); + // Far redefined as a 10 × 40 rectangle: the graphic is 20 pt tall and 5 pt wide. + s.edit("Redefine Far", |d, _| { + let tall = filled_rect(d, Rect::new(0.0, 0.0, 10.0, 40.0)); + set_symbol_art(d, "Far", vec![tall]); + Ok(()) + }) + .unwrap(); + let tall = Some(Rect::new(0.0, 0.0, 10.0, 40.0)); + let t = obj(&s, id); + assert_eq!(inline_bounds(&t), tall); + assert_eq!(s.doc().unwrap().doc.symbol_art_bounds("Holder"), tall); + let w2 = t.bounds().unwrap().width(); + assert!((w2 - w0 - 5.0).abs() < 1.5, "{w0} → {w2}"); + s.execute("edit.undo", &json!({})).unwrap(); + assert_eq!(inline_bounds(&obj(&s, id)), wide); + assert!((obj(&s, id).bounds().unwrap().width() - w1).abs() < 1e-6); + s.execute("edit.redo", &json!({})).unwrap(); + assert_eq!(inline_bounds(&obj(&s, id)), tall); + // Opening a saved copy measures it the same way. + let doc = (*s.doc().unwrap().doc).clone(); + let mut back = vectorcraft_format::load(&vectorcraft_format::save(&doc, false)).unwrap(); + back.title = "copy".into(); + let mut s2 = Session::new(); + s2.add_document(back, None); + assert_eq!(inline_bounds(&obj(&s2, id)), tall); + assert!((obj(&s2, id).bounds().unwrap().width() - w2).abs() < 1e-6); +} + +/// Symbol C shows Holder inline, Holder holds an instance of B, and B shows A inline: with the +/// symbols listed C, Holder, B, A, a change to A reaches C through B's and Holder's new sizes. +#[test] +fn symbols_are_resolved_after_the_symbols_their_instances_show() { + let mut s = session(); + circle_symbol(&mut s, "A", 10.0); + let t = text(&mut s, "z"); + s.execute("text.insertInline", &json!({"id": t.0, "at": 0, "symbol": "A"})).unwrap(); + s.execute("symbol.new", &json!({"name": "B", "ids": [t.0]})).unwrap(); + s.execute("edit.clear", &json!({})).unwrap(); + s.edit("Holder", |d, _| { + let inner = symbol_instance(d, "B", Affine::IDENTITY); + set_symbol_art(d, "Holder", vec![inner]); + Ok(()) + }) + .unwrap(); + let t = text(&mut s, "z"); + s.execute("text.insertInline", &json!({"id": t.0, "at": 0, "symbol": "Holder"})).unwrap(); + s.execute("symbol.new", &json!({"name": "C", "ids": [t.0]})).unwrap(); + s.execute("edit.clear", &json!({})).unwrap(); + s.edit("Reverse the symbols", |d, _| { + d.symbols.reverse(); + Ok(()) + }) + .unwrap(); + let h0 = s.doc().unwrap().doc.symbol_art_bounds("Holder"); + redefine_as_wide_ellipse(&mut s, "A"); + let d = &s.doc().unwrap().doc; + assert_ne!(d.symbol_art_bounds("Holder"), h0); + assert_eq!(inline_bounds(&art_text(&s, "C")), d.symbol_art_bounds("Holder")); +} + +/// Symbol A holds an instance of B, and B's type shows A inline: the size of each would depend on +/// itself, so both are empty slots, and stay so through later edits. +#[test] +fn a_symbol_that_shows_itself_through_an_instance_is_an_empty_slot() { + let mut s = session(); + circle_symbol(&mut s, "A", 10.0); + let t = text(&mut s, "ab"); + s.execute("text.insertInline", &json!({"id": t.0, "at": 1, "symbol": "A"})).unwrap(); + s.execute("symbol.new", &json!({"name": "B", "ids": [t.0]})).unwrap(); + s.execute("edit.clear", &json!({})).unwrap(); + s.edit("A holds B", |d, _| { + let inner = symbol_instance(d, "B", Affine::IDENTITY); + set_symbol_art(d, "A", vec![inner]); + Ok(()) + }) + .unwrap(); + let line = text(&mut s, "x"); + s.execute("text.insertInline", &json!({"id": line.0, "at": 0, "symbol": "A"})).unwrap(); + for _ in 0..2 { + for name in ["A", "B"] { + assert_eq!(s.doc().unwrap().doc.inline_art_bounds(name), None, "{name}"); + } + assert_eq!(inline_bounds(&art_text(&s, "B")), None); + assert_eq!(inline_bounds(&obj(&s, line)), None); + s.execute("shape.rectangle", &json!({"x": 0, "y": 0, "width": 10, "height": 10})).unwrap(); + } + let _ = s.execute("document.serialize", &json!({"format": "png"})).unwrap(); + // Redefined without the instance, A is on no cycle. + redefine_as_wide_ellipse(&mut s, "A"); + let d = &s.doc().unwrap().doc; + assert!(d.inline_art_bounds("A").is_some()); + assert_eq!(inline_bounds(&art_text(&s, "B")), d.symbol_art_bounds("A")); + assert_eq!(inline_bounds(&obj(&s, line)), d.symbol_art_bounds("A")); +} + /// A list paragraph that starts with an inline graphic draws its bullet before the graphic, and /// live SVG text writes the bullet. #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ad7e9f4eab..8f70e93d11 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1314,6 +1314,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Manual kerning in right-to-left text:** a manual kerning value on a Hebrew or Arabic character changes the space between it and the next character in reading order, the one drawn to its left, under Auto and Optical kerning. The character before it keeps its place, and the caret between the pair stays beside the next character. The side the space goes on is VectorCraft's own rule. Behavior reference: [Line and character spacing](https://web.archive.org/web/20260916050333/https://helpx.adobe.com/illustrator/using/line-character-spacing.html). Test: `rtl_manual_kerning_spaces_the_character_from_the_next_in_reading_order`. - **Manual kerning on inline graphics:** a manual kerning value on an inline graphic's character spaces it from the next character in reading order by the same distance as on a letter of its run's size, in left-to-right, right-to-left and vertical type; Auto and Optical kerning still apply no font pairs to it. This is VectorCraft's own rule. Test: `manual_kerning_on_an_inline_graphic_spaces_it_like_a_letter`. - **Inline graphics in symbol art follow their symbols:** when a symbol changes, type with an inline graphic of it is laid out again wherever the type is: in the layers, in the art of other symbols, graph designs and pattern tiles, and in opacity masks. A symbol's type is laid out before the type that shows that symbol inline, so a symbol whose art holds an inline graphic, its instances and the inline graphics that show it take its new size. Opening and reverting a document and Refresh Font List resolve them in the same order. An inline graphic of a symbol whose art shows that symbol inline, directly or through other symbols, is an empty slot. This is VectorCraft's own rule. Tests: `inline_graphics_in_symbol_art_follow_their_symbol`, `inline_graphics_in_masks_and_pattern_tiles_follow_their_symbol`, `symbols_are_resolved_after_the_symbols_they_show_inline`, `a_symbol_that_shows_itself_inline_is_an_empty_slot` in `crates/engine/src/tests/inline.rs`. +- **Inline graphics of symbols that hold other symbols:** an inline graphic of a symbol whose art holds an instance of another symbol is sized by that symbol's own art, placed by the instance, and follows it when that symbol changes. A symbol's type is laid out after the type in the art of the symbols its instances show. An inline graphic of a symbol whose art reaches that symbol through an instance and an inline graphic is an empty slot; an instance that does not size the art, such as one a clipping path hides, does not count. An instance of a missing symbol, of a symbol without art, of a symbol that holds an instance of itself, or of a symbol whose art nests symbols 32 deep is measured by the 20 × 20 square. This is VectorCraft's own rule. Tests: `an_inline_graphic_follows_the_art_of_a_symbol_nested_in_its_symbol`, `symbols_are_resolved_after_the_symbols_their_instances_show`, `a_symbol_that_shows_itself_through_an_instance_is_an_empty_slot` in `crates/engine/src/tests/inline.rs`; `a_symbol_nested_in_symbol_art_is_measured_by_its_own_art`, `nested_instances_without_art_of_their_own_are_measured_by_the_square`, `only_instances_that_size_a_symbols_art_make_it_depend_on_their_symbol` in `crates/doc/src/inline.rs`. - **Recent font pickers (#3515):** The shared Character, Properties, Glyphs and Find Font family picker lists recently applied families first, once each, in most-recent order and limited by Preferences › Type › Number of Recent Fonts. Search and filters apply to both sections; unavailable families are omitted. Section headings cannot be selected or previewed. Confirmed character-range font edits update the same saved history; previews and failed edits do not. Requirement: [issue #3515](https://github.com/storytold/vectorcraft/issues/3515). - **Show samples on white (a VectorCraft addition):** Preferences › Type › Show samples on white (`fontSamplesOnWhite`, off by default) draws each family's sample in every font menu, and in Type → Font in the in-window menu bar, in dark type on a white area in every interface brightness. A highlighted row's color shows above and below the white area, and the names and the rest of the menu keep the interface's colors. The checkbox is dimmed while Enable in-menu font previews is off. Tests: `crates/ui-egui/src/tests/font_menu.rs`, `crates/ui-egui/src/font_menu/tests.rs`, `crates/ui-egui/src/prefs_dialog/tests.rs`. - **Find Font: Replace With Font From:** a dropdown under Replace With Font chooses the list the replacement font comes from: Document lists the families the document uses, once each; Recent lists the recently applied families that are installed (fonts applied with Find Font's Change and Change All included), newest first, as many as Preferences › Type › Number of Recent Fonts allows; System, the default, lists the installed families available in the font menu. The dialog opens on System with Source Sans 3 chosen, or the font menu's first family when Source Sans 3 is not installed. Choosing a list keeps the chosen font when the list has it and it is installed; otherwise Document and Recent choose the list's first installed font, and System chooses Source Sans 3 or the font menu's first family. Change and Change All are unavailable when the list has no installed font (Recent before any font was applied) and when the chosen family is not installed or is not in the shown list. Behavior reference: [Find and replace fonts](https://helpx.adobe.com/illustrator/desktop/design-with-text/fonts-and-scripts/find-and-replace-fonts.html) (public documentation). Tests: `crates/ui-egui/src/find_font.rs`. From 01359bc7536ddc49dba7616d0c96ad7bea9da674 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 05:11:34 -0800 Subject: [PATCH 106/108] Image Trace: a trace made off the UI thread applies only in its own document A trace handed in for imageTrace.make or imageTrace.makeAndExpand was matched by its object, image, pixels and settings alone, so a trace made in one document could stand in for the command in another open document with the same image and settings. The trace's inputs now carry the document's uid: TraceRun::current is false in any other document, and the commands there drop the trace handed in and trace their own image, as one undo step. Test: a_trace_run_applies_only_in_its_own_document. --- crates/engine/src/cmd/buildcmds/trace.rs | 20 ++++++++------ crates/engine/src/tests/build.rs | 35 ++++++++++++++++++++++++ docs/target-app-parity.md | 1 + 3 files changed, 48 insertions(+), 8 deletions(-) diff --git a/crates/engine/src/cmd/buildcmds/trace.rs b/crates/engine/src/cmd/buildcmds/trace.rs index 11519b84be..932ef1819a 100644 --- a/crates/engine/src/cmd/buildcmds/trace.rs +++ b/crates/engine/src/cmd/buildcmds/trace.rs @@ -526,12 +526,15 @@ fn color_groups(cmd: &str, d: &mut Document, items: Vec<Arc<Node>>) -> Result<Ve .collect()) } -/// What a trace depends on: the object traced (an image, or an Image Trace object traced again), -/// its image, the image's encoded bytes, and the settings it is traced with. The tracer makes the -/// same paths of the same inputs, so a trace made away from the command ([`TraceRun`]) stands in -/// for the command's own. +/// What a trace depends on: the document it is made in, the object traced (an image, or an Image +/// Trace object traced again), its image, the image's encoded bytes, and the settings it is traced +/// with. The tracer makes the same paths of the same inputs, so a trace made away from the command +/// ([`TraceRun`]) stands in for the command's own in the same document. #[derive(Clone, Debug, PartialEq)] struct TraceInputs { + /// The [`DocState::uid`](crate::DocState::uid) of the document traced in. A trace made in one + /// document never stands in for one in another, however alike their images and settings. + doc: u64, target: NodeId, image: Box<ImageObject>, /// The settings traced with, as JSON. @@ -600,7 +603,7 @@ fn prepare(s: &Session, c: &str, p: &Value) -> Result<Prepared> { let bytes = Arc::clone(&blob.bytes); let library = trace_library(c, s, &mut params)?; let traced_with = serde_json::to_value(¶ms).map_err(|e| EngineError::Other(e.to_string()))?; - let inputs = TraceInputs { target, image, params: traced_with, swatches: params.swatches.clone(), bytes }; + let inputs = TraceInputs { doc: s.doc()?.uid, target, image, params: traced_with, swatches: params.swatches.clone(), bytes }; Ok(Prepared { inputs, trace: params, view, params_json, preset_label, library }) } @@ -612,8 +615,9 @@ pub struct Traced { } impl Traced { - /// Hand it to the next run of its command with the same inputs ([`TraceRun::params`]), which - /// applies it as one undo step instead of tracing again. Any other trace drops it. + /// Hand it to the next run of its command with the same inputs ([`TraceRun::params`]) in the + /// document it was made in, which applies it as one undo step instead of tracing again. Any + /// other trace drops it, a trace in another document included. pub fn hand_in(self, s: &mut Session) { s.trace_hand_off = Some(self); } @@ -686,7 +690,7 @@ impl TraceRun { } /// Does it still apply: would the command trace the same object, image, pixels and settings - /// now? + /// now, in the document it was prepared in? pub fn current(&self, s: &Session) -> bool { prepare(s, self.command, &self.params).is_ok_and(|now| now.inputs == self.prepared.inputs) } diff --git a/crates/engine/src/tests/build.rs b/crates/engine/src/tests/build.rs index 1c3ad5d8b4..02860fa4e5 100644 --- a/crates/engine/src/tests/build.rs +++ b/crates/engine/src/tests/build.rs @@ -4229,6 +4229,41 @@ fn a_trace_run_hands_its_trace_to_the_command() { assert!((bb.center().x - 160.0).abs() < 1.5, "traced where the image is now: {bb:?}"); } +/// A trace made in one document applies only there: in another document with the same image, +/// object and settings, the run no longer applies, and both trace commands drop the trace handed +/// in and trace that document's own image, as one undo step. +#[test] +fn a_trace_run_applies_only_in_its_own_document() { + let p = json!({"params": {"ignoreWhite": true}}); + for command in ["imageTrace.make", "imageTrace.makeAndExpand"] { + let mut direct = session(); + image_doc(&mut direct); + let want = direct.execute(command, &p).unwrap(); + let mut s = session(); + let img = image_doc(&mut s); + let a = s.active_index().unwrap(); + let copy = (*s.doc().unwrap().doc).clone(); + let run = cmd::TraceRun::prepare(&s, command, &p).unwrap(); + let traced = run.run(&|_, _| true).unwrap(); + let b = s.add_document(copy, None); + assert_ne!(s.documents()[a].uid, s.documents()[b].uid); + assert!(!run.current(&s), "{command}: another document"); + assert!(s.set_active(a)); + assert!(run.current(&s), "{command}: its own document"); + assert!(s.set_active(b)); + traced.hand_in(&mut s); + let got = s.execute(run.command(), run.params()).unwrap(); + assert!(s.trace_hand_off.is_none(), "{command}: dropped"); + assert_eq!(got, want, "{command}"); + let g = NodeId(got["id"].as_u64().unwrap()); + assert_eq!(node(&s, g), node(&direct, g), "{command}"); + s.execute("edit.undo", &json!({})).unwrap(); + assert!(matches!(node(&s, img).kind, NodeKind::Image(_)), "{command}: one undo step"); + assert!(s.set_active(a)); + assert!(matches!(node(&s, img).kind, NodeKind::Image(_)), "{command}: the first document is untouched"); + } +} + /// A plug-in run that calls Image Trace and then fails leaves a trace handed in for the command in /// place, as it leaves the document. #[test] diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ad7e9f4eab..39f99a606b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1428,6 +1428,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - **Image Trace, Flat Logo working size:** Flat Logo traces at most 1024 px on a side; a larger decoded raster (the 64-megapixel copy for a bigger image) is averaged down in whole-number blocks first, and the trace's `warnings` name the size it was traced at and the image's own size, in place of the slower-trace and 64-megapixel notes; code-drawn 1024 and 1025 px tests in `crates/trace` and `crates/engine`. - **Image Trace, Flat Logo working size:** Flat Logo traces at most 1024 px on a side; a larger image is averaged down by a whole factor first, and the trace's `warnings` name the size it was traced at and the image's own size, in place of the slower-trace and 64-megapixel notes; code-drawn 1024 and 1025 px tests in `crates/trace` and `crates/engine`. - **Image Trace, Preview:** the Image Trace panel's Preview checkbox, before Trace, is on by default, and a setting change traces the selected Image Trace object again at once. Off, changes wait in the panel until Trace applies them as one undo step, or until Preview is turned on again. Changes stay with the object they were made for while another object is selected. When Preview is turned on with that object not selected, the object is traced with its changes when it is selected again. Preview is kept with the UI preferences, and Reset to Default leaves it. The `imageTrace.preview` command turns it on or off. +- **Image Trace, traces made off the UI thread stay with their document:** a trace made away from the command (`TraceRun`) applies only in the document it was made in. In another open document with the same image, object and settings, `imageTrace.make` and `imageTrace.makeAndExpand` drop it and trace that document's image, as one undo step (VectorCraft's own rule). Test: `a_trace_run_applies_only_in_its_own_document` in `crates/engine`. Scores and hours unchanged. - **Image Trace small contours:** closed fits too small to form an editable subpath retain their positioned outline, including holes. Source-generated island, hole/winding and stepped-region regressions cover Corners and Noise; defaults, parity scores and estimates are unchanged. - **Image Trace, custom presets:** Manage Presets next to the Image Trace panel's Preset dropdown saves the panel's settings as a new preset under a name (Save as New Preset…) and renames or deletes the saved preset shown; built-in presets don't change. Saved presets are kept with the preferences and follow the built-in ones in the panel, Control bar and Properties preset lists. `imageTrace.presets.save` and `imageTrace.presets.delete` save, rename and delete them, `imageTrace.presets` lists them, and `imageTrace.make {preset}` traces with one by name. - **Image Trace, preset buttons:** six buttons above the Image Trace panel's Preset dropdown choose a preset as the dropdown does, for the options the [help page](https://helpx.adobe.com/illustrator/desktop/manage-objects/traces-mockups-symbols/image-trace-panel-options.html) lists before Preset. The presets each button chooses are VectorCraft's own: Auto Color chooses Auto Color, High Color chooses High Fidelity Photo, Low Color chooses Low Fidelity Photo, Grayscale chooses Shades of Gray, Black and White chooses Black and White Logo, and Outline chooses Outline. With Preview on, a click traces the selected Image Trace object again as one undo step; with nothing traced selected, it changes the panel's settings only. The button of the panel's preset shows as selected. From 36c62e14d2f1ab50b0969a67924270ad833e1078 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 05:14:11 -0800 Subject: [PATCH 107/108] Panels: drag autoscroll scrolls the right way in a short list In a list view shorter than 56 pt the 28 pt top and bottom bands of the drag autoscroll overlapped, so their speeds partly canceled: in a 40 pt view a pointer 19 pt down scrolled at 20 pt/s instead of 74. In a view shorter than 28 pt a pointer just outside one edge scrolled toward the other. Each band is now at most half the view, so the pointer is in one band at most. Views of 56 pt or more keep their bands and speeds. The band and speed math moves into drag_scroll_speed, with a test of short, tall and invalid view heights. --- crates/ui-egui/src/panels.rs | 42 +++++++++++++++++++++++++++++++++--- docs/target-app-parity.md | 2 +- 2 files changed, 40 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/panels.rs b/crates/ui-egui/src/panels.rs index 71019385b6..0b0435b3c6 100644 --- a/crates/ui-egui/src/panels.rs +++ b/crates/ui-egui/src/panels.rs @@ -529,6 +529,21 @@ const DRAG_SCROLL_EDGE: f32 = 28.0; /// the list's edge. const DRAG_SCROLL_SPEED: (f32, f32) = (60.0, 280.0); +/// The scrolling [`scroll_at_edges`] asks for, in points per second (positive shows earlier rows), +/// with the pointer `depth` points below the top of a list view `view_height` points tall. Each +/// band is [`DRAG_SCROLL_EDGE`] deep, or half the view in a view shorter than two bands, so the +/// pointer is in one band at most and the middle of a short view scrolls neither way. A view with +/// no height, or a value that isn't a number, gives 0. +fn drag_scroll_speed(view_height: f32, depth: f32) -> f32 { + if !(view_height.is_finite() && view_height > 0.0) { + return 0.0; + } + let band = DRAG_SCROLL_EDGE.min(view_height / 2.0); + let (slow, more) = DRAG_SCROLL_SPEED; + let speed = |depth: f32| if (0.0..band).contains(&depth) { slow + more * (1.0 - depth / band) } else { 0.0 }; + speed(depth) - speed(view_height - depth) +} + /// While something is dragged near the top or bottom edge of a scrolled list (`ui`: its contents), /// scroll that way, faster nearer the edge, and draw the next frame so a pointer held still keeps /// it scrolling. The pointer must be over the list's width. Each frame scrolls by the time it @@ -540,9 +555,7 @@ pub(crate) fn scroll_at_edges(ui: &mut Ui) { if !view.x_range().contains(pos.x) { return; } - let (slow, more) = DRAG_SCROLL_SPEED; - let speed = |depth: f32| if (0.0..DRAG_SCROLL_EDGE).contains(&depth) { slow + more * (1.0 - depth / DRAG_SCROLL_EDGE) } else { 0.0 }; - let per_second = speed(pos.y - view.top()) - speed(view.bottom() - pos.y); + let per_second = drag_scroll_speed(view.height(), pos.y - view.top()); if per_second != 0.0 { let dt = ui.input(|i| i.stable_dt).min(0.1); ui.scroll_with_delta_animation(vec2(0.0, per_second * dt), egui::style::ScrollAnimation::none()); @@ -683,6 +696,29 @@ mod tests { let tint = Paint::Solid { color: Color::gray(0.5), swatch: Some("Ink".into()), tint: 0.5 }; assert_eq!(paint_params(&tint), json!({"swatch": "Ink", "tint": 50.0}), "a tint keeps its percentage"); } + + #[test] + fn drag_scrolling_in_a_short_list_goes_toward_the_nearer_edge() { + let near = |a: f32, b: f32| (a - b).abs() < 1e-3; + // A 40 pt view: each band is 20 pt deep, so the pointer is in one band at most. + for (depth, want) in [(5.0, 270.0), (15.0, 130.0), (20.0, 0.0), (25.0, -130.0), (35.0, -270.0)] { + let got = drag_scroll_speed(40.0, depth); + assert!(near(got, want), "40 pt view, pointer {depth} pt down: {got} pt/s, want {want}"); + } + // Just outside a 20 pt view, the pointer does not scroll the list toward the far edge. + for depth in [-1.0, 21.0] { + assert_eq!(drag_scroll_speed(20.0, depth), 0.0, "20 pt view, pointer {depth} pt down"); + } + // From 56 pt up, the bands stay 28 pt deep and the speeds are unchanged. + for (h, depth, want) in [(100.0, 5.0, 290.0), (100.0, 95.0, -290.0), (100.0, 50.0, 0.0), (56.0, 0.0, 340.0), (56.0, 27.0, 70.0)] { + let got = drag_scroll_speed(h, depth); + assert!(near(got, want), "{h} pt view, pointer {depth} pt down: {got} pt/s, want {want}"); + } + for h in [0.0, -10.0, f32::NAN, f32::INFINITY] { + assert_eq!(drag_scroll_speed(h, 5.0), 0.0, "view height {h}"); + } + assert_eq!(drag_scroll_speed(40.0, f32::NAN), 0.0); + } } #[cfg(test)] mod tests_appearance; diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index ad7e9f4eab..bdf2706a14 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -879,7 +879,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - Screen readers get the value of the color and channel sliders that panels and dialogs draw (the Color panel, the Color Picker, Swatch Options, the Navigator's Zoom, the Character panel's variable font axes, the Perspective Grid and flattener options, and the sliders of the effect, tool option and transform dialogs): the number and text of the field beside each one, such as 128 for G or 50% for an opacity, with the slider's range, which extends to include a number past the slider's end. The harmony wheel's Brightness slider, which has no field, reports its brightness in percent. - A layer whose Layer Options › Print is off shows its name italic in the Layers panel, and while its row is dragged, as the reference application shows non-printing layers (#5739); a printing layer stays upright and ticking Print again restores the upright name (`panels::layers` test `a_layer_that_does_not_print_has_its_name_italic`). - In the Layers panel only the primary mouse button drags. A drag with the right or middle button on a row, a guide row, the selection square, the eye or lock column or a target circle moves, copies, hides, locks and transfers nothing and records no undo step, and a right-click still opens the row's menu (`panels::layers` test `only_the_primary_button_drags_rows_guides_art_columns_and_appearances`). - - Rows dragged in the Layers panel and held within 28 points of the list's top or bottom edge scroll a long list that way, faster nearer the edge (60 points a second at the band's inner side, 340 at the edge, at every frame rate), and keep scrolling while the pointer stays still, so a row out of view can take the drop (a move, or a copy with Alt); the Libraries panel's list scrolls by the same rule. A pointer beside the list, a drag of the eye or lock column and a release stop the scrolling, and scrolling changes nothing in the document. The band and speeds are VectorCraft's own (`panels::layers` tests `rows_held_near_the_bottom_or_top_edge_scroll_the_list_to_a_row_out_of_view`, `a_held_row_scrolls_the_list_as_far_in_the_same_time_at_any_frame_rate` and `the_list_scrolls_only_for_rows_held_over_it`). + - Rows dragged in the Layers panel and held within 28 points of the list's top or bottom edge scroll a long list that way, faster nearer the edge (60 points a second at the band's inner side, 340 at the edge, at every frame rate), and keep scrolling while the pointer stays still, so a row out of view can take the drop (a move, or a copy with Alt); the Libraries panel's list scrolls by the same rule. In a list view shorter than 56 points each band is half the view, so a pointer in the top half scrolls up, one in the bottom half scrolls down, and a pointer just outside the view does not scroll it toward the far edge. A pointer beside the list, a drag of the eye or lock column and a release stop the scrolling, and scrolling changes nothing in the document. The band and speeds are VectorCraft's own (`panels::layers` tests `rows_held_near_the_bottom_or_top_edge_scroll_the_list_to_a_row_out_of_view`, `a_held_row_scrolls_the_list_as_far_in_the_same_time_at_any_frame_rate` and `the_list_scrolls_only_for_rows_held_over_it`; `panels` test `drag_scrolling_in_a_short_list_goes_toward_the_nearer_edge`). - The other panels' item drags start only with the primary mouse button too: swatches and color groups, brushes, symbols, graphic styles, library items and groups, character and paragraph styles, Appearance rows and its thumbnail, the Fill and Stroke squares, Recent Colors and the Gradient panel's thumbnail. A right or middle drag on one carries nothing, moves, copies, deletes and applies nothing and records no undo step; right-click menus and the Graphic Styles panel's held right-button preview stay as they were (`panels::swatches` test `only_a_primary_drag_moves_swatches_and_groups`, `panels::text_styles` test `only_a_primary_drag_carries_a_style_row`, `panels::tests_symbol_libraries` test `only_a_primary_drag_carries_a_library_symbol_out`, `panels::tests_effectedit` test `only_a_primary_drag_carries_the_thumbnail_or_a_row`). - Panels undock (#495): a dock tab, a panel icon or a popped-out panel's title dragged out of the dock floats that panel (in an OS window of its own on the desktop, #4135), and the strip right of the dock's tabs floats the whole tabbed group. A floating group moves by its title bar, a tab dragged out of it floats on its own, and dropped on another group's title bar or tabs it stacks with that group; dropped on a dock group's tabs, which light up under the pointer, its panels join that group, and on the group's upper or lower half they make a new group above or below it (`window.panel.dock {anchor, zone}`); dropped on the icon column they become icons there, the tabbed group's panels too (`window.panel.dock {icon: true}`); dropped anywhere else on the dock, which lights up, they go back where they live (the tabbed group or the icon column), as its × and the panel menus' Float Panel / Dock Panel do (`window.panel.float`, `window.panel.dock`). The Tools panel floats by its title bar and docks again on the window's left edge. Floating groups stack into sets: dropped on the upper or lower half of another group (a line shows where), a group joins it right above or below it, and the set's groups stack top to bottom, each showing one panel, moving together by the top group's title bar, whose × docks them all; a group dragged by its tab strip leaves the set (`window.panel.float {below, above}`). A double-click on a tab collapses a floating group to its tabs (`collapsed`), and a dock group too, a group below it moving up into the room; a second double-click, or a click on another of its tabs, expands it (`window.panel.collapse`, kept with the preferences and in saved workspaces). Sets dropped on the left edge of the icon column or of another dock column dock as dock columns (a multi-column dock, `window.panel.dock {column}`), whose groups stack, tab and tear out as a floating set's do, and whose top strip floats the column again. Floating panels, their sets and the Tools panel's position are kept with the preferences and in user workspaces, and clamped into a smaller window. Not done: panels in separate OS windows, reordering tabs by dragging, collapsing a set or dock column to icons, dock columns right of the default dock, resizing floating panels and the groups of a set. - A floating panel's OS window hides while a tool group's flyout or the All Tools drawer is open in the main window, as it does under a modal dialog or a menu, and shows again when the flyout or the drawer closes (#5813; `a_tool_flyout_hides_the_palette_windows_until_it_closes`). From 1ec44403c154ada25323e98daff59456a75a74c9 Mon Sep 17 00:00:00 2001 From: dotCooCoo <RobertLeeLW@gmail.com> Date: Sat, 14 Nov 2026 05:20:31 -0800 Subject: [PATCH 108/108] SVG import: reading the links of linked SVG files stops at the read and text limits Reading an SVG file that an <image> links to, and gathering its own links, counts toward the 1,024 reads and 512 MB of text, wherever the file is linked from. Inside a linked SVG file, every file read for its links, raster or SVG, also counts toward the 512 MB before it is decoded, and once either limit is passed no file is read there: the image is left out with a warning. An SVG file the imported SVG links to is still shown past the limits, but the files its own links name are not read, with the same warning. Rasters the imported SVG links to are read as before. Every SVG file read is kept by its file, wherever it was read, so another href to it (another spelling, or the same file from another SVG file) does not read it again, past the limits too. An SVG file whose art depends on where it is shown (too deep there for its links to be read, or with a link that leads back) is not kept, so a link to it from a shallower place shows the rasters it links to. --- crates/svg/src/import/files.rs | 318 +++++++++++++++++++++----- crates/svg/tests/it/import_details.rs | 16 ++ docs/target-app-parity.md | 2 +- 3 files changed, 281 insertions(+), 55 deletions(-) diff --git a/crates/svg/src/import/files.rs b/crates/svg/src/import/files.rs index 605b206717..d2b5504f9d 100644 --- a/crates/svg/src/import/files.rs +++ b/crates/svg/src/import/files.rs @@ -68,6 +68,9 @@ pub(in crate::import) struct Files { svg_text: AtomicU64, /// SVG images were left out for exceeding [`MAX_NESTED_SVG_READS`] or [`MAX_NESTED_SVG_TEXT`]. too_much_svg_read: AtomicBool, + /// Images linked from linked SVG files were left out, their files not read, past the same + /// limits for the files read for links. + too_much_linked: AtomicBool, /// The CMYK TIFF stored in place of a turned CMYK image, by the address of the PNG usvg got /// (kept here too, so the address stays its own). cmyk: Mutex<HashMap<usize, (Bytes, Bytes)>>, @@ -110,19 +113,59 @@ struct Reading<'a, 'w> { /// The placeholder's bytes, made once. placeholder: Option<Option<Vec<u8>>>, /// What each file read gave, by the file: hrefs spelled differently (`a.png`, `./a.png`, - /// `%61.png`), and in different SVG files, share one read and one copy of its bytes. An SVG - /// file with a link inside it that led back to an SVG file isn't kept: what it shows depends - /// on where it is. - by_file: HashMap<String, Result<Source, &'static str>>, + /// `%61.png`), and in different SVG files, share one read and one copy of its bytes. Only an + /// SVG file whose art depends on where it is shown ([`Reading::placed`]) isn't kept, and a + /// raster read past the limits, which is left out. + by_file: HashMap<String, Outcome>, /// The SVG files whose links are being read, innermost last, by [`identity`]. active: Vec<String>, - /// A link led back to one of them while the file being read was read. - led_back: bool, - /// How many linked SVG files were read for their links, and the bytes of their text. + /// What the file being read gives depends on where it is shown: a link inside it led back to + /// an SVG file around it, or an SVG file inside it nests too deep there for its links to be + /// read. + placed: bool, + /// How many linked SVG files were read for their links, and the bytes of every linked SVG + /// file read and of every file read for the links of a linked SVG file. Rasters the imported + /// SVG links to aren't counted. svg_reads: usize, svg_text: u64, } +impl Reading<'_, '_> { + /// The files read for links passed [`MAX_NESTED_SVG_READS`] or [`MAX_NESTED_SVG_TEXT`]. + fn spent(&self) -> bool { + self.svg_reads > MAX_NESTED_SVG_READS || self.svg_text > MAX_NESTED_SVG_TEXT + } +} + +/// What reading a linked file gave: what usvg gets, or why it can't be read. +#[derive(Clone)] +struct Outcome { + source: Result<Source, &'static str>, + /// An SVG file whose own links weren't read, past [`Reading::spent`]: inside a linked SVG + /// file it is left out, and where the imported SVG links to it, it is shown without them. + capped: bool, +} + +impl Outcome { + fn not_read(why: &'static str) -> Self { + Outcome { source: Err(why), capped: false } + } + + fn shown(source: Source) -> Self { + Outcome { source: Ok(source), capped: false } + } +} + +/// Does SVG text `text` have an `<image>` that links to a file (not a data URL)? +fn links_files(text: &str) -> bool { + super::parse(text).is_ok_and(|xml| xml.descendants().any(|n| n.is_element() && n.tag_name().name() == "image" && file_href(n).is_some())) +} + +/// The href of `<image>` element `n`, unless it is a data URL. +fn file_href<'a>(n: roxmltree::Node<'a, '_>) -> Option<&'a str> { + href(n).filter(|h| !h.trim_start().starts_with("data:")) +} + /// What the link to an SVG file being read is compared by, to find a link back to it: its path /// with links and `..` resolved, or the path as given when that can't be found. fn identity(file: &str) -> String { @@ -206,7 +249,7 @@ impl Files { pub(in crate::import) fn read(svg: &str, xml: &roxmltree::Document, opts: &ImportOptions, edits: &mut Edits, warnings: &mut Vec<String>) -> Self { let mut files = Files::default(); let mut reading = - Reading { opts, warnings, placeholder: None, by_file: HashMap::new(), active: vec![], led_back: false, svg_reads: 0, svg_text: 0 }; + Reading { opts, warnings, placeholder: None, by_file: HashMap::new(), active: vec![], placed: false, svg_reads: 0, svg_text: 0 }; files.sources = files.links_of(svg, xml, opts.folder, None, edits, &mut reading); files } @@ -224,49 +267,44 @@ impl Files { reading: &mut Reading<'_, '_>, ) -> HashMap<String, Source> { let mut sources: HashMap<String, Source> = HashMap::new(); + let nested = !reading.active.is_empty(); for n in xml.descendants().filter(|n| n.is_element() && n.tag_name().name() == "image") { - let Some(h) = href(n).filter(|h| !h.trim_start().starts_with("data:")) else { continue }; + let Some(h) = file_href(n) else { continue }; if !sources.contains_key(h) { let (path, file) = target(h, folder); // A failed read is cached too, but each href gets its own placeholder: its own link // path (an Arc shared between hrefs would share the first href's link) and warning. - let back = !reading.active.is_empty() && file.as_deref().is_some_and(|f| reading.active.contains(&identity(f))); + let back = nested && file.as_deref().is_some_and(|f| reading.active.contains(&identity(f))); let cached = file.as_ref().and_then(|f| reading.by_file.get(f)).cloned(); - let source = match cached { + let outcome = match cached { _ if back => { - reading.led_back = true; - Err("leads back to an SVG file that shows it") + reading.placed = true; + Some(Outcome::not_read("leads back to an SVG file that shows it")) } - Some(source) => source, + Some(outcome) => Some(outcome), None => { - let read = file.clone().and_then(|file| reading.opts.read.and_then(|read| read(&file))); - let around = std::mem::replace(&mut reading.led_back, false); - let source = match (read, file.as_deref()) { - (Some((bytes, link)), Some(f)) => match self.source(bytes, link) { - Some(Source::Svg(text)) => { - let inside = *inside.get_or_insert_with(|| depth::height(xml, MAX_ELEMENT_DEPTH).unwrap_or(MAX_ELEMENT_DEPTH)); - // Past what may be read of the SVG files, the image is left out (noted). - let Some(source) = self.svg_file(text, f, inside, reading) else { - reading.led_back = around; - continue; - }; - Ok(source) - } - source => source.ok_or("is not an image VectorCraft reads"), - }, - _ => Err("not found"), - }; - // Kept unless a link inside it led back to an SVG file. - let led_back = reading.led_back; - reading.led_back |= around; - if let Some(file) = file - && !led_back + let around = std::mem::replace(&mut reading.placed, false); + let outcome = self.file(file.as_deref(), xml, &mut inside, reading); + // Kept unless what it shows depends on where it is. + let placed = reading.placed; + reading.placed |= around; + if let (Some(file), Some(outcome)) = (file, &outcome) + && !placed { - reading.by_file.insert(file, source.clone()); + reading.by_file.insert(file, outcome.clone()); } - source + outcome } }; + // Inside a linked SVG file, past what may be read, the image is left out (noted). + let source = match outcome { + None => continue, + Some(Outcome { capped: true, .. }) if nested => { + self.too_much_svg_read.store(true, Ordering::Relaxed); + continue; + } + Some(outcome) => outcome.source, + }; let source = source.or_else(|why| { reading.warnings.push(format!("linked image '{h}' {why}: a placeholder keeps its place until it is relinked")); let bytes = Arc::new(reading.placeholder.get_or_insert_with(missing_placeholder).clone().ok_or(why)?); @@ -283,32 +321,73 @@ impl Files { sources } - /// Linked SVG file `file`, read as `svg`, with the files its own `<image>` elements link to - /// read from its folder; `inside` is how deep it nests in the SVGs around it. Its links aren't - /// read when it nests too deep to be shown, or when it isn't XML. `None`, noted, once the SVG - /// files read for their links pass [`MAX_NESTED_SVG_READS`] or [`MAX_NESTED_SVG_TEXT`]. - fn svg_file(&mut self, svg: Arc<SvgFile>, file: &str, inside: usize, reading: &mut Reading<'_, '_>) -> Option<Source> { - let left = MAX_ELEMENT_DEPTH.saturating_sub(inside); - if !svg.text.contains("image") || depth::xml_deeper_than(&svg.text, left) { - return Some(Source::Svg(svg)); - } - reading.svg_reads += 1; - reading.svg_text = reading.svg_text.saturating_add(svg.text.len() as u64); - if reading.svg_reads > MAX_NESTED_SVG_READS || reading.svg_text > MAX_NESTED_SVG_TEXT { - self.too_much_svg_read.store(true, Ordering::Relaxed); + /// What reading linked file `file` gives, linked from `xml`, whose SVG images nest `inside` + /// deep (measured here when an SVG file is read); `None` for an image left out, noted. Inside + /// a linked SVG file each file read counts toward [`MAX_NESTED_SVG_TEXT`] before it is looked + /// at, and once the files read for links pass [`MAX_NESTED_SVG_READS`] or + /// [`MAX_NESTED_SVG_TEXT`] no file is read there; a raster whose read passes them is left out + /// undecoded. Every file the imported SVG links to is read. + fn file(&mut self, file: Option<&str>, xml: &roxmltree::Document, inside: &mut Option<usize>, reading: &mut Reading<'_, '_>) -> Option<Outcome> { + let (Some(file), Some(read)) = (file, reading.opts.read) else { return Some(Outcome::not_read("not found")) }; + let nested = !reading.active.is_empty(); + if nested && reading.spent() { + self.too_much_linked.store(true, Ordering::Relaxed); return None; } + let Some((bytes, link)) = read(file) else { return Some(Outcome::not_read("not found")) }; + let counted = if nested { bytes.len() as u64 } else { 0 }; + reading.svg_text = reading.svg_text.saturating_add(counted); + if nested && reading.spent() && image::guess_format(&bytes).is_ok() { + self.too_much_linked.store(true, Ordering::Relaxed); + return None; + } + match self.source(bytes, link) { + Some(Source::Svg(svg)) => { + let inside = *inside.get_or_insert_with(|| depth::height(xml, MAX_ELEMENT_DEPTH).unwrap_or(MAX_ELEMENT_DEPTH)); + Some(self.svg_file(svg, file, inside, counted, reading)) + } + source => Some(source.map_or_else(|| Outcome::not_read("is not an image VectorCraft reads"), Outcome::shown)), + } + } + + /// Linked SVG file `file`, read as `svg`, with the files its own `<image>` elements link to + /// read from its folder; `inside` is how deep it nests in the SVGs around it, and `counted` the + /// bytes of it already counted toward [`MAX_NESTED_SVG_TEXT`]. Its text counts toward + /// [`MAX_NESTED_SVG_TEXT`], and reading its links toward [`MAX_NESTED_SVG_READS`]; once they + /// are passed, its links aren't read ([`Outcome::capped`], noted when it links to files). Its + /// links aren't read either when it nests too deep to be shown, or when it isn't XML. + fn svg_file(&mut self, svg: Arc<SvgFile>, file: &str, inside: usize, counted: u64, reading: &mut Reading<'_, '_>) -> Outcome { + reading.svg_text = reading.svg_text.saturating_add((svg.text.len() as u64).saturating_sub(counted)); + let links = svg.text.contains("image"); + reading.svg_reads += usize::from(links); + if reading.spent() { + if links && links_files(&svg.text) { + self.too_much_linked.store(true, Ordering::Relaxed); + } + return Outcome { source: Ok(Source::Svg(svg)), capped: true }; + } + let left = MAX_ELEMENT_DEPTH.saturating_sub(inside); + if !links { + return Outcome::shown(Source::Svg(svg)); + } + if depth::xml_deeper_than(&svg.text, left) { + reading.placed = true; + return Outcome::shown(Source::Svg(svg)); + } // Read from its own handle: the text stays borrowed while `svg` may be given back. let text = svg.text.clone(); - let Ok(xml) = super::parse(&text) else { return Some(Source::Svg(svg)) }; - let Some(height) = depth::height(&xml, left) else { return Some(Source::Svg(svg)) }; + let Ok(xml) = super::parse(&text) else { return Outcome::shown(Source::Svg(svg)) }; + let Some(height) = depth::height(&xml, left) else { + reading.placed = true; + return Outcome::shown(Source::Svg(svg)); + }; let folder = Path::new(file).parent().map(|p| p.to_string_lossy().into_owned()); let mut edits = Edits::default(); reading.active.push(identity(file)); let sources = self.links_of(&text, &xml, folder.as_deref(), Some(inside + height), &mut edits, reading); reading.active.pop(); let text = Arc::from(edits.apply(&text).as_ref()); - Some(Source::Svg(Arc::new(SvgFile { text, sources }))) + Outcome::shown(Source::Svg(Arc::new(SvgFile { text, sources }))) } /// What usvg gets for a file read (`bytes`, linked by `link`): a raster as [`shown`] gives it @@ -391,6 +470,12 @@ impl Files { MAX_NESTED_SVG_TEXT >> 20 )); } + if self.too_much_linked.load(Ordering::Relaxed) { + notes.push(format!( + "images linked from linked SVG files were left out: once {MAX_NESTED_SVG_READS} SVG files or {} MB have been read for their links, the files they link to aren't read", + MAX_NESTED_SVG_TEXT >> 20 + )); + } notes } @@ -770,6 +855,131 @@ mod tests { assert!(read("1")); } + /// An SVG file of 2 × 2 showing `hrefs`. + fn linking(hrefs: &[&str]) -> Vec<u8> { + let images: String = hrefs.iter().map(|h| format!(r#"<image href="{h}" width="1" height="1"/>"#)).collect(); + format!(r#"<svg xmlns="http://www.w3.org/2000/svg" width="2" height="2">{images}</svg>"#).into_bytes() + } + + /// The links of the SVG showing `hrefs` read as [`Files::read`] reads them, the files `served` + /// by name, with the SVG files and bytes read for links starting at `reads` and `text`: the + /// names of the files read, in order, and the files. + fn read_links(hrefs: &[&str], served: &[(&str, Vec<u8>)], reads: usize, text: u64) -> (Vec<String>, Files) { + let log = Mutex::new(vec![]); + let read = |path: &str| { + let name = Path::new(path).file_name()?.to_string_lossy().into_owned(); + log.lock().ok()?.push(name.clone()); + served.iter().find(|(n, _)| *n == name).map(|(_, bytes)| (bytes.clone(), LinkInfo::new(path))) + }; + let folder = std::env::temp_dir().join("vectorcraft-svg-limits"); + let folder = folder.to_string_lossy(); + let opts = ImportOptions { folder: Some(&folder), read: Some(&read) }; + let svg = String::from_utf8(linking(hrefs)).unwrap(); + let xml = super::super::parse(&svg).unwrap(); + let mut warnings = vec![]; + let mut reading = Reading { + opts: &opts, + warnings: &mut warnings, + placeholder: None, + by_file: HashMap::new(), + active: vec![], + placed: false, + svg_reads: reads, + svg_text: text, + }; + let mut files = Files::default(); + files.sources = files.links_of(&svg, &xml, opts.folder, None, &mut Edits::default(), &mut reading); + (log.into_inner().unwrap(), files) + } + + fn png() -> Vec<u8> { + let mut out = vec![]; + image::RgbaImage::new(1, 1).write_to(&mut std::io::Cursor::new(&mut out), image::ImageFormat::Png).unwrap(); + out + } + + fn linked_note() -> String { + format!( + "images linked from linked SVG files were left out: once {MAX_NESTED_SVG_READS} SVG files or {} MB have been read for their links, the files they link to aren't read", + MAX_NESTED_SVG_TEXT >> 20 + ) + } + + /// Every file read for a linked SVG file's links counts toward [`MAX_NESTED_SVG_TEXT`], a + /// raster too, after the linked SVG file's own text: the file that passes it is left out, and + /// no file after it is read. + #[test] + fn linked_files_past_the_text_limit_are_not_read() { + let a = linking(&["one.png", "two.png", "three.png"]); + let served = [("a.svg", a.clone()), ("one.png", png()), ("two.png", png()), ("three.png", png())]; + let (log, files) = read_links(&["a.svg"], &served, 0, MAX_NESTED_SVG_TEXT - (png().len() + a.len()) as u64); + assert_eq!(log, ["a.svg", "one.png", "two.png"]); + let Some(Source::Svg(a)) = files.sources.get("a.svg") else { panic!("a.svg is shown") }; + assert!(a.sources.contains_key("one.png") && a.sources.len() == 1, "{:?}", a.sources.keys()); + assert_eq!(files.left_out(), [linked_note()]); + } + + /// Once more than [`MAX_NESTED_SVG_READS`] SVG files are read for their links, the SVG file + /// past it is left out inside a linked SVG file, and no file a linked SVG file links to is + /// read (a nested link past the limit); rasters the imported SVG links to still are. + #[test] + fn linked_files_past_the_read_limit_are_not_read() { + let served = [("a.svg", linking(&["b.svg", "two.png"])), ("b.svg", linking(&["one.png"])), ("one.png", png()), ("two.png", png())]; + let (log, files) = read_links(&["a.svg", "two.png"], &served, MAX_NESTED_SVG_READS - 1, 0); + assert_eq!(log, ["a.svg", "b.svg", "two.png"]); + let Some(Source::Svg(a)) = files.sources.get("a.svg") else { panic!("a.svg is shown") }; + assert!(a.sources.is_empty(), "{:?}", a.sources.keys()); + assert!(matches!(files.sources.get("two.png"), Some(Source::Raster(..)))); + assert_eq!(files.left_out().len(), 2, "{:?}", files.left_out()); + assert!(files.left_out().contains(&linked_note())); + } + + /// Reading the SVG files the imported SVG links to, and their links, counts toward the + /// limits: past them, such a file is still shown, but the files it links to aren't read. + #[test] + fn svg_files_the_imported_svg_links_to_are_shown_without_their_links_past_the_limits() { + let served = [("a.svg", linking(&["one.png"])), ("one.png", png())]; + for (reads, text) in [(MAX_NESTED_SVG_READS, 0), (0, MAX_NESTED_SVG_TEXT)] { + let (log, files) = read_links(&["a.svg"], &served, reads, text); + assert_eq!(log, ["a.svg"], "one.png isn't read"); + let Some(Source::Svg(a)) = files.sources.get("a.svg") else { panic!("a.svg is shown") }; + assert!(a.sources.is_empty(), "{:?}", a.sources.keys()); + assert_eq!(files.left_out(), [linked_note()]); + } + // More of them than the limit: those past it are shown without their links. + let names: Vec<String> = (0..MAX_NESTED_SVG_READS + 2).map(|i| format!("s{i}.svg")).collect(); + let hrefs: Vec<&str> = names.iter().map(String::as_str).collect(); + let mut served: Vec<(&str, Vec<u8>)> = hrefs.iter().map(|h| (*h, linking(&["one.png"]))).collect(); + served.push(("one.png", png())); + let (log, files) = read_links(&hrefs, &served, 0, 0); + assert_eq!(log.len(), hrefs.len() + 1, "one.png is read once"); + let with_links = hrefs.iter().filter(|h| matches!(files.sources.get(**h), Some(Source::Svg(s)) if s.sources.contains_key("one.png"))); + assert_eq!(with_links.count(), MAX_NESTED_SVG_READS); + assert!(hrefs.iter().all(|h| matches!(files.sources.get(*h), Some(Source::Svg(_)))), "all shown"); + assert_eq!(files.left_out(), [linked_note()]); + } + + /// An SVG file read once is kept by its file wherever it was read: another spelling of its + /// href doesn't read it again, past the limits too. + #[test] + fn an_svg_file_is_read_once_past_the_limits() { + let served = [("a.svg", linking(&["one.png"])), ("one.png", png())]; + let (log, files) = read_links(&["a.svg", "./a.svg", "%61.svg"], &served, MAX_NESTED_SVG_READS, 0); + assert_eq!(log, ["a.svg"]); + assert!(["a.svg", "./a.svg", "%61.svg"].iter().all(|h| matches!(files.sources.get(*h), Some(Source::Svg(_))))); + // Read inside a linked SVG file, where its read passes the text limit: left out there, + // and shown, not read again, where the imported SVG links to it. + let x = linking(&["a.svg"]); + let served = [("x.svg", x.clone()), ("a.svg", linking(&["one.png"])), ("one.png", png())]; + let (log, files) = read_links(&["x.svg", "./a.svg"], &served, 0, MAX_NESTED_SVG_TEXT - x.len() as u64); + assert_eq!(log, ["x.svg", "a.svg"]); + let Some(Source::Svg(x)) = files.sources.get("x.svg") else { panic!("x.svg is shown") }; + assert!(x.sources.is_empty(), "{:?}", x.sources.keys()); + let Some(Source::Svg(a)) = files.sources.get("./a.svg") else { panic!("a.svg is shown") }; + assert!(a.sources.is_empty(), "{:?}", a.sources.keys()); + assert_eq!(files.left_out().len(), 2, "{:?}", files.left_out()); + } + /// The nested SVG images read, decoded or not, take at most [`MAX_NESTED_SVG_TEXT`] bytes of /// text together: an image whose text goes past it is left out and noted. A broken image's /// text counts too, and its decoded place is given back. diff --git a/crates/svg/tests/it/import_details.rs b/crates/svg/tests/it/import_details.rs index cea67c14bc..69e5cafa21 100644 --- a/crates/svg/tests/it/import_details.rs +++ b/crates/svg/tests/it/import_details.rs @@ -379,6 +379,22 @@ fn a_chain_of_linked_svg_files_stops_at_the_depth_cap() { assert!(w.iter().any(|w| w.contains("nest more than")), "{w:?}"); } +/// An SVG file reached first inside an SVG file where it nests too deep to be shown, then from the +/// imported SVG, shows the raster it links to where it fits. +#[test] +fn an_svg_file_too_deep_in_one_place_shows_its_links_in_another() { + let dir = folder("nested-deep-then-shallow"); + let depth = vectorcraft_svg::MAX_ELEMENT_DEPTH; + let nest = |n: usize, inner: &str| format!("{}{inner}{}", "<g>".repeat(n), "</g>".repeat(n)); + std::fs::write(dir.join("img").join("photo.png"), png(4, 4)).unwrap(); + std::fs::write(dir.join("img").join("deep.svg"), svg_file(&nest(depth * 2 / 3, r#"<image href="a.svg" width="10" height="10"/>"#))).unwrap(); + std::fs::write(dir.join("img").join("a.svg"), svg_file(&nest(depth / 2, r#"<image href="photo.png" width="10" height="10"/>"#))).unwrap(); + let (d, w) = open_in(&dir, r#"<image href="img/deep.svg" width="20" height="20"/><image href="img/a.svg" x="50" width="20" height="20"/>"#); + assert!(w.iter().any(|w| w.contains("nest more than")), "{w:?}"); + let [(_, im)] = images(&d)[..] else { panic!("{:?} {w:?}", art(&d)) }; + assert_eq!(Path::new(&im.link.as_ref().unwrap().path), dir.join("img").join("photo.png")); +} + const SVG_NS: &str = r#"xmlns="http://www.w3.org/2000/svg""#; /// An image showing `svg`, from a base64 data URL of type `mime` (none when empty). diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 680e72b947..4543f05ae7 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1790,7 +1790,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - An image that Open and Place store again keeps the ICC profile its file embeds and its 16-bit samples. A turned PNG, JPEG, WebP or TIFF stored as PNG, and a TIFF the image decoder reads, keep their gray or RGB samples at 8 or 16 bits with their gray or RGB profile in the PNG's `iCCP` chunk ([PNG specification, iCCP](https://www.w3.org/TR/png-3/#11iCCP)). A CMYK TIFF stored with one plane per ink and a turned CMYK JPEG or TIFF keep their CMYK profile as TIFF tag 34675, a JPEG's put together from all its APP2 segments ([ICC image-format guide](https://github.com/InternationalColorConsortium/iccDEV/blob/master/iccdev-mcp/docs/icc-format-guide.md)). A profile whose color space differs from the stored samples' is left out. The profile is kept in the stored image; how CMYK inks are drawn and exported to PDF does not change (`crates/engine/src/cmd/fileio/tests.rs`). - SVG import shows a raster `<image>` whose EXIF orientation or TIFF Orientation tag turns or flips it upright, linked or as a data URL, and inside an SVG shown as an image: the pixels are stored turned, the width and height swap, and the `<image>` box fits the turned image under `preserveAspectRatio`, as CSS `image-orientation: from-image` describes (<https://www.w3.org/TR/css-images-3/#the-image-orientation>). A turned CMYK JPEG or TIFF keeps its inks as a CMYK TIFF, as does a CMYK TIFF that is not turned. TIFF data URLs (`image/tiff`, or untyped TIFF bytes) are read, and TIFFs with an alpha or other extra channel, CCITT Group 3 TIFFs and CMYK TIFFs stored one plane per ink are read as Open and Place read them. The pixels are decoded within the decode allowance, and a TIFF claiming more strips or tiles than the decoder can count is refused before it is decoded (`crates/svg/tests/it/image_orientation.rs`). - SVG import leaves out an SVG shown as an image that it can't read (text that isn't XML, an SVG without a size) and goes on with the images after it, as SVG 2's error processing describes (<https://www.w3.org/TR/SVG2/conform.html>). Only images that decode count toward the 256 nested SVG images an SVG may show, so an image after many broken ones is imported. Every nested SVG image read, decoded or not, counts toward VectorCraft's own limits of 1,024 reads and 512 MB of text per import; past them, nested SVG images are left out with a warning (`crates/svg/tests/it/import_details.rs`). - - SVG import reads the files that a linked SVG file's own `<image>` elements link to, relative paths from that file's folder (<https://www.rfc-editor.org/rfc/rfc3986#section-5.1.3>), as it reads the imported SVG's links: a raster stays linked, an SVG file imports as vector art, and one that can't be read gets the placeholder, its link and a warning. SVG 2 tells a viewer not to load these links (<https://www.w3.org/TR/SVG2/conform.html#secure-static-mode>); reading them is VectorCraft's own rule. The same href in SVG files of two folders names two files. A link that leads back to an SVG file showing it gets the placeholder and a warning, and reading the links of linked SVG files stops at the nesting depth cap and at 1,024 reads and 512 MB of text per import, the same limits decoded nested SVG images have, counted separately from them (`crates/svg/tests/it/import_details.rs`). + - SVG import reads the files that a linked SVG file's own `<image>` elements link to, relative paths from that file's folder (<https://www.rfc-editor.org/rfc/rfc3986#section-5.1.3>), as it reads the imported SVG's links: a raster stays linked, an SVG file imports as vector art, and one that can't be read gets the placeholder, its link and a warning. SVG 2 tells a viewer not to load these links (<https://www.w3.org/TR/SVG2/conform.html#secure-static-mode>); reading them is VectorCraft's own rule. The same href in SVG files of two folders names two files. A link that leads back to an SVG file showing it gets the placeholder and a warning, and reading the links of linked SVG files stops at the nesting depth cap and at 1,024 reads and 512 MB per import, the same limits decoded nested SVG images have, counted separately from them. The text of every linked SVG file read counts, and so does every file read for the links of a linked SVG file, raster or SVG; rasters the imported SVG links to don't. Once either limit is passed, no file linked from a linked SVG file is read and its image is left out with a warning, and an SVG file the imported SVG links to is still shown, without the files its own links name, with a warning. Another href to an SVG file already read, spelled differently or in another SVG file, does not read it again, unless a link back or the depth cap changes what it shows there (`crates/svg/tests/it/import_details.rs`, `crates/svg/src/import/files.rs`). - File › Place and a file dropped on the canvas refuse a PNG, JPEG, GIF or WebP file whose pixels can't be read, such as one cut short by a download or a sync still running, and the status bar shows "Couldn't place <name>: the image's pixels can't be read". Paste and Relink refuse such an image too, and Update Links, or Open when it reads the file again, counts it as missing. A JPEG cut short still places when its pixels can be decoded (`file.place`, `crates/engine/src/tests_place.rs`). - On the desktop, Copy and Cut make the system clipboard's formats (text, SVG, PDF, PNG) from a copy of the clipboard on the thread that writes background saves and exports, and write them when they are ready; while that thread has a save, an export, a print or a recovery copy to finish, they are made and written at once. Until they are written, Paste in VectorCraft takes the internal clipboard, and while a text field or the Type tool has the keyboard the app waits for them. Another Copy or Cut, or a copy of text in VectorCraft, drops them. - In the Linux Flatpak on GNOME, where the clipboard goes through the compositor's core Wayland protocol, one Copy offers the PNG (`image/png`), the SVG (`image/svg+xml`, with Include SVG Code on) and the text, and Paste takes another app's SVG, text or PNG in that order, a picture over blank text or text that only names it; the Paste menu item is enabled by the types offered (`clipboard::wayland` tests in `apps/vectorcraft/src/clipboard.rs`; not yet run in the Flatpak on a GNOME session).