diff --git a/crates/engine/tests/import_fuzz.rs b/crates/engine/tests/import_fuzz.rs index 8192049fcb..041e1f6194 100644 --- a/crates/engine/tests/import_fuzz.rs +++ b/crates/engine/tests/import_fuzz.rs @@ -3827,6 +3827,83 @@ fn editing_text() -> String { ) } +/// The range of [`ai_written_meshes_never_panic`]'s cuts and edits: past the end of [`meshes_text`]. +const MESHES_FUZZ_CHARS: usize = 24_000; + +/// The editing data VectorCraft writes for a document with two gradient meshes: 2 × 3 patches whose +/// rows of points are RGB, CMYK and gray, at half opacity and named; a 1 × 1 mesh with a point at +/// 40% opacity; and an instance of a symbol whose art is a 2 × 1 mesh. +fn meshes_text() -> &'static str { + static TEXT: std::sync::OnceLock = std::sync::OnceLock::new(); + TEXT.get_or_init(|| { + use vectorcraft_color::Color; + use vectorcraft_doc::live::{GradientMesh, MeshPoint, grid_points, smooth_handles}; + use vectorcraft_doc::{Node, NodeKind}; + use vectorcraft_geom::Rect; + let mesh = |r: Rect, rows: u32, cols: u32, color: &dyn Fn(usize) -> Color| { + let pts = grid_points(r, rows, cols); + let handles = smooth_handles(rows, cols, &pts); + let width = cols as usize + 1; + let points = pts + .iter() + .zip(handles) + .enumerate() + .map(|(i, (p, h))| MeshPoint { p: *p, color: color(i / width), opacity: 1.0, handles: h }) + .collect(); + GradientMesh { rows, cols, points } + }; + let mut doc = Document::new(300.0, 200.0); + let layer = doc.layers[0].id; + let sheet = mesh(Rect::new(20.0, 20.0, 200.0, 120.0), 2, 3, &|row| match row { + 0 => Color::rgb(1.0, 0.5, 0.0), + 1 => Color::cmyk(0.1, 0.6, 0.2, 0.05), + _ => Color::gray(0.4), + }); + let mut sheet = Node::new(doc.alloc_id(), NodeKind::Mesh(sheet)); + (sheet.name, sheet.opacity) = (Some("Sheet".into()), 0.5); + doc.insert(Some(layer), usize::MAX, sheet).unwrap(); + let mut small = mesh(Rect::new(220.0, 20.0, 280.0, 80.0), 1, 1, &|row| Color::rgb(0.0, 0.3, 0.3 + 0.5 * row as f32)); + small.points[1].opacity = 0.4; + let small = Node::new(doc.alloc_id(), NodeKind::Mesh(small)); + doc.insert(Some(layer), usize::MAX, small).unwrap(); + let patch = mesh(Rect::new(0.0, 0.0, 40.0, 30.0), 2, 1, &|row| Color::rgb(0.2 * row as f32, 0.6, 0.1)); + let patch = Node::new(doc.alloc_id(), NodeKind::Mesh(patch)); + doc.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Patch".into(), art: std::sync::Arc::new(patch) }); + let instance = + Node::new(doc.alloc_id(), NodeKind::SymbolInstance { symbol: "Patch".into(), xf: vectorcraft_geom::Affine::translate((20.0, 140.0)) }); + doc.insert(Some(layer), usize::MAX, instance).unwrap(); + let out = vectorcraft_eps::export_ai_editing(&doc, &vectorcraft_eps::AiEditingOptions::default()).unwrap(); + String::from_utf8(out.program).unwrap() + }) +} + +/// The data [`ai_written_meshes_never_panic`] damages, as it is, opens with both meshes, the symbol +/// with its mesh and its instance, and the property's cuts and edits reach all of it. +#[test] +fn the_written_meshes_fuzz_data_opens_as_meshes() { + use vectorcraft_doc::NodeKind; + let text = meshes_text(); + assert!(text.chars().count() < MESHES_FUZZ_CHARS, "{}", text.chars().count()); + for mark in ["%AI14_BeginSymbol", "%AI5_BeginLayer", "/Mesh X!", "%_[2 3] /Size X#", "%_/DeviceCMYK /CS X#", "/End X!", "/SymbolInstance :"] { + assert!(text.replace("\r\n", "\n").contains(mark), "{mark}"); + } + let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(text)].concat(); + let (d, warnings, layered) = vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, true, 1.0); + assert!(layered, "{warnings:?}"); + let art = d.layers[0].children().unwrap(); + let kinds: Vec<&str> = art + .iter() + .map(|n| match n.kind { + NodeKind::Mesh(_) => "mesh", + NodeKind::SymbolInstance { .. } => "instance", + _ => "other", + }) + .collect(); + assert_eq!(kinds, ["mesh", "mesh", "instance"], "{warnings:?}"); + let patch = d.symbols.iter().find(|s| s.name == "Patch").map(|s| &s.art.kind); + assert!(matches!(patch, Some(NodeKind::Mesh(_))), "{patch:?}"); +} + fn zstd(text: &str) -> Vec { ruzstd::encoding::compress_to_vec(text.as_bytes(), ruzstd::encoding::CompressionLevel::Fastest) } @@ -4482,6 +4559,17 @@ proptest! { survive("mutated .ai editing data", || Some(vectorcraft_eps::layered_ai(&private, Document::new(100.0, 100.0), vec![], false, false, 1.0).0))?; } + /// A `.ai` whose gradient meshes, as the writer writes them, are damaged: the record's type, + /// size, places, color spaces and corners on `%_` lines, its `/Mesh X!` and `/End X!`, and the + /// mesh's transparency and name, cut short or edited. + #[test] + fn ai_written_meshes_never_panic(cut in 0usize..MESHES_FUZZ_CHARS, edits in prop::collection::vec((0usize..MESHES_FUZZ_CHARS, prop::sample::select(vec!['0', '1', '2', '9', '-', '.', 'e', ' ', '\n', '[', ']', '(', ')', '/', '%', '_', 'X', '!', '#', 'N', 'P', 'E'])), 0..12)) { + let text = mutate_text(meshes_text(), cut, &edits); + let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(&text)].concat(); + survive("mutated .ai meshes", || Some(vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, false, 1.0).0))?; + survive("mutated .ai meshes, trusted", || Some(vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, true, 1.0).0))?; + } + /// The active artboard that a restored `.ai` opens on, read from damaged or hostile editing data. #[test] fn ai_active_artboard_never_panics(cut in 0usize..600, edits in prop::collection::vec((0usize..600, prop::sample::select(vec!['0', '9', '-', ' ', '\n', '/', ':', ';', ',', '%', '_'])), 0..12)) { @@ -8124,95 +8212,3 @@ proptest! { prop_assert_eq!(paths, 2, "{:?}", notes); } } - -proptest! { - #![proptest_config(config())] - - /// A `.ai` whose gradient meshes, as the writer writes them, are damaged: the record's type, - /// size, places, color spaces and corners on `%_` lines, its `/Mesh X!` and `/End X!`, and the - /// mesh's transparency and name, cut short or edited. - #[test] - fn ai_written_meshes_never_panic(cut in 0usize..MESHES_FUZZ_CHARS, edits in prop::collection::vec((0usize..MESHES_FUZZ_CHARS, prop::sample::select(vec!['0', '1', '2', '9', '-', '.', 'e', ' ', '\n', '[', ']', '(', ')', '/', '%', '_', 'X', '!', '#', 'N', 'P', 'E'])), 0..12)) { - let text = mutate_text(meshes_text(), cut, &edits); - let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(&text)].concat(); - survive("mutated .ai meshes", || Some(vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, false, 1.0).0))?; - survive("mutated .ai meshes, trusted", || Some(vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, true, 1.0).0))?; - } -} - -/// The range of [`ai_written_meshes_never_panic`]'s cuts and edits: past the end of [`meshes_text`]. -const MESHES_FUZZ_CHARS: usize = 24_000; - -/// The editing data VectorCraft writes for a document with two gradient meshes: 2 × 3 patches whose -/// rows of points are RGB, CMYK and gray, at half opacity and named; a 1 × 1 mesh with a point at -/// 40% opacity; and an instance of a symbol whose art is a 2 × 1 mesh. -fn meshes_text() -> &'static str { - static TEXT: std::sync::OnceLock = std::sync::OnceLock::new(); - TEXT.get_or_init(|| { - use vectorcraft_color::Color; - use vectorcraft_doc::live::{GradientMesh, MeshPoint, grid_points, smooth_handles}; - use vectorcraft_doc::{Node, NodeKind}; - use vectorcraft_geom::Rect; - let mesh = |r: Rect, rows: u32, cols: u32, color: &dyn Fn(usize) -> Color| { - let pts = grid_points(r, rows, cols); - let handles = smooth_handles(rows, cols, &pts); - let width = cols as usize + 1; - let points = pts - .iter() - .zip(handles) - .enumerate() - .map(|(i, (p, h))| MeshPoint { p: *p, color: color(i / width), opacity: 1.0, handles: h }) - .collect(); - GradientMesh { rows, cols, points } - }; - let mut doc = Document::new(300.0, 200.0); - let layer = doc.layers[0].id; - let sheet = mesh(Rect::new(20.0, 20.0, 200.0, 120.0), 2, 3, &|row| match row { - 0 => Color::rgb(1.0, 0.5, 0.0), - 1 => Color::cmyk(0.1, 0.6, 0.2, 0.05), - _ => Color::gray(0.4), - }); - let mut sheet = Node::new(doc.alloc_id(), NodeKind::Mesh(sheet)); - (sheet.name, sheet.opacity) = (Some("Sheet".into()), 0.5); - doc.insert(Some(layer), usize::MAX, sheet).unwrap(); - let mut small = mesh(Rect::new(220.0, 20.0, 280.0, 80.0), 1, 1, &|row| Color::rgb(0.0, 0.3, 0.3 + 0.5 * row as f32)); - small.points[1].opacity = 0.4; - let small = Node::new(doc.alloc_id(), NodeKind::Mesh(small)); - doc.insert(Some(layer), usize::MAX, small).unwrap(); - let patch = mesh(Rect::new(0.0, 0.0, 40.0, 30.0), 2, 1, &|row| Color::rgb(0.2 * row as f32, 0.6, 0.1)); - let patch = Node::new(doc.alloc_id(), NodeKind::Mesh(patch)); - doc.symbols.push(vectorcraft_doc::Symbol { dynamic: false, name: "Patch".into(), art: std::sync::Arc::new(patch) }); - let instance = - Node::new(doc.alloc_id(), NodeKind::SymbolInstance { symbol: "Patch".into(), xf: vectorcraft_geom::Affine::translate((20.0, 140.0)) }); - doc.insert(Some(layer), usize::MAX, instance).unwrap(); - let out = vectorcraft_eps::export_ai_editing(&doc, &vectorcraft_eps::AiEditingOptions::default()).unwrap(); - String::from_utf8(out.program).unwrap() - }) -} - -/// The data [`ai_written_meshes_never_panic`] damages, as it is, opens with both meshes, the symbol -/// with its mesh and its instance, and the property's cuts and edits reach all of it. -#[test] -fn the_written_meshes_fuzz_data_opens_as_meshes() { - use vectorcraft_doc::NodeKind; - let text = meshes_text(); - assert!(text.chars().count() < MESHES_FUZZ_CHARS, "{}", text.chars().count()); - for mark in ["%AI14_BeginSymbol", "%AI5_BeginLayer", "/Mesh X!", "%_[2 3] /Size X#", "%_/DeviceCMYK /CS X#", "/End X!", "/SymbolInstance :"] { - assert!(text.replace("\r\n", "\n").contains(mark), "{mark}"); - } - let private = [b"%AI24_ZStandard_Data".as_slice(), &zstd(text)].concat(); - let (d, warnings, layered) = vectorcraft_eps::layered_ai(&private, Document::new(300.0, 200.0), vec![], false, true, 1.0); - assert!(layered, "{warnings:?}"); - let art = d.layers[0].children().unwrap(); - let kinds: Vec<&str> = art - .iter() - .map(|n| match n.kind { - NodeKind::Mesh(_) => "mesh", - NodeKind::SymbolInstance { .. } => "instance", - _ => "other", - }) - .collect(); - assert_eq!(kinds, ["mesh", "mesh", "instance"], "{warnings:?}"); - let patch = d.symbols.iter().find(|s| s.name == "Patch").map(|s| &s.art.kind); - assert!(matches!(patch, Some(NodeKind::Mesh(_))), "{patch:?}"); -} diff --git a/crates/eps/src/ai_editing/tests.rs b/crates/eps/src/ai_editing/tests.rs index 7ba2cf935e..bf5ee1e5a0 100644 --- a/crates/eps/src/ai_editing/tests.rs +++ b/crates/eps/src/ai_editing/tests.rs @@ -13381,7 +13381,8 @@ fn filled_paths(nodes: &[Arc], out: &mut Vec<(Rect, Color)>) { /// Meshes the reader wouldn't read back as they are, and meshes in places where the writer doesn't /// write them as meshes, are written as their drawn look, with a warning: a point in a Lab color; /// more than 128 rows (129); more than 128 columns (129); a mesh whose points all lie in one place -/// (the reader takes its rows for columns); a folded mesh, whose patches turn different ways; a mesh +/// (the reader takes its rows for columns); a folded mesh, whose patches turn different ways; a +/// patch folded at one corner, by a point dragged across it or by handles that cross; a mesh /// in art cut to a clipping object; and a mesh on a large canvas. The drawn look reads back as /// filled paths in more than one color covering the mesh's box, and no mesh. #[test] @@ -13418,6 +13419,33 @@ fn meshes_the_reader_cant_read_are_written_as_their_drawn_look() { mesh_node(doc, m) }), ), + ( + "folded at a corner", + mesh_document(|doc| { + let mut m = grid_mesh(r, 1, 1, |_, c| Color::rgb(0.5 * c as f32, 0.0, 0.0)); + // The bottom right point is dragged across the patch's diagonal; its top left corner + // still turns as before. + m.points[3].p = vectorcraft_geom::Point::new(30.0, 30.0); + for p in &mut m.points { + p.handles = [vectorcraft_geom::Vec2::ZERO; 4]; + } + mesh_node(doc, m) + }), + ), + ( + "handles crossed", + mesh_document(|doc| { + let mut m = grid_mesh(r, 1, 1, |_, c| Color::rgb(0.5 * c as f32, 0.0, 0.0)); + // The top left point's handles cross inside the patch: the one towards the point + // below leans right of the one towards the point beside it. The corners stay put. + for p in &mut m.points { + p.handles = [vectorcraft_geom::Vec2::ZERO; 4]; + } + m.points[0].handles[vectorcraft_doc::live::H_DOWN] = vectorcraft_geom::Vec2::new(30.0, 10.0); + m.points[0].handles[vectorcraft_doc::live::H_RIGHT] = vectorcraft_geom::Vec2::new(10.0, 30.0); + mesh_node(doc, m) + }), + ), ( "collapsed", mesh_document(|doc| { @@ -13501,6 +13529,21 @@ fn a_reflected_mesh_is_written_with_its_columns_reversed() { }) .collect(); assert_mesh_exact(mesh_of(&back[0]), &want, name); + // It draws the same mesh: each patch's points and opacity, sampled across it, are where they + // were, in the patch at the other end of its row with u running the other way. + let got = mesh_of(&back[0]); + let cols = m.cols as usize; + let steps = [0.0, 0.25, 0.5, 0.75, 1.0]; + for r in 0..m.rows as usize { + for c in 0..cols { + for (u, v) in steps.iter().flat_map(|u| steps.iter().map(move |v| (*u, *v))) { + let (a, b) = (m.eval(r, c, u, v), got.eval(r, cols - 1 - c, 1.0 - u, v)); + assert!((a - b).hypot() < 1e-3, "{name}: patch ({r}, {c}) at ({u}, {v}): {a:?} read back as {b:?}"); + let (oa, ob) = (m.color_at(r, c, u, v).1, got.color_at(r, cols - 1 - c, 1.0 - u, v).1); + assert!((oa - ob).abs() < 1e-3, "{name}: patch ({r}, {c}) at ({u}, {v}): opacity {oa} read back as {ob}"); + } + } + } } } diff --git a/crates/eps/src/ai_editing/writer/meshes.rs b/crates/eps/src/ai_editing/writer/meshes.rs index c381e1901d..b0f3a8766c 100644 --- a/crates/eps/src/ai_editing/writer/meshes.rs +++ b/crates/eps/src/ai_editing/writer/meshes.rs @@ -14,11 +14,13 @@ //! (`0 XR`, `Xy`), its name and opacity mask follow `/End X!` in an `/ArtDictionary`, then `0 0 Xd` //! and `6 () XW`. //! -//! Each mesh is checked with the reader's own reading ([`crate::import::mesh_reads`]) before it is -//! written: one the reader would read otherwise is written as its drawn look, as are folded meshes -//! (patches that turn different ways, or a patch with no area), meshes in pattern tiles and in art -//! cut to a clipping object, and every mesh on a large canvas. A reflected mesh, whose patches all -//! turn the negative way, is written with its columns in reverse order. +//! Each record is read back with the reader's mesh reading ([`crate::import::mesh_reads`], the +//! patches and how they join; not the rest of the `.ai` reader) before it is written: a mesh it +//! would read otherwise is written as its drawn look, as are folded meshes (patches whose corners +//! turn different ways, along the handles there, or a corner with no angle), meshes in pattern +//! tiles and in art cut to a clipping object, and every mesh on a large canvas. A reflected mesh, +//! whose patches all turn the negative way, is written with its columns in reverse order: it draws +//! the same patches, and reads back with each row's points in reverse order. use std::fmt::Write; @@ -128,24 +130,38 @@ impl Writer<'_> { } } -/// Which way every patch of `m` turns where `to_art` takes it, from its top left point to the one -/// below it then to the one beside it, y up: `Some(true)` when all turn anticlockwise, -/// `Some(false)` when all turn clockwise, and `None` when they differ or one has no area. +/// Which way every patch of `m` turns where `to_art` takes it, at each of its four corners, from +/// its top left point to the one below it, then right and up, y up: `Some(true)` when all turn +/// anticlockwise, `Some(false)` when all turn clockwise, and `None` when they differ (a patch +/// folded across itself, or patches folded over each other) or a corner has no angle. Each corner +/// is measured twice: along the straight lines to the next corners, and along its handles (towards +/// the next corners where a handle is zero), where the patch's edges leave it. fn turns(m: &GradientMesh, to_art: Affine) -> Option { let (rows, cols) = (m.rows as usize, m.cols as usize); - let at = |r: usize, c: usize| m.points.get(r * (cols + 1) + c).map(|p| to_art * p.p); + let at = |r: usize, c: usize| m.points.get(r * (cols + 1) + c); let mut way = None; for r in 0..rows { for c in 0..cols { - let (a, b, d) = (at(r, c)?, at(r + 1, c)?, at(r, c + 1)?); - let cross = (b - a).cross(d - a); - let positive = match cross { - x if x > 0.0 => true, - x if x < 0.0 => false, - _ => return None, - }; - if *way.get_or_insert(positive) != positive { - return None; + // Each corner with the slots of its handles towards the next corner and the one before it. + let corners = + [(at(r, c)?, H_DOWN, H_RIGHT), (at(r + 1, c)?, H_RIGHT, H_UP), (at(r + 1, c + 1)?, H_UP, H_LEFT), (at(r, c + 1)?, H_LEFT, H_DOWN)]; + for i in 0..4 { + let (before, (here, next, prev), after) = (corners[(i + 3) % 4].0, corners[i], corners[(i + 1) % 4].0); + let line = |to: &MeshPoint| to_art * to.p - to_art * here.p; + let along = |h: usize, to: &MeshPoint| -> Option { + let h = *here.handles.get(h)?; + Some(if h == Vec2::ZERO { line(to) } else { to_art * (here.p + h) - to_art * here.p }) + }; + for cross in [line(after).cross(line(before)), along(next, after)?.cross(along(prev, before)?)] { + let positive = match cross { + x if x > 0.0 => true, + x if x < 0.0 => false, + _ => return None, + }; + if *way.get_or_insert(positive) != positive { + return None; + } + } } } } diff --git a/crates/eps/src/import/ai/tests.rs b/crates/eps/src/import/ai/tests.rs index 785a8d5258..e4c71f7b46 100644 --- a/crates/eps/src/import/ai/tests.rs +++ b/crates/eps/src/import/ai/tests.rs @@ -5284,6 +5284,29 @@ fn a_mesh_in_a_symbols_art_is_placed_from_the_canvas() { assert!(!r.unread.is_empty(), "{:?}", r.warnings); } +#[test] +fn an_envelope_in_a_symbols_art_is_read_from_the_canvas() { + // An envelope's grid in a symbol's art is read in the space a gradient mesh's corners are read + // in there. A grid and contents written in the symbol's own space, as earlier VectorCraft builds + // wrote them, don't meet there: the envelope opens as the art it draws. + let drawn = format!("{RED}{}f\n", rect_path(30.0, 10.0, 170.0, 90.0)); + let env = envelope_of(&straight_mesh(1, 1, (120.0, 60.0)), ENVELOPE_KEYS, &envelope_content(), 2, &drawn); + let doc = read_ok(&format!("%AI3_TemplateBox: 100.5 50.5 100.5 50.5\n{}{}", symbols(&symbol("Bent", &env, 5)), layer(""))).doc; + assert_eq!(doc.symbols.len(), 1); + let mut envelopes = 0; + doc.symbols[0].art.walk(&mut |n| envelopes += usize::from(matches!(n.kind, NodeKind::Envelope { .. }))); + assert_eq!(envelopes, 0, "{:?}", doc.symbols[0].art); + let mut paths = 0; + doc.symbols[0].art.walk(&mut |n| paths += usize::from(matches!(n.kind, NodeKind::Path { .. }))); + assert!(paths > 0, "{:?}", doc.symbols[0].art); + // Without a template box the grid can't be placed, as a gradient mesh there can't: the symbol + // isn't read whole and its instance comes in as the page draws it. + let group = format!("0 Ae\nu\n{}{RED}{}f\nU\n", instance("Bent", [1.0, 0.0, 0.0, -1.0, 20.0, 50.0]), rect_path(10.0, 0.0, 14.0, 4.0)); + let r = read_ok(&(symbols(&symbol("Bent", &env, 5)) + &layer(&group))); + assert!(r.doc.symbols.is_empty(), "{:?}", r.doc.symbols.iter().map(|s| &s.name).collect::>()); + assert!(!r.unread.is_empty(), "{:?}", r.warnings); +} + #[test] fn an_instance_keeps_its_hide_lock_transparency_and_clip() { let m = [1.0, 0.0, 0.0, -1.0, 20.0, 50.0]; diff --git a/docs/file-format-parity.md b/docs/file-format-parity.md index 83d395e30c..b4bb5c12ba 100644 --- a/docs/file-format-parity.md +++ b/docs/file-format-parity.md @@ -128,8 +128,9 @@ private editing data. VectorCraft: written as their brush's art. A document that uses a new document's brushes writes none until a path keeps one on its stroke; then the brushes are written, and the file opens without the new document's Pattern and Bristle brushes. Gradient meshes are written as meshes: each mesh point's place, color, opacity and handles, patch by - patch; a reflected mesh is written with its columns in reverse order. Meshes with a point in a Lab color, with - more than 128 rows or columns, folded meshes (patches that turn different ways), meshes VectorCraft's reader + patch; a reflected mesh is written with its columns in reverse order, and opens with each row's points in reverse + order. Meshes with a point in a Lab color, with + more than 128 rows or columns, folded meshes (patches whose corners turn different ways), meshes VectorCraft's reader wouldn't open as they are drawn, meshes in pattern tiles and in art cut to a clipping object, and every mesh on a large canvas are written as their drawn look with a warning. In a symbol's art, an envelope's contents are written in the canvas's space with y down. @@ -147,7 +148,7 @@ private editing data. VectorCraft: clipping object, mirrored type, turned or unevenly scaled area type and type on a path, area type in an open frame, type on an open path whose ends meet, area type whose wrap cannot be reconstructed from plain saved paths, compound paths or groups, type of only white space, threads of type on a path, threads whose frames differ in orientation, type and stories past the sizes VectorCraft's reader reads, and - type with inline graphics, ruby, gradient or pattern paint or an appearance or opacity mask of its own, other patterns, other clipping objects and live + type with inline graphics, ruby, gradient or pattern paint or an appearance or opacity mask of its own, other patterns, other clipping objects and other live objects (placed documents included) are written as plain filled and stroked paths, and freeform gradients, gradients along or across a stroke and gradients without stops, with more than 256 stops or without extent as their average color, each with a warning. Gradients that dither or mix their colors perceptually are written as classic @@ -285,7 +286,7 @@ An object in a pattern's art or in a brush's art takes the file's art styles in Names in the editing data that aren't UTF-8 (layers, objects, artboards, colors, gradients, patterns, graphic styles, swatches, brushes, symbols, variables and data sets) are read as Windows-1252 unless `legacyNameEncoding` (`convert --legacy-name-encoding`) picks `macintosh`, `windows-949`, `shift_jis`, `gbk` or `big5`; the open result's warnings list the first three such names as read and count the rest. The text values of data sets are read in the same encoding. -Gradient meshes in the editing data keep each point's own color where a patch's corners differ in color model. In a symbol's art, a gradient mesh's corners and an envelope's grid are read in the space an image's matrix is read in there, and an envelope's contents in its dictionary in the canvas's space with y down. In a file without a template box such a mesh is not read, and its symbol's instances open as the page draws them, as with an image there. +Gradient meshes in the editing data keep each point's own color where a patch's corners differ in color model. In a symbol's art, a gradient mesh's corners and an envelope's grid are read in the space an image's matrix is read in there, and an envelope's contents in its dictionary in the canvas's space with y down. In a file without a template box such a mesh or grid is not read, and its symbol's instances open as the page draws them, as with an image there. An envelope in a symbol's art whose grid and contents are in the symbol's own space, as earlier VectorCraft builds wrote them, opens as the art it draws. ## Format by format diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index a40c0f40dd..5c41baaf9b 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1878,7 +1878,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur On a large canvas ([the help page](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/start-a-new-file/large-canvas-faq.html); VectorCraft writes one when the artboards together are wider or taller than 16,381 points, its own limit), that `.ai` keeps warp, mesh and top object envelopes editable too: the editing copy writes them live at 1/10 of their size with the rest of the art, and VectorCraft's `.ai` reader opens them at their size, from the editing data alone or beside the PDF part. Read from the editing data alone, an envelope's saved box size is compared with its contents at the same scale, so a bounds margin kept with Distort Appearance comes back, and every path's stroke weight, dashes and dash offset come back at their size, not at 1/10 (`large_canvas_envelope_kinds_round_trip_on_both_ai_routes`, `large_canvas_envelope_stroke_margin_round_trips_on_both_ai_routes` and `a_large_canvas_path_keeps_its_stroke_weight_and_dashes_read_alone` in `crates/eps/src/ai_editing/tests.rs`). An envelope whose contents hold type keeps the type editable in that `.ai`: the editing copy writes the type as type in the envelope's contents, in the form the `.ai` reader opens as a live envelope of type (`TypedEnvelope` in `crates/eps/src/import/ai/envelope.rs`), so the file opens with the type shown and editable in the envelope's contents, with Edit Contents off or on. An envelope of type in a symbol's art, and one whose type is threaded, has text wrap options or is written as its outlines (mirrored type, for example), is written as its distorted art, as before (`an_envelope_of_type_is_read_back_live_with_its_type`, `an_envelope_of_type_written_as_its_art_leaves_no_story` and `an_envelope_of_type_in_a_symbol_or_a_thread_is_written_as_its_art` in `crates/eps/src/ai_editing/tests.rs`). A top object whose top and bottom sides, or left and right sides, have different numbers of segments is also saved live: the side with fewer segments is split into as many as the side across from it has (each segment into equal spans of its curve, a straight one at even steps), up to the 50 a side the grid holds, so the file opens with the same corners and the same mapping of the contents, its outline holding the added anchors. Where the split side would share out the contents another way, as a side of two curves that aren't one curve can, or a side has more than 50 segments, the envelope is written as its distorted art, with the warning (`a_top_object_with_uneven_sides_is_read_back_live`, `a_top_object_split_to_the_grids_limit_is_read_back_live` and `a_top_object_whose_split_side_would_map_another_way_is_written_as_its_art` in `crates/eps/src/ai_editing/tests.rs`). - A PDF-compatible `.ai` saved with Include Editing Data for Other Apps keeps gradient meshes editable ([gradient meshes](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=200)): its editing copy writes each mesh point's place, color (gray, RGB or CMYK), opacity and handles patch by patch, with the mesh's transparency, name and opacity mask, in the form VectorCraft's `.ai` mesh reader reads (`crates/eps/src/import/ai/mesh.rs`), so the file opens with the same mesh. A reflected mesh is written with its columns in reverse order. Meshes with a point in a Lab color, with more than 128 rows or columns, folded meshes, meshes the reader would open otherwise, meshes in pattern tiles and in art cut to a clipping object, and every mesh on a large canvas are written as their drawn look, with a warning (`meshes_are_read_back_as_they_are`, `meshes_in_masks_and_symbols_are_read_back`, `a_reflected_mesh_is_written_with_its_columns_reversed` and `meshes_the_reader_cant_read_are_written_as_their_drawn_look` in `crates/eps/src/ai_editing/tests.rs`). + A PDF-compatible `.ai` saved with Include Editing Data for Other Apps keeps gradient meshes editable ([gradient meshes](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=200), [opacity of mesh points](https://help.adobe.com/archive/en_US/illustrator/cs5/illustrator_cs5_help.pdf#page=203)): its editing copy writes each mesh point's place, color (gray, RGB or CMYK), opacity and handles patch by patch, with the mesh's transparency, name and opacity mask, in the form VectorCraft's `.ai` mesh reader reads (`crates/eps/src/import/ai/mesh.rs`), so the file opens with the same mesh. A reflected mesh is written with its columns in reverse order. Meshes with a point in a Lab color, with more than 128 rows or columns, folded meshes, meshes the reader would open otherwise, meshes in pattern tiles and in art cut to a clipping object, and every mesh on a large canvas are written as their drawn look, with a warning (`meshes_are_read_back_as_they_are`, `meshes_in_masks_and_symbols_are_read_back`, `a_reflected_mesh_is_written_with_its_columns_reversed` and `meshes_the_reader_cant_read_are_written_as_their_drawn_look` in `crates/eps/src/ai_editing/tests.rs`). A PDF-compatible `.ai` saved with Include Editing Data for Other Apps writes eligible paths, compound paths and groups with live effects with an art style when the writer supports their appearance and effects (not a filled path that uses the even-odd rule, and none on a large canvas), which VectorCraft's `.ai` reader opens as the same appearance with its effects live (`objects_with_live_effects_are_read_back` and `every_effect_setting_written_on_an_object_is_read_back` in `crates/eps/src/ai_editing/tests.rs`; [file-format-parity.md](file-format-parity.md) lists the objects written without one and the effects they lose). The same holds for the objects of an opacity mask's art, a mask inside another mask's art and a hidden art root included, so a mask whose art has Offset Path opens drawing the image it masks as it did, with the effect live; geometry effects that no art style holds on a mask's art, such as Roughen, are written applied to the art, which opens drawing what it drew (`a_masked_image_with_live_offset_path_round_trips`, `hidden_and_nested_mask_art_keep_live_offset_path` and `a_masks_art_with_an_effect_no_style_holds_is_written_as_it_draws` in `crates/eps/src/ai_editing/tests.rs`). Opacity masks in a symbol's art and in a pattern's tile are written the same way, so a symbol or pattern whose mask art has Offset Path opens with the effect live in its definition, and its instances and pattern fills draw as they did; each definition's mask art keeps its own style, and mask art linked to a graphic style opens still linked to it (`a_symbols_mask_art_keeps_live_offset_path`, `a_pattern_tiles_mask_art_keeps_live_offset_path`, `mask_art_styles_stay_with_their_own_art` and `opacity_mask_art_keeps_its_graphic_style_link` in `crates/eps/src/ai_editing/tests.rs`).