diff --git a/crates/cdr/PROVENANCE.md b/crates/cdr/PROVENANCE.md index 83815aa5d9..08c606077f 100644 --- a/crates/cdr/PROVENANCE.md +++ b/crates/cdr/PROVENANCE.md @@ -92,3 +92,4 @@ file is committed. | 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) | +| R47 | Argument 8000 marks an object seen through: a lens or a transparency. The reader does not apply it, and names lenses in the warnings | K L859 (the argument); S: of the sample files of versions 7 to 25, the argument is on the see-through objects that the pictures of UC `corel_lens_test_cdr7.cdr` to `corel_lens_test_x3.cdr`, LT `square_blackfill_nooutline_transparency50percent` of `testset/12` to `testset/25` and TDF 80103 show, and otherwise only on text in UC `fancytext_cdr7.cdr` to `fancytext_x3.cdr` and on two objects of TDF 114901. The value K reads at byte 10 (14 from version 13) is not the transparency in these samples | public-spec (the argument: K; what it marks: sample; its layout: unconfirmed, and it is not read) | diff --git a/crates/cdr/README.md b/crates/cdr/README.md index f59719912e..6946f5b11e 100644 --- a/crates/cdr/README.md +++ b/crates/cdr/README.md @@ -25,7 +25,8 @@ with each object's transform. It does not write `.cdr` files. | Styles (`LIST stlt`, versions 7 to 15) that objects name | the fill and outline of an object that has none of its own | Text, bitmaps, linked groups (blends, contours, brush strokes), B-spline curves, fountain, -pattern, texture and PostScript fills and outline arrowheads are not read; the drawing's +pattern, texture and PostScript fills, outline arrowheads, lenses and object transparency are not +read; the drawing's `warnings` name each kind it held. Drawings of versions after 27 are refused, and so are packages that are encrypted, ZIP64 archives or split across files. diff --git a/crates/cdr/src/build.rs b/crates/cdr/src/build.rs index 5462eb0920..fe54429fea 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_LENS: u32 = 8000; const ARG_CONTAINER: u32 = 8005; const ARG_POLYGON: u32 = 11000; const ARG_GUIDE: u32 = 16000; @@ -447,6 +448,10 @@ impl<'a, 'b> Ctx<'a, 'b> { return self.inline_object(&loda, outer); } let geometry = self.geometry(&loda)?; + // A lens or transparency (R47) is not applied: the shape shows opaque. + if loda.arg(ARG_LENS).is_some() { + push(self.warn, Warning::Lenses); + } // A transform that is there but can't be read is damage; the shape stays where it is. let matrix = match own_chunk(ix, list, &[b"trfd"]) { None => Matrix::IDENTITY, diff --git a/crates/cdr/src/model.rs b/crates/cdr/src/model.rs index c901d65d91..8cc15d6271 100644 --- a/crates/cdr/src/model.rs +++ b/crates/cdr/src/model.rs @@ -175,6 +175,8 @@ pub enum Warning { Arrowheads, /// Envelopes, which are not applied: the shapes under them keep their outlines. Envelopes, + /// Lenses and object transparency, which are not applied: the objects show opaque. + Lenses, /// Content nested deeper, or past the counts, that a read takes. TooDeep, /// Chunks or records that end early or don't parse. diff --git a/crates/cdr/tests/read.rs b/crates/cdr/tests/read.rs index 815688fba6..3e39384dad 100644 --- a/crates/cdr/tests/read.rs +++ b/crates/cdr/tests/read.rs @@ -1264,6 +1264,22 @@ fn a_missing_or_repeating_clipped_group_keeps_the_container() { assert_eq!(d.warnings, vec![Warning::TooDeep]); } +/// An object with a lens or transparency (argument 8000) comes in opaque, with the lenses +/// warning; one without the argument gives no warning. +#[test] +fn lenses_and_transparency_are_named_in_the_warnings() { + for (version, lens) in [(1000, [1u8, 0, 0, 0].to_vec()), (1200, [5, 0, 0, 0].to_vec()), (1500, [0x14, 5, 0, 0, 0x75, 0, 0, 0, 5].to_vec())] { + let v = V(version); + let plain = clip_rect(v, 10.0, &[], [0.0, 0.0]); + let d = read(&clip_drawing(version, vec![], vec![plain]), Limits::default()).unwrap(); + assert!(d.warnings.is_empty(), "{version}: {:?}", d.warnings); + let see_through = clip_rect(v, 10.0, &[(8000, lens)], [0.0, 0.0]); + let d = read(&clip_drawing(version, vec![], vec![see_through]), Limits::default()).unwrap(); + assert_eq!(shapes(&d.pages[0].layers[0].objects).len(), 1, "{version}"); + assert_eq!(d.warnings, vec![Warning::Lenses], "{version}"); + } +} + #[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 1658dc5dba..700a5a8671 100644 --- a/crates/engine/src/cmd/fileio/cdr.rs +++ b/crates/engine/src/cmd/fileio/cdr.rs @@ -24,6 +24,7 @@ const UNKNOWN_COLORS: &str = "colors in CDR color models VectorCraft doesn't rea const SPOT_LOOKS: &str = "CDR library colors that the drawing stores only by number were opened as black spot colors"; const ARROWHEADS: &str = "CDR outline arrowheads were left out"; const ENVELOPES: &str = "CDR envelopes were not applied, and the shapes under them keep their outlines"; +const LENSES: &str = "CDR lenses and object transparency were not applied, and the objects they are on show opaque"; const TOO_DEEP: &str = "parts of the drawing nested too deeply, or past the import limits, were left out"; const DAMAGED: &str = "damaged parts of the drawing were left out"; const PAGES_CUT: &str = "CDR pages longer than 163,830 pt were opened at that length, and art near their edges lies outside the artboard"; @@ -37,6 +38,7 @@ fn note(w: Warning) -> &'static str { Warning::SpotLooks => SPOT_LOOKS, Warning::Arrowheads => ARROWHEADS, Warning::Envelopes => ENVELOPES, + Warning::Lenses => LENSES, Warning::TooDeep => TOO_DEEP, Warning::Damaged => DAMAGED, } diff --git a/crates/engine/src/cmd/fileio/tests_cdr.rs b/crates/engine/src/cmd/fileio/tests_cdr.rs index 3056933dbf..e2980b525c 100644 --- a/crates/engine/src/cmd/fileio/tests_cdr.rs +++ b/crates/engine/src/cmd/fileio/tests_cdr.rs @@ -439,6 +439,17 @@ fn containers_open_as_clipping_groups() { assert!(children[1..].iter().all(|n| matches!(n.kind, NodeKind::Path { clipping: false, .. }))); } +/// An object with a lens or transparency opens opaque, and the warnings say so. +#[test] +fn lenses_and_transparency_are_named_in_the_warnings() { + let v = V(1200); + let args = vec![(30, v.rect(10.0, 10.0, 0.0)), (8000, vec![5, 0, 0, 0])]; + let page = synth::page(false, vec![synth::layer(v, [0, 0, 0, 0x98], "L", vec![synth::object(v, 1, &args, None)])]); + let (doc, warnings) = super::cdr::import(&synth::riff(1200, &[chunk(b"vrsn", 1200u16.to_le_bytes().to_vec()), page])).unwrap(); + assert_eq!(paths(&doc).len(), 1); + assert_eq!(warnings, ["CDR lenses and object transparency were not applied, and the objects they are on show opaque"]); +} + #[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 f5d6fd92ad..1d4a65c3f9 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -6849,7 +6849,8 @@ fills and outlines keep their colors, widths, caps, joins and dashes, and an obj takes its style's. A library color that the drawing stores with its name and values (version 13 and later) becomes a spot swatch with its tint, and one stored only by its number opens as a black spot color. Text, bitmaps, blends, contours, brush strokes, other objects the reader doesn't read yet, -fountain, pattern, texture and PostScript fills, and outline arrowheads are left out. The `warnings` of +fountain, pattern, texture and PostScript fills, and outline arrowheads are left out, and lenses and object +transparency are not applied. The `warnings` of `document.open` name each of these kinds the drawing had, and say when damaged parts or parts past the import limits were left out. Drawings of versions after 27 are refused with a message, and so are packages that are encrypted, ZIP64 archives or split across files. VectorCraft doesn't write `.cdr` files. diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 2bd3c612d1..09e349f523 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, 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`). + - `.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, lenses, object transparency 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`).