diff --git a/crates/cdr/PROVENANCE.md b/crates/cdr/PROVENANCE.md index 570171c7d4..83815aa5d9 100644 --- a/crates/cdr/PROVENANCE.md +++ b/crates/cdr/PROVENANCE.md @@ -91,3 +91,4 @@ file is committed. | R43 | A drawn object of version 1 or 2: a point (two i16) at byte 32; six i32 in 16.16 fixed point at 36, `a b tx c d ty`, with x' = a x + b y + tx + the point's x and y' = c x + d y + ty + the point's y; the object type at 60 (0 rectangle, 1 ellipse, 2 curve, 3 text); a byte at 67 that is not 0 when the object is outlined, the outline's width (u16) at 68 and its color at 74; the fill type (0 none, 1 uniform) and its color after it, at 94 and 95 with the marker `e` and at 105 and 106 with `l` and `m`; the shape from byte 114 with `e` and 136 with `l` and `m`. Colors are as R36 | S: TP `WI.CDR` (`e`), `FLAG.CDR` (`m`) and `MENU.CDR` (`l`), checked against the pictures of `FLAG.CDR` and `MENU.CDR` | sample | | R44 | Shapes of version 1 or 2: a rectangle's width and height (i16), then a corner radius; an ellipse's width and height, then two angles; a curve's point list as R39 and R16 | S: rectangles in TP `FLAG.CDR`, ellipses and curves in TP `WI.CDR`, curves in TP `MENU.CDR` | sample (the radius of files with the marker `e`, which no sample shows, and how the angles make an arc: unconfirmed; a radius is kept only when it is at most half the shorter side, and an ellipse whose angles differ is left out with a warning) | | R45 | `LIST stlt` from version 7: a u32 style count, and when it is not 0: the fill table (a u32 count, entries of a table id, 4 bytes and a `fild` id, 12 bytes each, 60 from version 13), the outline table (12-byte entries laid out the same way, naming `outl` ids), the text tables (fonts of 44 bytes, 60 from version 10; alignments of 12; spacings of 52; tables of 152 and 784; bullets whose length a u32 inside them sets; indents of 28; hyphenation of 32, 36 from 13; drop caps of 28; from 8.01 a table of 12), then the styles: kind (u32), id, parent id, 8 bytes, name length and name (bytes before 12, UTF-16 units from it), the fill and outline table ids, then 16 bytes (20 from 8.01) for kinds above 1 and 20 more for kinds above 2. An object names its style in argument 200 (u32). An object without argument 20 or 10 takes the fill or outline of its style; a style whose table id is 0 takes its parent's | K L593-L600, L852, L1926-L2198; S: UC `corel_rounded_rect_cdr7.cdr`, whose rectangles carry argument 200 and neither 10 nor 20, and name the style whose outline is a black hairline and whose fill is none, as the file's picture shows; the table parses exactly to the end of the list in each of the 498 sample files of versions 7 to 15 that has one, and every object with argument 200 in them names a style whose table ids are in the tables | public-spec (what the table ids name, and that an object takes its style's fill and outline: sample; a style taking its parent's entry: unconfirmed, as only text styles in the samples leave theirs to the parent, and a wrong guess draws a shape without that fill or outline) | +| R46 | A container (a PowerClip) carries argument 8005; its first u32 is the id that the `spnd` chunk (a u32) of one `LIST grp ` in the document's `LIST clpt` holds. That group's objects are the ones the container clips; they keep their own transforms, in page space like the container's | K L252, L860-L862, L1895-L1901 (the argument and the chunk); S: UC `corel_powerclip_cdr7.cdr` to `corel_powerclip_x3.cdr` (versions 7 to 13) and LT `powerclipsquare_blackfill_whiterectangleinside` of `testset/12` to `testset/25`, in each of which the id in argument 8005 matches one group's `spnd`; in `corel_powerclip_cdr7.cdr` the group's box, -1.96 to 1.97 inches across, overlaps the container's, -1.81 to 1.84 inches, and the file's picture shows the group cut to the container | public-spec (what the id names, and the space of the group's objects: sample) | diff --git a/crates/cdr/README.md b/crates/cdr/README.md index d1a7c8fc21..f59719912e 100644 --- a/crates/cdr/README.md +++ b/crates/cdr/README.md @@ -15,6 +15,7 @@ with each object's transform. It does not write `.cdr` files. | Layers (drawing, desktop, guides and grid layers), the master page's among them | layers by name and kind | | Guidelines (object type 0x16, and the version 7 `guid` chunk) | guidelines at their point and angle | | Groups (`LIST grp `) | groups | +| PowerClip containers and the groups of `LIST clpt` they clip | the container with the objects it clips | | Curves (point lists of moves, lines and cubic curves) and paths (object type 0x25, version 10 on) | paths | | Rectangles (one corner radius, four from version 9) | rectangles with each corner's radius | | Ellipses, arcs and pies | ellipses, and paths for arcs and pies | diff --git a/crates/cdr/src/build.rs b/crates/cdr/src/build.rs index df1ddba71d..5462eb0920 100644 --- a/crates/cdr/src/build.rs +++ b/crates/cdr/src/build.rs @@ -28,6 +28,7 @@ const ARG_COORDS: u32 = 30; const ARG_TRANSFORMS: u32 = 100; const ARG_STYLE: u32 = 200; const ARG_NAME: u32 = 1000; +const ARG_CONTAINER: u32 = 8005; const ARG_POLYGON: u32 = 11000; const ARG_GUIDE: u32 = 16000; const ARG_PAGE_SIZE: u32 = 19130; @@ -49,8 +50,15 @@ struct Ctx<'a, 'b> { /// The styles objects name in argument 200 (R45): `Err` when the file's style table doesn't /// parse. styles: Result, + /// The groups of `LIST clpt` that containers clip, by the id in their `spnd` chunk (R46). + clips: HashMap, + /// The clipped groups being read, innermost last. + open_clips: Vec, } +/// The most clipped groups read one inside another: VectorCraft's own limit. +const MAX_CLIP_DEPTH: usize = 64; + pub(crate) fn drawing(ix: &Index, budget: &mut Budget, warn: &mut Vec) -> Result { let root = ix.root().ok_or(Error::NotCdr)?; let version = version(ix, root); @@ -82,7 +90,14 @@ pub(crate) fn drawing(ix: &Index, budget: &mut Budget, warn: &mut Vec) fills: HashMap::new(), outlines: HashMap::new(), styles, + clips: HashMap::new(), + open_clips: Vec::new(), }; + for g in found.clpt.iter().flat_map(|c| ix.children(c)).filter(|g| g.is_list(b"grp ")) { + if let Some(id) = ix.children(g).iter().find(|c| &c.id == b"spnd").and_then(|c| Rd::new(ix.data(c)).u32()) { + cx.clips.entry(id).or_insert(g); + } + } for c in &found.fills { if let Some(id) = Rd::new(ix.data(c)).u32() { cx.fill_chunks.entry(id).or_insert(ix.data(c)); @@ -138,11 +153,12 @@ struct Found<'i> { mcfg: Option<&'i Chunk>, guid: Option<&'i Chunk>, stlt: Option<&'i Chunk>, + clpt: Vec<&'i Chunk>, pages: Vec<&'i Chunk>, } -/// Every fill, outline and page in file order, and the first `mcfg`, `guid` and `LIST stlt`; -/// pages are not looked into. +/// Every fill, outline, `LIST clpt` and page in file order, and the first `mcfg`, `guid` and +/// `LIST stlt`; pages are not looked into. fn collect<'i>(ix: &'i Index, root: &'i Chunk, found: &mut Found<'i>) { let mut stack: Vec<&Chunk> = ix.children(root).iter().rev().collect(); while let Some(c) = stack.pop() { @@ -152,6 +168,7 @@ fn collect<'i>(ix: &'i Index, root: &'i Chunk, found: &mut Found<'i>) { b"mcfg" => found.mcfg = found.mcfg.or(Some(c)), b"guid" => found.guid = found.guid.or(Some(c)), _ if c.is_list(b"stlt") => found.stlt = found.stlt.or(Some(c)), + _ if c.is_list(b"clpt") => found.clpt.push(c), _ if c.is_list(b"page") => found.pages.push(c), _ => stack.extend(ix.children(c).iter().rev()), } @@ -450,7 +467,34 @@ impl<'a, 'b> Ctx<'a, 'b> { }; let fill = fill_id.and_then(|id| self.fill(id)); let outline = outline_id.and_then(|id| self.outline(id)); - Some(Object::Shape(Box::new(Shape { geometry, matrix, fill, outline }))) + let shape = Box::new(Shape { geometry, matrix, fill, outline }); + // A container clips the group its argument 8005 names (R46). + Some(match loda.arg(ARG_CONTAINER).and_then(id_of) { + Some(id) => self.clip(shape, id, guides), + None => Object::Shape(shape), + }) + } + + /// `container` and the objects of the clipped group `id`, which keep their own transforms. + /// A group that isn't there is damage; one already being read, or past the depth limit, is + /// left out with the limit warning. Either way the container stays, as a plain shape. + fn clip(&mut self, container: Box, id: u32, guides: &mut Vec) -> Object { + let Some(&group) = self.clips.get(&id) else { + push(self.warn, Warning::Damaged); + return Object::Shape(container); + }; + if self.open_clips.contains(&id) || self.open_clips.len() >= MAX_CLIP_DEPTH { + push(self.warn, Warning::TooDeep); + return Object::Shape(container); + } + self.open_clips.push(id); + let ix = self.ix; + let objects = self.objects(ix.children(group), guides); + self.open_clips.pop(); + if objects.is_empty() { + return Object::Shape(container); + } + Object::Clip { container, objects } } /// The fill or outline record that style `id` names; a style table that doesn't parse is diff --git a/crates/cdr/src/model.rs b/crates/cdr/src/model.rs index f3553ce329..c901d65d91 100644 --- a/crates/cdr/src/model.rs +++ b/crates/cdr/src/model.rs @@ -119,6 +119,12 @@ pub struct Shape { pub enum Object { Shape(Box), Group(Vec), + /// A container and the objects it clips (a PowerClip): `objects` (front to back) show only + /// inside the container's shape, with its fill behind them and its outline over them. + Clip { + container: Box, + objects: Vec, + }, } /// A guideline through `at`, at `angle` degrees counterclockwise from horizontal. diff --git a/crates/cdr/src/synth.rs b/crates/cdr/src/synth.rs index f3bf25a6c7..21d3b1db72 100644 --- a/crates/cdr/src/synth.rs +++ b/crates/cdr/src/synth.rs @@ -569,6 +569,25 @@ pub fn stlt(v: V, fills: &[(u32, u32)], outlines: &[(u32, u32)], styles: &[Style Node::Chunk(*b"LIST", [b"stlt".to_vec(), stlt_body(v, fills, outlines, styles, text)].concat()) } +/// A `LIST clpt` of clipped groups (R46): each a `LIST grp ` with its `spnd` id, then its objects. +pub fn clpt(groups: Vec<(u32, Vec)>) -> Node { + let groups = groups + .into_iter() + .map(|(id, objects)| { + let mut kids = vec![chunk(b"spnd", id.to_le_bytes().to_vec())]; + kids.extend(objects); + list(b"grp ", kids) + }) + .collect(); + list(b"clpt", groups) +} + +/// The container argument (8005) naming clipped group `id` (R46), laid out as sample files lay it +/// out. +pub fn container(id: u32) -> (u32, Vec) { + (8005, [id, 1, 0, 1].iter().flat_map(|v| v.to_le_bytes()).collect()) +} + /// A file of `version` holding `content` as the program of that version saves it: a RIFF file /// before 14, then a package (R25, R26). pub fn file_of(version: u16, content: Vec) -> Vec { diff --git a/crates/cdr/tests/read.rs b/crates/cdr/tests/read.rs index 1df3b800be..815688fba6 100644 --- a/crates/cdr/tests/read.rs +++ b/crates/cdr/tests/read.rs @@ -14,6 +14,10 @@ fn shapes(objects: &[Object]) -> Vec<&vectorcraft_cdr::model::Shape> { match o { Object::Shape(s) => out.push(&**s), Object::Group(kids) => stack.extend(kids.iter().rev()), + Object::Clip { container, objects } => { + out.push(&**container); + stack.extend(objects.iter().rev()); + } } } out @@ -1203,6 +1207,63 @@ fn a_style_table_that_does_not_parse_is_damage_when_an_object_needs_it() { assert_eq!(d.warnings, vec![Warning::Damaged]); } +/// A drawing with fill 1 (red), whose `LIST clpt` holds `groups` and whose page holds `objects`. +fn clip_drawing(version: u16, groups: Vec<(u32, Vec)>, objects: Vec) -> Vec { + let v = V(version); + let doc = list( + b"doc ", + vec![ + synth::mcfg(v, 612.0, 792.0), + list(b"filt", vec![chunk(if version >= 700 { b"fild" } else { b"fill" }, v.fill(1, &synth::color(5, [0, 0, 255, 0])))]), + synth::clpt(groups), + ], + ); + let page = synth::page(false, vec![synth::layer(v, [0, 0, 0, 0x98], "L", objects)]); + synth::file_of(version, vec![doc, page]) +} + +fn clip_rect(v: V, w: f64, extra: &[(u32, Vec)], at: [f64; 2]) -> synth::Node { + let mut args = vec![(20, 1u32.to_le_bytes().to_vec()), (30, v.rect(w, w, 0.0))]; + args.extend(extra.iter().cloned()); + synth::object(v, 1, &args, Some([1.0, 0.0, 0.0, 1.0, at[0], at[1]])) +} + +/// A container (argument 8005) clips the group of `LIST clpt` whose `spnd` id it names; the +/// group's objects keep their own transforms, front to back. +#[test] +fn a_container_clips_the_group_it_names() { + for version in [700, 900, 1200, 1300, 1500, 1600, 2000] { + let v = V(version); + let contents = vec![clip_rect(v, 10.0, &[], [5.0, 6.0]), clip_rect(v, 20.0, &[], [-50.0, 0.0])]; + let container = clip_rect(v, 40.0, &[synth::container(0x77)], [0.0, 0.0]); + let d = read(&clip_drawing(version, vec![(0x77, contents)], vec![container]), Limits::default()).unwrap_or_else(|e| panic!("{version}: {e}")); + let objects = &d.pages[0].layers[0].objects; + let [Object::Clip { container, objects: clipped }] = objects.as_slice() else { panic!("{version}: {objects:?}") }; + assert!(matches!(container.geometry, Geometry::Rect { w, .. } if (w - 40.0).abs() < 0.01), "{version}"); + let s = shapes(clipped); + assert_eq!(s.len(), 2, "{version}"); + assert!((s[0].matrix.0[4] - 5.0).abs() < 0.01 && (s[1].matrix.0[4] + 50.0).abs() < 0.01, "{version}: {:?}", s[0].matrix); + assert!(d.warnings.is_empty(), "{version}: {:?}", d.warnings); + } +} + +/// A container whose group isn't there is damage, and one whose group holds a container naming +/// it again is read once, with the limit warning; the containers stay as plain shapes. +#[test] +fn a_missing_or_repeating_clipped_group_keeps_the_container() { + let v = V(1100); + let missing = clip_rect(v, 40.0, &[synth::container(0x78)], [0.0, 0.0]); + let d = read(&clip_drawing(1100, vec![(0x77, vec![clip_rect(v, 10.0, &[], [0.0, 0.0])])], vec![missing]), Limits::default()).unwrap(); + assert!(matches!(d.pages[0].layers[0].objects.as_slice(), [Object::Shape(_)])); + assert_eq!(d.warnings, vec![Warning::Damaged]); + let inner = clip_rect(v, 10.0, &[synth::container(0x77)], [0.0, 0.0]); + let outer = clip_rect(v, 40.0, &[synth::container(0x77)], [0.0, 0.0]); + let d = read(&clip_drawing(1100, vec![(0x77, vec![inner])], vec![outer]), Limits::default()).unwrap(); + let [Object::Clip { objects: clipped, .. }] = d.pages[0].layers[0].objects.as_slice() else { panic!("{:?}", d.pages[0].layers[0].objects) }; + assert!(matches!(clipped.as_slice(), [Object::Shape(_)]), "{clipped:?}"); + assert_eq!(d.warnings, vec![Warning::TooDeep]); +} + #[test] fn linked_groups_are_left_out_with_a_warning() { let v = V(1100); diff --git a/crates/engine/src/cmd/fileio/cdr.rs b/crates/engine/src/cmd/fileio/cdr.rs index 394220f194..1658dc5dba 100644 --- a/crates/engine/src/cmd/fileio/cdr.rs +++ b/crates/engine/src/cmd/fileio/cdr.rs @@ -321,17 +321,26 @@ fn copy_cost(objects: &[cd::Object]) -> usize { n = n.saturating_add(1); match o { cd::Object::Group(kids) => stack.extend(kids), - cd::Object::Shape(s) => { - if let cd::Geometry::Path(p) = &s.geometry { - n = p.subpaths.iter().fold(n, |n, sp| n.saturating_add(1 + sp.segments.len())); - } - n = n.saturating_add(s.outline.as_ref().map_or(0, |o| o.dashes.len())); + cd::Object::Shape(s) => n = n.saturating_add(shape_cost(s)), + cd::Object::Clip { container, objects } => { + n = n.saturating_add(shape_cost(container)); + stack.extend(objects); } } } n } +/// What one copy of shape `s` takes past the object itself: its path's subpaths and segments and +/// its outline's dashes. +fn shape_cost(s: &cd::Shape) -> usize { + let mut n: usize = 0; + if let cd::Geometry::Path(p) = &s.geometry { + n = p.subpaths.iter().fold(n, |n, sp| n.saturating_add(1 + sp.segments.len())); + } + n.saturating_add(s.outline.as_ref().map_or(0, |o| o.dashes.len())) +} + /// A layer of the document named `name` holding `kids` (bottom to top). fn layer(doc: &mut Document, name: &str, i: usize, kids: Vec>) -> Arc { let name = if name.is_empty() { format!("Layer {}", i + 1) } else { name.to_string() }; diff --git a/crates/engine/src/cmd/fileio/cdr/shapes.rs b/crates/engine/src/cmd/fileio/cdr/shapes.rs index 7bd04c6a70..71d8d78ad5 100644 --- a/crates/engine/src/cmd/fileio/cdr/shapes.rs +++ b/crates/engine/src/cmd/fileio/cdr/shapes.rs @@ -67,6 +67,12 @@ impl Builder { } } cd::Object::Group(kids) => stack.extend(kids), + cd::Object::Clip { container, objects } => { + for c in container.fill.iter().chain(container.outline.iter().map(|o| &o.color)) { + self.learn_spot(c); + } + stack.extend(objects); + } } } } @@ -108,19 +114,28 @@ impl Builder { let mut out = Vec::with_capacity(objects.len()); for o in objects.iter().rev() { match o { - cd::Object::Shape(s) => out.extend(self.shape(s, to_doc)), + cd::Object::Shape(s) => out.extend(self.shape(s, to_doc, false)), cd::Object::Group(kids) => { let children = self.objects_at(kids, to_doc, depth + 1); if !children.is_empty() { out.push(Arc::new(Node::new(self.doc.alloc_id(), NodeKind::Group { children, clip: false }))); } } + // A clipping group whose clipping path keeps the container's paint: its fill + // behind the clipped objects and its outline over them. + cd::Object::Clip { container, objects } => { + let Some(clip) = self.shape(container, to_doc, true) else { continue }; + let mut children = vec![clip]; + children.extend(self.objects_at(objects, to_doc, depth + 1)); + out.push(Arc::new(Node::new(self.doc.alloc_id(), NodeKind::Group { children, clip: true }))); + } } } out } - fn shape(&mut self, s: &cd::Shape, to_doc: Affine) -> Option> { + /// Shape `s` placed by `to_doc`; as a clipping path when `clipping`. + fn shape(&mut self, s: &cd::Shape, to_doc: Affine, clipping: bool) -> Option> { let m = to_doc * affine(&s.matrix); let (path, live) = match &s.geometry { Geometry::Path(p) => (PathData::from_bezpath(&(m * bez(p))), None), @@ -145,7 +160,7 @@ impl Builder { // A curve of several subpaths is filled with holes where they overlap: VectorCraft's own // choice of rule for it. let rule = FillRule::EvenOdd; - let mut n = Node::new(self.doc.alloc_id(), NodeKind::Path { path, rule, live: live.map(Box::new), clipping: false, guide: false }); + let mut n = Node::new(self.doc.alloc_id(), NodeKind::Path { path, rule, live: live.map(Box::new), clipping, guide: false }); n.appearance = Appearance { items, ..Appearance::default() }.into(); Some(Arc::new(n)) } diff --git a/crates/engine/src/cmd/fileio/tests_cdr.rs b/crates/engine/src/cmd/fileio/tests_cdr.rs index 9b3d3cdb77..3056933dbf 100644 --- a/crates/engine/src/cmd/fileio/tests_cdr.rs +++ b/crates/engine/src/cmd/fileio/tests_cdr.rs @@ -410,6 +410,35 @@ fn fills_and_outlines_keep_their_colors_widths_caps_joins_and_dashes() { assert!(dash.pattern.len() == 2 && (dash.pattern[0] - 6.0).abs() < 0.01 && (dash.pattern[1] - 2.0).abs() < 0.01, "{:?}", dash.pattern); } +/// A container and the group it clips open as a clipping group: the container's shape first, as +/// the clipping path keeping its fill, then the clipped shapes. +#[test] +fn containers_open_as_clipping_groups() { + let v = V(1100); + let rect = |w: f64, extra: Vec<(u32, Vec)>| { + let mut args = vec![(20, 1u32.to_le_bytes().to_vec()), (30, v.rect(w, w, 0.0))]; + args.extend(extra); + synth::object(v, 1, &args, None) + }; + let doc = list( + b"doc ", + vec![ + list(b"filt", vec![chunk(b"fild", v.fill(1, &synth::color(5, [0, 0, 255, 0])))]), + synth::clpt(vec![(5, vec![rect(10.0, vec![]), rect(20.0, vec![])])]), + ], + ); + let page = synth::page(false, vec![synth::layer(v, [0, 0, 0, 0x98], "L", vec![rect(40.0, vec![synth::container(5)])])]); + let (doc, warnings) = super::cdr::import(&synth::riff(1100, &[chunk(b"vrsn", 1100u16.to_le_bytes().to_vec()), doc, page])).unwrap(); + assert!(warnings.is_empty(), "{warnings:?}"); + let layer = doc.layers.last().and_then(|l| l.children()).unwrap(); + let [group] = layer.as_slice() else { panic!("{layer:?}") }; + let NodeKind::Group { children, clip: true } = &group.kind else { panic!("{:?}", group.kind) }; + assert_eq!(children.len(), 3); + assert!(matches!(children[0].kind, NodeKind::Path { clipping: true, .. })); + assert_eq!(children[0].appearance.items.len(), 1, "the container keeps its fill"); + assert!(children[1..].iter().all(|n| matches!(n.kind, NodeKind::Path { clipping: false, .. }))); +} + #[test] fn other_versions_and_damaged_drawings_say_why() { let mut s = Session::new(); diff --git a/docs/mcp.md b/docs/mcp.md index cc10b8e828..f5d6fd92ad 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6842,7 +6842,8 @@ its pixels are decoded. `file.place {path}` links the file like any image. Vecto `.cdr` drawings of versions 1 to 27 (and `.cdt` templates, which open as a new untitled document) open and place as editable art, the ZIP packages that versions 14 and later save included. Each page becomes an artboard, side by side. Layers of the same name on different pages become one layer when the pages stack them in the same order, and -the master page's guidelines become guides on every page. Groups stay groups. Curves, paths, arcs and polygons (stars +the master page's guidelines become guides on every page. Groups stay groups, and a PowerClip becomes a clipping +group whose clipping path keeps the container's fill and outline. Curves, paths, arcs and polygons (stars included) become paths, and rectangles and ellipses become live shapes; a rectangle keeps each corner's radius. Uniform fills and outlines keep their colors, widths, caps, joins and dashes, and an object without a fill or outline of its own takes its style's. A library color that the drawing stores with its diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 82b20aed3d..2bd3c612d1 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -1542,7 +1542,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur - DXF export's Include Placed Images and Include Fill Hatches (`includeImages`, `includeHatches`; VectorCraft's own options, on by default and off in CNC / CAM) leave out placed images with their linked files, without decoding them, and the solid hatch after each filled area's outlines, each on its own, with one note in `warnings` when something was left out; R12 keeps its own notes. An open path's fill outline is closed, as the fill is, in every version (`an_open_path_s_fill_outline_keeps_its_closing_edge`, `fills_without_hatches_keep_their_outlines`, `images_can_be_left_out_with_their_files`, `images_and_hatches_are_left_out_independently_and_the_cnc_preset_leaves_out_both`, `placed_images_and_fill_hatches_can_be_left_out`, `include_placed_images_and_fill_hatches_follow_the_preset_and_a_change_shows_custom`). - DXF export writes a path of straight segments and circular arcs (a slot, a D shape, a rounded rectangle, a pie) as one polyline whose vertices carry a bulge (group 42) for each arc: an LWPOLYLINE in R14 and later, a POLYLINE with VERTEX entities in R12 and R13, closed when the path is closed, and it reads back as the same outline (#1299, `crates/cad/src/tests.rs`). Such a path was written as one SPLINE (a flattened polyline in R12); a path with any other curve still is. A shallow curve becomes an ARC or a bulge only when it lies on the circle within 5e-4 of its own extent as well as of the radius, and the drawing extents (`$EXTMIN`, `$EXTMAX`) reach the furthest points of every ARC and bulge. - Affinity documents in (AF.1–AF.4): `.af` (Affinity 3) and `.afdesign`/`.afphoto`/`.afpub` (Affinity 1 and 2, container versions 8–12) open and place as editable art: layers and sublayers, groups (pass-through or isolated), artboards (with their names and backgrounds) and Publisher pages side by side, curves with live corners, parametric shapes (rectangles with corner radii, ellipses, polygons, stars, pies, triangles, trapezoids), compound shapes, solid/linear/elliptical gradient fills and strokes (weight, dashes, alignment, scale-with-object), clipping by nesting, vector and pixel masks, artistic and frame text with fonts, sizes, tracking, leading and alignment, placed images (their original JPEG/PNG) and pixel layers (8/16-bit RGB, CMYK), opacity, visibility, locking and blend modes, at the document's resolution in points. Effects, adjustments, brushes and pressure profiles, transparency gradients, master pages, symbol instances (imported as their cached picture), special shapes (cloud, heart, cog…, imported as ellipses) and Affinity-only blend modes are named in the import warning. A file whose native data can't be read opens as its embedded preview with the reason, and that preview can't be placed. Save never writes back over the Affinity file and there is no Affinity export. AF.5 (from DesignCraft's import, storytold/designcraft#291) adds master pages (on a locked layer behind the pages that show them), tables (area type per cell and a line per edge), each paragraph's alignment, indents, spacing and leading, horizontal text scale, outlined text, frame text sized by its text scale, drop shadows and outer glows as live effects (inner shadows as inner glows), outline effects as strokes, colour and gradient overlays baked into the paint, embedded Affinity documents as editable content (their artboards don't become artboards), pixel layers over 64 MP at a reduced resolution and HEIC photos from their stored pixels; automatic leading (size plus the font's line gap) fitted on thumbnails; underlines and strikethrough; strokes whose style is None (every shape stores one) left out, which also brings 6 public files closer to their thumbnails; line breaks inside a paragraph; table cell text centred as Affinity centres it, also where it is taller than its cell; CMYK pixel layers converted through the document's embedded CMYK profile (relative colorimetric with black-point compensation, as each layer's colour settings name), or kept as CMYK images when there is none; outline effects on stroked shapes around their stroke; artistic text whose paragraphs align differently aligned within its longest line, a frame's first baseline at cap height, and frames whose last lines' descenders hang out made tall enough to show them (all measured on a local document's own PDF export: baselines match to 0.1 pt); a local 56-artboard document's mean thumbnail difference went from 16.2 to 11.4, and its pages' mean difference from the owner's PDF export from 12.9 to 9.3. AF.4 adds Affinity 3 artboard recognition and actual-outline clipping, source-backed JPEG/PNG raster tiles, Unicode text-run recovery, stored fallback/exact installed fonts, OpenType feature flags and compound-geometry limits. 51 public CC0/MIT/Apache-2.0 files (33 current `.af`), pinned and sha256-verified (`cargo xtask corpus --affinity`), test native retention and every-board native/SVG/PDF/PSD output for current files; selected files compare their saved thumbnails. No Affinity reopen or independent paired PSD oracle was available; [source audit and complex-font gaps](affinity-validation.md); [scope, provenance and limits](../crates/affinity/README.md). - - `.cdr` drawings of versions 1 to 27 open and place, and `.cdt` templates open as new untitled documents. `vectorcraft-cdr` reads the `WL` files of versions 1 and 2 (one page and one layer of rectangles, whole ellipses and curves with uniform fills and outlines), the RIFF chunk tree of versions 3 on and its compressed lists, and the ZIP packages of versions 14 on with the data streams of versions 16 on, and the importer maps pages to artboards side by side, layers by name, the master page's guidelines to guides on every page, groups, curves and paths, rectangles (live, with each corner's radius), ellipses (live), arcs and polygons, uniform fills in CMYK, CMY, RGB, gray and registration, and outlines with their width, caps, joins and dashes, an object without a fill or outline of its own taking its style's. A library color stored with its name and values (version 13 and later) becomes a spot swatch with its tint; one stored only by its number opens as a black spot color named by its palette and number, with a warning. Text, bitmaps, blends, contours, brush strokes, fountain, pattern, texture and PostScript fills, arrowheads and the envelopes of version 3 are left out with a warning, and encrypted, ZIP64 and split packages are refused with a message. Every record layout has a source in `crates/cdr/PROVENANCE.md`. Reading is bounded by limits on input size, inflated size, package members, nesting, chunks, objects, coordinates and dashes, where an outline's dashes count for every shape that uses it (`crates/cdr/tests/read.rs`, `crates/engine/src/cmd/fileio/tests_cdr.rs`, `crates/engine/tests/import_fuzz.rs`). + - `.cdr` drawings of versions 1 to 27 open and place, and `.cdt` templates open as new untitled documents. `vectorcraft-cdr` reads the `WL` files of versions 1 and 2 (one page and one layer of rectangles, whole ellipses and curves with uniform fills and outlines), the RIFF chunk tree of versions 3 on and its compressed lists, and the ZIP packages of versions 14 on with the data streams of versions 16 on, and the importer maps pages to artboards side by side, layers by name, the master page's guidelines to guides on every page, groups, PowerClips (as clipping groups), curves and paths, rectangles (live, with each corner's radius), ellipses (live), arcs and polygons, uniform fills in CMYK, CMY, RGB, gray and registration, and outlines with their width, caps, joins and dashes, an object without a fill or outline of its own taking its style's. A library color stored with its name and values (version 13 and later) becomes a spot swatch with its tint; one stored only by its number opens as a black spot color named by its palette and number, with a warning. Text, bitmaps, blends, contours, brush strokes, fountain, pattern, texture and PostScript fills, arrowheads and the envelopes of version 3 are left out with a warning, and encrypted, ZIP64 and split packages are refused with a message. Every record layout has a source in `crates/cdr/PROVENANCE.md`. Reading is bounded by limits on input size, inflated size, package members, nesting, chunks, objects, coordinates and dashes, where an outline's dashes count for every shape that uses it (`crates/cdr/tests/read.rs`, `crates/engine/src/cmd/fileio/tests_cdr.rs`, `crates/engine/tests/import_fuzz.rs`). - Placed documents: File › Place of a `.vectorcraft` file links to it by default (`file.place`'s `link`): one locked object showing an artboard of the document (or its art's bounds), read the way placing it without Link reads it, its symbols, patterns and images kept apart from the document's; without Link (or from bytes, not a file) it is an editable copy as before. It stays vectors in every output (SVG, PDF, EPS, EMF, DXF), and so do placed documents inside it, read from their own files up to 8 levels deep (documents that place each other stop there). On screen they draw from bitmaps cached per file and zoom step, shared by every copy and made in the background (a placeholder until ready), so a sheet of them redraws in about a millisecond; exports and prints draw them exactly. Like linked images, a save keeps only a preview of each (JPEG when opaque) unless Include Linked Files; output, and zooming past the preview, read the file again, falling back to the preview with a warning when it is gone or changed. Saves for older versions write them as plain art. Links check, update, relink, Update Links on open, Link Info (the artboard's size), Placement Options, Break Link (also Embed, Object › Expand: the editable copy placing without Link gives, its resources joining the document), Edit Original (the document in a new tab) and the Links panel cover them; saving a document updates the open documents that place it. The native format (v4) keeps data of 8 KB or more after the JSON instead of base64 in it. - Placed documents' bitmaps on screen: when a bitmap made in the background is ready, the desktop app renders the canvas again only where the objects that show its file are, when the frame shown was rendered on the UI thread and that part is at most half the canvas. Bitmaps drawn or made since a frame began are kept for that frame past the 512 MiB budget, up to 2 GiB, so a view showing more than the budget does not make them again in every frame. A bitmap that would take them past 2 GiB is not kept, and its file draws exactly at that zoom. A bitmap that can't be made (the file can't be read and there is no preview) shows the light placeholder and is not asked for again. Each ready bitmap used to render the whole canvas again, and bitmaps past the budget and bitmaps that could not be made were asked for again in every frame (`crates/render/src/tests/placed_document.rs`). - Linked PDF and `.ai` pages: File › Place with Link (the default) places a page of a PDF, `.ai` or `.ait` file read as PDF pages as a placed document, as it links an image, the page and its box (`crop`) kept with the link: Links check, update and relink it, Break Link and Object › Expand give the group placing it without Link gives, every output draws the page's vectors, and Package copies the file. Without Link, or with a password or `textAs: "outlines"`, the page is embedded. EPS and PostScript `.ai` files are still embedded (`crates/engine/src/tests/placed_document.rs`).