diff --git a/crates/cdr/PROVENANCE.md b/crates/cdr/PROVENANCE.md index 08c606077f..57c217d0e9 100644 --- a/crates/cdr/PROVENANCE.md +++ b/crates/cdr/PROVENANCE.md @@ -93,3 +93,4 @@ file is committed. | 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) | +| R48 | Bit 2 (0x04) of the outline's line type marks the outline dashed; the dashes of an outline without it are not drawn | S: every outline of versions 6 to 25 in the sample files with that bit set stores dashes, such as the dashed lines of UC `corel_dashes_cdr7.cdr` to `corel_dashes_x3.cdr`; TDF 76771 (version 15) stores dashes 2 and 1 in an outline of line type 0x22, and the file's picture draws that outline solid | sample | diff --git a/crates/cdr/src/records.rs b/crates/cdr/src/records.rs index dd3ac5e18a..d1db4cdc6f 100644 --- a/crates/cdr/src/records.rs +++ b/crates/cdr/src/records.rs @@ -355,7 +355,9 @@ pub(crate) fn outline(b: &[u8], p: &Profile, warn: &mut Vec) -> Option< 2 => Join::Bevel, _ => Join::Miter, }; - let dashes = if dashes.iter().any(|d| *d > 0.0) { dashes } else { Vec::new() }; + // Bit 2 of the line type marks the outline dashed; without it the dashes stored are not drawn + // (R48). + let dashes = if line_type & 4 != 0 && dashes.iter().any(|d| *d > 0.0) { dashes } else { Vec::new() }; Some((id, Some(Outline { width, color, cap, join, dashes }))) } diff --git a/crates/cdr/tests/read.rs b/crates/cdr/tests/read.rs index 3e39384dad..c114d6392d 100644 --- a/crates/cdr/tests/read.rs +++ b/crates/cdr/tests/read.rs @@ -1401,6 +1401,25 @@ fn outlines_flagged_none_and_dashes_read() { assert_eq!((o.cap, o.join), (Cap::Square, vectorcraft_cdr::model::Join::Bevel)); } +/// Dashes stored in an outline whose line type doesn't mark it dashed (bit 2) are not drawn: the +/// outline is solid. +#[test] +fn dashes_are_drawn_only_when_the_line_type_marks_them() { + let black = synth::color(2, [0, 0, 0, 100]); + for version in [700, 1200, 1500] { + for (line_type, dashed) in [(2, false), (0x22, false), (0x42, false), (4, true), (0x24, true), (0x44, true)] { + let v = V(version); + let outline = v.outline(9, synth::Pen { line_type, width: 1.0, cap: 0, join: 0 }, &black, &[2, 1]); + let style = vec![(10, 9u32.to_le_bytes().to_vec()), (30, v.points(&[(0.0, 0.0, 0), (10.0, 0.0, 0x40)]))]; + let page = synth::page(false, vec![synth::layer(v, [0, 0, 0, 0x98], "L", vec![synth::object(v, 3, &style, None)])]); + let d = read(&synth::file_of(version, vec![list(b"otlt", vec![chunk(b"outl", outline)]), page]), Limits::default()).unwrap(); + let s = shapes(&d.pages[0].layers[0].objects); + let o = s[0].outline.as_ref().unwrap(); + assert_eq!(o.dashes.is_empty(), !dashed, "{version} {line_type:#x}: {:?}", o.dashes); + } + } +} + #[test] fn library_colors_from_version_13_keep_their_names_and_tints() { // A model 21 color (blue, green, red, tint) shown at 50 %, and its library name. diff --git a/crates/engine/src/cmd/fileio/tests_cdr.rs b/crates/engine/src/cmd/fileio/tests_cdr.rs index e2980b525c..11c544de2a 100644 --- a/crates/engine/src/cmd/fileio/tests_cdr.rs +++ b/crates/engine/src/cmd/fileio/tests_cdr.rs @@ -385,7 +385,8 @@ fn fills_and_outlines_keep_their_colors_widths_caps_joins_and_dashes() { let v = V(1300); let red = synth::color(5, [0, 0, 255, 0]); let black = synth::color(2, [0, 0, 0, 100]); - let pen = synth::Pen { line_type: 0, width: 2.0, cap: 1, join: 2 }; + // Line type 4: a dashed outline. + let pen = synth::Pen { line_type: 4, width: 2.0, cap: 1, join: 2 }; let args = vec![ (20, 1u32.to_le_bytes().to_vec()), (10, 2u32.to_le_bytes().to_vec()),