From 447e1f898e9148a26f043d0ad9bf326512c5fde5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 15:39:31 -0800 Subject: [PATCH 01/13] Blob Brush: path.blob rejects invalid fidelity, angle and roundness path.blob used to clamp a supplied angle to -180..180, a roundness to 0..100 and a fidelity to 0.01..100 pt, so a value such as 200 or -1 painted with a different value than the one given. It now returns an invalid-parameters error for a value outside its range, before the document changes, and records no undo step. A key left out or null still takes its default: 0 degrees, 100% and no fitting. path.freehand (and brush.freehand) treated any style other than "brush" as "pencil", and any extend end other than "start" as "end". It now rejects an unknown style or extend end with an error, as it already did for connect end; left out or null, they keep their defaults. The new messages have rows in every complete-message catalog, and the connect end message gets rows in the catalogs that lacked one. Docs: path.blob and path.freehand params text, docs/mcp.md, docs/target-app-parity.md. --- crates/engine/src/cmd/draw2/commands.rs | 4 +- crates/engine/src/cmd/draw2/freehand.rs | 38 +++++++---- crates/engine/src/tests/draw2.rs | 88 ++++++++++++++++++++++++- crates/ui-egui/src/i18n/ca.tsv | 6 ++ crates/ui-egui/src/i18n/cs.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 | 8 ++- crates/ui-egui/src/i18n/hu.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/tests.rs | 57 ++++++++++++++++ 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 ++ docs/mcp.md | 10 ++- docs/target-app-parity.md | 1 + 29 files changed, 317 insertions(+), 21 deletions(-) diff --git a/crates/engine/src/cmd/draw2/commands.rs b/crates/engine/src/cmd/draw2/commands.rs index 53949fdaf0..9b8a648411 100644 --- a/crates/engine/src/cmd/draw2/commands.rs +++ b/crates/engine/src/cmd/draw2/commands.rs @@ -11,7 +11,7 @@ pub fn specs() -> Vec { "Pencil", [], None, - "{points: [[x,y]…] or [[x,y,pressure]…] or [[x,y,pressure,tiltX,tiltY,rotation]…] (pen pressure 0..1: the stroke keeps it, for Calligraphic and Scatter brushes with Pressure variation; a point without one presses fully. Pen tilt in degrees, each −90..90, x positive leaning right and y leaning down the page, and barrel rotation in degrees clockwise: the stroke keeps how far the pen leaned, which way and how far its barrel turned, for brushes with Tilt, Bearing and Rotation variation; null for what a point lacks), fidelity?: pt (1.5; from 0.000015625 (0.01 / 640) to 100 / 0.0313 (about 3194.89), the Pencil's and the Paintbrush's 0.01 to 100 px Fidelity at the highest and the lowest zoom; a value outside that range is an error. The tools send their Fidelity in pixels divided by the zoom, kept within the range), fit?: bool (true; false: the points are joined by straight segments, as the Pencil previews a stroke with Live curve fitting off), closed?, style?: \"pencil\"|\"brush\", fill?: bool, keepSelected?: bool (true: the drawn or continued path is selected; false: a new path leaves nothing selected, and a continued or redrawn one is deselected while the rest of the selection stays), extend?: {id, end: \"start\"|\"end\"}, connect?: {id, end: \"start\"|\"end\"}, redraw?: {id, within?: pt (12)}} fit a freehand stroke → {id}. extend continues the path from that end; with connect, the stroke ends on that end of another path's last open subpath and joins it on, in one path with the extended path's appearance (the other path is removed when nothing of it is left); redraw (Edit Selected Paths) replaces the section of the path between where the stroke starts and ends, each within `within` of one subpath (the shorter way round a closed one), and draws a new path when the stroke doesn't end on it", + "{points: [[x,y]…] or [[x,y,pressure]…] or [[x,y,pressure,tiltX,tiltY,rotation]…] (pen pressure 0..1: the stroke keeps it, for Calligraphic and Scatter brushes with Pressure variation; a point without one presses fully. Pen tilt in degrees, each −90..90, x positive leaning right and y leaning down the page, and barrel rotation in degrees clockwise: the stroke keeps how far the pen leaned, which way and how far its barrel turned, for brushes with Tilt, Bearing and Rotation variation; null for what a point lacks), fidelity?: pt (1.5; from 0.000015625 (0.01 / 640) to 100 / 0.0313 (about 3194.89), the Pencil's and the Paintbrush's 0.01 to 100 px Fidelity at the highest and the lowest zoom; a value outside that range is an error. The tools send their Fidelity in pixels divided by the zoom, kept within the range), fit?: bool (true; false: the points are joined by straight segments, as the Pencil previews a stroke with Live curve fitting off), closed?, style?: \"pencil\" (default) | \"brush\", fill?: bool, keepSelected?: bool (true: the drawn or continued path is selected; false: a new path leaves nothing selected, and a continued or redrawn one is deselected while the rest of the selection stays), extend?: {id, end?: \"end\" (default) | \"start\"}, connect?: {id, end: \"start\"|\"end\"}, redraw?: {id, within?: pt (12)}} fit a freehand stroke → {id}. extend continues the path from that end; with connect, the stroke ends on that end of another path's last open subpath and joins it on, in one path with the extended path's appearance (the other path is removed when nothing of it is left); redraw (Edit Selected Paths) replaces the section of the path between where the stroke starts and ends, each within `within` of one subpath (the shorter way round a closed one), and draws a new path when the stroke doesn't end on it. Any other style, extend end or connect end is an error, and nothing changes", has_doc, freehand ), @@ -128,7 +128,7 @@ pub fn specs() -> Vec { "Blob Brush", [], None, - "{points: [[x,y]…] or [[x,y,pressure]…] (pen pressure 0..1), size?: pt (10), sizeMode?: \"fixed\" (default) | \"pressure\" (Blob Brush Tool Options' Size set to Pressure: the brush is size − sizeVariation wide at the lightest pen pressure and size + sizeVariation at the heaviest, at least 0.1 pt; a stroke without pressure keeps the size), sizeVariation?: pt (0), angle?: ° (0, kept within −180–180: the tip's long axis counter-clockwise from horizontal, kept on the page along the stroke), roundness?: % (100, kept within 0–100: the tip's short axis in percent of its long one, 100 round; 0 is drawn as 0.1), fidelity?: pt (0.01–100; the brush follows the stroke fitted at this tolerance as path.freehand fits a Pencil stroke, and a higher value gives a smoother shape; without it the brush follows every point), merge?: true, mergeOnlySelection?: bool (false: merge with any touching same-color blob; true: only with selected ones), keepSelected?: bool (false: the drawn or merged path is not selected, and the rest of the selection stays; true: it is selected)} filled brush shape, merged with the topmost touching same-color blob and the touching ones next to it in stacking order in its group or layer → {id}", + "{points: [[x,y]…] or [[x,y,pressure]…] (pen pressure 0..1), size?: pt (10), sizeMode?: \"fixed\" (default) | \"pressure\" (Blob Brush Tool Options' Size set to Pressure: the brush is size − sizeVariation wide at the lightest pen pressure and size + sizeVariation at the heaviest, at least 0.1 pt; a stroke without pressure keeps the size), sizeVariation?: pt (0), angle?: ° (0, −180–180: the tip's long axis counter-clockwise from horizontal, kept on the page along the stroke), roundness?: % (100, 0–100: the tip's short axis in percent of its long one, 100 round; 0 is drawn as 0.1), fidelity?: pt (0.01–100; the brush follows the stroke fitted at this tolerance as path.freehand fits a Pencil stroke, and a higher value gives a smoother shape; without it the brush follows every point), merge?: true, mergeOnlySelection?: bool (false: merge with any touching same-color blob; true: only with selected ones), keepSelected?: bool (false: the drawn or merged path is not selected, and the rest of the selection stays; true: it is selected)} filled brush shape, merged with the topmost touching same-color blob and the touching ones next to it in stacking order in its group or layer → {id}. An angle, roundness or fidelity outside its range is rejected with an error, and nothing changes", has_doc, blob ), diff --git a/crates/engine/src/cmd/draw2/freehand.rs b/crates/engine/src/cmd/draw2/freehand.rs index 31e184e195..645fad27f8 100644 --- a/crates/engine/src/cmd/draw2/freehand.rs +++ b/crates/engine/src/cmd/draw2/freehand.rs @@ -159,12 +159,20 @@ pub(super) fn freehand(s: &mut Session, p: &Value) -> Result { // The tolerance the stroke is fitted at; with `fit: false` it is not fitted. let fit_tol = switch_or(p, "fit", true, C)?.then_some(tol); let closed = switch_or(p, "closed", false, C)?; - let brush = str_param(p, "style") == Some("brush"); + let brush = match p.get("style").filter(|v| !v.is_null()).map(Value::as_str) { + None | Some(Some("pencil")) => false, + Some(Some("brush")) => true, + Some(_) => return Err(bad(C, "style must be \"pencil\" or \"brush\"")), + }; let keep_selected = switch_or(p, "keepSelected", true, C)?; let filled = switch_or(p, "fill", false, C)?; if let Some(ext) = p.get("extend").filter(|v| !v.is_null()) { let id = object_param(ext, "id", C)?.ok_or_else(|| bad(C, "extend needs id"))?; - let at_start = str_param(ext, "end") == Some("start"); + let at_start = match ext.get("end").filter(|v| !v.is_null()).map(Value::as_str) { + None | Some(Some("end")) => false, + Some(Some("start")) => true, + Some(_) => return Err(bad(C, "extend end must be \"start\" or \"end\"")), + }; let (pd, _) = path_of(&s.doc()?.doc, id)?; let si = pd.subpaths.iter().rposition(|s| !s.closed && !s.anchors.is_empty()).ok_or_else(|| bad(C, "path has no open end"))?; let mut sp = pd.subpaths[si].clone(); @@ -391,12 +399,23 @@ pub(super) fn blob(s: &mut Session, p: &Value) -> Result { return Err(bad(C, "size must be positive")); } let angle = number_or(p, "angle", 0.0, C)?; + if !(-180.0..=180.0).contains(&angle) { + return Err(bad(C, "`angle` must be from -180 to 180 degrees")); + } let roundness = number_or(p, "roundness", 100.0, C)?; - if !angle.is_finite() || !roundness.is_finite() { - return Err(bad(C, "angle and roundness must be finite")); + if !(0.0..=100.0).contains(&roundness) { + return Err(bad(C, "`roundness` must be from 0 to 100%")); + } + // With `fidelity` (pt), the brush follows the stroke fitted by [`fit_freehand`], as a Pencil + // stroke is fitted. Without it, or when the fitted stroke has no length (a short stroke back to + // its start), the brush follows every point. + let fidelity = match p.get("fidelity") { + None | Some(Value::Null) => None, + Some(_) => Some(number_or(p, "fidelity", 0.0, C)?), + }; + if fidelity.is_some_and(|f| !(vectorcraft_tools::draw2::MIN_FIDELITY..=100.0).contains(&f)) { + return Err(bad(C, "`fidelity` must be from 0.01 to 100 pt")); } - let angle = angle.clamp(-180.0, 180.0); - let roundness = roundness.clamp(0.0, 100.0); let tip = vectorcraft_tools::draw2::blob_tip(angle, roundness); let squash = tip.inverse(); // Width profiles use distance along the spine, so measure pressure on the same squashed @@ -418,13 +437,6 @@ pub(super) fn blob(s: &mut Session, p: &Value) -> Result { let mapped_pts: Vec = mapped_samples.into_iter().map(|s| s.pt).collect(); // The widest the brush gets: the area merges look in. let reach = pressure.as_ref().map_or(size, |(_, v)| size + v); - // With `fidelity` (pt), the brush follows the stroke fitted by [`fit_freehand`], as a Pencil - // stroke is fitted. Without it, or when the fitted stroke has no length (a short stroke back to - // its start), the brush follows every point. - let fidelity = match p.get("fidelity") { - None | Some(Value::Null) => None, - Some(_) => Some(number_or(p, "fidelity", 0.0, C)?.clamp(vectorcraft_tools::draw2::MIN_FIDELITY, 100.0)), - }; let spine = |tol: Option| { let path = match tol { Some(tol) => PathData::single(fit_freehand(&pts, tol, false)), diff --git a/crates/engine/src/tests/draw2.rs b/crates/engine/src/tests/draw2.rs index 79dbd366f6..3a4ec30ab5 100644 --- a/crates/engine/src/tests/draw2.rs +++ b/crates/engine/src/tests/draw2.rs @@ -86,8 +86,57 @@ fn blob_tip_zero_and_invalid_values_are_safe() { p[key] = value; assert!(s.execute("path.blob", &p).is_err(), "{key}: {p}"); } - s.execute("path.blob", &json!({"points": [[100, 200], [300, 200]], "angle": 1e300, "roundness": -1e300, "merge": false})).unwrap(); - assert!(paths(&s)[1].1.control_bounds().unwrap().height().is_finite()); + let stroke = json!({"points": [[100, 200], [300, 200]], "merge": false}); + refuses_with(&mut s, "path.blob", &with(&stroke, json!({"angle": 1e300})), "`angle` must be from -180 to 180 degrees"); + refuses_with(&mut s, "path.blob", &with(&stroke, json!({"roundness": -1e300})), "`roundness` must be from 0 to 100%"); + assert_eq!(paths(&s).len(), 1); +} + +/// `path.blob` refuses an `angle`, `roundness` or `fidelity` outside its range and changes nothing; +/// each end of a range paints, and a key left out or null takes its default (0°, 100% and no fitting). +#[test] +fn blob_brush_rejects_out_of_range_tip_and_fidelity_without_edit() { + let mut s = session(); + let stroke = json!({"points": [[100, 100], [300, 100]], "size": 20, "merge": false}); + let angle = "`angle` must be from -180 to 180 degrees"; + let roundness = "`roundness` must be from 0 to 100%"; + let fidelity = "`fidelity` must be from 0.01 to 100 pt"; + for (extra, want) in [ + (json!({"angle": -180.5}), angle), + (json!({"angle": 181}), angle), + (json!({"angle": 1e300}), angle), + (json!({"roundness": -0.5}), roundness), + (json!({"roundness": 101}), roundness), + (json!({"fidelity": 0.005}), fidelity), + (json!({"fidelity": 0}), fidelity), + (json!({"fidelity": -1}), fidelity), + (json!({"fidelity": 101}), fidelity), + (json!({"fidelity": 1e300}), fidelity), + (json!({"angle": 45, "roundness": 50, "fidelity": 100.5}), fidelity), + ] { + refuses_with(&mut s, "path.blob", &with(&stroke, extra), want); + } + assert!(paths(&s).is_empty()); + let painted = |s: &mut Session, extra: serde_json::Value| { + let id = NodeId(s.execute("path.blob", &with(&stroke, extra)).unwrap()["id"].as_u64().unwrap()); + path(s, id) + }; + for extra in [ + json!({"angle": -180}), + json!({"angle": 180}), + json!({"roundness": 0}), + json!({"roundness": 100}), + json!({"fidelity": 0.01}), + json!({"fidelity": 100}), + ] { + let pd = painted(&mut s, extra.clone()); + assert!(pd.control_bounds().is_some_and(|b| b.height().is_finite() && b.height() > 0.0), "{extra}: {pd:?}"); + } + let defaults = painted(&mut s, json!({})); + let nulls = painted(&mut s, json!({"angle": null, "roundness": null, "fidelity": null})); + let given = painted(&mut s, json!({"angle": 0, "roundness": 100})); + assert_eq!(nulls, defaults); + assert_eq!(given, defaults); } #[test] @@ -311,6 +360,41 @@ fn pencil_connect_keeps_the_rest_of_a_compound_path_and_refuses_the_extended_pat assert!(s.execute("path.freehand", &json!({"points": points, "extend": {"id": a.0}, "connect": {"id": a.0}})).is_err()); } +/// `path.freehand` refuses a `style` other than "pencil" or "brush" and an `extend` end other than +/// "start" or "end" and changes nothing; left out or null, the style is "pencil" and the stroke +/// continues the path from its end. +#[test] +fn pencil_refuses_an_unknown_style_or_extend_end() { + let mut s = session(); + let a = line(&mut s, 100.0, 100.0, 200.0, 100.0); + let stroke = json!({"points": [[100, 300], [200, 320], [300, 300]]}); + for style in [json!("calligraphic"), json!("Brush"), json!(""), json!(1), json!(true)] { + refuses_with(&mut s, "path.freehand", &with(&stroke, json!({ "style": style })), "style must be \"pencil\" or \"brush\""); + } + let from_end = json!({"points": [[200, 100], [250, 150], [300, 100]]}); + for end in [json!("middle"), json!("START"), json!(""), json!(0), json!(false)] { + let p = with(&from_end, json!({"extend": {"id": a.0, "end": end}})); + refuses_with(&mut s, "path.freehand", &p, "extend end must be \"start\" or \"end\""); + } + assert_eq!((paths(&s).len(), path(&s, a).anchor_count()), (1, 2), "refused: nothing changed"); + for style in [json!("pencil"), json!("brush"), json!(null)] { + s.execute("path.freehand", &with(&stroke, json!({ "style": style }))).unwrap(); + } + assert_eq!(paths(&s).len(), 4); + for end in [json!(null), json!("end")] { + let mut s = session(); + let a = line(&mut s, 100.0, 100.0, 200.0, 100.0); + s.execute("path.freehand", &with(&from_end, json!({"extend": {"id": a.0, "end": end}}))).unwrap(); + let sp = &path(&s, a).subpaths[0]; + assert_eq!((sp.anchors[0].p, sp.anchors[sp.anchors.len() - 1].p), (Point::new(100.0, 100.0), Point::new(300.0, 100.0)), "{end}"); + } + let mut s = session(); + let a = line(&mut s, 100.0, 100.0, 200.0, 100.0); + s.execute("path.freehand", &json!({"points": [[100, 100], [50, 150], [0, 100]], "extend": {"id": a.0, "end": "start"}})).unwrap(); + let ends: Vec = path(&s, a).subpaths[0].anchors.iter().map(|x| x.p).collect(); + assert!(ends.contains(&Point::new(0.0, 100.0)) && ends.contains(&Point::new(200.0, 100.0)), "continued from its start: {ends:?}"); +} + /// With Keep selected off, a compound path whose direct-selected anchors all lie on the subpath /// that connect joins on is no longer selected, and Delete then has nothing to delete. #[test] diff --git a/crates/ui-egui/src/i18n/ca.tsv b/crates/ui-egui/src/i18n/ca.tsv index 9dfc5458b5..aa5ee3510f 100644 --- a/crates/ui-egui/src/i18n/ca.tsv +++ b/crates/ui-egui/src/i18n/ca.tsv @@ -7457,6 +7457,12 @@ breakText Glyphs Glifs @msg No bridge of this width fits across the selected art Cap pont d’aquesta amplada no cap a la il·lustració seleccionada @msg Some islands could not be joined to the area around the art Algunes illes no s’han pogut unir a l’àrea que envolta la il·lustració @msg `width` must be from {lo} to {hi} pt `width` ha d’estar entre {lo} i {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` ha d’estar entre -180 i 180 graus +@msg `roundness` must be from 0 to 100% `roundness` ha d’estar entre 0 i 100% +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` ha d’estar entre 0.01 i 100 pt +@msg style must be "pencil" or "brush" style ha de ser "pencil" o "brush" +@msg extend end must be "start" or "end" l’extrem d’extend ha de ser "start" o "end" +@msg connect end must be "start" or "end" l’extrem de connect ha de ser "start" o "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` ha de ser un nombre enter d’1 a {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Caixa i línies de pelat… Weed Box and Lines Caixa i línies de pelat diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index edaad350a0..2ff4359d18 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -7476,6 +7476,12 @@ breakText Glyphs Glyfy @msg No bridge of this width fits across the selected art Přes vybranou kresbu se nevejde žádný můstek této šířky @msg Some islands could not be joined to the area around the art Některé ostrůvky nebylo možné připojit k oblasti kolem kresby @msg `width` must be from {lo} to {hi} pt `width` musí být od {lo} do {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` musí být od -180 do 180 stupňů +@msg `roundness` must be from 0 to 100% `roundness` musí být od 0 do 100 % +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` musí být od 0.01 do 100 pt +@msg style must be "pencil" or "brush" style musí být "pencil" nebo "brush" +@msg extend end must be "start" or "end" konec extend musí být "start" nebo "end" +@msg connect end must be "start" or "end" konec connect musí být "start" nebo "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` musí být celé číslo od 1 do {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Rámeček a linie pro vybírání… Weed Box and Lines Rámeček a linie pro vybírání diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index cd6a428631..345c772d9e 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -7072,6 +7072,12 @@ breakText Glyphs Glyphen @msg No bridge of this width fits across the selected art Kein Steg dieser Breite passt über das ausgewählte Bildmaterial @msg Some islands could not be joined to the area around the art Einige Inseln konnten nicht mit der Fläche um das Bildmaterial verbunden werden @msg `width` must be from {lo} to {hi} pt `width` muss zwischen {lo} und {hi} pt liegen +@msg `angle` must be from -180 to 180 degrees `angle` muss zwischen -180 und 180 Grad liegen +@msg `roundness` must be from 0 to 100% `roundness` muss zwischen 0 und 100 % liegen +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` muss zwischen 0.01 und 100 pt liegen +@msg style must be "pencil" or "brush" style muss "pencil" oder "brush" sein +@msg extend end must be "start" or "end" Das Ende von extend muss "start" oder "end" sein +@msg connect end must be "start" or "end" Das Ende von connect muss "start" oder "end" sein @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` muss eine ganze Zahl von 1 bis {MAX_BRIDGES_PER_ISLAND} sein Weed Box and Lines… Entgitterrahmen und -linien… Weed Box and Lines Entgitterrahmen und -linien diff --git a/crates/ui-egui/src/i18n/el.tsv b/crates/ui-egui/src/i18n/el.tsv index fc76658c72..2a3c947e76 100644 --- a/crates/ui-egui/src/i18n/el.tsv +++ b/crates/ui-egui/src/i18n/el.tsv @@ -7429,6 +7429,12 @@ breakText Glyphs Γλύφοι @msg No bridge of this width fits across the selected art Καμία γέφυρα αυτού του πλάτους δεν χωράει στο επιλεγμένο γραφικό @msg Some islands could not be joined to the area around the art Ορισμένες νησίδες δεν ήταν δυνατό να συνδεθούν με την περιοχή γύρω από το γραφικό @msg `width` must be from {lo} to {hi} pt Το `width` πρέπει να είναι από {lo} έως {hi} pt +@msg `angle` must be from -180 to 180 degrees Το `angle` πρέπει να είναι από -180 έως 180 μοίρες +@msg `roundness` must be from 0 to 100% Το `roundness` πρέπει να είναι από 0 έως 100% +@msg `fidelity` must be from 0.01 to 100 pt Το `fidelity` πρέπει να είναι από 0.01 έως 100 pt +@msg style must be "pencil" or "brush" Το style πρέπει να είναι "pencil" ή "brush" +@msg extend end must be "start" or "end" Το άκρο του extend πρέπει να είναι "start" ή "end" +@msg connect end must be "start" or "end" Το άκρο του connect πρέπει να είναι "start" ή "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} Το `count` πρέπει να είναι ακέραιος από 1 έως {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Πλαίσιο και γραμμές αφαίρεσης περισσευμάτων… Weed Box and Lines Πλαίσιο και γραμμές αφαίρεσης περισσευμάτων diff --git a/crates/ui-egui/src/i18n/es.tsv b/crates/ui-egui/src/i18n/es.tsv index c7c9c8bc1e..070238b7a0 100644 --- a/crates/ui-egui/src/i18n/es.tsv +++ b/crates/ui-egui/src/i18n/es.tsv @@ -7420,6 +7420,12 @@ breakText Glyphs Glifos @msg No bridge of this width fits across the selected art Ningún puente de este ancho cabe en la ilustración seleccionada @msg Some islands could not be joined to the area around the art Algunas islas no se pudieron unir al área que rodea la ilustración @msg `width` must be from {lo} to {hi} pt `width` debe estar entre {lo} y {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` debe estar entre -180 y 180 grados +@msg `roundness` must be from 0 to 100% `roundness` debe estar entre 0 y 100 % +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` debe estar entre 0.01 y 100 pt +@msg style must be "pencil" or "brush" style debe ser "pencil" o "brush" +@msg extend end must be "start" or "end" el extremo de extend debe ser "start" o "end" +@msg connect end must be "start" or "end" el extremo de connect debe ser "start" o "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` debe ser un número entero entre 1 y {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Caja y líneas de pelado… Weed Box and Lines Caja y líneas de pelado diff --git a/crates/ui-egui/src/i18n/fi.tsv b/crates/ui-egui/src/i18n/fi.tsv index 126e7854f9..70c6851636 100644 --- a/crates/ui-egui/src/i18n/fi.tsv +++ b/crates/ui-egui/src/i18n/fi.tsv @@ -7511,6 +7511,12 @@ breakText Glyphs Merkit @msg No bridge of this width fits across the selected art Näin leveä silta ei mahdu valitun grafiikan poikki @msg Some islands could not be joined to the area around the art Joitakin saarekkeita ei voitu yhdistää grafiikkaa ympäröivään alueeseen @msg `width` must be from {lo} to {hi} pt `width`-arvon on oltava {lo}–{hi} pt +@msg `angle` must be from -180 to 180 degrees `angle`-arvon on oltava -180–180 astetta +@msg `roundness` must be from 0 to 100% `roundness`-arvon on oltava 0–100 % +@msg `fidelity` must be from 0.01 to 100 pt `fidelity`-arvon on oltava 0.01–100 pt +@msg style must be "pencil" or "brush" style-arvon on oltava "pencil" tai "brush" +@msg extend end must be "start" or "end" extend-pään on oltava "start" tai "end" +@msg connect end must be "start" or "end" connect-pään on oltava "start" tai "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` on oltava kokonaisluku 1–{MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Karsintakehys ja -viivat… Weed Box and Lines Karsintakehys ja -viivat diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index 3941bf0497..8c90ad7233 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7471,6 +7471,12 @@ breakText Glyphs Glyphes @msg No bridge of this width fits across the selected art Aucun pont de cette largeur ne tient en travers de l’illustration sélectionnée @msg Some islands could not be joined to the area around the art Certains îlots n’ont pas pu être reliés à la zone autour de l’illustration @msg `width` must be from {lo} to {hi} pt `width` doit être compris entre {lo} et {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` doit être compris entre -180 et 180 degrés +@msg `roundness` must be from 0 to 100% `roundness` doit être compris entre 0 et 100 % +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` doit être compris entre 0.01 et 100 pt +@msg style must be "pencil" or "brush" style doit être "pencil" ou "brush" +@msg extend end must be "start" or "end" l’extrémité de extend doit être "start" ou "end" +@msg connect end must be "start" or "end" l’extrémité de connect doit être "start" ou "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` doit être un nombre entier compris entre 1 et {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Cadre et lignes d’échenillage… Weed Box and Lines Cadre et lignes d’échenillage diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index bf2f223fc0..f0e45ef79c 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -6386,7 +6386,6 @@ antiAlias Sharp शार्प @msg anchor `{key}` must be a number एंकर `{key}` को एक नंबर होना चाहिए @msg anchor `smooth` must be true or false एंकर का `smooth` true या false होना चाहिए @msg anchor must name a registered panel anchor किसी पंजीकृत पैनल का नाम होना चाहिए -@msg angle and roundness must be finite कोण और गोलाई परिमित होना चाहिए @msg angles must be a list as long as pins (degrees or null) angles पिन जितनी लंबी सूची होनी चाहिए (डिग्री या null) @msg Angles require two straight segments कोणों को दो सीधे खंडों की आवश्यकता होती है @msg antiAlias `{id}`: none, art or type antiAlias `{id}`: none, art या type @@ -6569,7 +6568,7 @@ antiAlias Sharp शार्प @msg compound paths can only contain paths यौगिक पाथ में केवल पाथ हो सकते हैं @msg compound shapes take paths, compound paths, groups, compound shapes, type, blends and envelopes कंपाउंड शेप पाथ, कंपाउंड पाथ, समूह, कंपाउंड शेप, टाइप, ब्लेंड और एन्वेलप लेते हैं @msg compressed (RLE) bitmaps can't be read yet संकुचित (RLE) bitmaps अभी तक पढ़ा नहीं जा सकता है -@msg connect end must be "start" or "end" कनेक्ट अंत "start" या "end" होना चाहिए +@msg connect end must be "start" or "end" connect अंत "start" या "end" होना चाहिए @msg connect needs a path other than the one extended connect के लिए बढ़ाए गए पाथ के अलावा कोई दूसरा पाथ चाहिए @msg connect needs id connect के लिए id चाहिए @msg connect path has no open end कनेक्ट पाथ का कोई खुला अंत नहीं है @@ -8868,6 +8867,11 @@ theme Appearance अपीयरेंस @msg No bridge of this width fits across the selected art इस चौड़ाई का कोई ब्रिज चुने गए आर्टवर्क के पार नहीं आता @msg Some islands could not be joined to the area around the art कुछ आइलैंड आर्टवर्क के आसपास के क्षेत्र से नहीं जोड़े जा सके @msg `width` must be from {lo} to {hi} pt `width` {lo} से {hi} pt तक होना चाहिए +@msg `angle` must be from -180 to 180 degrees `angle` -180 से 180 डिग्री तक होना चाहिए +@msg `roundness` must be from 0 to 100% `roundness` 0 से 100% तक होना चाहिए +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 0.01 से 100 pt तक होना चाहिए +@msg style must be "pencil" or "brush" style "pencil" या "brush" होना चाहिए +@msg extend end must be "start" or "end" extend अंत "start" या "end" होना चाहिए @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 1 से {MAX_BRIDGES_PER_ISLAND} तक पूरी संख्या होना चाहिए Weed Box and Lines… वीड बॉक्स और लाइनें… Weed Box and Lines वीड बॉक्स और लाइनें diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index 969b923a1c..939ccb6912 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -7460,6 +7460,12 @@ breakText Glyphs Glifák @msg No bridge of this width fits across the selected art Ilyen széles híd nem fér el a kijelölt grafikán @msg Some islands could not be joined to the area around the art Egyes szigeteket nem sikerült összekötni a grafikát körülvevő területtel @msg `width` must be from {lo} to {hi} pt A `width` értéke {lo} és {hi} pt között lehet +@msg `angle` must be from -180 to 180 degrees Az `angle` értéke -180 és 180 fok között lehet +@msg `roundness` must be from 0 to 100% A `roundness` értéke 0 és 100% között lehet +@msg `fidelity` must be from 0.01 to 100 pt A `fidelity` értéke 0.01 és 100 pt között lehet +@msg style must be "pencil" or "brush" A style értéke "pencil" vagy "brush" lehet +@msg extend end must be "start" or "end" Az extend vége "start" vagy "end" lehet +@msg connect end must be "start" or "end" A connect vége "start" vagy "end" lehet @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count`: 1 és {MAX_BRIDGES_PER_ISLAND} közötti egész szám kell Weed Box and Lines… Gyomláló keret és vonalak… Weed Box and Lines Gyomláló keret és vonalak diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index ea10433ebd..bb7dda9ee7 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -7106,6 +7106,12 @@ breakText Glyphs Glifi @msg No bridge of this width fits across the selected art Nessun ponte di questa larghezza entra nella grafica selezionata @msg Some islands could not be joined to the area around the art Non è stato possibile collegare alcune isole all’area intorno alla grafica @msg `width` must be from {lo} to {hi} pt `width` deve essere compreso tra {lo} e {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` deve essere compreso tra -180 e 180 gradi +@msg `roundness` must be from 0 to 100% `roundness` deve essere compreso tra 0 e 100% +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` deve essere compreso tra 0.01 e 100 pt +@msg style must be "pencil" or "brush" style deve essere "pencil" o "brush" +@msg extend end must be "start" or "end" l’estremità di extend deve essere "start" o "end" +@msg connect end must be "start" or "end" l’estremità di connect deve essere "start" o "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` deve essere un numero intero compreso tra 1 e {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Riquadro e linee di spellicolatura… Weed Box and Lines Riquadro e linee di spellicolatura diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index ca80ba3a83..cb7b962a42 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -7172,6 +7172,12 @@ breakText Glyphs 字形 @msg No bridge of this width fits across the selected art この幅のブリッジは選択したアートワークに収まりません @msg Some islands could not be joined to the area around the art 一部のアイランドをアートワークの周囲の領域につなげられませんでした @msg `width` must be from {lo} to {hi} pt `width` は {lo}~{hi} pt の範囲で指定してください +@msg `angle` must be from -180 to 180 degrees `angle` は -180~180 度の範囲で指定してください +@msg `roundness` must be from 0 to 100% `roundness` は 0~100% の範囲で指定してください +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` は 0.01~100 pt の範囲で指定してください +@msg style must be "pencil" or "brush" style は "pencil" または "brush" を指定してください +@msg extend end must be "start" or "end" extend の端は "start" または "end" を指定してください +@msg connect end must be "start" or "end" connect の端は "start" または "end" を指定してください @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` には 1 から {MAX_BRIDGES_PER_ISLAND} の整数を指定してください Weed Box and Lines… カス取り枠とライン… Weed Box and Lines カス取り枠とライン diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 0778b2e405..06dbf93110 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -7590,6 +7590,12 @@ font-script Japanese იაპონური @msg No bridge of this width fits across the selected art ამ სიგანის ხიდი მონიშნულ ნახატზე არ ეტევა @msg Some islands could not be joined to the area around the art ზოგიერთი კუნძული ვერ დაუკავშირდა ნახატის გარშემო არეს @msg `width` must be from {lo} to {hi} pt `width` უნდა იყოს {lo}-დან {hi} pt-მდე +@msg `angle` must be from -180 to 180 degrees `angle` უნდა იყოს -180-დან 180 გრადუსამდე +@msg `roundness` must be from 0 to 100% `roundness` უნდა იყოს 0-დან 100%-მდე +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` უნდა იყოს 0.01-დან 100 pt-მდე +@msg style must be "pencil" or "brush" style უნდა იყოს "pencil" ან "brush" +@msg extend end must be "start" or "end" extend-ის ბოლო უნდა იყოს "start" ან "end" +@msg connect end must be "start" or "end" connect-ის ბოლო უნდა იყოს "start" ან "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` უნდა იყოს მთელი რიცხვი 1-დან {MAX_BRIDGES_PER_ISLAND}-მდე Weed Box and Lines… ნარჩენის მოსაცილებელი ჩარჩო და ხაზები… Weed Box and Lines ნარჩენის მოსაცილებელი ჩარჩო და ხაზები diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index d0e5750000..59e2f4cda0 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -7067,6 +7067,12 @@ breakText Glyphs 글리프 @msg No bridge of this width fits across the selected art 이 너비의 브리지가 선택한 아트워크에 들어가지 않습니다 @msg Some islands could not be joined to the area around the art 일부 섬을 아트워크 주변 영역에 연결할 수 없습니다 @msg `width` must be from {lo} to {hi} pt `width`는 {lo}에서 {hi}pt 사이여야 합니다 +@msg `angle` must be from -180 to 180 degrees `angle`는 -180도에서 180도 사이여야 합니다 +@msg `roundness` must be from 0 to 100% `roundness`는 0%에서 100% 사이여야 합니다 +@msg `fidelity` must be from 0.01 to 100 pt `fidelity`는 0.01에서 100pt 사이여야 합니다 +@msg style must be "pencil" or "brush" style은 "pencil" 또는 "brush"여야 합니다 +@msg extend end must be "start" or "end" extend 끝은 "start" 또는 "end"여야 합니다 +@msg connect end must be "start" or "end" connect 끝은 "start" 또는 "end"여야 합니다 @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count`는 1에서 {MAX_BRIDGES_PER_ISLAND} 사이의 정수여야 합니다 Weed Box and Lines… 위딩 상자 및 선… Weed Box and Lines 위딩 상자 및 선 diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 0d4ceaf795..a414c66bae 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -526,6 +526,12 @@ @msg No bridge of this width fits across the selected art Geen brug van deze breedte past over de geselecteerde illustratie @msg Some islands could not be joined to the area around the art Sommige eilanden konden niet worden verbonden met het gebied rond de illustratie @msg `width` must be from {lo} to {hi} pt `width` moet van {lo} tot {hi} pt zijn +@msg `angle` must be from -180 to 180 degrees `angle` moet van -180 tot 180 graden zijn +@msg `roundness` must be from 0 to 100% `roundness` moet van 0 tot 100% zijn +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` moet van 0.01 tot 100 pt zijn +@msg style must be "pencil" or "brush" style moet "pencil" of "brush" zijn +@msg extend end must be "start" or "end" het einde van extend moet "start" of "end" zijn +@msg connect end must be "start" or "end" het einde van connect moet "start" of "end" zijn @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` moet een geheel getal van 1 tot {MAX_BRIDGES_PER_ISLAND} zijn File Bestand diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 7911a22071..61ef1e88e0 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -7333,6 +7333,12 @@ breakText Glyphs Glify @msg No bridge of this width fits across the selected art Żaden mostek o tej szerokości nie mieści się w zaznaczonej grafice @msg Some islands could not be joined to the area around the art Niektórych wysp nie udało się połączyć z obszarem wokół grafiki @msg `width` must be from {lo} to {hi} pt `width` musi mieścić się w zakresie od {lo} do {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` musi mieścić się w zakresie od -180 do 180 stopni +@msg `roundness` must be from 0 to 100% `roundness` musi mieścić się w zakresie od 0 do 100% +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` musi mieścić się w zakresie od 0.01 do 100 pt +@msg style must be "pencil" or "brush" style musi mieć wartość "pencil" lub "brush" +@msg extend end must be "start" or "end" koniec extend musi mieć wartość "start" lub "end" +@msg connect end must be "start" or "end" koniec connect musi mieć wartość "start" lub "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` musi być liczbą całkowitą od 1 do {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Ramka i linie do wybierania… Weed Box and Lines Ramka i linie do wybierania diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index c2349359ed..63ea51a16e 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -7549,6 +7549,12 @@ swatch Yellow Green Verde-amarelado @msg No bridge of this width fits across the selected art Nenhuma ponte desta largura cabe na arte selecionada @msg Some islands could not be joined to the area around the art Algumas ilhas não puderam ser unidas à área ao redor da arte @msg `width` must be from {lo} to {hi} pt `width` deve estar entre {lo} e {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` deve estar entre -180 e 180 graus +@msg `roundness` must be from 0 to 100% `roundness` deve estar entre 0 e 100% +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` deve estar entre 0.01 e 100 pt +@msg style must be "pencil" or "brush" style deve ser "pencil" ou "brush" +@msg extend end must be "start" or "end" a extremidade de extend deve ser "start" ou "end" +@msg connect end must be "start" or "end" a extremidade de connect deve ser "start" ou "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` deve ser um número inteiro de 1 a {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Caixa e Linhas de Descasque… Weed Box and Lines Caixa e Linhas de Descasque diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index f878461da5..7ae5d6619f 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -7565,6 +7565,12 @@ shape Open Открытый @msg No bridge of this width fits across the selected art Мостик такой ширины не помещается поперёк выделенной графики @msg Some islands could not be joined to the area around the art Некоторые островки не удалось соединить с областью вокруг графики @msg `width` must be from {lo} to {hi} pt `width` должно быть от {lo} до {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` должно быть от -180 до 180 градусов +@msg `roundness` must be from 0 to 100% `roundness` должно быть от 0 до 100% +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` должно быть от 0.01 до 100 pt +@msg style must be "pencil" or "brush" style должен быть "pencil" или "brush" +@msg extend end must be "start" or "end" конец extend должен быть "start" или "end" +@msg connect end must be "start" or "end" конец connect должен быть "start" или "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` должно быть целым числом от 1 до {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Рамка и линии выборки… Weed Box and Lines Рамка и линии выборки diff --git a/crates/ui-egui/src/i18n/sv.tsv b/crates/ui-egui/src/i18n/sv.tsv index 70efcf795f..b4cbebf383 100644 --- a/crates/ui-egui/src/i18n/sv.tsv +++ b/crates/ui-egui/src/i18n/sv.tsv @@ -7766,7 +7766,6 @@ digits Hindi Hindi @msg anchor `{key}` must be [x, y] ankarpunktens `{key}` måste vara [x, y] @msg anchor `{key}` must be a number ankarpunktens `{key}` måste vara ett tal @msg anchor `smooth` must be true or false ankarpunktens `smooth` måste vara true eller false -@msg angle and roundness must be finite vinkel och rundhet måste vara ändliga @msg angles must be a list as long as pins (degrees or null) angles måste vara en lista lika lång som pins (grader eller null) @msg appearance must be flat|center|edge appearance måste vara flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply är "fill" eller "stroke", inte `{other}` @@ -8915,6 +8914,11 @@ digits Hindi Hindi @msg No bridge of this width fits across the selected art Ingen brygga med den här bredden får plats över den markerade teckningen @msg Some islands could not be joined to the area around the art Vissa öar kunde inte förbindas med området runt teckningen @msg `width` must be from {lo} to {hi} pt `width` måste vara från {lo} till {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` måste vara från -180 till 180 grader +@msg `roundness` must be from 0 to 100% `roundness` måste vara från 0 till 100 % +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` måste vara från 0.01 till 100 pt +@msg style must be "pencil" or "brush" style måste vara "pencil" eller "brush" +@msg extend end must be "start" or "end" extend end måste vara "start" eller "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` måste vara ett heltal från 1 till {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Rensningsram och rensningslinjer… Weed Box and Lines Rensningsram och rensningslinjer diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 6c9deb97d0..634c7fa84e 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -2335,6 +2335,63 @@ fn three_d_refusals_translate_with_their_values() { assert_eq!(message(de(), &errors[1].0), "ungültige Parameter für `effect.apply`: Licht: intensity muss eine Zahl von 0 bis 100 sein"); } +/// The Blob Brush's range refusals (`path.blob` `angle`, `roundness` and `fidelity`) show in every +/// complete-message language with the key and the range numbers as given; the error the command +/// returns stays English. +#[test] +fn blob_brush_range_refusals_translate_with_their_values() { + use serde_json::json; + let mut s = vectorcraft_engine::Session::new(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let refusals = [ + (json!({"angle": 200}), "`angle`", ["-180", "180"]), + (json!({"roundness": 101}), "`roundness`", ["0", "100"]), + (json!({"fidelity": 0}), "`fidelity`", ["0.01", "100"]), + ]; + for (extra, key, numbers) in &refusals { + let mut p = json!({"points": [[10, 10], [60, 10]]}); + p.as_object_mut().unwrap().extend(extra.as_object().unwrap().clone()); + let e = s.execute("path.blob", &p).unwrap_err().to_string(); + assert!(e.starts_with("invalid parameters for `path.blob`: ") && e.contains(key) && e.contains(" must be from "), "{e}"); + assert_eq!(message(Lang::EN, &e), e); + for code in COMPLETE_MESSAGES { + let shown = message(Lang::from_code(code).expect("registered"), &e); + assert!(!shown.contains(" must be from ") && shown.contains("`path.blob`") && shown.contains(key), "{code}: {e} -> {shown}"); + assert!(numbers.iter().all(|n| shown.contains(n)), "{code}: {e} -> {shown}"); + } + } + assert_eq!( + message(de(), &s.execute("path.blob", &json!({"points": [[10, 10], [60, 10]], "angle": -181})).unwrap_err().to_string()), + "ungültige Parameter für `path.blob`: `angle` muss zwischen -180 und 180 Grad liegen" + ); +} + +/// `path.freehand`'s refusals of an unknown `style`, `extend` end or `connect` end show in every +/// complete-message language with the key and the accepted values as given. +#[test] +fn freehand_choice_refusals_translate_with_their_values() { + use serde_json::json; + let mut s = vectorcraft_engine::Session::new(); + s.execute("file.new", &json!({"width": 100, "height": 100})).unwrap(); + let a = s.execute("path.create", &json!({"d": "M10 10 L20 10"})).unwrap()["id"].clone(); + let b = s.execute("path.create", &json!({"d": "M10 50 L20 50"})).unwrap()["id"].clone(); + let points = json!([[20, 10], [30, 30], [20, 50]]); + let refusals = [ + (json!({"points": points, "style": "ink"}), ["style", "\"pencil\"", "\"brush\""]), + (json!({"points": points, "extend": {"id": a, "end": "middle"}}), ["extend", "\"start\"", "\"end\""]), + (json!({"points": points, "extend": {"id": a}, "connect": {"id": b, "end": "middle"}}), ["connect", "\"start\"", "\"end\""]), + ]; + for (p, words) in &refusals { + let e = s.execute("path.freehand", p).unwrap_err().to_string(); + assert!(e.starts_with("invalid parameters for `path.freehand`: ") && e.contains(" must be "), "{e}"); + for code in COMPLETE_MESSAGES { + let shown = message(Lang::from_code(code).expect("registered"), &e); + assert!(!shown.contains(" must be ") && shown.contains("`path.freehand`"), "{code}: {e} -> {shown}"); + assert!(words.iter().all(|w| shown.contains(w)), "{code}: {e} -> {shown}"); + } + } +} + /// A value a message quotes is a name and is shown as written, even when a catalog row translates /// the same text: a symbol called Rotate stays Rotate while the effect's name is translated. #[test] diff --git a/crates/ui-egui/src/i18n/tr.tsv b/crates/ui-egui/src/i18n/tr.tsv index ff88601736..20d27c1c3a 100644 --- a/crates/ui-egui/src/i18n/tr.tsv +++ b/crates/ui-egui/src/i18n/tr.tsv @@ -7432,6 +7432,12 @@ breakText Glyphs Glifler @msg No bridge of this width fits across the selected art Bu genişlikte bir köprü seçili çizime sığmıyor @msg Some islands could not be joined to the area around the art Bazı adalar çizimin çevresindeki alana bağlanamadı @msg `width` must be from {lo} to {hi} pt `width` {lo} ile {hi} pt arasında olmalıdır +@msg `angle` must be from -180 to 180 degrees `angle` -180 ile 180 derece arasında olmalıdır +@msg `roundness` must be from 0 to 100% `roundness` %0 ile %100 arasında olmalıdır +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 0.01 ile 100 pt arasında olmalıdır +@msg style must be "pencil" or "brush" style "pencil" veya "brush" olmalıdır +@msg extend end must be "start" or "end" extend ucu "start" veya "end" olmalıdır +@msg connect end must be "start" or "end" connect ucu "start" veya "end" olmalıdır @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 1 ile {MAX_BRIDGES_PER_ISLAND} arasında bir tam sayı olmalıdır Weed Box and Lines… Ayıklama Kutusu ve Çizgileri… Weed Box and Lines Ayıklama Kutusu ve Çizgileri diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index a7b3ea2c2e..aa6e956bdb 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -7086,6 +7086,12 @@ breakText Glyphs Гліфи @msg No bridge of this width fits across the selected art Місток такої ширини не вміщується впоперек виділеної графіки @msg Some islands could not be joined to the area around the art Деякі острівці не вдалося з’єднати з областю навколо графіки @msg `width` must be from {lo} to {hi} pt `width` має бути від {lo} до {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` має бути від -180 до 180 градусів +@msg `roundness` must be from 0 to 100% `roundness` має бути від 0 до 100% +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` має бути від 0.01 до 100 pt +@msg style must be "pencil" or "brush" style має бути "pencil" або "brush" +@msg extend end must be "start" or "end" кінець extend має бути "start" або "end" +@msg connect end must be "start" or "end" кінець connect має бути "start" або "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` має бути цілим числом від 1 до {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Рамка й лінії вибірки… Weed Box and Lines Рамка й лінії вибірки diff --git a/crates/ui-egui/src/i18n/vi.tsv b/crates/ui-egui/src/i18n/vi.tsv index 518d89e4b6..f7962427f5 100644 --- a/crates/ui-egui/src/i18n/vi.tsv +++ b/crates/ui-egui/src/i18n/vi.tsv @@ -7087,6 +7087,12 @@ breakText Glyphs Glyph @msg No bridge of this width fits across the selected art Không có cầu nối nào rộng như vậy vừa với hình vẽ đã chọn @msg Some islands could not be joined to the area around the art Không thể nối một số đảo với vùng xung quanh hình vẽ @msg `width` must be from {lo} to {hi} pt `width` phải từ {lo} đến {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` phải từ -180 đến 180 độ +@msg `roundness` must be from 0 to 100% `roundness` phải từ 0 đến 100% +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` phải từ 0.01 đến 100 pt +@msg style must be "pencil" or "brush" style phải là "pencil" hoặc "brush" +@msg extend end must be "start" or "end" đầu extend phải là "start" hoặc "end" +@msg connect end must be "start" or "end" đầu connect phải là "start" hoặc "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` phải là số nguyên từ 1 đến {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Khung và đường bóc phần thừa… Weed Box and Lines Khung và đường bóc phần thừa diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 26fb9e0c1b..45f2ffaede 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -7315,6 +7315,12 @@ breakText Glyphs 字形 @msg No bridge of this width fits across the selected art 此宽度的连接桥无法放入所选图稿 @msg Some islands could not be joined to the area around the art 部分孤岛无法连接到图稿周围的区域 @msg `width` must be from {lo} to {hi} pt `width` 必须介于 {lo} 到 {hi} pt 之间 +@msg `angle` must be from -180 to 180 degrees `angle` 必须介于 -180 到 180 度之间 +@msg `roundness` must be from 0 to 100% `roundness` 必须介于 0 到 100% 之间 +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 必须介于 0.01 到 100 pt 之间 +@msg style must be "pencil" or "brush" style 必须为 "pencil" 或 "brush" +@msg extend end must be "start" or "end" extend 的端点必须为 "start" 或 "end" +@msg connect end must be "start" or "end" connect 的端点必须为 "start" 或 "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 必须是 1 到 {MAX_BRIDGES_PER_ISLAND} 之间的整数 Weed Box and Lines… 除废框和除废线… Weed Box and Lines 除废框和除废线 diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index 5685430cc8..2639252539 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -7122,6 +7122,12 @@ breakText Glyphs 字符 @msg No bridge of this width fits across the selected art 此寬度的連接橋無法放入所選圖稿 @msg Some islands could not be joined to the area around the art 部分孤島無法連接到圖稿周圍的區域 @msg `width` must be from {lo} to {hi} pt `width` 必須介於 {lo} 到 {hi} pt 之間 +@msg `angle` must be from -180 to 180 degrees `angle` 必須介於 -180 到 180 度之間 +@msg `roundness` must be from 0 to 100% `roundness` 必須介於 0 到 100% 之間 +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` 必須介於 0.01 到 100 pt 之間 +@msg style must be "pencil" or "brush" style 必須為 "pencil" 或 "brush" +@msg extend end must be "start" or "end" extend 的端點必須為 "start" 或 "end" +@msg connect end must be "start" or "end" connect 的端點必須為 "start" 或 "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` 必須是介於 1 到 {MAX_BRIDGES_PER_ISLAND} 的整數 Weed Box and Lines… 除廢框與除廢線… Weed Box and Lines 除廢框與除廢線 diff --git a/docs/mcp.md b/docs/mcp.md index 912ac32562..cc6524bf53 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -3111,7 +3111,10 @@ already walks Image Trace. Short agent entry points: divided by the zoom (0.0313 to 640) and kept within that range, so a stroke is fitted at the same tolerance on screen at every zoom. A stroke that continues a path (`extend`) closes it when it ends within four times the Fidelity of the path's other end, at - least 6 pt and at most 400 pt. The Blob Brush's `path.blob` Fidelity stays in points, 0.01 to 100 pt. + least 6 pt and at most 400 pt. The Blob Brush's `path.blob` Fidelity stays in points, 0.01 to 100 pt, and is + not used when left out or null. `path.blob` rejects a `fidelity` outside 0.01 to 100 pt, an `angle` outside -180° to + 180° and a `roundness` outside 0% to 100% with an error such as `` `angle` must be from -180 to 180 degrees ``; the + document does not change and no undo step is recorded. These ranges are VectorCraft's own values. - Variables: `variable.list`, `variable.define {name, kind: text|visibility|image|graph}`, `variable.bind {variable, ids?}`, `variable.makeTextDynamic`, `variable.makeVisibilityDynamic`, `variable.makeImageDynamic`, `variable.makeGraphDynamic` (`variable.bind` and `variable.makeTextDynamic` refuse type that already has another text variable and name it), @@ -5167,6 +5170,11 @@ These commands refuse a string, a number or another value that is not true or fa in `path.curvatureEdit`; `perpendicular` in `path.reshapeSegment`; and `keepSelected`, `mergeOnlySelection` and `merge` in `path.blob`. A null is read as a key left out. +`path.freehand` (and `brush.freehand`, which runs it) refuses a `style` other than "pencil" or "brush" with +`style must be "pencil" or "brush"`, and an `end` of `extend` other than "start" or "end" with +`extend end must be "start" or "end"`; the document does not change and no undo step is recorded. Left out or null, +`style` is "pencil" and the `end` of `extend` is "end". + A `pointer_gesture` with `mods: {cmd: true}` held at the press, with any tool but the selection tools (Command on macOS, Ctrl elsewhere), drags with the selection tool chosen last (`select_tool`), or Direct Selection with the Pen, Curvature and anchor tools until one is chosen; the release gives the tool back as it was, so the Pen goes on drawing diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 26681e5b7f..ece6f7356b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1148,6 +1148,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur The Blob Brush Tool Options also have Angle and Roundness, as the reference app's [Blob Brush options](https://web.archive.org/web/20261012042029/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/blob-brush-options-and-best-practices.html) list them: Angle from −180° to 180° (0° by default) and Roundness from 0% to 100% (100%, a round tip, by default). The elliptical tip keeps its angle on the page along a stroke, a 0% tip is drawn 0.1% as wide as it is long, and the dialog shows the tip and three dabs of it. The values are kept with the tool's options (`path.blob` `angle` and `roundness`). Not done: the Random and pen-driven variations of Angle and Roundness. The Blob Brush Tool Options' tip preview is the Angle slider for screen readers, with the Angle in degrees as its value: a click or a drag in it points the Angle at the pointer and gives it the keyboard focus, Tab reaches it after the Roundness field, and the arrow keys step the Angle by 1° (10° with Shift, Home and End to −180° and 180°). The Blob Brush Tool Options also have Fidelity, which the reference app's [Blob Brush options](https://web.archive.org/web/20261012042029/https://helpx.adobe.com/illustrator/desktop/paint-and-fill/learn-painting-basics/blob-brush-options-and-best-practices.html) list as setting how far the pointer moves before the path gets a new anchor point. The range and default are VectorCraft's own values: the Pencil's logarithmic slider from Accurate (0.01 pt) to Smooth (20 pt) and its field (up to 100 pt), 1.5 pt by default and kept with the tool's options. The brush follows the stroke fitted at the Fidelity, as a Pencil stroke is fitted: a low value follows the drag closely, jitter included, and a higher one gives smoother curves (`path.blob` `fidelity`). + `path.blob` rejects an Angle outside −180° to 180°, a Roundness outside 0% to 100% and a Fidelity outside 0.01 to 100 pt with an error and leaves the document unchanged; a key left out or null takes its default (0°, 100% and no fitting). A Blob Brush stroke merges with the topmost path of its fill color and no stroke that it touches, and with the other such paths it touches in the same group or layer that are next to that path in stacking order with no other kind of object between them; matching paths in other groups or layers are left alone, as the Blob Brush tool guidelines in [Paint with fills and strokes](https://web.archive.org/web/20241219085603/https://helpx.adobe.com/illustrator/using/painting-fills-strokes.html) describe (`path.blob`). - **Ruler guides as layer objects:** a guide goes on the current layer, shows, hides, locks and is deleted with it, is listed in the Layers panel (its row selects it) and moves to another layer (`guide.setLayer`, or its row dragged onto that layer's rows); guides on a hidden or locked layer can't be selected, moved or deleted, Duplicate copies a layer's guides and Merge Selected and Flatten Artwork keep them on the merged layer; guides from files saved before guides had layers go on the top visible, unlocked layer when the document opens. A guide's row has its own eye and lock, which hide or lock that guide alone in one undo step and take part in a drag down either column ([help page](https://helpx.adobe.com/in_hi/tutorial-builder/user-guide/illustrator-tutorial-builder/-ai--examples-of-common-coach-marks.html) lists a Guide among the Layers panel's items); a hidden guide is not drawn and does not snap, a locked one is drawn and snaps but can't be selected, moved or deleted, and its own state is kept through save and reopen and while its layer is hidden or locked (`layer.setProps` on its `guide.list` id). Object › Lock › Selection and Object › Hide › Selection lock or hide a selected guide with the selected art, and Unlock All and Show All unlock or show such guides and select them ([help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf) for Lock and Hide Selection). A guide row dropped on the panel's trash deletes its guide, the trash deletes a guide its row selected, and after a click on a guide row Delete deletes the guide rather than the rows highlighted before ([help page](https://helpx.adobe.com/illustrator/desktop/measure-and-align/grids-and-guides/align-graphic-objects-with-guides.html) for deleting a selected guide). Not done: guides stacked among the art of their layer (they are listed above it). Lock Guides also locks the objects made into guides: they can't be selected, moved or deleted (#1543); they are drawn in the guide colour and style of Preferences, and a dragged selection snaps to ruler guides with Smart Guides on (#1583, fixes #1534). Preferences › Guides & Grid › Lock Guides by Default locks guides when the app starts; it is off by default, and new guides can still be dragged out of a ruler while guides are locked. The Transform panel shows a selected ruler guide's X or Y, and typing a value moves it (#1659, part of #1597). This is not established by the documentation we could find: the public help pages on guides, rulers and the Transform, Control and Properties panels (read again on 2026-10-14) describe selecting and dragging unlocked guides and the panels' X and Y for a selection, not a guide's position in a panel, and the one public statement of it is a user's [community answer](https://community.adobe.com/questions-652/adding-a-new-custom-guide-785586), which is not documentation. It is kept as a convenience pending the owner's decision, with no parity claim and nothing counted towards a score. - **Releasing ruler guides:** View › Guides › Release Guides turns the selected ruler guides into paths with no fill or stroke. An artboard guide becomes a line across its artboard, and a canvas guide becomes a line across the artboards (`view.guides.release {index?, ids?}`). A Cmd/Ctrl+Shift double-click with the Selection, Direct Selection or Group Selection tool releases the ruler guide or guide path under the pointer. From 7402ca4fd8cdcab03027dbb308262cd9879a54cc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Fri, 13 Nov 2026 17:09:49 -0800 Subject: [PATCH 02/13] .ai editing data: Scatter and Art brushes keep their art's opacity masks A Scatter or Art brush whose art holds an opacity mask was left out of the Brushes panel in the editing data with the brushes warning. The writer now writes such a brush when each mask's art passes the same check as the brush's art, in the form define_brush_art in crates/eps/src/import/ai/read/directives.rs reads: the mask's art between X= and X+ in the object's art dictionary, with its Clip, Invert Mask, disabled and linked options. Masks may sit up to seven deep in one another's art. Masks on a compound path's members, gradient masks and mask art past the reader's limits still leave the brush out with the warning. - The reader turns an Art brush's art over with the art of masks that don't move with their objects, so such a mask stays over the part of the object it was over. - A brush's mask art is written as the brush holds it, not as an object of the layers' mask art that has the same id and keeps an art style. --- crates/eps/src/ai_editing/tests.rs | 169 +++++++++++++++++++- crates/eps/src/ai_editing/writer/brushes.rs | 46 +++++- crates/eps/src/import.rs | 2 +- crates/eps/src/import/ai.rs | 4 +- crates/eps/src/import/ai/brush.rs | 27 +++- crates/eps/src/import/ai/tests.rs | 24 +++ docs/file-format-parity.md | 4 +- docs/target-app-parity.md | 1 + 8 files changed, 263 insertions(+), 14 deletions(-) diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 3af515181c..1d006dbadc 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -8085,7 +8085,8 @@ fn brushes_document() -> Document { } /// Brush art `n` as a tree to compare with [`same_tree`]: each object's kind, its anchors and handles, -/// the fills and strokes that paint (a stroke with its width), and its members in order. +/// the fills and strokes that paint (a stroke with its width), its members in order, and its opacity +/// mask's art and options when it has one. fn art_tree(n: &Node) -> serde_json::Value { let kind = match &n.kind { NodeKind::Path { .. } => "path", @@ -8110,7 +8111,11 @@ fn art_tree(n: &Node) -> serde_json::Value { }) .collect(); let members: Vec = n.children().map(|c| c.iter().map(|m| art_tree(m)).collect()).unwrap_or_default(); - serde_json::json!({"kind": kind, "anchors": anchors, "paints": paints, "members": members}) + let mut tree = serde_json::json!({"kind": kind, "anchors": anchors, "paints": paints, "members": members}); + if let Some(m) = &n.extras().mask { + tree["mask"] = serde_json::json!({"art": art_tree(&m.art), "options": [m.clip, m.invert, m.disabled, m.linked]}); + } + tree } /// Are trees `a` and `b` ([`art_tree`]) the same but for numbers within the written numbers' @@ -8253,6 +8258,166 @@ fn an_art_brush_whose_art_doesnt_bend_keeps_its_paths_look() { assert!(same_tree(&art_tree(&got.art), &art_tree(&want.art)), "{:#?}", got.art); } +/// An opacity mask whose art is rectangle `r` filled in `paint`, with the options given. +fn rect_mask(id: u64, r: Rect, paint: Paint, clip: bool, invert: bool, linked: bool) -> OpacityMask { + let art = Node::path(vectorcraft_doc::NodeId(id), shapes::rectangle(r), Appearance::basic(paint, Paint::None, 0.0)); + OpacityMask { art: Arc::new(art), clip, invert, disabled: false, linked } +} + +/// `levels` white rectangle masks that clip, each but the last holding the next in its art. +fn mask_chain(levels: u32) -> Option> { + (0..levels).fold(None, |inner, i| { + let mut m = rect_mask(100 + u64::from(i), Rect::new(0.0, 0.0, 30.0 - f64::from(i), 8.0), solid(Color::WHITE), true, false, true); + Arc::make_mut(&mut m.art).extras_mut().mask = inner; + Some(Box::new(m)) + }) +} + +/// [`brush_art_node`] with opacity masks: on the group, a mid-gray rectangle that clips; on the wide +/// block, a white rectangle inverted without clipping. Both masks are `linked` or not. +fn masked_brush_art(linked: bool) -> Node { + let mut art = brush_art_node(); + if let Some(c) = art.children_mut() { + let wide = rect_mask(10, Rect::new(0.0, 0.0, 20.0, 4.0), solid(Color::WHITE), false, true, linked); + Arc::make_mut(&mut c[0]).extras_mut().mask = Some(Box::new(wide)); + } + art.extras_mut().mask = Some(Box::new(rect_mask(11, Rect::new(0.0, 0.0, 30.0, 8.0), solid(Color::rgb(0.5, 0.5, 0.5)), true, false, linked))); + art +} + +/// Scatter and Art brushes whose art holds opacity masks come back in the Brushes panel with their +/// settings, the masks' art in place with its paint, and the masks' options: masks on the art and on +/// a member, masks that don't move with their objects, and masks seven deep in one another's art. A +/// path with the masked Art brush comes back as its drawn look, with the stroke warning. +#[test] +fn scatter_and_art_brush_mask_art_round_trips() { + use vectorcraft_brush::{ArtBrush, Brush, BrushKind, Scatter}; + let mut deep = brush_art_node(); + deep.extras_mut().mask = mask_chain(7); + let lib = vec![ + Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(true), ..Scatter::default() }) }, + Brush { name: "Masked ribbon".into(), kind: BrushKind::Art(ArtBrush { art: masked_brush_art(true), ..ArtBrush::default() }) }, + Brush { name: "Unlinked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(false), ..Scatter::default() }) }, + Brush { name: "Unlinked ribbon".into(), kind: BrushKind::Art(ArtBrush { art: masked_brush_art(false), ..ArtBrush::default() }) }, + Brush { name: "Deep spray".into(), kind: BrushKind::Scatter(Scatter { art: deep.clone(), ..Scatter::default() }) }, + Brush { name: "Deep ribbon".into(), kind: BrushKind::Art(ArtBrush { art: deep, ..ArtBrush::default() }) }, + ]; + let mut doc = Document::new(300.0, 200.0); + vectorcraft_brush::store(&mut doc, &lib); + brushed(&mut doc, "Masked ribbon", (20.0, 120.0), (280.0, 150.0), 1.0); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(!out.warnings.iter().any(|w| w == writer::BRUSHES || w == writer::DEEP_MASKS), "{:?}", out.warnings); + assert!(out.warnings.iter().any(|w| w == writer::STROKES), "{:?}", out.warnings); + assert_eq!(program(&doc).matches("%AI8_BeginBrushPattern").count(), lib.len()); + let back = read_back(&doc); + assert!(matches!(back.layers[0].children().unwrap()[0].kind, NodeKind::Group { .. }), "the path's drawn look"); + let got = vectorcraft_brush::library(&back); + assert_eq!(got.iter().map(|b| b.name.as_str()).collect::>(), lib.iter().map(|b| b.name.as_str()).collect::>()); + let none = || Node::group(vectorcraft_doc::NodeId(0), vec![]); + for (g, w) in got.iter().zip(&lib) { + let name = &w.name; + let (ga, wa) = match (&g.kind, &w.kind) { + (BrushKind::Scatter(gs), BrushKind::Scatter(ws)) => { + let settings = |s: &Scatter| Scatter { art: none(), modes: Some(s.modes()), ..s.clone() }; + assert_eq!(settings(gs), settings(ws), "{name}"); + (&gs.art, &ws.art) + } + (BrushKind::Art(ga), BrushKind::Art(wa)) => { + assert_eq!(ArtBrushOptions::of(ga), ArtBrushOptions::of(wa), "{name}"); + (&ga.art, &wa.art) + } + _ => panic!("{name}: {g:?}"), + }; + let (gt, wt) = (art_tree(ga), art_tree(wa)); + assert!(same_tree(>, &wt), "{name}: {gt:#} for {wt:#}"); + } +} + +/// Brushes whose mask art the reader wouldn't read back as it is are left out with a warning, beside +/// a brush that comes back: a Scatter brush whose art's mask is a gradient, one whose art holds +/// masks eight deep in one another's art (deeper than the editing data writes masks), one whose +/// mask's art is a compound path of 26,500 members of two squares each, which the reader reads as +/// 53,000 paths, more art than it copies into one file's brushes, and one whose art is a compound +/// path with a mask on a member (a compound path is written as one path, without its members' masks). +#[test] +fn brushes_whose_mask_art_isnt_read_back_are_left_out() { + use vectorcraft_brush::{Brush, BrushKind, Scatter}; + let keep = Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art: masked_brush_art(true), ..Scatter::default() }) }; + let mut gradient = brush_art_node(); + let ramp = gradient_paint(sunset(), None, None); + gradient.extras_mut().mask = Some(Box::new(rect_mask(11, Rect::new(0.0, 0.0, 30.0, 8.0), ramp, true, false, true))); + let mut deep = brush_art_node(); + deep.extras_mut().mask = mask_chain(8); + let square = |i: u32| { + let (x, y) = (f64::from(i % 400) * 2.0, f64::from(i / 400) * 2.0); + shapes::rectangle(Rect::new(x, y, x + 1.0, y + 1.0)).subpaths + }; + let members = (0..26_500) + .map(|m| { + let path = PathData::new((0..2).flat_map(|k| square(m * 2 + k)).collect()); + Arc::new(Node::path(vectorcraft_doc::NodeId(21), path, Appearance::basic(solid(Color::WHITE), Paint::None, 0.0))) + }) + .collect(); + let mut squares = Node::path(vectorcraft_doc::NodeId(20), PathData::default(), Appearance::basic(solid(Color::WHITE), Paint::None, 0.0)); + squares.kind = NodeKind::Compound { children: members, rule: FillRule::NonZero }; + let mut heavy = brush_art_node(); + heavy.extras_mut().mask = Some(Box::new(OpacityMask { art: Arc::new(squares), clip: true, invert: false, disabled: false, linked: true })); + let mut member = brush_art_node(); + member.kind = match member.kind { + NodeKind::Group { mut children, .. } => { + let mask = rect_mask(10, Rect::new(0.0, 0.0, 20.0, 4.0), solid(Color::WHITE), true, false, true); + Arc::make_mut(&mut children[0]).extras_mut().mask = Some(Box::new(mask)); + NodeKind::Compound { children, rule: FillRule::NonZero } + } + kind => kind, + }; + member.appearance = Appearance::basic(black_fill(), Paint::None, 0.0).into(); + let cases = [ + ("gradient mask", gradient), + ("masks eight deep", deep), + ("mask art past the reader's limit", heavy), + ("mask on a compound path's member", member), + ]; + for (why, art) in cases { + let mut doc = Document::new(300.0, 200.0); + let lib = vec![keep.clone(), Brush { name: why.into(), kind: BrushKind::Scatter(Scatter { art, ..Scatter::default() }) }]; + vectorcraft_brush::store(&mut doc, &lib); + let out = export_ai_editing(&doc, &opts()).unwrap(); + assert!(out.warnings.iter().any(|w| w == writer::BRUSHES), "{why}: {:?}", out.warnings); + assert!(!out.warnings.iter().any(|w| w == writer::DEEP_MASKS), "{why}: {:?}", out.warnings); + let names: Vec = vectorcraft_brush::library(&read_back(&doc)).into_iter().map(|b| b.name).collect(); + assert_eq!(names, ["Masked spray"], "{why}"); + assert_eq!(program(&doc).matches("%AI8_BeginBrushPattern").count(), 1, "{why}"); + } +} + +/// A brush's mask art is written as the brush holds it when an object of the layers' mask art with +/// the same id keeps a live effect as an art style: the brush's mask comes back as its own plain +/// rectangle, without the layers' object's effect or geometry. +#[test] +fn a_brushs_mask_art_isnt_written_as_a_styled_object_with_its_id() { + use vectorcraft_brush::{Brush, BrushKind, Scatter}; + let offset = fx("path.offsetPath", serde_json::json!({"offset": 8.0, "joins": "miter", "miterLimit": 4.0})); + let mut id = None; + let mut doc = masked_image(|doc| { + let grown = styled_rect(doc, "Grown", Rect::new(60.0, 30.0, 110.0, 70.0), solid(Color::rgb(0.0, 0.0, 0.0)), Paint::None, vec![offset]); + id = Some(grown.id); + grown + }); + let id = id.expect("the mask's art"); + let mut art = brush_art_node(); + art.extras_mut().mask = Some(Box::new(rect_mask(id.0, Rect::new(0.0, 0.0, 30.0, 8.0), solid(Color::WHITE), true, false, true))); + let lib = vec![Brush { name: "Masked spray".into(), kind: BrushKind::Scatter(Scatter { art, ..Scatter::default() }) }]; + vectorcraft_brush::store(&mut doc, &lib); + let got = vectorcraft_brush::library(&read_back(&doc)); + let [Brush { kind: BrushKind::Scatter(s), .. }] = got.as_slice() else { panic!("{got:?}") }; + let BrushKind::Scatter(want) = &lib[0].kind else { panic!("a Scatter brush") }; + let m = s.art.extras().mask.as_deref().unwrap_or_else(|| panic!("the mask is read: {:#?}", s.art)); + assert!(m.art.appearance.effects.is_empty(), "{:?}", m.art.appearance.effects); + let (gt, wt) = (art_tree(&s.art), art_tree(&want.art)); + assert!(same_tree(>, &wt), "{gt:#} for {wt:#}"); +} + /// Settings the other tests don't use come back: a Calligraphic brush varying with tilt and bearing, /// a Scatter brush keeping its art's colors whose rotation doesn't follow the path, and brushes whose /// modes aren't given (the reader gives them, the same ones). diff --git a/crates/eps/src/ai_editing/writer/brushes.rs b/crates/eps/src/ai_editing/writer/brushes.rs index 2c281e702d..14836bdb5b 100644 --- a/crates/eps/src/ai_editing/writer/brushes.rs +++ b/crates/eps/src/ai_editing/writer/brushes.rs @@ -23,7 +23,7 @@ use super::{Writer, Xy}; use crate::ai_ops; use crate::ps; -pub(in crate::ai_editing) const BRUSHES: &str = "Pattern and Bristle brushes, Art brushes that don't stretch their art along the path from left to right at 100% unflipped without overlap, Scatter and Art brushes in Tints and Shades or Hue Shift, brushes whose art holds an empty path or group or more than paths, compound paths and groups with one solid fill and one plain stroke each, brushes whose names hold a slash or repeat an earlier brush's name, brushes that would open with other settings, brushes past the number or the amount of art one file's brushes can hold, and every brush on a large canvas are left out of the Brushes panel in the editing data for other apps"; +pub(in crate::ai_editing) const BRUSHES: &str = "Pattern and Bristle brushes, Art brushes that don't stretch their art along the path from left to right at 100% unflipped without overlap, Scatter and Art brushes in Tints and Shades or Hue Shift, brushes whose art or its opacity masks' art holds an empty path or group or more than paths, compound paths and groups with one solid fill and one plain stroke each, or opacity masks on a compound path's members or more than seven deep in one another's art, brushes whose names hold a slash or repeat an earlier brush's name, brushes that would open with other settings, brushes past the number or the amount of art one file's brushes can hold, and every brush on a large canvas are left out of the Brushes panel in the editing data for other apps"; /// Most brushes written (the reader's limit). const MAX_BRUSHES: usize = 4096; @@ -164,17 +164,38 @@ fn art_params(a: &ArtBrush, art: &str) -> Option { Some(format!("2 / {art}/ / / / / 0 0/ 5 0 0 0 / {}", nums6(&numbers))) } +/// Most opacity masks in one another's art in a brush's art: a brush's art section writes its art +/// one level inside, and masks at [`super::MAX_NEST`] levels are left out ([`super::DEEP_MASKS`]). +const MAX_MASK_NEST: u32 = super::MAX_NEST - 1; + /// Is `art` written as the reader reads it back, within a brush: paths and compound paths with /// points and groups with members (not clipping, without paint of their own), each opaque in the -/// normal blending mode, without effects or opacity masks, with at most one fill and one plain -/// stroke (no brush, width profile, arrowheads, alignment off the path or dashes fitted to corners) -/// over it, each in a color or none? A path without points isn't written ([`Writer::plain_object`]). +/// normal blending mode, without effects, with at most one fill and one plain stroke (no brush, +/// width profile, arrowheads, alignment off the path or dashes fitted to corners) over it, each in a +/// color or none, and opacity masks whose art is such art too, at most [`MAX_MASK_NEST`] deep and +/// none on a compound path's members? A path without points isn't written +/// ([`Writer::plain_object`]). fn plain_art(art: &Node) -> bool { + plain_within(art, MAX_MASK_NEST) +} + +/// Does no object of `art` have an opacity mask? +fn unmasked(art: &Node) -> bool { + let mut unmasked = true; + art.walk(&mut |n| unmasked &= n.extras().mask.is_none()); + unmasked +} + +/// [`plain_art`] with at most `masks` opacity masks in one another's art. +fn plain_within(art: &Node, masks: u32) -> bool { let mut plain = true; art.walk(&mut |n| { let kind = match &n.kind { NodeKind::Path { path, guide: false, clipping: false, .. } => path.subpaths.iter().any(|sp| !sp.anchors.is_empty()), - NodeKind::Compound { .. } => super::compound_path(n).subpaths.iter().any(|sp| !sp.anchors.is_empty()), + // A compound path is written as one path of its members' subpaths, without their masks. + NodeKind::Compound { children, .. } => { + children.iter().all(|c| unmasked(c)) && super::compound_path(n).subpaths.iter().any(|sp| !sp.anchors.is_empty()) + } NodeKind::Group { children, clip: false } => !children.is_empty(), _ => false, }; @@ -198,7 +219,7 @@ fn plain_art(art: &Node) -> bool { && order && quiet && n.appearance.effects.is_empty() - && n.extras().mask.is_none() + && n.extras().mask.as_deref().is_none_or(|m| masks > 0 && plain_within(&m.art, masks - 1)) && n.opacity >= 1.0 && n.blend == BlendMode::Normal; }); @@ -209,8 +230,13 @@ fn plain_art(art: &Node) -> bool { /// compound path with the subpaths of all its members as one path ([`super::compound_path`]), is /// written as one path when it has one subpath with points and as a compound path when it has more /// ([`Writer::plain_object`]); the reader reads that compound path as one path for each subpath, -/// each with the object's paint. +/// each with the object's paint. An opacity mask's art is written shown ([`Writer::mask`]). fn as_read(art: &mut Node) { + if let Some(m) = art.extras_if_any().and_then(|e| e.mask.as_mut()) { + let mask_art = Arc::make_mut(&mut m.art); + mask_art.visible = true; + as_read(mask_art); + } let (subpaths, rule) = match &art.kind { NodeKind::Path { path, rule, .. } => (path.subpaths.clone(), *rule), NodeKind::Compound { rule, .. } => (super::compound_path(art).subpaths, *rule), @@ -341,7 +367,7 @@ impl Writer<'_> { } let mut read = a.clone(); if *to_section == Affine::IDENTITY { - read.transform(Affine::FLIP_Y, false); + crate::import::turn_brush_art_over(&mut read); } as_read(&mut read); Some(read) @@ -378,6 +404,9 @@ impl Writer<'_> { // The art is the brush's own: not on `%_` lines, in a drawn look or in a symbol that // first uses the brush. (std::mem::take(&mut self.hidden), std::mem::take(&mut self.in_look), std::mem::take(&mut self.in_symbol)), + // The layers' objects written with art styles, by id: none of them is the brush's art, + // which may hold objects with the same ids. + std::mem::take(&mut self.styled), ); (self.to_art, self.grad_space, self.canvas, self.block_end) = (to_section, to_section, to_section, usize::MAX); self.state(false, false); @@ -413,6 +442,7 @@ impl Writer<'_> { self.clip, (self.block_start, self.block_end), (self.hidden, self.in_look, self.in_symbol), + self.styled, ) = saved; let text = std::mem::replace(&mut self.body, body); if !std::mem::replace(&mut self.warnings, warnings).is_empty() { diff --git a/crates/eps/src/import.rs b/crates/eps/src/import.rs index bdb3b9cf50..dbfdc15417 100644 --- a/crates/eps/src/import.rs +++ b/crates/eps/src/import.rs @@ -90,7 +90,7 @@ pub(crate) use ai::objects_read; pub(crate) use ai::{ BRUSH_MANAGER, BrushesRead, DEFORM_PLUGIN, EnvelopeGridPoint, MAX_CHECKED as ENVELOPE_CHECKS, MAX_EDITING_OBJECTS, MAX_GRADIENT_STOPS, MAX_LISTED, MAX_LISTED_NAME, MAX_SYMBOLS, brush_plugin_name, brushes_kept, envelope_outline, envelope_upright, read_art_style, read_brush_object, - read_style_list, style_moves_with, symbol_art_member, warp_number, + read_style_list, style_moves_with, symbol_art_member, turn_brush_art_over, warp_number, }; pub(crate) use ate::{MAX_BYTES as MAX_TEXT_DOCUMENT, MAX_FRAMES, MAX_SEGMENTS, MAX_STORY, MAX_VALUES as MAX_TEXT_VALUES, record_version}; pub use native::{AiLayers, ai_alone, ai_alone_on_page, ai_alone_with, ai_layers_alone, ai_opened_artboard, is_loss, layered_ai, layered_ai_from}; diff --git a/crates/eps/src/import/ai.rs b/crates/eps/src/import/ai.rs index 4595061151..2bf72588de 100644 --- a/crates/eps/src/import/ai.rs +++ b/crates/eps/src/import/ai.rs @@ -34,7 +34,9 @@ use std::io::Read as _; use super::lex::find; use crate::ps; -pub(crate) use brush::{BrushesRead, MANAGER_NAME as BRUSH_MANAGER, brushes_kept, plugin_name as brush_plugin_name, read_brush_object}; +pub(crate) use brush::{ + BrushesRead, MANAGER_NAME as BRUSH_MANAGER, brushes_kept, plugin_name as brush_plugin_name, read_brush_object, turn_over as turn_brush_art_over, +}; pub(crate) use envelope::DRAWN as ENVELOPE_DRAWN; pub(crate) use envelope::MAX_CHECKED; pub(crate) use envelope::TYPE_DRAWN as ENVELOPE_TYPE_DRAWN; diff --git a/crates/eps/src/import/ai/brush.rs b/crates/eps/src/import/ai/brush.rs index 5a5db47114..e768c154e7 100644 --- a/crates/eps/src/import/ai/brush.rs +++ b/crates/eps/src/import/ai/brush.rs @@ -50,6 +50,7 @@ //! at None so the art keeps its own colors. use std::collections::{HashMap, HashSet}; +use std::sync::Arc; use kurbo::Affine; use vectorcraft_brush::{ArtBrush, Bristle, Brush, BrushKind, Calligraphic, Colorization, Scatter, Variation}; @@ -377,6 +378,30 @@ pub(super) fn parse_tool_object(kind: Tool, name: &str, params: &str) -> Result< Ok(BrushDraft { name: name.to_string(), kind }) } +/// Turn `art` over (y for -y) with the art of all its opacity masks, those that don't move with +/// their objects too: the art changes the space it is in, and no object moves over its mask. +pub(crate) fn turn_over(art: &mut Node) { + art.transform(Affine::scale_non_uniform(1.0, -1.0), false); + turn_unlinked_masks(art); +} + +/// Turn over the art of the opacity masks in `n` that a transform of `n` leaves in place (the masks +/// that don't move with their objects), in members and in other masks' art too. +fn turn_unlinked_masks(n: &mut Node) { + if let Some(m) = n.extras_if_any().and_then(|e| e.mask.as_mut()) { + let linked = m.linked; + let art = Arc::make_mut(&mut m.art); + if linked { + turn_unlinked_masks(art); + } else { + turn_over(art); + } + } + for c in n.children_mut().into_iter().flatten() { + turn_unlinked_masks(Arc::make_mut(c)); + } +} + /// The brushes of `drafts`, their art from the sections `art` (by name), in the brush manager's /// `order` (brushes it doesn't list after those it does, in the order of their objects), each /// kept within its ranges → the brushes and how many were left out: those whose art isn't read, @@ -456,7 +481,7 @@ pub(super) fn finish_brushes_within( DraftKind::Art { brush, art: name, .. } => copy(&name).map(|mut a| { // The side of the section with y up draws on the right of the path, and a brush // draws art's y (down here) on the left of the path. - a.transform(Affine::scale_non_uniform(1.0, -1.0), false); + turn_over(&mut a); BrushKind::Art(ArtBrush { art: a, ..brush }) }), DraftKind::Pattern { .. } => None, diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index e2a1943de7..cbeb3ff7f3 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -6358,6 +6358,30 @@ fn a_brushs_opacity_mask_art_takes_ids_of_the_document() { assert_eq!(unique.len(), all.len(), "{all:?}"); } +/// An Art brush's art is turned over with the art of its opacity mask, whether the mask moves with +/// its object or not: the mask's art stays over the part of the object it is over in the section. +#[test] +fn an_art_brushs_opacity_mask_art_turns_over_with_its_object() { + let mut read = vec![]; + for linked in [true, false] { + let mask_art: String = format!("1 g\n{}f\n", rect_path(0.0, 0.0, 40.0, 3.0)).lines().map(|l| format!("%_{l}\n")).collect(); + let options = format!("%_1 /Bool (Clipping) ,\n%_{} /Bool (Linked) ,\n", u8::from(linked)); + let mask = format!("%_/ArtDictionary :\n%_/Mask :\n%_X=\n{mask_art}%_X+\n%_(Art) ,\n{options}%_; (AI9_Mask) ,\n%_;\n"); + let section = format!("%AI8_BeginBrushPattern\n(Ribbon art)\n0 A\n0 g\n{}f\n{mask}%AI8_EndBrushPattern\n", rect_path(0.0, 0.0, 40.0, 8.0)); + let shape = format!("{RED}{}f\n", rect_path(0.0, 0.0, 10.0, 10.0)); + let r = read_ok(&format!("{section}{}{}", plugin_object(ART_BRUSH, "Ribbon", RIBBON), layer(&shape))); + let lib = vectorcraft_brush::library(&r.doc); + let vectorcraft_brush::BrushKind::Art(brush) = brush_named(&lib, "Ribbon") else { panic!("art: {:?}", r.warnings) }; + let m = brush.art.extras().mask.as_deref().unwrap_or_else(|| panic!("the mask is read: {:#?}", brush.art)); + assert_eq!(m.linked, linked); + let (object, over) = (brush.art.geometric_bounds().unwrap(), m.art.geometric_bounds().unwrap()); + assert!((object.height() - 8.0).abs() < 1e-6 && (over.height() - 3.0).abs() < 1e-6, "linked {linked}: {over:?} over {object:?}"); + assert!(over.y0 > object.y0 - 1e-6 && over.y1 < object.y1 + 1e-6, "linked {linked}: {over:?} over {object:?}"); + read.push((object, over)); + } + assert_eq!(read[0], read[1], "a mask is in the same place whether it moves with its object or not"); +} + /// An art styles section inside a symbol's, a pattern's or a brush's art is skipped: the file's own /// art styles still style the layers' objects read after the definition. #[test] diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 490b47464d..5852781d75 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -118,7 +118,9 @@ private editing data. VectorCraft: Scatter and Art brushes with their art, are written in its order: Scatter and Art brushes in Tints or keeping their art's colors, Art brushes that stretch their art along the path from left to right at 100% unflipped without overlap, and art of paths and compound paths with points and groups with members, with one solid fill and one - plain stroke each. Other brushes, + plain stroke each. Such art may hold opacity masks whose art is of the same kinds, up to seven deep in one + another's art; the masks are written with their options, and an Art brush whose art holds one is written with + its strokes as their drawn look. Other brushes, Pattern and Bristle brushes among them, and brushes past the number or the art VectorCraft's reader reads are left out with a warning; no brush is written on a large canvas. A path or compound path with a Calligraphic brush, or with an Art brush in Tints whose art bends along the path, keeps the brush on its stroke; other brushed strokes are diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index f3707717e6..46eb5ac83a 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1651,6 +1651,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur A `.ai` or EPS whose editing data has brushes opens with the file's Calligraphic, Scatter, Art and Bristle brushes in the Brushes panel in place of the default ones, in the file's order: the Calligraphic size, roundness and angle with their variation, the Scatter size, spacing, scatter and rotation, the Bristle settings, and the Scatter and Art brushes' art (Art brushes in the older and newer forms of their objects). A brush library `.ai` (brushes and no layers) opens from its PDF part with its brushes, so Other Library lists them. An Art brush in Tints keeps that colorization. Pattern brushes and brushes that can't be read are left out with a note. Paths with a Calligraphic brush, and paths with an Art brush in the newer form at 100% in Tints that stretches art of solid-filled paths unflipped, open as the path with the brush on its stroke. Paths with an Art brush in the older form, and other brushed paths, still come in as their drawn look (part of #372 and #637; `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`). In a `.ai` opened from its editing data, a path or type object with Offset Path, Outline Object or Outline Stroke on the whole object opens as itself with those effects live, in their order and shown or hidden; on a fill or stroke of type they stay on that fill or stroke. Offset Path keeps its Offset, Joins and Miter Limit, and Outline Stroke takes its width from the stroke. An Offset Path with a setting missing, out of range or not read keeps the drawn art, as does a path with a Path effect on one fill or stroke (`crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/tests_native.rs`). In a `.ai` or EPS opened from its editing data, a Scatter brush whose last 15 numbers start with 1 comes into the Brushes panel in Tints, and 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). 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 (`crates/eps/src/import/ai/tests.rs`). + A PDF-compatible `.ai` saved with Include Editing Data for Other Apps writes a Scatter or Art brush whose art holds opacity masks to the Brushes panel of its editing copy. This is VectorCraft's own rule for brushes a document already holds. Each mask's art is written in the brush's art section in the form VectorCraft's `.ai` reader reads (`define_brush_art` in `crates/eps/src/import/ai/read/directives.rs`), with the mask's Clip and Invert Mask options, whether it is disabled and whether it moves with its object, for masks up to seven deep in one another's art. A brush whose mask art holds more than paths, compound paths and groups with one solid fill and one plain stroke each is left out with a warning, and a path with an Art brush whose art holds a mask is written as its drawn look. When the reader turns an Art brush's art over, it turns the art of a mask that doesn't move with its object over too (`scatter_and_art_brush_mask_art_round_trips` and `brushes_whose_mask_art_isnt_read_back_are_left_out` in `crates/eps/src/ai_editing/tests.rs`, `an_art_brushs_opacity_mask_art_turns_over_with_its_object` in `crates/eps/src/import/ai/tests.rs`). In a `.ai` opened from its editing data, type with Warp on the object or on one of its fills or strokes opens as type with the effect live when the live warp draws as the art saved with it. When it draws differently, or when the file's limit of checks has no check left for it, it opens as that art, and one note says how many did. Type stays live without a comparison when the saved art paints nothing or draws type of its own, in frames of threaded type, when a text variable binds it, and when its text object doesn't come in as one text object (`crates/eps/src/import/ai/envelope.rs`, `crates/eps/src/import/tests_native.rs`). In a `.ai` opened from its editing data, an object with a Tweak that moves nothing or Pucker & Bloat at 0 opens as itself with the effect live. A path, compound path or group whose only effect is Transform without copies, or a Free Distort whose corners make a parallelogram, opens as itself with it live, and so does an object with nothing stroked whose only effect is Twist: a path or compound path with straight segments at up to 180° either way, and another path, compound path or group with no guide in it at up to 90° either way (limits VectorCraft sets); one twisted further keeps the drawn art. A gradient or pattern, an image, type, a clipping group, an opacity mask or effects inside the object, or a stroke with a Transform that scales, rotates or reflects, keep the drawn art (`crates/eps/src/import/ai/style/tests.rs`, `crates/eps/src/import/ai/tests.rs`, `crates/eps/src/import/ai/read/ops.rs`). A PDF page whose `UserUnit` (PDF 1.6) is above 1 opens at its size in points, its numbers times the `UserUnit` (one above 75,000 counts as 75,000), and `document.pdfInfo` gives its size and boxes in points too. A `.ai` whose editing data has its artboards in the units of such a page opens from that data at the page's size, with its layers, and when the layers can't be read its pages still take the artboard layout of the data, scaled the same way (part of #1482). From 3a3e03998bfc77fb99129e9e698af24940c1d007 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 07:25:59 -0800 Subject: [PATCH 03/13] i18n: drop connect end rows that main already has main now carries its own de, fr and it rows for the connect end message, so the duplicate rows this branch added are removed. --- crates/ui-egui/src/i18n/de.tsv | 1 - crates/ui-egui/src/i18n/fr.tsv | 1 - crates/ui-egui/src/i18n/it.tsv | 1 - 3 files changed, 3 deletions(-) diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 9af9bb3de8..8d8bbdcee9 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -7088,7 +7088,6 @@ breakText Glyphs Glyphen @msg `fidelity` must be from 0.01 to 100 pt `fidelity` muss zwischen 0.01 und 100 pt liegen @msg style must be "pencil" or "brush" style muss "pencil" oder "brush" sein @msg extend end must be "start" or "end" Das Ende von extend muss "start" oder "end" sein -@msg connect end must be "start" or "end" Das Ende von connect muss "start" oder "end" sein @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` muss eine ganze Zahl von 1 bis {MAX_BRIDGES_PER_ISLAND} sein Weed Box and Lines… Entgitterrahmen und -linien… Weed Box and Lines Entgitterrahmen und -linien diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index a5965e711c..ffe5272552 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7487,7 +7487,6 @@ breakText Glyphs Glyphes @msg `fidelity` must be from 0.01 to 100 pt `fidelity` doit être compris entre 0.01 et 100 pt @msg style must be "pencil" or "brush" style doit être "pencil" ou "brush" @msg extend end must be "start" or "end" l’extrémité de extend doit être "start" ou "end" -@msg connect end must be "start" or "end" l’extrémité de connect doit être "start" ou "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` doit être un nombre entier compris entre 1 et {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Cadre et lignes d’échenillage… Weed Box and Lines Cadre et lignes d’échenillage diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 0910ab5bac..b0fb190cc3 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -7122,7 +7122,6 @@ breakText Glyphs Glifi @msg `fidelity` must be from 0.01 to 100 pt `fidelity` deve essere compreso tra 0.01 e 100 pt @msg style must be "pencil" or "brush" style deve essere "pencil" o "brush" @msg extend end must be "start" or "end" l’estremità di extend deve essere "start" o "end" -@msg connect end must be "start" or "end" l’estremità di connect deve essere "start" o "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` deve essere un numero intero compreso tra 1 e {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Riquadro e linee di spellicolatura… Weed Box and Lines Riquadro e linee di spellicolatura From 80e361b39a1b4dcdee03be5ea353dcd63b5c52d5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 07:58:28 -0800 Subject: [PATCH 04/13] Tests: freehand refusal check accepts a catalog's own quotation marks MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit main's German row for the connect end refusal quotes the values as „start“ and „end“, so the test now looks for each accepted value inside any of the quotation mark pairs the catalogs use. --- crates/ui-egui/src/i18n/tests.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 150d26825f..600d0d57a9 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -2544,17 +2544,20 @@ fn freehand_choice_refusals_translate_with_their_values() { let b = s.execute("path.create", &json!({"d": "M10 50 L20 50"})).unwrap()["id"].clone(); let points = json!([[20, 10], [30, 30], [20, 50]]); let refusals = [ - (json!({"points": points, "style": "ink"}), ["style", "\"pencil\"", "\"brush\""]), - (json!({"points": points, "extend": {"id": a, "end": "middle"}}), ["extend", "\"start\"", "\"end\""]), - (json!({"points": points, "extend": {"id": a}, "connect": {"id": b, "end": "middle"}}), ["connect", "\"start\"", "\"end\""]), + (json!({"points": points, "style": "ink"}), "style", ["pencil", "brush"]), + (json!({"points": points, "extend": {"id": a, "end": "middle"}}), "extend", ["start", "end"]), + (json!({"points": points, "extend": {"id": a}, "connect": {"id": b, "end": "middle"}}), "connect", ["start", "end"]), ]; - for (p, words) in &refusals { + // A catalog may put the accepted values in its own quotation marks (German „start“). + let quotes = [("\"", "\""), ("„", "“"), ("“", "”"), ("«", "»"), ("« ", " »"), ("「", "」"), ("‘", "’")]; + for (p, key, values) in &refusals { let e = s.execute("path.freehand", p).unwrap_err().to_string(); assert!(e.starts_with("invalid parameters for `path.freehand`: ") && e.contains(" must be "), "{e}"); for code in COMPLETE_MESSAGES { let shown = message(Lang::from_code(code).expect("registered"), &e); - assert!(!shown.contains(" must be ") && shown.contains("`path.freehand`"), "{code}: {e} -> {shown}"); - assert!(words.iter().all(|w| shown.contains(w)), "{code}: {e} -> {shown}"); + assert!(!shown.contains(" must be ") && shown.contains("`path.freehand`") && shown.contains(key), "{code}: {e} -> {shown}"); + let quoted = |v: &str| quotes.iter().any(|(open, close)| shown.contains(&format!("{open}{v}{close}"))); + assert!(values.iter().all(|v| quoted(v)), "{code}: {e} -> {shown}"); } } } From 2ec0af8eb03fa73d147f89c52ae701f4ff588c4d Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 10:19:14 -0800 Subject: [PATCH 05/13] i18n: keep the Hindi connect-end row and drop the stale finite-angle rows The freehand refusal test now checks only that each catalog shows the accepted values as written, in its own quotation marks, so the Hindi row keeps its translated parameter name. No command emits "angle and roundness must be finite" any more, so its row goes from every catalog. --- crates/ui-egui/src/i18n/cs.tsv | 1 - crates/ui-egui/src/i18n/de.tsv | 1 - crates/ui-egui/src/i18n/fr.tsv | 1 - crates/ui-egui/src/i18n/hi.tsv | 2 +- crates/ui-egui/src/i18n/it.tsv | 1 - crates/ui-egui/src/i18n/ko.tsv | 1 - crates/ui-egui/src/i18n/nl.tsv | 1 - crates/ui-egui/src/i18n/pl.tsv | 1 - crates/ui-egui/src/i18n/pt-br.tsv | 1 - crates/ui-egui/src/i18n/tests.rs | 15 ++++++++------- crates/ui-egui/src/i18n/uk.tsv | 1 - crates/ui-egui/src/i18n/zh-hans.tsv | 1 - crates/ui-egui/src/i18n/zh-hant.tsv | 1 - 13 files changed, 9 insertions(+), 19 deletions(-) diff --git a/crates/ui-egui/src/i18n/cs.tsv b/crates/ui-egui/src/i18n/cs.tsv index 83e2a80d2d..e8af19c539 100644 --- a/crates/ui-egui/src/i18n/cs.tsv +++ b/crates/ui-egui/src/i18n/cs.tsv @@ -8132,7 +8132,6 @@ breakText Glyphs Glyfy @msg anchor `smooth` must be true or false `smooth` kotevního bodu musí být true nebo false @msg anchor `{key}` must be [x, y] `{key}` kotevního bodu musí být [x, y] @msg anchor `{key}` must be a number `{key}` kotevního bodu musí být číslo -@msg angle and roundness must be finite úhel a zaoblení musí být konečné @msg angles must be a list as long as pins (degrees or null) angles musí být seznam stejně dlouhý jako pins (stupně nebo null) @msg appearance must be flat|center|edge appearance musí být flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply je "fill" nebo "stroke", ne `{other}` diff --git a/crates/ui-egui/src/i18n/de.tsv b/crates/ui-egui/src/i18n/de.tsv index 73063193ae..692543107f 100644 --- a/crates/ui-egui/src/i18n/de.tsv +++ b/crates/ui-egui/src/i18n/de.tsv @@ -7832,7 +7832,6 @@ breakText Glyphs Glyphen @msg anchor `smooth` must be true or false Ankerpunkt-`smooth` muss true oder false sein @msg anchor `{key}` must be [x, y] Ankerpunkt-`{key}` muss [x, y] sein @msg anchor `{key}` must be a number Ankerpunkt-`{key}` muss eine Zahl sein -@msg angle and roundness must be finite angle und roundness müssen endlich sein @msg angles must be a list as long as pins (degrees or null) angles muss eine Liste so lang wie pins sein (Grad oder null) @msg appearance must be flat|center|edge appearance muss flat|center|edge sein @msg apply is "fill" or "stroke", not `{other}` apply ist „fill“ oder „stroke“, nicht `{other}` diff --git a/crates/ui-egui/src/i18n/fr.tsv b/crates/ui-egui/src/i18n/fr.tsv index fae74c7bfb..6a93251632 100644 --- a/crates/ui-egui/src/i18n/fr.tsv +++ b/crates/ui-egui/src/i18n/fr.tsv @@ -7996,7 +7996,6 @@ breakText Glyphs Glyphes @msg anchor `smooth` must be true or false `smooth` d’un point d’ancrage doit valoir true ou false @msg anchor `{key}` must be [x, y] `{key}` d’un point d’ancrage doit être [x, y] @msg anchor `{key}` must be a number `{key}` d’un point d’ancrage doit être un nombre -@msg angle and roundness must be finite l’angle et l’arrondi doivent être finis @msg angles must be a list as long as pins (degrees or null) angles doit être une liste aussi longue que pins (degrés ou null) @msg appearance must be flat|center|edge appearance doit valoir flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply vaut "fill" ou "stroke", pas `{other}` diff --git a/crates/ui-egui/src/i18n/hi.tsv b/crates/ui-egui/src/i18n/hi.tsv index a2a55a82d6..8aa0216ebd 100644 --- a/crates/ui-egui/src/i18n/hi.tsv +++ b/crates/ui-egui/src/i18n/hi.tsv @@ -6575,7 +6575,7 @@ antiAlias Sharp शार्प @msg compound paths can only contain paths यौगिक पाथ में केवल पाथ हो सकते हैं @msg compound shapes take paths, compound paths, groups, compound shapes, type, blends and envelopes कंपाउंड शेप पाथ, कंपाउंड पाथ, समूह, कंपाउंड शेप, टाइप, ब्लेंड और एन्वेलप लेते हैं @msg compressed (RLE) bitmaps can't be read yet संकुचित (RLE) bitmaps अभी तक पढ़ा नहीं जा सकता है -@msg connect end must be "start" or "end" connect अंत "start" या "end" होना चाहिए +@msg connect end must be "start" or "end" कनेक्ट अंत "start" या "end" होना चाहिए @msg connect needs a path other than the one extended connect के लिए बढ़ाए गए पाथ के अलावा कोई दूसरा पाथ चाहिए @msg connect needs id connect के लिए id चाहिए @msg connect path has no open end कनेक्ट पाथ का कोई खुला अंत नहीं है diff --git a/crates/ui-egui/src/i18n/it.tsv b/crates/ui-egui/src/i18n/it.tsv index 2ca1590448..47aeb50c6e 100644 --- a/crates/ui-egui/src/i18n/it.tsv +++ b/crates/ui-egui/src/i18n/it.tsv @@ -7880,7 +7880,6 @@ breakText Glyphs Glifi @msg anchor `smooth` must be true or false `smooth` del punto di ancoraggio deve essere true o false @msg anchor `{key}` must be [x, y] `{key}` del punto di ancoraggio deve essere [x, y] @msg anchor `{key}` must be a number `{key}` del punto di ancoraggio deve essere un numero -@msg angle and roundness must be finite angle e roundness devono essere finiti @msg angles must be a list as long as pins (degrees or null) angles deve essere un elenco lungo quanto pins (gradi o null) @msg appearance must be flat|center|edge appearance deve essere flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply è "fill" o "stroke", non `{other}` diff --git a/crates/ui-egui/src/i18n/ko.tsv b/crates/ui-egui/src/i18n/ko.tsv index 3f61a79a36..6fc8f867c5 100644 --- a/crates/ui-egui/src/i18n/ko.tsv +++ b/crates/ui-egui/src/i18n/ko.tsv @@ -7728,7 +7728,6 @@ breakText Glyphs 글리프 @msg anchor `smooth` must be true or false 앵커의 `smooth`은(는) true 또는 false여야 합니다 @msg anchor `{key}` must be [x, y] 앵커의 `{key}`은(는) [x, y]여야 합니다 @msg anchor `{key}` must be a number 앵커의 `{key}`은(는) 숫자여야 합니다 -@msg angle and roundness must be finite 각도와 원형률은 유한해야 합니다 @msg angles must be a list as long as pins (degrees or null) angles는 pins와 길이가 같은 목록이어야 합니다(도 또는 null) @msg appearance must be flat|center|edge appearance는 flat|center|edge여야 합니다 @msg apply is "fill" or "stroke", not `{other}` apply는 "fill" 또는 "stroke"입니다: `{other}` diff --git a/crates/ui-egui/src/i18n/nl.tsv b/crates/ui-egui/src/i18n/nl.tsv index 7cd4268e4a..188a96c2be 100644 --- a/crates/ui-egui/src/i18n/nl.tsv +++ b/crates/ui-egui/src/i18n/nl.tsv @@ -6080,7 +6080,6 @@ imageTrace Outline Contour @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}` diff --git a/crates/ui-egui/src/i18n/pl.tsv b/crates/ui-egui/src/i18n/pl.tsv index 74055fa27e..3e7e130257 100644 --- a/crates/ui-egui/src/i18n/pl.tsv +++ b/crates/ui-egui/src/i18n/pl.tsv @@ -8120,7 +8120,6 @@ breakText Glyphs Glify @msg anchor `smooth` must be true or false `smooth` punktu kontrolnego musi mieć wartość true lub false @msg anchor `{key}` must be [x, y] `{key}` punktu kontrolnego musi mieć postać [x, y] @msg anchor `{key}` must be a number `{key}` punktu kontrolnego musi być liczbą -@msg angle and roundness must be finite kąt i okrągłość muszą być skończone @msg angles must be a list as long as pins (degrees or null) angles musi być listą tej samej długości co pins (stopnie lub null) @msg appearance must be flat|center|edge appearance musi mieć wartość flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply ma wartość "fill" lub "stroke", a nie `{other}` diff --git a/crates/ui-egui/src/i18n/pt-br.tsv b/crates/ui-egui/src/i18n/pt-br.tsv index e7cba2800b..ca296ae025 100644 --- a/crates/ui-egui/src/i18n/pt-br.tsv +++ b/crates/ui-egui/src/i18n/pt-br.tsv @@ -8199,7 +8199,6 @@ swatch Yellow Green Verde-amarelado @msg anchor `smooth` must be true or false `smooth` do ponto de ancoragem deve ser true ou false @msg anchor `{key}` must be [x, y] `{key}` do ponto de ancoragem deve ser [x, y] @msg anchor `{key}` must be a number `{key}` do ponto de ancoragem deve ser um número -@msg angle and roundness must be finite angle e roundness devem ser finitos @msg angles must be a list as long as pins (degrees or null) angles deve ser uma lista do mesmo tamanho que pins (graus ou null) @msg appearance must be flat|center|edge appearance deve ser flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply é "fill" ou "stroke", não `{other}` diff --git a/crates/ui-egui/src/i18n/tests.rs b/crates/ui-egui/src/i18n/tests.rs index 600d0d57a9..3657269a88 100644 --- a/crates/ui-egui/src/i18n/tests.rs +++ b/crates/ui-egui/src/i18n/tests.rs @@ -2534,7 +2534,7 @@ fn blob_brush_range_refusals_translate_with_their_values() { } /// `path.freehand`'s refusals of an unknown `style`, `extend` end or `connect` end show in every -/// complete-message language with the key and the accepted values as given. +/// complete-message language with the accepted values as given. #[test] fn freehand_choice_refusals_translate_with_their_values() { use serde_json::json; @@ -2544,18 +2544,19 @@ fn freehand_choice_refusals_translate_with_their_values() { let b = s.execute("path.create", &json!({"d": "M10 50 L20 50"})).unwrap()["id"].clone(); let points = json!([[20, 10], [30, 30], [20, 50]]); let refusals = [ - (json!({"points": points, "style": "ink"}), "style", ["pencil", "brush"]), - (json!({"points": points, "extend": {"id": a, "end": "middle"}}), "extend", ["start", "end"]), - (json!({"points": points, "extend": {"id": a}, "connect": {"id": b, "end": "middle"}}), "connect", ["start", "end"]), + (json!({"points": points, "style": "ink"}), ["pencil", "brush"]), + (json!({"points": points, "extend": {"id": a, "end": "middle"}}), ["start", "end"]), + (json!({"points": points, "extend": {"id": a}, "connect": {"id": b, "end": "middle"}}), ["start", "end"]), ]; - // A catalog may put the accepted values in its own quotation marks (German „start“). + // A catalog may translate the parameter's name (Hindi कनेक्ट) and put the accepted values in its + // own quotation marks (German „start“); the values themselves stay as written. let quotes = [("\"", "\""), ("„", "“"), ("“", "”"), ("«", "»"), ("« ", " »"), ("「", "」"), ("‘", "’")]; - for (p, key, values) in &refusals { + for (p, values) in &refusals { let e = s.execute("path.freehand", p).unwrap_err().to_string(); assert!(e.starts_with("invalid parameters for `path.freehand`: ") && e.contains(" must be "), "{e}"); for code in COMPLETE_MESSAGES { let shown = message(Lang::from_code(code).expect("registered"), &e); - assert!(!shown.contains(" must be ") && shown.contains("`path.freehand`") && shown.contains(key), "{code}: {e} -> {shown}"); + assert!(!shown.contains(" must be ") && shown.contains("`path.freehand`"), "{code}: {e} -> {shown}"); let quoted = |v: &str| quotes.iter().any(|(open, close)| shown.contains(&format!("{open}{v}{close}"))); assert!(values.iter().all(|v| quoted(v)), "{code}: {e} -> {shown}"); } diff --git a/crates/ui-egui/src/i18n/uk.tsv b/crates/ui-egui/src/i18n/uk.tsv index 7b4aa8d611..144450a87f 100644 --- a/crates/ui-egui/src/i18n/uk.tsv +++ b/crates/ui-egui/src/i18n/uk.tsv @@ -7618,7 +7618,6 @@ breakText Glyphs Гліфи @msg anchor `smooth` must be true or false `smooth` опорної точки має бути true або false @msg anchor `{key}` must be [x, y] `{key}` опорної точки має бути [x, y] @msg anchor `{key}` must be a number `{key}` опорної точки має бути числом -@msg angle and roundness must be finite angle і roundness мають бути скінченними @msg angles must be a list as long as pins (degrees or null) angles має бути списком такої самої довжини, як pins (градуси або null) @msg appearance must be flat|center|edge appearance має бути flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply — це "fill" або "stroke", а не `{other}` diff --git a/crates/ui-egui/src/i18n/zh-hans.tsv b/crates/ui-egui/src/i18n/zh-hans.tsv index 035549f81e..894008ce8b 100644 --- a/crates/ui-egui/src/i18n/zh-hans.tsv +++ b/crates/ui-egui/src/i18n/zh-hans.tsv @@ -8106,7 +8106,6 @@ breakText Glyphs 字形 @msg anchor `smooth` must be true or false 锚点的 `smooth` 必须为 true 或 false @msg anchor `{key}` must be [x, y] 锚点的 `{key}` 必须是 [x, y] @msg anchor `{key}` must be a number 锚点的 `{key}` 必须是数字 -@msg angle and roundness must be finite angle 和 roundness 必须是有限值 @msg angles must be a list as long as pins (degrees or null) angles 必须是与 pins 等长的列表 (度数或 null) @msg appearance must be flat|center|edge appearance 必须是 flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply 为 "fill" 或 "stroke",不能是 `{other}` diff --git a/crates/ui-egui/src/i18n/zh-hant.tsv b/crates/ui-egui/src/i18n/zh-hant.tsv index dabcad1aca..09a6d8f72e 100644 --- a/crates/ui-egui/src/i18n/zh-hant.tsv +++ b/crates/ui-egui/src/i18n/zh-hant.tsv @@ -8031,7 +8031,6 @@ breakText Glyphs 字符 @msg anchor `smooth` must be true or false 錨點的 `smooth` 必須是 true 或 false @msg anchor `{key}` must be [x, y] 錨點的 `{key}` 必須是 [x, y] @msg anchor `{key}` must be a number 錨點的 `{key}` 必須是數字 -@msg angle and roundness must be finite angle 和 roundness 必須是有限值 @msg angles must be a list as long as pins (degrees or null) angles 必須是與 pins 等長的清單 (度數或 null) @msg appearance must be flat|center|edge appearance 必須是 flat|center|edge @msg apply is "fill" or "stroke", not `{other}` apply 是 "fill" 或 "stroke",而非 `{other}` From 0f342cd68968c3aaa4ffd8922b0af0d4c71144cc Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 10:46:38 -0800 Subject: [PATCH 06/13] i18n: drop the duplicate Japanese connect-end row and the stale finite-angle rows main now has a Japanese row for `connect end must be "start" or "end"`, so the branch's copy is removed and ja.tsv keeps main's row. Nothing emits `angle and roundness must be finite` any more, so the rows main added for it in hu.tsv and ja.tsv are removed. --- crates/ui-egui/src/i18n/hu.tsv | 1 - crates/ui-egui/src/i18n/ja.tsv | 2 -- 2 files changed, 3 deletions(-) diff --git a/crates/ui-egui/src/i18n/hu.tsv b/crates/ui-egui/src/i18n/hu.tsv index c223e86e5c..673d49b4ae 100644 --- a/crates/ui-egui/src/i18n/hu.tsv +++ b/crates/ui-egui/src/i18n/hu.tsv @@ -8001,7 +8001,6 @@ breakText Glyphs Glifák @msg anchor `smooth` must be true or false horgonypont, `smooth`: true vagy false kell @msg anchor `{key}` must be [x, y] horgonypont, `{key}`: [x, y] kell @msg anchor `{key}` must be a number horgonypont, `{key}`: szám kell -@msg angle and roundness must be finite angle és roundness: véges érték kell @msg angles must be a list as long as pins (degrees or null) angles: a pins listával azonos hosszúságú lista kell (fok vagy null) @msg appearance must be flat|center|edge appearance: flat|center|edge kell @msg apply is "fill" or "stroke", not `{other}` apply: "fill" vagy "stroke", ez nem az: `{other}` diff --git a/crates/ui-egui/src/i18n/ja.tsv b/crates/ui-egui/src/i18n/ja.tsv index fa38b6374a..176b536439 100644 --- a/crates/ui-egui/src/i18n/ja.tsv +++ b/crates/ui-egui/src/i18n/ja.tsv @@ -7086,7 +7086,6 @@ axis Y Axis Y 軸 @msg anchor `smooth` must be true or false アンカーの `smooth` には true または false を指定してください @msg anchor `{key}` must be [x, y] アンカーの `{key}` には [x, y] を指定してください @msg anchor `{key}` must be a number アンカーの `{key}` には数値を指定してください -@msg angle and roundness must be finite angle と roundness には有限の値を指定してください @msg angles must be a list as long as pins (degrees or null) angles には pins と同じ長さのリスト (度数または null) を指定してください @msg appearance must be flat|center|edge appearance には flat|center|edge のいずれかを指定してください @msg apply is "fill" or "stroke", not `{other}` apply には "fill" または "stroke" を指定してください (`{other}` は指定できません) @@ -9000,7 +8999,6 @@ breakText Glyphs 字形 @msg `fidelity` must be from 0.01 to 100 pt `fidelity` は 0.01~100 pt の範囲で指定してください @msg style must be "pencil" or "brush" style は "pencil" または "brush" を指定してください @msg extend end must be "start" or "end" extend の端は "start" または "end" を指定してください -@msg connect end must be "start" or "end" connect の端は "start" または "end" を指定してください @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` には 1 から {MAX_BRIDGES_PER_ISLAND} の整数を指定してください Weed Box and Lines… カス取り枠とライン… Weed Box and Lines カス取り枠とライン From 963d38d040a1f67fe501bec474a262c8fa5dbbef Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 14 Nov 2026 15:13:44 -0800 Subject: [PATCH 07/13] i18n: Danish rows for Blob Brush and freehand refusals --- crates/ui-egui/src/i18n/da.tsv | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/ui-egui/src/i18n/da.tsv b/crates/ui-egui/src/i18n/da.tsv index ca27bdd2f9..75943180a3 100644 --- a/crates/ui-egui/src/i18n/da.tsv +++ b/crates/ui-egui/src/i18n/da.tsv @@ -632,6 +632,12 @@ @msg No bridge of this width fits across the selected art Ingen bro med denne bredde passer hen over den markerede grafik @msg Some islands could not be joined to the area around the art Nogle øer kunne ikke forbindes med området omkring grafikken @msg `width` must be from {lo} to {hi} pt `width` skal være fra {lo} til {hi} pt +@msg `angle` must be from -180 to 180 degrees `angle` skal være fra -180 til 180 grader +@msg `roundness` must be from 0 to 100% `roundness` skal være fra 0 til 100 % +@msg `fidelity` must be from 0.01 to 100 pt `fidelity` skal være fra 0.01 til 100 pt +@msg style must be "pencil" or "brush" style skal være "pencil" eller "brush" +@msg extend end must be "start" or "end" enden for extend skal være "start" eller "end" +@msg connect end must be "start" or "end" enden for connect skal være "start" eller "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` skal være et heltal fra 1 til {MAX_BRIDGES_PER_ISLAND} File Filer From 2ae0db53c0d47b42c2c6f33ac0035ac25f8ba89f Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sun, 15 Nov 2026 09:35:53 -0800 Subject: [PATCH 08/13] i18n: Georgian and Russian keep one row of the connect end message The ka and ru catalogs already had a row for `connect end must be "start" or "end"`, and this branch added a second one, which fails bundled_catalogs_are_consistent. The added rows are removed and the existing translations stay. --- crates/ui-egui/src/i18n/ka.tsv | 1 - crates/ui-egui/src/i18n/ru.tsv | 1 - 2 files changed, 2 deletions(-) diff --git a/crates/ui-egui/src/i18n/ka.tsv b/crates/ui-egui/src/i18n/ka.tsv index 8b768bea96..c8f29ba1a7 100644 --- a/crates/ui-egui/src/i18n/ka.tsv +++ b/crates/ui-egui/src/i18n/ka.tsv @@ -9854,7 +9854,6 @@ font-script Japanese იაპონური @msg `fidelity` must be from 0.01 to 100 pt `fidelity` უნდა იყოს 0.01-დან 100 pt-მდე @msg style must be "pencil" or "brush" style უნდა იყოს "pencil" ან "brush" @msg extend end must be "start" or "end" extend-ის ბოლო უნდა იყოს "start" ან "end" -@msg connect end must be "start" or "end" connect-ის ბოლო უნდა იყოს "start" ან "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` უნდა იყოს მთელი რიცხვი 1-დან {MAX_BRIDGES_PER_ISLAND}-მდე Weed Box and Lines… ნარჩენის მოსაცილებელი ჩარჩო და ხაზები… Weed Box and Lines ნარჩენის მოსაცილებელი ჩარჩო და ხაზები diff --git a/crates/ui-egui/src/i18n/ru.tsv b/crates/ui-egui/src/i18n/ru.tsv index 92fe3db6a3..de59f54987 100644 --- a/crates/ui-egui/src/i18n/ru.tsv +++ b/crates/ui-egui/src/i18n/ru.tsv @@ -7752,7 +7752,6 @@ shape Open Открытый @msg `fidelity` must be from 0.01 to 100 pt `fidelity` должно быть от 0.01 до 100 pt @msg style must be "pencil" or "brush" style должен быть "pencil" или "brush" @msg extend end must be "start" or "end" конец extend должен быть "start" или "end" -@msg connect end must be "start" or "end" конец connect должен быть "start" или "end" @msg `count` must be a whole number from 1 to {MAX_BRIDGES_PER_ISLAND} `count` должно быть целым числом от 1 до {MAX_BRIDGES_PER_ISLAND} Weed Box and Lines… Рамка и линии выборки… Weed Box and Lines Рамка и линии выборки From 30693f211bc31a44c2226fc30c9bc73862f25dd7 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 16 Nov 2026 21:21:37 -0800 Subject: [PATCH 09/13] PDF/X: PDF/X-4 files carry xmp:MetadataDate, equal to xmp:ModifyDate A PDF/X-4 export wrote xmp:ModifyDate and xmp:CreateDate in its XMP metadata but no xmp:MetadataDate. The PDF/X-4 metadata edit now adds xmp:MetadataDate next to xmp:ModifyDate, with the same value, and grows the stream's /Length to match. When the export dates the file as modified later, post::modification_date already rewrites every xmp:MetadataDate, so the two dates stay equal. PDF/X-1a, PDF/X-3, PDF/A and plain PDF exports are unchanged. --- crates/pdf/src/pdfx.rs | 23 +++++++++++++++--- crates/pdf/src/post.rs | 5 ++-- crates/pdf/src/tests/pdfx.rs | 45 ++++++++++++++++++++++++++++++++++++ docs/mcp.md | 2 +- 4 files changed, 69 insertions(+), 6 deletions(-) diff --git a/crates/pdf/src/pdfx.rs b/crates/pdf/src/pdfx.rs index e367221d59..2313d62129 100644 --- a/crates/pdf/src/pdfx.rs +++ b/crates/pdf/src/pdfx.rs @@ -6,7 +6,7 @@ //! transparency (the app flattens it before writing), no layers, PDF 1.3. //! - PDF/X-3:2002: colours are ICC-based (always tagged), no transparency, no layers, PDF 1.3. //! - PDF/X-4:2010: transparency and layers are kept, colours are tagged, PDF 1.6 at most, and the -//! XMP metadata names the standard too. +//! XMP metadata names the standard too and carries `xmp:MetadataDate`. //! - All of them: a `/GTS_PDFX` output intent (blank, the CMYK profile in effect, embedded), a //! TrimBox on every page (the artboard), `/Trapped` True or False, `/GTS_PDFXVersion` in the //! document information, a title and dates, embedded fonts (or text as outlines), no editing @@ -120,8 +120,9 @@ pub(crate) fn info_entries(standard: Standard) -> String { } /// Edit the XMP metadata of a PDF/X file (the catalog's `/Metadata` stream; `root` is the -/// catalog dictionary's contents) into `patch`: PDF/X-4 adds the standard, Trapped and a version -/// id (PDF 1.3 files say so in [`finish`]). Files without metadata are left as they are. +/// catalog dictionary's contents) into `patch`: PDF/X-4 adds the standard, Trapped, a version id +/// and the metadata date (PDF 1.3 files say so in [`finish`]). Files without metadata are left as +/// they are. pub(crate) fn xmp(pdf: &[u8], xref: &Xref, root: (usize, usize), patch: &mut Patch, standard: Standard, trapped: bool) -> Result<(), PdfError> { if !standard.is_pdfx() { return Ok(()); @@ -145,6 +146,22 @@ pub(crate) fn xmp(pdf: &[u8], xref: &Xref, root: (usize, usize), patch: &mut Pat "{version}{trapped}1" ); edits.push((close, close, props.into_bytes())); + // When the packet has no `` element, this adds one after the writer's + // `` element with the same value. The search expects the writer's form: + // properties written as elements with the `xmp` prefix, and `<` in text written as `<`. + // The writer's description declares the `xmp` prefix there, and + // [`crate::post::modification_date`] keeps the two dates equal. + if find(xml, b"", 0).is_none() + && let Some(at) = find(xml, b"", 0).map(|i| i + b"".len()) + && let Some(to) = find(xml, b"", at) + { + let date = xml.get(at..to).ok_or_else(bad)?; + let mut prop = b"".to_vec(); + prop.extend_from_slice(date); + prop.extend_from_slice(b""); + let after = to + b"".len(); + edits.push((after, after, prop)); + } } // Every edit grows the stream (or keeps its length). let grown: usize = edits.iter().map(|(s, e, new)| new.len().saturating_sub(e - s)).sum(); diff --git a/crates/pdf/src/post.rs b/crates/pdf/src/post.rs index 79e872e59b..81d0d5aa0a 100644 --- a/crates/pdf/src/post.rs +++ b/crates/pdf/src/post.rs @@ -84,8 +84,9 @@ pub(crate) fn user_units(pdf: Vec, units: &[f64]) -> Result, PdfErro /// `pdf` dated as modified at `modified` (Unix seconds, UTC), its creation dates kept: the /// document information's `/ModDate` (a PDF date, ISO 32000-1 §7.9.4) and every `xmp:ModifyDate`, /// `xmp:MetadataDate` and `stEvt:when` of the catalog's XMP metadata (ISO 8601 dates), in UTC as -/// the PDF writer writes the creation date. The writer gives `/ModDate`, `xmp:ModifyDate` and -/// `stEvt:when` the creation date. +/// the PDF writer writes the creation date. The writer gives `/ModDate`, `xmp:ModifyDate`, +/// `stEvt:when` and, in a PDF/X-4 file, `xmp:MetadataDate` ([`crate::pdfx::xmp`]) the creation +/// date. pub(crate) fn modification_date(pdf: Vec, modified: i64) -> Result, PdfError> { let failed = |why: &str| PdfError::Write(format!("can't write the file's modification date: {why}")); let Parsed { xref, objects, trailer, root, .. } = linearize::parse(&pdf).map_err(failed)?; diff --git a/crates/pdf/src/tests/pdfx.rs b/crates/pdf/src/tests/pdfx.rs index 2003a6b7c6..1c12b9586f 100644 --- a/crates/pdf/src/tests/pdfx.rs +++ b/crates/pdf/src/tests/pdfx.rs @@ -42,6 +42,51 @@ fn text(pdf: &[u8]) -> String { String::from_utf8_lossy(pdf).into_owned() } +/// The XMP packet of `pdf`, read as its stream's `/Length` says: the packet's end must be inside +/// those bytes and nothing but the end of line may follow them before `endstream`. +fn xmp_packet(pdf: &[u8]) -> String { + use crate::lab_spot::{find, rfind}; + let begin = find(pdf, b" = dict[at..].iter().copied().take_while(u8::is_ascii_digit).collect(); + let length: usize = String::from_utf8(digits).unwrap().parse().unwrap(); + let mut data = obj + rfind(dict, b"stream").unwrap() + b"stream".len(); + data += pdf[data..].iter().take(2).take_while(|b| matches!(b, b'\r' | b'\n')).count(); + let stream = &pdf[data..data + length]; + let close = find(stream, b"", close).is_some(), "the packet ends inside the stream's length"); + let rest = String::from_utf8_lossy(&pdf[data + length..]); + assert!(rest.trim_start_matches(['\r', '\n']).starts_with("endstream"), "the stream ends at its length"); + String::from_utf8(stream.to_vec()).unwrap() +} + +/// The value of the XMP element `tag` in `xmp`. +fn xmp_value<'a>(xmp: &'a str, tag: &str) -> Option<&'a str> { + let open = format!("<{tag}>"); + let rest = &xmp[xmp.find(&open)? + open.len()..]; + Some(&rest[..rest.find(&format!(""))?]) +} + +#[test] +fn pdfx4_metadata_has_a_metadata_date_equal_to_the_modification_date() { + let d = doc(&[Color::cmyk(0.0, 1.0, 1.0, 0.0)]); + // Dated by the writer (created), then dated again after writing (modified later). + for modified in [None, Some(1_800_000_000)] { + let mut o = opts(Standard::PdfX4, |_| {}); + o.modified = modified; + let xmp = xmp_packet(&export(&d, &o).unwrap()); + let modify = xmp_value(&xmp, "xmp:ModifyDate").expect("xmp:ModifyDate"); + assert_eq!(xmp_value(&xmp, "xmp:MetadataDate"), Some(modify), "{modified:?}: {xmp}"); + assert_eq!(xmp.matches("").count(), 1, "{modified:?}"); + if modified.is_some() { + assert!(modify.starts_with("2027-01-15T"), "the later date: {modify}"); + } + } +} + #[test] fn each_standard_writes_its_header_output_intent_boxes_and_identification() { let mut d = doc(&[Color::cmyk(0.0, 1.0, 1.0, 0.0), Color::rgb(0.2, 0.4, 0.9)]); diff --git a/docs/mcp.md b/docs/mcp.md index 46cf846fae..46339e6516 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -9354,7 +9354,7 @@ layers are refused. destination or output intent is refused. Transparency is flattened before writing. - **pdfX3** (PDF/X-3:2002, written as PDF 1.3): colours are tagged with ICC profiles; transparency is flattened. - **pdfX4** (PDF/X-4:2010, PDF 1.6 at most): transparency and layers are kept, colours are tagged, and the XMP metadata - names the standard. + names the standard and has an `xmp:MetadataDate` equal to its `xmp:ModifyDate`. Flattening uses `flattenerPreset` (default High Resolution, see PDF 1.3 above) on a copy (the document is untouched; a warning says so), and images with see-through pixels count as transparency. The written file is checked against From 586db4da062164ace8c919322b825481f07a6394 Mon Sep 17 00:00:00 2001 From: Hamza Date: Tue, 17 Nov 2026 13:41:14 +0500 Subject: [PATCH 10/13] Scale Text Attributes: an area's frame and a path type's path keep their size Baking an object's scale into the character attributes removed that scale from the type's transform, but the area frame (and a path type's path), which is drawn through that transform too, kept its unscaled size. A 120 x 80 frame scaled 200% shrank back to 120 x 80 on the page, so the 24 pt type broke into two lines and the rest became overset. The frame and the path now take the scale the transform loses, so they, the line breaks and every glyph stay where they were. Fixes #8297 --- crates/doc/src/text/object.rs | 8 +++ crates/engine/src/tests/typescale.rs | 93 ++++++++++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/crates/doc/src/text/object.rs b/crates/doc/src/text/object.rs index 5bd31f7699..5ad13d385c 100644 --- a/crates/doc/src/text/object.rs +++ b/crates/doc/src/text/object.rs @@ -78,6 +78,14 @@ impl TextObject { // Character strokes are drawn in text space: widen them by the vertical scale we remove. self.scale_char_strokes(1.0 / sy); self.xf *= Affine::scale_non_uniform(1.0 / sx, 1.0 / sy); + // An area's frame and a path type's path are drawn through `xf` too: give them the scale + // `xf` loses, so the frame (and so the line breaks) and the path stay where they were. + let grow = Affine::scale_non_uniform(sx, sy); + match &mut self.kind { + TextKind::Area { frame } => frame.transform(grow), + TextKind::OnPath { path, .. } => path.transform(grow), + TextKind::Point => {} + } self.cached_bounds = None; self.cached_baselines.clear(); self.cached_ink = None; diff --git a/crates/engine/src/tests/typescale.rs b/crates/engine/src/tests/typescale.rs index f96193a6c4..80c917aff1 100644 --- a/crates/engine/src/tests/typescale.rs +++ b/crates/engine/src/tests/typescale.rs @@ -369,3 +369,96 @@ fn scale_text_attributes_keeps_tracked_type_where_it_was() { assert!((*a - *b).hypot() < 1e-6, "{before:?} {after:?}"); } } + +/// What Scale Text Attributes must leave as it was: the document-space bounds of an area's frame +/// or a path type's path, each line's text, whether the text overflows, and where each glyph +/// starts on the page. +struct Placed { + outline: Option, + lines: Vec<(usize, usize)>, + overflow: bool, + pens: Vec, +} + +fn placed(s: &Session, id: NodeId) -> Placed { + let t = text(s, id); + let lay = vectorcraft_text::layout(vectorcraft_text::FontDb::global(), &t); + let outline = match &t.kind { + vectorcraft_doc::TextKind::Area { frame } => Some(frame), + vectorcraft_doc::TextKind::OnPath { path, .. } => Some(path), + vectorcraft_doc::TextKind::Point => None, + }; + Placed { + outline: outline.and_then(|p| p.transformed(t.xf).bounds()), + lines: lay.lines.iter().map(|l| (l.start, l.end)).collect(), + overflow: lay.overflow, + pens: lay.glyphs.iter().map(|g| t.xf * (g.xf * Point::ZERO)).collect(), + } +} + +fn same_place(before: &Placed, after: &Placed) { + let (Some(b), Some(a)) = (before.outline, after.outline) else { panic!("no frame or path: {:?} {:?}", before.outline, after.outline) }; + for (x, y) in [(b.x0, a.x0), (b.y0, a.y0), (b.x1, a.x1), (b.y1, a.y1)] { + assert!((x - y).abs() < 1e-6, "frame {b:?} became {a:?}"); + } + assert_eq!(after.lines, before.lines, "line breaks"); + assert_eq!(after.overflow, before.overflow, "overflow"); + assert_eq!(before.pens.len(), after.pens.len()); + for (b, a) in before.pens.iter().zip(&after.pens) { + assert!((*a - *b).hypot() < 1e-6, "{:?} {:?}", before.pens, after.pens); + } +} + +/// #8297: Scale Text Attributes on scaled area type keeps the frame the scale gave it, so the +/// lines break where they did and no text becomes overset. It used to leave the frame at its +/// unscaled size, which then held two lines of the larger type and hid the rest. +#[test] +fn scale_text_attributes_keeps_an_area_frame_and_its_lines() { + for (sx, sy, size) in [(200, 200, 24.0), (200, 100, 12.0), (50, 50, 6.0)] { + let mut s = session(); + let id = NodeId( + s.execute( + "text.create", + &json!({"x": 40, "y": 60, "size": 12, "area": {"width": 120, "height": 80}, "text": "Bright river stones mark a gentle path past old trees."}), + ) + .unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute("object.scale", &json!({"sx": sx, "sy": sy, "origin": [0, 0]})).unwrap(); + let before = placed(&s, id); + assert!(before.lines.len() >= 3 && !before.overflow, "{sx}x{sy}: {:?}", before.lines); + s.execute("type.scaleTextAttributes", &json!({})).unwrap(); + near(text(&s, id).runs[0].style.size, size); + same_place(&before, &placed(&s, id)); + if (sx, sy) == (200, 200) { + let f = before.outline.unwrap(); + assert_eq!((f.x0.round(), f.y0.round(), f.x1.round(), f.y1.round()), (80.0, 120.0, 320.0, 280.0)); + } + s.execute("edit.undo", &json!({})).unwrap(); + near(text(&s, id).runs[0].style.size, 12.0); + same_place(&before, &placed(&s, id)); + s.execute("edit.redo", &json!({})).unwrap(); + same_place(&before, &placed(&s, id)); + } +} + +/// Type on a path keeps its path: it used to shrink with the scale removed, so the type ran past +/// its end. +#[test] +fn scale_text_attributes_keeps_a_path_types_path() { + let mut s = session(); + let pid = s.execute("path.create", &json!({ "d": "M100 300 L300 300" })).unwrap()["id"].as_u64().unwrap(); + let id = NodeId( + s.execute("text.createInPath", &json!({"path": pid, "mode": "onPath", "text": "Along the way", "size": 12, "at": [100, 300]})).unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + s.execute("object.scale", &json!({"sx": 200, "origin": [0, 0]})).unwrap(); + let before = placed(&s, id); + assert!(!before.overflow); + s.execute("type.scaleTextAttributes", &json!({})).unwrap(); + near(text(&s, id).runs[0].style.size, 24.0); + same_place(&before, &placed(&s, id)); +} From 219ad4fbf037ce608b800b3b69e28910cc68a63a Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Tue, 17 Nov 2026 01:12:46 -0800 Subject: [PATCH 11/13] Color Guide: renaming, deleting or unspotting the base spot color keeps the link right A Swatch Options rename of the spot color base keeps it the base, also as a command.batch step, and so do an Undo and a Redo of the rename. Deleting the swatch or its color group, merging it into another, making it a process color or closing its document ends the link, so a later spot color of the same name does not become the base until it is chosen again. The base keeps the color it showed. A batch's Activate Document, New, Open, Close and Move Document steps are followed, so steps in another document leave the link alone. When the swatch goes in a way the panel does not follow, the link waits for an Undo or Redo, and the next other command ends it. --- crates/ui-egui/src/app/commands.rs | 9 +- crates/ui-egui/src/panels/color_guide.rs | 648 ++++++++++++++++++++++- docs/target-app-parity.md | 2 +- 3 files changed, 640 insertions(+), 19 deletions(-) diff --git a/crates/ui-egui/src/app/commands.rs b/crates/ui-egui/src/app/commands.rs index d663419acb..6c31668533 100644 --- a/crates/ui-egui/src/app/commands.rs +++ b/crates/ui-egui/src/app/commands.rs @@ -236,6 +236,7 @@ impl VectorcraftApp { let ime_target = crate::ime::target(&mut self.session, ime_view); let ime_before = crate::ime::stamp(&mut self.session, ime_view); let cursor_settings = (self.session.caps_lock, self.session.prefs.use_precise_cursors); + let spot_base = panels::color_guide::before_command(self); let r = self.session.execute(id, ¶ms).map_err(|e| e.to_string()); let r = panels::actions::after_recorded_command(self, r); if r.is_ok() && cursor_settings != (self.session.caps_lock, self.session.prefs.use_precise_cursors) { @@ -267,12 +268,8 @@ impl VectorcraftApp { { self.ui.status = w.to_string(); } - // A renamed spot color swatch stays the Color Guide's base. - if id == "swatch.edit" - && let (Some(from), Some(to)) = (params["name"].as_str(), v["name"].as_str()) - { - crate::panels::color_guide::swatch_renamed(self, from, to); - } + // A renamed spot color swatch stays the Color Guide's base; a deleted one ends the link. + panels::color_guide::after_command(self, id, ¶ms, v, spot_base); if id == "file.new" { self.ui.status.clear(); // New Document's Pixel preview mode (Overprint Preview is the engine's). diff --git a/crates/ui-egui/src/panels/color_guide.rs b/crates/ui-egui/src/panels/color_guide.rs index b53bb36a08..28b0726920 100644 --- a/crates/ui-egui/src/panels/color_guide.rs +++ b/crates/ui-egui/src/panels/color_guide.rs @@ -41,6 +41,17 @@ pub struct SpotBase { pub swatch: String, /// The base's tint of it, 0..1. pub tint: f32, + /// The names it had before renames, oldest first (at most as many as the History panel keeps + /// states), for an Undo or Redo that gives it one of them back. + pub earlier: Vec, + /// Its swatch went without a command the panel followed: the link waits for an Undo or Redo + /// ([`check_spot`]). + pub resting: bool, +} + +/// Whether `name` is a spot color of `doc`. +fn is_spot(doc: &vectorcraft_doc::Document, name: &str) -> bool { + doc.swatch(name).is_some_and(|w| w.spot) && doc.global_color(name).is_some() } /// The spot color the base is a tint of, while its swatch is still a spot color of the active @@ -48,8 +59,7 @@ pub struct SpotBase { fn live_spot(app: &VectorcraftApp) -> Option<&SpotBase> { let s = app.ui.color_guide_spot.as_ref()?; let st = app.session.active()?; - let spot = st.doc.swatch(&s.swatch).is_some_and(|w| w.spot) && st.doc.global_color(&s.swatch).is_some(); - (st.uid == s.doc && spot).then_some(s) + (st.uid == s.doc && !s.resting && is_spot(&st.doc, &s.swatch)).then_some(s) } /// The color of tint `tint` (0..1) of global swatch `name` in the active document. @@ -79,20 +89,324 @@ pub(crate) fn choose_linked_base(app: &mut VectorcraftApp, c: Color, link: Optio app.ui.color_guide_spot = link.and_then(|(swatch, tint)| { let st = app.session.active()?; st.doc.swatch(&swatch).filter(|w| w.spot)?; - Some(SpotBase { doc: st.uid, swatch, tint: tint.clamp(0.0, 1.0) }) + Some(SpotBase { doc: st.uid, swatch, tint: tint.clamp(0.0, 1.0), earlier: Vec::new(), resting: false }) }); } -/// `swatch.edit` renamed swatch `from` of the active document to `to`: a spot color base linked to -/// it links to `to`. -pub(crate) fn swatch_renamed(app: &mut VectorcraftApp, from: &str, to: &str) { - let uid = app.session.active().map(|st| st.uid); - if let Some(s) = app.ui.color_guide_spot.as_mut() - && Some(s.doc) == uid - && s.swatch == from - { - s.swatch = to.to_string(); +/// The spot color base before a command runs ([`before_command`]). +pub(crate) struct LinkBefore { + /// Its document is the active one. + active: bool, + /// The color group that holds its swatch. + group: Option, + /// The color the guide shows as the base. + color: Option, + /// The open documents' `uid`s in order, while there is a spot color base. + docs: Vec, + /// The active document's index. + active_index: Option, +} + +/// The spot color base before a command runs, for [`after_command`]. +pub(crate) fn before_command(app: &VectorcraftApp) -> LinkBefore { + let s = app.ui.color_guide_spot.as_ref(); + let active = app.session.active().is_some_and(|st| s.is_some_and(|s| s.doc == st.uid)); + // Its document, active or not. + let st = s.and_then(|s| app.session.documents().iter().find(|d| d.uid == s.doc)); + let group = + st.zip(s).and_then(|(st, s)| st.doc.swatch_groups.iter().find(|g| g.swatches.iter().any(|w| w.name == s.swatch)).map(|g| g.name.clone())); + let docs = if s.is_some() { app.session.documents().iter().map(|d| d.uid).collect() } else { Vec::new() }; + // The color it shows: its swatch's tint in its document, while that is a spot color there. + let shown = st + .zip(s) + .filter(|(st, s)| st.doc.swatch(&s.swatch).is_some_and(|w| w.spot)) + .and_then(|(st, s)| st.doc.tint_paint(&s.swatch, s.tint)?.color()); + let color = s.map(|_| shown.unwrap_or_else(|| base_color(app))); + LinkBefore { active, group, color, docs, active_index: app.session.active_index() } +} + +/// Where the steps of a `command.batch` run, as far as the steps before each one show: new +/// documents open after the others and become the active one, and Close and Move Document shift +/// the documents after them. +struct BatchDocs { + /// The tab index of the base's document, when known. + base: Option, + /// The base's document was closed. + closed: bool, + /// The tab index of the active document, when known. + active: Option, + /// The number of open documents, when known. + len: Option, +} + +impl BatchDocs { + /// Whether the next step runs in the base's document, when that is known. + fn in_base(&self) -> Option { + if self.closed { + return Some(false); + } + Some(self.active? == self.base?) } + + /// Follow step `id`, which ran with params `p` and replied `r`. + fn step(&mut self, id: &str, p: &Value, r: &Value) { + let index = |key: &str| p[key].as_u64().and_then(|i| usize::try_from(i).ok()); + // The tab index a step that opens a document replies with: a new one after the others, or + // one already open made active. + let opened = r["index"].as_u64().and_then(|i| usize::try_from(i).ok()); + match id { + "document.activate" => self.active = index("index"), + "file.new" | "file.newFromTemplate" | "edit.newDocumentFromState" => { + self.len = self.len.map(|n| n + 1); + self.active = opened.or(self.len.map(|n| n - 1)); + } + "file.close" | "document.close" => { + let i = index("index").or(self.active); + let len = self.len.map(|n| n.saturating_sub(1)); + match (i, self.base) { + (Some(i), Some(b)) if i == b => (self.closed, self.base) = (true, None), + (Some(i), Some(b)) if i < b => self.base = Some(b - 1), + (Some(_), Some(_)) => {} + _ => self.base = None, + } + // Closing another document keeps the active one; closing the active one makes the + // one at its index active (the last one when it was last). + self.active = match (i, self.active) { + (Some(i), Some(a)) if i != a => Some(if i < a { a - 1 } else { a }), + (Some(i), Some(_)) => len.and_then(|n| n.checked_sub(1)).map(|last| i.min(last)), + _ => None, + }; + self.len = len; + } + "file.closeAll" => self.closed = true, + "document.move" => { + let moved = |x: usize, from: usize, to: usize| { + if x == from { + return to; + } + let x = if from < x { x - 1 } else { x }; + if to <= x { x + 1 } else { x } + }; + match (index("from").or(self.active), index("to"), self.len) { + (Some(from), Some(to), Some(n)) if n > 0 => { + let to = to.min(n - 1); + self.base = self.base.map(|b| moved(b, from, to)); + self.active = self.active.map(|a| moved(a, from, to)); + } + _ => (self.base, self.active) = (None, None), + } + } + _ if id.starts_with("file.open") + || id.starts_with("recovery.") + || matches!(id, "document.open" | "document.compare" | "stroke.arrowheads.edit") => + { + match (opened, self.len) { + (Some(i), Some(n)) if i <= n => (self.active, self.len) = (Some(i), Some(n.max(i + 1))), + _ => (self.active, self.len) = (None, None), + } + } + _ => {} + } + } +} + +/// The name the spot color base's swatch `name` of document `base` has after a `command.batch` +/// ran `steps` and replied `results`, or `None` when a step may have +/// removed it or made it a process color ([`follow_step`]). Steps in the base's document are +/// followed and steps in another document are skipped. A step in a document that is not known +/// keeps the name, and a rename there adds a second name to choose from once the batch is done: +/// the one that is a spot color of the base's document. Scripts and plug-ins may do anything, so +/// they end the link. +fn follow_batch(app: &VectorcraftApp, base: u64, name: String, steps: &[Value], results: &[Value], before: &LinkBefore) -> Option { + let mut group = before.group.clone(); + let at = before.docs.iter().position(|&u| u == base); + let mut docs = BatchDocs { base: at, closed: at.is_none(), active: before.active_index, len: Some(before.docs.len()) }; + let mut names = vec![name]; + for (i, step) in steps.iter().enumerate() { + let sid = step["command"].as_str().unwrap_or_default(); + let (p, r) = (&step["params"], results.get(i).unwrap_or(&Value::Null)); + if sid.starts_with("script.") || sid.starts_with("plugin.") { + return None; + } + match docs.in_base() { + Some(true) => { + let one = names.len() == 1; + let mut next = Vec::with_capacity(names.len()); + for n in names { + let mut scratch = group.clone(); + next.push(follow_step(sid, p, r, n, if one { &mut group } else { &mut scratch })?); + } + names = next; + } + Some(false) => {} + None => { + // The step may have run elsewhere, so the name stays a candidate whatever the step + // did; a rename adds the new name. + let mut next = Vec::with_capacity(names.len() + 1); + for n in names { + if let Some(m) = follow_step(sid, p, r, n.clone(), &mut group.clone()) + && m != n + { + next.push(m); + } + next.push(n); + } + next.sort(); + next.dedup(); + names = next; + } + } + docs.step(sid, p, r); + } + if names.len() == 1 { + return names.pop(); + } + // The one name that is a spot color of the base's document. + let st = app.session.documents().iter().find(|d| d.uid == base)?; + let mut spots = names.into_iter().filter(|n| is_spot(&st.doc, n)); + let first = spots.next()?; + spots.next().is_none().then_some(first) +} + +/// Command `id` ran with `params` and replied `reply`: a spot color base linked to a swatch that +/// Swatch Options renamed links to the new name, and one whose swatch a command deleted or made a +/// process color is no longer linked to it, so a later spot color of the same name does not +/// become the base; the base keeps the color it showed. A `command.batch`'s steps are followed in +/// order ([`follow_batch`]). +pub(crate) fn after_command(app: &mut VectorcraftApp, id: &str, params: &Value, reply: &Value, before: LinkBefore) { + let Some(s) = app.ui.color_guide_spot.as_ref() else { return }; + let (base, n) = (s.doc, s.swatch.clone()); + let name = if id == "command.batch" { + let steps = params["commands"].as_array().map(Vec::as_slice).unwrap_or_default(); + let results = reply["results"].as_array().map(Vec::as_slice).unwrap_or_default(); + follow_batch(app, base, n, steps, results, &before) + } else if before.active { + follow_step(id, params, reply, n, &mut before.group.clone()) + } else { + Some(n) + }; + let keep = usize::try_from(app.session.prefs.history_states).unwrap_or(usize::MAX).max(1); + let Some(s) = app.ui.color_guide_spot.as_mut() else { return }; + match name { + Some(n) => { + if n != s.swatch { + let old = std::mem::replace(&mut s.swatch, n); + s.earlier.retain(|e| *e != old && *e != s.swatch); + s.earlier.push(old); + if s.earlier.len() > keep { + s.earlier.drain(..s.earlier.len() - keep); + } + } + } + None => app.ui.color_guide_spot = None, + } + let undo = |id: &str| matches!(id, "edit.undo" | "edit.redo"); + let undone = undo(id) + || (id == "command.batch" + && params["commands"].as_array().is_some_and(|a| a.iter().any(|st| undo(st["command"].as_str().unwrap_or_default())))); + check_spot(app, if undone { Ran::UndoRedo } else { Ran::Command }); + if app.ui.color_guide_spot.is_none() + && let Some(c) = before.color + { + app.ui.color_guide_base = Some(c); + } +} + +/// The name swatch `name` (in color group `group`) has after command `id` ran with `params` and +/// replied `reply` in its document, or `None` when the command may have removed it or made it a +/// process color: Swatch Options making it a process color, Delete Swatch naming it or its group, +/// Merge Swatches merging it into another and Edit Color Group leaving it out of its group. +/// `group` follows the step: New Color Group, Move Swatch, Edit Color Group and Ungroup Color +/// Group. +fn follow_step(id: &str, p: &Value, reply: &Value, name: String, group: &mut Option) -> Option { + let ours = |v: &Value| v == name.as_str(); + let in_group = |key: &str| group.as_deref().is_some_and(|g| p[key] == g); + let named = |key: &str| p[key].as_array().is_some_and(|a| a.iter().any(|n| ours(n) || group.as_deref().is_some_and(|g| n == g))); + let members = |key: &str| reply[key].as_array().is_some_and(|a| a.iter().any(ours)); + let removed = match id { + "swatch.edit" => ours(&p["name"]) && p["spot"] == false, + "swatch.delete" => ours(&p["name"]) || in_group("name") || named("names"), + "swatch.merge" => named("names") && !ours(&p["names"][0]), + "swatch.editGroup" => in_group("group") && !members("swatches"), + _ => false, + }; + if removed { + return None; + } + // The color group that holds it after the step. + let moved = match id { + "swatch.newGroup" | "swatch.editGroup" if members("swatches") => Some(reply["name"].as_str().map(str::to_string)), + "swatch.ungroup" if in_group("name") => Some(None), + "swatch.move" if ours(&p["name"]) || p["names"].as_array().is_some_and(|a| a.iter().any(ours)) => { + Some(p["group"].as_str().map(str::to_string)) + } + _ => None, + }; + if let Some(m) = moved { + *group = m; + } + // A rename by Swatch Options, or of the swatch Merge Swatches keeps. + let renamed = match id { + "swatch.edit" if p["name"] == name.as_str() => reply["name"].as_str(), + "swatch.merge" if p["names"][0] == name.as_str() => reply["name"].as_str(), + _ => None, + }; + Some(renamed.map_or(name, str::to_string)) +} + +/// What ran before the spot color base's link is checked ([`check_spot`]). +#[derive(Clone, Copy, PartialEq)] +pub(crate) enum Ran { + /// Nothing the panel followed: a frame of the panel (a script's commands, for example). + Frame, + /// A command other than Undo and Redo. + Command, + /// Undo or Redo, or a batch with one of them. + UndoRedo, +} + +/// Check the spot color base's link after `ran`. A closed document ends it. When its swatch is no +/// longer a spot color of its document (deleted, renamed or made a process color by something the +/// panel did not follow), after an Undo or Redo a name it had before that is one again takes its +/// place (an Undo or Redo of a rename); otherwise the link rests until an Undo or Redo makes it a spot color again, and +/// the next other command ends it. The base keeps the color it last showed. +pub(crate) fn check_spot(app: &mut VectorcraftApp, ran: Ran) { + let Some(s) = app.ui.color_guide_spot.as_mut() else { return }; + if !app.session.documents().iter().any(|d| d.uid == s.doc) { + app.ui.color_guide_spot = None; + return; + } + let Some(st) = app.session.active().filter(|st| st.uid == s.doc) else { return }; + if s.resting && ran != Ran::UndoRedo { + if ran == Ran::Command { + app.ui.color_guide_spot = None; + } + return; + } + if ran == Ran::UndoRedo && !is_spot(&st.doc, &s.swatch) { + // An Undo or Redo of a rename gave it a name it had before. + if let Some(i) = s.earlier.iter().rposition(|n| is_spot(&st.doc, n)) { + let name = s.earlier.remove(i); + let gone = std::mem::replace(&mut s.swatch, name); + s.earlier.push(gone); + } + } + if is_spot(&st.doc, &s.swatch) { + s.resting = false; + // Kept for when the link ends where the color can no longer be read (a closed document). + if let Some(c) = st.doc.tint_paint(&s.swatch, s.tint).and_then(|p| p.color()) { + app.ui.color_guide_base = Some(c); + } + return; + } + if ran != Ran::Command { + s.resting = true; + return; + } + if let Some(c) = st.doc.tint_paint(&s.swatch, s.tint).and_then(|p| p.color()) { + app.ui.color_guide_base = Some(c); + } + app.ui.color_guide_spot = None; } /// The global swatch and tint (0..1) a solid paint links to. @@ -295,6 +609,7 @@ fn save_group(app: &mut VectorcraftApp, ctx: &egui::Context) { pub fn show(app: &mut VectorcraftApp, ui: &mut Ui) { let t = crate::theme::Tokens::get(ui.ctx()); let ctx = ui.ctx().clone(); + check_spot(app, Ran::Frame); // The current color becomes the base when the panel first shows; selecting artwork later // leaves it as it is. if app.ui.color_guide_base.is_none() { @@ -938,6 +1253,315 @@ mod tests { app.run("swatch.edit", json!({"name": "Deep Ink", "color": "#cc0000"})).unwrap(); let red = app.session.active().unwrap().doc.global_color("Deep Ink").unwrap(); assert_eq!(base_color(&app), red, "the base follows the renamed spot color"); + // Renames in a batch, in step order. + let steps = json!([ + {"command": "swatch.edit", "params": {"name": "Deep Ink", "newName": "Ink A"}}, + {"command": "swatch.edit", "params": {"name": "Ink A", "newName": "Ink B"}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + let Paint::Solid { swatch, .. } = cell_paint(&app, &guide(&app, &ctx), 0, c + 1).unwrap() else { panic!("a solid") }; + assert_eq!(swatch.as_deref(), Some("Ink B"), "renamed in a batch"); + } + + /// Deleting the spot color, or making it a process color, ends the base's link: a new spot color + /// of the same name, or the swatch made a spot color again, gives process colors until it is + /// chosen again. + #[test] + fn a_deleted_spot_color_ends_the_link() { + let mut app = spot_app(1.0); + let ctx = egui::Context::default(); + frame(&mut app, &ctx); + let c = guide(&app, &ctx).centre(); + let linked = |app: &VectorcraftApp, ctx: &egui::Context| { + matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. }) + }; + assert!(linked(&app, &ctx)); + app.run("swatch.delete", json!({"name": "Ink"})).unwrap(); + app.run("swatch.new", json!({"name": "Ink", "color": "#00cc66", "spot": true})).unwrap(); + assert!(!linked(&app, &ctx), "a new spot color of the same name"); + assert!(app.ui.color_guide_spot.is_none()); + let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap(); + choose_linked_base(&mut app, ink, Some(("Ink".to_string(), 1.0))); + assert!(linked(&app, &ctx)); + app.run("swatch.edit", json!({"name": "Ink", "spot": false, "global": false})).unwrap(); + app.run("swatch.edit", json!({"name": "Ink", "spot": true})).unwrap(); + assert!(!linked(&app, &ctx), "a spot color again"); + // The same in a batch: a step that deletes the swatch, or one that makes it a process color. + let relink = |app: &mut VectorcraftApp| { + let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap(); + choose_linked_base(app, ink, Some(("Ink".to_string(), 1.0))); + }; + for steps in [ + json!([ + {"command": "swatch.edit", "params": {"name": "Ink", "newName": "Ink 2"}}, + {"command": "swatch.delete", "params": {"name": "Ink 2"}}, + {"command": "swatch.new", "params": {"name": "Ink 2", "color": "#cc6600", "spot": true}}, + {"command": "swatch.edit", "params": {"name": "Ink 2", "newName": "Ink"}}, + ]), + json!([ + {"command": "swatch.edit", "params": {"name": "Ink", "spot": false, "global": false}}, + {"command": "swatch.edit", "params": {"name": "Ink", "spot": true}}, + ]), + ] { + relink(&mut app); + assert!(linked(&app, &ctx)); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(!linked(&app, &ctx), "{steps}"); + } + // A batch that edits the spot color's values and deletes another swatch keeps the link. + relink(&mut app); + app.run("swatch.new", json!({"name": "Spare", "color": "#999999"})).unwrap(); + let steps = json!([ + {"command": "swatch.edit", "params": {"name": "Ink", "color": "#cc0000"}}, + {"command": "swatch.delete", "params": {"name": "Spare"}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "an unrelated batch"); + // `global: false` leaves a spot color global, so the link stays. + let steps = json!([{"command": "swatch.edit", "params": {"name": "Ink", "global": false}}, {"command": "swatch.sortByName"}]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "global: false on a spot color"); + // Closing its document ends the link, and the base keeps the color it showed. + app.run("swatch.edit", json!({"name": "Ink", "color": "#00aa00"})).unwrap(); + let shown = base_color(&app); + // Closed the way the tab's close button closes it, outside `app.run`. + app.session.execute("file.new", &json!({})).unwrap(); + app.session.execute("file.close", &json!({"index": 0})).unwrap(); + frame(&mut app, &ctx); + assert_eq!(app.session.documents().len(), 1); + assert!(app.ui.color_guide_spot.is_none(), "its document closed"); + assert_eq!(base_color(&app), shown, "the color it showed before the close"); + } + + /// An Undo or a Redo of a rename keeps the spot color base's link under the name the swatch has + /// again, also after more renames than a short list would hold and after a rename the panel did + /// not follow (a script's); another command after such a rename ends the link. + #[test] + fn an_undone_rename_keeps_the_link() { + let mut app = spot_app(1.0); + let ctx = egui::Context::default(); + frame(&mut app, &ctx); + let c = guide(&app, &ctx).centre(); + let linked = |app: &VectorcraftApp, ctx: &egui::Context| { + matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. }) + }; + let spot_name = |app: &VectorcraftApp| app.ui.color_guide_spot.as_ref().map(|s| s.swatch.clone()); + app.run("swatch.edit", json!({"name": "Ink", "newName": "Ink U"})).unwrap(); + app.run("edit.undo", json!({})).unwrap(); + assert!(linked(&app, &ctx), "a rename undone"); + assert_eq!(spot_name(&app).as_deref(), Some("Ink")); + app.run("edit.redo", json!({})).unwrap(); + assert!(linked(&app, &ctx), "a rename redone"); + assert_eq!(spot_name(&app).as_deref(), Some("Ink U")); + app.run("edit.undo", json!({})).unwrap(); + // Forty renames undone one by one. + for i in 0..40 { + let from = if i == 0 { "Ink".to_string() } else { format!("Ink {i}") }; + app.run("swatch.edit", json!({"name": from, "newName": format!("Ink {}", i + 1)})).unwrap(); + } + for _ in 0..40 { + app.run("edit.undo", json!({})).unwrap(); + } + assert_eq!(spot_name(&app).as_deref(), Some("Ink"), "forty renames undone"); + assert!(linked(&app, &ctx)); + // A rename the panel did not follow: the link rests, and the Undo brings it back. + app.session.execute("swatch.edit", &json!({"name": "Ink", "newName": "Ink S"})).unwrap(); + frame(&mut app, &ctx); + assert!(!linked(&app, &ctx), "resting"); + app.run("edit.undo", json!({})).unwrap(); + assert!(linked(&app, &ctx), "an unfollowed rename undone"); + assert_eq!(spot_name(&app).as_deref(), Some("Ink")); + // Another command while it rests ends it. + app.session.execute("swatch.edit", &json!({"name": "Ink", "newName": "Ink S"})).unwrap(); + frame(&mut app, &ctx); + app.run("swatch.new", json!({"name": "Spare", "color": "#999999"})).unwrap(); + assert!(app.ui.color_guide_spot.is_none(), "another command while it rests"); + // Outside an Undo or Redo, a new spot color with an earlier name does not take its place. + app.run("swatch.edit", json!({"name": "Ink S", "newName": "Ink"})).unwrap(); + let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap(); + choose_linked_base(&mut app, ink, Some(("Ink".to_string(), 1.0))); + app.run("swatch.edit", json!({"name": "Ink", "newName": "Ink U"})).unwrap(); + app.run("swatch.new", json!({"name": "Ink", "color": "#00cc66", "spot": true})).unwrap(); + app.session.execute("swatch.edit", &json!({"name": "Ink U", "newName": "Ink V"})).unwrap(); + frame(&mut app, &ctx); + assert!(!linked(&app, &ctx), "a new spot color with an earlier name"); + assert_eq!(spot_name(&app).as_deref(), Some("Ink U")); + } + + /// A `command.batch` that switches, opens, closes or moves documents follows the spot color + /// base's swatch in its own document and leaves the link alone for steps in the others. + #[test] + fn a_batch_follows_the_spot_color_across_documents() { + let mut app = spot_app(1.0); + let ctx = egui::Context::default(); + frame(&mut app, &ctx); + let c = guide(&app, &ctx).centre(); + let linked = |app: &VectorcraftApp, ctx: &egui::Context| { + matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. }) + }; + let relink = |app: &mut VectorcraftApp| { + let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap(); + choose_linked_base(app, ink, Some(("Ink".to_string(), 1.0))); + }; + assert!(linked(&app, &ctx)); + // Undo, Activate Document and New in a batch keep the link while the swatch is a spot color, + // and the steps in the base's document are still followed. + app.run("swatch.new", json!({"name": "Spare 2", "color": "#777777"})).unwrap(); + let steps = json!([ + {"command": "edit.undo"}, + {"command": "document.activate", "params": {"index": 0}}, + {"command": "swatch.sortByName"}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "an undo, an activate and a sort"); + let steps = json!([ + {"command": "file.new"}, + {"command": "swatch.new", "params": {"name": "Other", "color": "#123456", "spot": true}}, + {"command": "swatch.delete", "params": {"name": "Other"}}, + {"command": "document.activate", "params": {"index": 0}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "steps in a new document"); + let spot_name = |app: &VectorcraftApp| app.ui.color_guide_spot.as_ref().map(|s| s.swatch.clone()); + let steps = json!([ + {"command": "file.new"}, + {"command": "document.activate", "params": {"index": 0}}, + {"command": "swatch.edit", "params": {"name": "Ink", "newName": "Ink C"}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "renamed after a new document"); + assert_eq!(spot_name(&app).as_deref(), Some("Ink C")); + // Moves and closes shift the tabs: [base, 1, 2] becomes [1, 2, base], then [2, base], then + // [base, 2]; the steps in tab 2 leave the link alone. + let steps = json!([ + {"command": "document.move", "params": {"from": 0, "to": 2}}, + {"command": "document.activate", "params": {"index": 2}}, + {"command": "swatch.edit", "params": {"name": "Ink C", "newName": "Ink M"}}, + {"command": "file.close", "params": {"index": 0}}, + {"command": "document.activate", "params": {"index": 0}}, + {"command": "swatch.new", "params": {"name": "Ink M", "color": "#123456", "spot": true}}, + {"command": "swatch.delete", "params": {"name": "Ink M"}}, + {"command": "document.activate", "params": {"index": 1}}, + {"command": "document.move", "params": {"from": 1, "to": 0}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert_eq!(app.session.active_index(), Some(0)); + assert!(linked(&app, &ctx), "moved and closed tabs"); + assert_eq!(spot_name(&app).as_deref(), Some("Ink M")); + app.run("swatch.edit", json!({"name": "Ink M", "newName": "Ink"})).unwrap(); + assert!(linked(&app, &ctx), "renamed back"); + // A batch that starts in another document follows the base's color group too. + app.run("swatch.newGroup", json!({"name": "Held", "swatches": ["Ink"]})).unwrap(); + app.run("document.activate", json!({"index": 1})).unwrap(); + let steps = json!([ + {"command": "document.activate", "params": {"index": 0}}, + {"command": "swatch.delete", "params": {"names": ["Held"]}}, + {"command": "swatch.new", "params": {"name": "Ink", "color": "#cc6600", "spot": true}}, + {"command": "document.activate", "params": {"index": 1}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + app.run("document.activate", json!({"index": 0})).unwrap(); + assert!(!linked(&app, &ctx), "its group deleted in a batch that started elsewhere"); + relink(&mut app); + // Where an opened document's steps run is not known: deleting a swatch of the same name + // there keeps the link. + let svg = r#""#; + let steps = json!([ + {"command": "document.open", "params": {"name": "a.svg", "dataBase64": vectorcraft_format::base64_encode(svg.as_bytes())}}, + {"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}}, + {"command": "swatch.delete", "params": {"name": "Ink"}}, + {"command": "document.activate", "params": {"index": 0}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "deleted in an opened document"); + // The opened document's tab is known from its reply: a rename there is not the base's, + // even when the base's document has spot colors of both names. + app.run("swatch.new", json!({"name": "Ink Alt", "color": "#654321", "spot": true})).unwrap(); + let steps = json!([ + {"command": "document.open", "params": {"name": "b.svg", "dataBase64": vectorcraft_format::base64_encode(svg.as_bytes())}}, + {"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}}, + {"command": "swatch.edit", "params": {"name": "Ink", "newName": "Ink Alt"}}, + {"command": "document.activate", "params": {"index": 0}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "renamed in an opened document"); + assert_eq!(spot_name(&app).as_deref(), Some("Ink")); + // Deleted by a batch that starts in another tab: the base keeps the color it showed. + app.run("swatch.edit", json!({"name": "Ink", "color": "#00aa00"})).unwrap(); + let shown = base_color(&app); + app.run("document.activate", json!({"index": 1})).unwrap(); + let steps = json!([ + {"command": "document.activate", "params": {"index": 0}}, + {"command": "swatch.delete", "params": {"name": "Ink"}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(app.ui.color_guide_spot.is_none()); + assert_eq!(base_color(&app), shown, "the edited color"); + app.run("swatch.new", json!({"name": "Ink", "color": "#cc0000", "spot": true})).unwrap(); + relink(&mut app); + let steps = json!([ + {"command": "document.activate", "params": {"index": 1}}, + {"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}}, + {"command": "swatch.delete", "params": {"name": "Ink"}}, + {"command": "document.activate", "params": {"index": 0}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(linked(&app, &ctx), "a swatch of the same name deleted in another document"); + let steps = json!([ + {"command": "document.activate", "params": {"index": 0}}, + {"command": "swatch.delete", "params": {"name": "Ink"}}, + {"command": "swatch.new", "params": {"name": "Ink", "color": "#123456", "spot": true}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(!linked(&app, &ctx), "deleted after an activate"); + relink(&mut app); + assert!(linked(&app, &ctx)); + } + + /// Deleting the color group that holds the spot color base's swatch ends the link; an Edit + /// Color Group that keeps it does not. + #[test] + fn a_deleted_color_group_ends_the_link() { + let mut app = spot_app(1.0); + let ctx = egui::Context::default(); + frame(&mut app, &ctx); + let c = guide(&app, &ctx).centre(); + let linked = |app: &VectorcraftApp, ctx: &egui::Context| { + matches!(cell_paint(app, &guide(app, ctx), 0, c + 1).unwrap(), Paint::Solid { swatch: Some(_), .. }) + }; + let relink = |app: &mut VectorcraftApp| { + let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap(); + choose_linked_base(app, ink, Some(("Ink".to_string(), 1.0))); + }; + // Deleting the color group that holds it, then a new spot color of the same name. + app.run("swatch.newGroup", json!({"name": "Inks", "swatches": ["Ink"]})).unwrap(); + assert!(linked(&app, &ctx), "moved into a group"); + let steps = json!([ + {"command": "swatch.delete", "params": {"names": ["Inks"]}}, + {"command": "swatch.new", "params": {"name": "Ink", "color": "#cc6600", "spot": true}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(!linked(&app, &ctx), "its group deleted"); + // Moved into a group and the group deleted in the same batch. + relink(&mut app); + let steps = json!([ + {"command": "swatch.newGroup", "params": {"name": "Spots", "swatches": ["Ink"]}}, + {"command": "swatch.delete", "params": {"names": ["Spots"]}}, + {"command": "swatch.new", "params": {"name": "Ink", "color": "#336699", "spot": true}}, + ]); + app.run("command.batch", json!({"commands": steps})).unwrap(); + assert!(!linked(&app, &ctx), "moved into a group that was deleted"); + // Edit Color Group that keeps it, with a new group name, keeps the link. + relink(&mut app); + app.run("swatch.newGroup", json!({"name": "Spots", "swatches": ["Ink"]})).unwrap(); + let ink = app.session.active().unwrap().doc.global_color("Ink").unwrap(); + app.run("swatch.editGroup", json!({"group": "Spots", "colors": [ink.to_hex()], "rename": "Spot Inks"})).unwrap(); + assert!(linked(&app, &ctx), "a group edit that keeps it"); + // A deleted base keeps the color it showed after an edit. + app.run("swatch.edit", json!({"name": "Ink", "color": "#cc0000"})).unwrap(); + let shown = base_color(&app); + app.run("swatch.delete", json!({"name": "Ink"})).unwrap(); + assert_eq!(base_color(&app), shown, "the color it showed"); } /// Save Colors as Swatches and Save Color Group save a spot color base's tints as tint swatches diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index aaa5d62775..33bad9e43d 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1753,7 +1753,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, a still copy of every monitor under a crosshair on Windows, 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. On Windows, the copy is read as sRGB, so the colors of HDR and wide-gamut displays are not converted; Escape, a click of another mouse button or switching to another window cancels (VectorCraft's own rules). The BSDs and other browsers have no sampler yet; the button is gray there. - **Color Guide color groups:** with variation cells selected, the Color Guide's Save Color Group to Swatches button saves those cells as one swatch group, and with none selected it saves the harmony colors, as the [help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf) describes saving several selected variations together (printed page 135). The group takes the cells in grid order (row by row, left to right, each cell once), is named after the harmony rule and is one undo step; these are VectorCraft's own rules. A selection lasts until the base, the Color Guide Options, the variation mode, the harmony rule, the library limit or the colors the grid shows (for example after a new swatch while the guide is limited to the document's swatches) change. - **Color Guide colors dragged to Swatches:** a variation cell dragged from the Color Guide onto the Swatches panel's list becomes a swatch of that color, as the [help page](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf) describes for saving variations as individual swatches (printed page 135). In VectorCraft a harmony strip color drags the same way, a drag carries only the grabbed color (the selected cells stay selected and the selection is not saved), it carries the color the cell shows (snapped to the Limit to Library colors), keeps the color's model and does not paint the selected art; the swatch follows the panel's rules for a dropped color (`swatch.new`, one undo step, a color that is already a swatch is added again under another name, a drop on a color group joins it). These are VectorCraft's own rules. Tests: `a_dragged_guide_color_carries_its_color_and_applies_nothing` and `a_guide_color_dragged_onto_the_swatches_panel_becomes_a_swatch` in `crates/ui-egui/src/panels/color_guide.rs`. - - **Color Guide tints of a spot color:** when the Color Guide's base is a spot color, or a tint of one, chosen in the Swatches panel, with the Color panel's tint slider or with the base chip, the cells right of the center in the base row of Tints/Shades are tints of that spot color: a click paints the art with the tint, a drag carries it, and Save Colors as Swatches and Save Color Group to Swatches make tint swatches ("Ink 60%") linked to the spot color, so they follow an edit of it. The [help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/color-guide-panel-overview.html) says spot colors are kept only on the right side of Tints/Shades and every other variation gives process colors. The tint percentages (the base's tint reduced by the share each cell goes toward white), the shades on the left staying process colors, a Limit to Library giving process colors, and a global process base keeping plain colors are VectorCraft's own rules. `swatch.new {colors}` and `swatch.newGroup {colors}` take `{swatch, tint}` entries. Tests: `a_spot_color_base_gives_tints_of_that_spot_color`, `a_tinted_spot_base_gives_lighter_tints_and_a_lost_link_gives_process_colors`, `a_renamed_spot_color_stays_the_base`, `saved_spot_tints_are_tint_swatches_of_the_spot_color`, `a_dragged_spot_tint_becomes_a_tint_swatch`, `a_clicked_spot_color_swatch_becomes_a_linked_color_guide_base`, `colors_entries_naming_a_spot_color_save_tint_swatches`. + - **Color Guide tints of a spot color:** when the Color Guide's base is a spot color, or a tint of one, chosen in the Swatches panel, with the Color panel's tint slider or with the base chip, the cells right of the center in the base row of Tints/Shades are tints of that spot color: a click paints the art with the tint, a drag carries it, and Save Colors as Swatches and Save Color Group to Swatches make tint swatches ("Ink 60%") linked to the spot color, so they follow an edit of it. The [help page](https://helpx.adobe.com/illustrator/desktop/manage-colors/learn-color-basics/color-guide-panel-overview.html) says spot colors are kept only on the right side of Tints/Shades and every other variation gives process colors. The tint percentages (the base's tint reduced by the share each cell goes toward white), the shades on the left staying process colors, a Limit to Library giving process colors, and a global process base keeping plain colors are VectorCraft's own rules. So are these: renaming the spot color in Swatch Options, also as a `command.batch` step, keeps it the base, and so do an Undo and a Redo of the rename; deleting it (or its color group), making it a process color or closing its document ends the link, so a later spot color of the same name does not become the base until it is chosen, and the base keeps the color it showed. A batch's steps in other documents leave the link alone. `swatch.new {colors}` and `swatch.newGroup {colors}` take `{swatch, tint}` entries. Tests: `a_spot_color_base_gives_tints_of_that_spot_color`, `a_tinted_spot_base_gives_lighter_tints_and_a_lost_link_gives_process_colors`, `a_renamed_spot_color_stays_the_base`, `a_deleted_spot_color_ends_the_link`, `an_undone_rename_keeps_the_link`, `a_batch_follows_the_spot_color_across_documents`, `a_deleted_color_group_ends_the_link`, `saved_spot_tints_are_tint_swatches_of_the_spot_color`, `a_dragged_spot_tint_becomes_a_tint_swatch`, `a_clicked_spot_color_swatch_becomes_a_linked_color_guide_base`, `colors_entries_naming_a_spot_color_save_tint_swatches`. - **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, both ends of a vector drawn on the art and the start of a clicked one snap as other drawn points do (path segments, construction guides and View › Snap to Glyph's guides included) 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`. From 957cd66a823987e9a11896c1cb8722c24a298be2 Mon Sep 17 00:00:00 2001 From: Hamza Date: Tue, 17 Nov 2026 14:17:49 +0500 Subject: [PATCH 12/13] Scale Text Attributes: path type bakes only the uniform part of a scale Type on a path sits at fractions of its path's length. Scaling the path non-uniformly changes where a fraction lands (CodeRabbit's case: M0 0 L100 0 L100 100 under diag(2, 1) moves the start bracket from (200, 0) to (150, 0)). Path type now bakes the vertical scale into the character sizes and scales its path uniformly by it, which keeps every fraction where it was; the horizontal stretch stays in the transform. --- crates/doc/src/text/object.rs | 26 ++++++++++++++++------ crates/engine/src/tests/typescale.rs | 33 ++++++++++++++++++++++++++++ 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/crates/doc/src/text/object.rs b/crates/doc/src/text/object.rs index 5ad13d385c..c556f2f5b0 100644 --- a/crates/doc/src/text/object.rs +++ b/crates/doc/src/text/object.rs @@ -27,7 +27,11 @@ impl TextObject { /// Character attributes as presented by controls (stored runs stay local for layout /// and rich-text clipboard operations). Explicit vertical character scale stays separate. pub fn effective_char_style(&self, style: &CharStyle) -> Option { - let scale = self.style_scale()?; + Self::scaled_char_style(style, self.style_scale()?) + } + + /// `style` with `scale` taken into its attributes ([`Self::effective_char_style`]). + fn scaled_char_style(style: &CharStyle, scale: TextStyleScale) -> Option { let mut style = style.clone(); style.size *= scale.points; style.leading = style.leading.map(|v| v * scale.points); @@ -57,19 +61,27 @@ impl TextObject { /// scale from `xf`, so panels show document-point sizes without a separate transform factor. /// Returns `false` when there is nothing to bake (identity scale or an unrepresentable /// transform). + /// + /// Type on a path bakes only the uniform part of the scale (the vertical one) and keeps any + /// stretch in `xf`: its brackets and glyphs sit at fractions of the path's length, which a + /// non-uniform scale of the path would move, and a uniform one keeps. pub fn scale_text_attributes(&mut self) -> bool { - let Some(scale) = self.style_scale() else { return false }; - if (scale.points - 1.0).abs() <= 1e-12 && (scale.horizontal - 1.0).abs() <= 1e-12 { + let Some(mut scale) = self.style_scale() else { return false }; + let [a, b, c, d, _, _] = self.xf.as_coeffs(); + let (mut sx, sy) = (a.hypot(b), c.hypot(d)); + if sx <= 1e-12 || sy <= 1e-12 { return false; } - let [a, b, c, d, _, _] = self.xf.as_coeffs(); - let (sx, sy) = (a.hypot(b), c.hypot(d)); - if sx <= 1e-12 || sy <= 1e-12 { + if matches!(self.kind, TextKind::OnPath { .. }) { + scale.horizontal = 1.0; + sx = sy; + } + if (scale.points - 1.0).abs() <= 1e-12 && (scale.horizontal - 1.0).abs() <= 1e-12 { return false; } let mut baked = Vec::with_capacity(self.runs.len()); for run in &self.runs { - let Some(eff) = self.effective_char_style(&run.style) else { return false }; + let Some(eff) = Self::scaled_char_style(&run.style, scale) else { return false }; baked.push(eff); } for (run, style) in self.runs.iter_mut().zip(baked) { diff --git a/crates/engine/src/tests/typescale.rs b/crates/engine/src/tests/typescale.rs index 80c917aff1..9aa287f601 100644 --- a/crates/engine/src/tests/typescale.rs +++ b/crates/engine/src/tests/typescale.rs @@ -462,3 +462,36 @@ fn scale_text_attributes_keeps_a_path_types_path() { near(text(&s, id).runs[0].style.size, 24.0); same_place(&before, &placed(&s, id)); } + +/// A non-uniform scale on type on a path: only the uniform part is baked and the stretch stays in +/// the transform, so the brackets, which sit at fractions of the path's length, stay where they +/// were. Baking the stretch into the path would move them: on this path, scaled 3 × 2, the length +/// grows from 200 to 500 and not in proportion, so the same fraction lands elsewhere. +#[test] +fn scale_text_attributes_keeps_path_type_on_a_stretched_path_where_it_was() { + let mut s = session(); + let pid = s.execute("path.create", &json!({ "d": "M0 0 L100 0 L100 100" })).unwrap()["id"].as_u64().unwrap(); + let id = NodeId( + s.execute("text.createInPath", &json!({"path": pid, "mode": "onPath", "text": "Corner", "size": 12, "at": [60, 0]})).unwrap()["id"] + .as_u64() + .unwrap(), + ); + s.execute("select.set", &json!({"ids": [id.0]})).unwrap(); + s.execute("object.scale", &json!({"sx": 300, "sy": 200, "origin": [0, 0]})).unwrap(); + let before = placed(&s, id); + let brackets = |s: &Session| match text(s, id).kind { + vectorcraft_doc::TextKind::OnPath { start, end, .. } => (start, end), + k => panic!("not path type: {k:?}"), + }; + let before_brackets = brackets(&s); + s.execute("type.scaleTextAttributes", &json!({})).unwrap(); + near(text(&s, id).runs[0].style.size, 24.0); + near(text(&s, id).runs[0].style.h_scale, 100.0); + let left = text(&s, id).style_scale().unwrap(); + near(left.points, 1.0); + near(left.horizontal, 1.5); + assert_eq!(brackets(&s), before_brackets); + same_place(&before, &placed(&s, id)); + // Only the stretch is left: there is nothing more to bake. + assert!(s.execute("type.scaleTextAttributes", &json!({})).is_err()); +} From ec2260c369cbe15a73be1909a5dbdf7a5ebaa7fe Mon Sep 17 00:00:00 2001 From: bflatastic Date: Tue, 17 Nov 2026 16:21:07 +0700 Subject: [PATCH 13/13] Tests: the font menu helper waits until the menu's own rect stays put egui places a popup by its size the frame before, so on the frame a late-measured name widens the menu the filter text can stay where it was while the menu's rect already reaches past the window. The helper now waits until both the filter and the menu's rect stay put, which fixes the intermittent failure of a_menu_wider_than_its_field_stays_in_the_window (the menu ending 0.7 pt past the window's edge). --- crates/ui-egui/src/tests/font_menu.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/crates/ui-egui/src/tests/font_menu.rs b/crates/ui-egui/src/tests/font_menu.rs index 3873868af2..52df50fd2c 100644 --- a/crates/ui-egui/src/tests/font_menu.rs +++ b/crates/ui-egui/src/tests/font_menu.rs @@ -1045,17 +1045,20 @@ fn open_menu_with(id: &str, left: f32, width: f32, screen: egui::Vec2, look: Men } // egui places the menu by the size it had the frame before. When a name measured late (a face // added for its script, a font found in the background) widens it on that frame, the menu sits - // where the narrower one fit until the next: draw until it stays put. - let filter_at = |shapes: &[egui::epaint::ClippedShape]| { - shapes.iter().find_map(|s| match &s.shape { + // where the narrower one fit until the next: draw until it stays put. The filter alone can stay + // put on the frame that widens the menu, so the menu's own rect must stay put too. + let placed = |shapes: &[egui::epaint::ClippedShape]| { + let filter = shapes.iter().find_map(|s| match &s.shape { egui::Shape::Text(t) if t.galley.text() == crate::i18n::t("Any Kind") => Some(t.pos), _ => None, - }) + }); + let menu = filter.and_then(|p| ctx.layer_id_at(p)).and_then(|l| ctx.memory(|m| m.area_rect(l.id))); + (filter, menu) }; for _ in 0..100 { - let before = filter_at(&shapes); + let before = placed(&shapes); shapes = frame(vec![]); - if filter_at(&shapes) == before && !crate::font_menu::wait_for_samples(&ctx) { + if placed(&shapes) == before && !crate::font_menu::wait_for_samples(&ctx) { break; } }