diff --git a/crates/engine/src/cmd/fileio/eps.rs b/crates/engine/src/cmd/fileio/eps.rs index 105f4deb8a..0ff99200c8 100644 --- a/crates/engine/src/cmd/fileio/eps.rs +++ b/crates/engine/src/cmd/fileio/eps.rs @@ -33,7 +33,7 @@ pub fn specs() -> Vec { "Export EPS", [], None, - "{path?, level?: 2|3 (default; PostScript language level: 3 writes smooth gradients and masks transparent image pixels out, 2 steps gradients and writes those pixels white), previewFormat?: none|tiffBw|tiffColor (default: a TIFF preview other apps show), transparentPreview?: true (else on white), overprints?: preserve (default; paper white fills and strokes knock out with document.setup discardWhiteOverprint; white linked to a spot swatch at a tint above 0% still overprints)|discard, flattenerPreset?: \"medium\" (default; high, low or a saved preset: flattener.presets.list), flattener?: {the options of object.flattenTransparency over the preset}, embedFonts?: true (type is always written as outlines, so no fonts are needed), includeLinkedFiles?: false (the embedded document keeps linked images whole, not just their previews), thumbnails?: true (a PNG thumbnail in the file), cmykPostScript?: true (RGB documents written in CMYK), compatibleGradients?: false (stepped gradients at level 3 too), selectedOnly?: false, useArtboards?: true (one file per chosen artboard, artboards?/range?, {stem}_{artboard}.eps, the bounding box the artboard; with two or more, also the central file {stem}.eps first: the whole document, the bounding box the visible art; none when no art shows) | false (one file, the bounding box the visible art, y up from the first artboard's bottom-left corner, even when artboards are named; the default when none are named), format?: \"eps\", artboard?: i | artboards?: [i…] | range?: \"1-3, 5\" (the artboards written; naming them without useArtboards works as useArtboards: true)} → {path, bytes, warnings, files?}; no path → {dataBase64, …}. Transparency is flattened with the preset (EPS has none); the native document rides along in comments, for reopening the file as it was. Same as document.export {format: eps}. A key EPS doesn't take, and an unknown key inside flattener, are refused", + "{path?, level?: 2|3 (default; PostScript language level: 3 writes smooth gradients and masks transparent image pixels out, 2 steps gradients and writes those pixels white), previewFormat?: none|tiffBw|tiffColor (default: a TIFF preview other apps show), transparentPreview?: true (else on white), overprints?: preserve (default; paper white fills and strokes knock out with document.setup discardWhiteOverprint; white linked to a spot swatch that has a color, at a tint above 0%, still overprints)|discard, flattenerPreset?: \"medium\" (default; high, low or a saved preset: flattener.presets.list), flattener?: {the options of object.flattenTransparency over the preset}, embedFonts?: true (type is always written as outlines, so no fonts are needed), includeLinkedFiles?: false (the embedded document keeps linked images whole, not just their previews), thumbnails?: true (a PNG thumbnail in the file), cmykPostScript?: true (RGB documents written in CMYK), compatibleGradients?: false (stepped gradients at level 3 too), selectedOnly?: false, useArtboards?: true (one file per chosen artboard, artboards?/range?, {stem}_{artboard}.eps, the bounding box the artboard; with two or more, also the central file {stem}.eps first: the whole document, the bounding box the visible art; none when no art shows) | false (one file, the bounding box the visible art, y up from the first artboard's bottom-left corner, even when artboards are named; the default when none are named), format?: \"eps\", artboard?: i | artboards?: [i…] | range?: \"1-3, 5\" (the artboards written; naming them without useArtboards works as useArtboards: true)} → {path, bytes, warnings, files?}; no path → {dataBase64, …}. Transparency is flattened with the preset (EPS has none); the native document rides along in comments, for reopening the file as it was. Same as document.export {format: eps}. A key EPS doesn't take, and an unknown key inside flattener, are refused", has_doc, export_eps )] diff --git a/crates/eps/src/print/tests.rs b/crates/eps/src/print/tests.rs index e560f7ab8d..f32bebaa4c 100644 --- a/crates/eps/src/print/tests.rs +++ b/crates/eps/src/print/tests.rs @@ -132,6 +132,15 @@ fn over(under: Option, art: &[Node]) -> Document { /// Ink `ink`'s plate of `d` as the print plan separates it for PostScript, and as a PostScript /// separation at `level` read back, both drawn at 1 px a point. fn plate_of(d: &Document, ink: &str, level: Level) -> (Image, Image) { + let area = Rect::new(0.0, 0.0, 200.0, 100.0); + let (plate, out) = separation(d, ink, level); + let back = crate::import(&out.bytes).unwrap().document; + (render_region(&plate, area, 1.0), render_region(&back, area, 1.0)) +} + +/// Ink `ink`'s plate of `d` as the print plan separates it for PostScript, and that plate written +/// as a PostScript separation at `level`. +fn separation(d: &Document, ink: &str, level: Level) -> (Document, EpsOutput) { let area = Rect::new(0.0, 0.0, 200.0, 100.0); let settings = serde_json::from_value(serde_json::json!({"output": {"mode": "separations"}})).unwrap(); let plan = vectorcraft_pdf::plan(d, &vectorcraft_pdf::PrintOptions { settings, postscript: true, ..Default::default() }).unwrap(); @@ -151,8 +160,7 @@ fn plate_of(d: &Document, ink: &str, level: Level) -> (Image, Image) { }; let out = print(&[page], &[0], &PrintJob { level, ..PrintJob::default() }).unwrap(); assert!(level == Level::Three || !text(&out).contains("shfill"), "Level 2 has no smooth shadings"); - let back = crate::import(&out.bytes).unwrap().document; - (render_region(plate, area, 1.0), render_region(&back, area, 1.0)) + (plate.clone(), out) } /// Ink `ink`'s PostScript plate of `art` over a page of 100% `ink` (`under`), checked against the @@ -234,6 +242,44 @@ fn an_overprinting_gradient_keeps_the_ink_below_where_it_puts_none_on_a_postscri assert_keeps_the_ink_below(&cases); } +/// With Discard White Overprint, a process white fill or stroke marked to overprint knocks out the +/// cyan below it on the Cyan plate and is written without overprinting, as in composite output. +/// Without the setting, and for a white linked to a spot swatch with a color at a tint above 0%, +/// the cyan below it prints. +#[test] +fn white_overprints_knock_out_on_postscript_plates_with_discard_white_overprint() { + let cyan = Paint::solid(Color::cmyk(1.0, 0.0, 0.0, 0.0)); + let white = Paint::solid(Color::cmyk(0.0, 0.0, 0.0, 0.0)); + let spot_white = Paint::Solid { color: Color::cmyk(0.0, 0.0, 0.0, 0.0), swatch: Some("White Ink".into()), tint: 1.0 }; + // The fill is sampled in the rectangle's middle, the stroke on its top edge. + let (fill_at, stroke_at) = ((100, 50), (100, 10)); + let cases = [ + ("process white fill", overprinting(white.clone(), Paint::None), fill_at, true, true), + ("process white stroke", overprinting(Paint::None, white.clone()), stroke_at, true, true), + ("process white fill without the setting", overprinting(white.clone(), Paint::None), fill_at, false, false), + ("process white stroke without the setting", overprinting(Paint::None, white), stroke_at, false, false), + ("spot white fill", overprinting(spot_white.clone(), Paint::None), fill_at, true, false), + ("spot white stroke", overprinting(Paint::None, spot_white), stroke_at, true, false), + ]; + let mut failed = vec![]; + for (name, art, (x, y), discard, knocks_out) in cases { + let mut d = over(Some(cyan.clone()), &[art]); + d.swatches.push(Swatch { name: "White Ink".into(), paint: Paint::solid(Color::cmyk(0.0, 0.0, 0.0, 0.0)), global: true, spot: true }); + d.setup.discard_white_overprint = discard; + for level in [Level::Three, Level::Two] { + let (_, printed) = plate_of(&d, "Cyan", level); + let paper = printed.over_white(x, y)[0] >= 254; + if paper != knocks_out { + failed.push(format!("{name} at level {level:?}: knocked out {paper}, expected {knocks_out}")); + } + if text(&separation(&d, "Cyan", level).1).contains("true op") { + failed.push(format!("{name} at level {level:?}: overprints on the plate")); + } + } + } + assert!(failed.is_empty(), "{failed:#?}"); +} + #[test] fn an_overprinting_gradient_with_a_hard_stop_at_an_end_keeps_the_ink_below_on_a_postscript_plate() { // Two stops at an end, one with cyan and one without: Level 2's bands pad with the end stop, diff --git a/crates/eps/src/scene.rs b/crates/eps/src/scene.rs index b862e5e0dd..8452decdf6 100644 --- a/crates/eps/src/scene.rs +++ b/crates/eps/src/scene.rs @@ -541,8 +541,8 @@ impl<'a> Scene<'a> { /// Whether a fill or stroke of `paint` marked to overprint (`overprint`) does: not when it is /// paper white with Discard White Overprint in Output (Document Setup); a spot white still /// overprints ([`Self::spot_ink`]). On a plate the colors are already the plate's coverage, and - /// the plate's document already left out or kept each overprinting paint by that setting, so - /// white is not checked there. + /// the plate's document has already turned overprinting off for each white the setting knocks + /// out, so white is not checked there. fn overprints(&self, overprint: bool, paint: &Paint) -> bool { let discarded = !self.plate && self.doc.setup.discard_white_overprint && vectorcraft_doc::overprint::is_white(paint) && !self.spot_ink(paint); overprint && !discarded @@ -634,7 +634,9 @@ impl<'a> Scene<'a> { && vectorcraft_doc::overprint::is_white(p) && vectorcraft_doc::overprint::DiscardWhite::of(self.doc).discards(p); let on = self.overprint_on(n.colorize_overprints() && !discarded); - self.colorized_image(im, blob, p, on); + // Inside an overprinting pattern fill the image overprints with its tiles. + let overprinting = self.overprinting; + self.colorized_image(im, blob, p, overprinting); self.overprint_off(on); } _ => self.image(&im.key, blob, im.width, im.height, im.xf), diff --git a/crates/eps/src/tests.rs b/crates/eps/src/tests.rs index 44994d11d4..3b45578deb 100644 --- a/crates/eps/src/tests.rs +++ b/crates/eps/src/tests.rs @@ -1353,6 +1353,27 @@ fn an_overprinting_colorized_image_writes_only_its_process_inks() { assert!(ps.contains("VCdn0 setcolorspace") && ps.contains("/DeviceCMYK setcolorspace"), "{ps}"); } +/// An overprinting colorized image in the tile of an overprinting pattern fill is written in only +/// the process inks it puts down, as it is outside a pattern, so the inks below it stay. +#[test] +fn an_overprinting_colorized_image_in_an_overprinting_pattern_writes_only_its_process_inks() { + let mut d = overprinting_colorized_doc(vec![0, 128, 255], Color::cmyk(1.0, 0.0, 0.0, 0.0), true); + let id = d.layers[0].children().unwrap()[0].id; + let image = d.remove(id).unwrap(); + d.patterns.push(vectorcraft_doc::PatternDef::new("tile", vec![image])); + let mut n = red_rect(&mut d); + if let Some(AppearanceItem::Fill(f)) = n.appearance.items.first_mut() { + f.paint = Paint::Pattern { pattern: "tile".into(), xf: Affine::IDENTITY }; + f.overprint = true; + } + let layer = d.layers[0].id; + d.insert(Some(layer), 0, n).unwrap(); + for level in Level::ALL { + let ps = page_of(&d, &EpsOptions { level, ..opts(&d) }); + assert!(ps.contains("true op") && ps.contains("VCdn0 setcolorspace") && !ps.contains("/DeviceCMYK setcolorspace"), "{level:?}: {ps}"); + } +} + /// On a separation plate, an overprinting colorized image whose color puts none of the plate's ink /// down is drawn as nothing, so the ink below stays; one that knocks out, or whose overprint is /// discarded, is drawn as paper. (The plate's colors come from the separator, which has already diff --git a/crates/pdf/src/print/plates.rs b/crates/pdf/src/print/plates.rs index 38e46654cf..f93b7a4d8a 100644 --- a/crates/pdf/src/print/plates.rs +++ b/crates/pdf/src/print/plates.rs @@ -238,8 +238,9 @@ impl<'a> Separator<'a> { /// Overprinting fills and strokes of `a`'s subtree with a Normal blending mode, and /// overprinting character fills and strokes, that put none of ink `plate` down leave its plate - /// as it is: they are drawn as nothing on it (paper white ones that `discard_white` knocks out - /// aside, [`DiscardWhite::discards`]). A writer without blending modes (PostScript) then keeps the ink below them, + /// as it is: they are drawn as nothing on it. Paper white ones that `discard_white` knocks out + /// ([`DiscardWhite::discards`]) stop overprinting instead, and knock out the ink below them on + /// the plate as in composite output. A writer without blending modes (PostScript) then keeps the ink below them, /// where it would draw their Darken as a knockout. One that puts any ink down is drawn, and on /// a PostScript plate its ink replaces the ink below, as a nonzero component of an overprinting /// color replaces the backdrop's with overprint mode 1 (ISO 32000-1, 11.7.4.2). On a @@ -259,6 +260,9 @@ impl<'a> Separator<'a> { } let image = whole && n.extras().colorize.as_deref().is_some_and(|p| self.no_ink(plate, p)); for it in &mut n.appearance.items { + if it.overprint() && discard_white.discards(it.paint()) { + *it.overprint_mut() = false; + } let normal = match it { AppearanceItem::Fill(l) => l.blend == BlendMode::Normal, AppearanceItem::Stroke(l) => l.blend == BlendMode::Normal, @@ -274,6 +278,8 @@ impl<'a> Separator<'a> { } if let NodeKind::Text(t) = &mut n.kind { for r in &mut t.runs { + r.style.overprint_fill &= !discard_white.discards(&r.style.fill); + r.style.overprint_stroke &= !discard_white.discards(&r.style.stroke); if inkless(r.style.overprint_fill, &r.style.fill) { r.style.fill = Paint::None; } else if r.style.overprint_fill { diff --git a/docs/mcp.md b/docs/mcp.md index da6743e1f2..ca9f0e63e6 100644 --- a/docs/mcp.md +++ b/docs/mcp.md @@ -10461,7 +10461,8 @@ shadings and masks transparent image pixels out; `level: 2` writes gradients as `compatibleGradients`) and transparent pixels white. Type is always glyph outlines, so no fonts are needed (`embedFonts` is accepted); spot colours are Separation colour spaces, and overprinting fills and strokes overprint unless `overprints: "discard"`. With `discardWhiteOverprint` (`document.setup`, on by default) paper white ones knock out -instead; a white linked to a spot swatch at a tint above 0% still overprints. RGB documents are written in CMYK unless +instead; a white linked to a spot swatch that has a color, at a tint above 0%, still overprints. RGB documents are +written in CMYK unless `cmykPostScript: false`. A freeform gradient is written as an image, in CMYK when every point is CMYK or when every point is Gray in a file written in CMYK. When the file would hold an image that can't be decoded, the image is left out, and `warnings` carries "an image couldn't be decoded and is missing diff --git a/docs/target-app-parity.md b/docs/target-app-parity.md index 377d2d0fdf..95fedb08bf 100644 --- a/docs/target-app-parity.md +++ b/docs/target-app-parity.md @@ -809,7 +809,7 @@ since 2026-10-01. - **EPS Save with Use Artboards:** Save As › EPS Options show Use Artboards with All or Range, for a separate file per artboard ([saving in EPS](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/save-artwork-in-eps-format.html)), unchecked by default (the scripting reference's EPS save options list `saveMultipleArtboards` with a default of false, [scripting reference](https://web.archive.org/web/20160803105056/https://wwwimages.adobe.com/content/dam/Adobe/en/devnet/illustrator/sdk/CC2015_3/Illustrator%20JavaScript%20Scripting%20Reference.pdf)). Unchecked, Save writes one file whose bounding box fits all the visible art, as Export does, without the artboards' background colors; when no art shows, the page is the first artboard in its color. An opened EPS saved back this way loses its page margins. Checked with two or more chosen artboards, the file at the path is the central file of the visible art and each artboard is also written to `_.eps` beside it. Checked with one chosen artboard, VectorCraft writes that artboard as the page of the file at the path alone (the behavior Save had since #4293). Evidence: `cmd::fileio::tests_artboard_fill::eps_save_draws_the_color_on_an_artboard_page`, `tests::save::eps_save_without_use_artboards_fits_the_box_to_art_past_the_artboard`, `tests::save::opened_eps_saves_to_its_own_file_around_its_art_or_on_its_page`, `tests::save::eps_save_with_use_artboards_writes_the_central_file_and_one_per_artboard`, `dialogs::save_options::tests::eps_save_as_shows_use_artboards_off_and_writes_the_art_or_the_artboard`. - **EPS Options custom flattener settings:** the help page describes flattening an EPS's transparency with a preset or with custom options, adjusted through Custom ([saving in EPS](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/save-artwork-in-eps-format.html)). EPS Options now has Custom… beside the flattener Preset. It opens Custom Transparency Flattener Options on the settings the export would use: the raster/vector balance, both resolutions, the text and stroke outline switches, Clip Complex Regions and Anti-alias Rasters. OK goes back to EPS Options with the preset shown as [Custom], the export flattens with those settings, and the next EPS Options start from them; choosing a preset drops them, and Cancel goes back to EPS Options unchanged. Preserve Alpha Transparency stays off, and overprints are kept only with Overprints set to Preserve. The [Custom] label, the remembering, the Cancel behavior, Anti-alias Rasters and the ranges (balance 0 to 100, resolutions 1 to 2400 ppi) are VectorCraft's own. Evidence: `dialogs::tests_eps::custom_flattener_options_start_from_the_preset_and_cancel_goes_back_unchanged`, `custom_flattener_options_are_exported_and_remembered_until_a_preset_is_chosen`, `bad_custom_flattener_options_keep_the_dialog_open`. -- **EPS export and Discard White Overprint:** the help page describes Discard White Overprint as taking the overprint attribute off white objects in output, without changing the artwork ([white overprint](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/white-overprint.html)). EPS export and composite PostScript printing now follow Discard White Overprint in Output (Document Setup), as PDF export does: a white fill or stroke marked to overprint knocks out while the setting is on and overprints while it is off. The same page says the setting covers process white and not spot white, so in EPS export a white fill linked to a spot swatch keeps overprinting. The tiles of an overprinting pattern fill overprint with it. Evidence: `cmd::fileio::tests_eps::overprints_are_kept_or_discarded`, `tests::tiles_overprint_with_their_overprinting_pattern`, `tests::white_type_fills_knock_out_with_discard_white_overprint`, `tests::spot_white_fills_overprint_with_discard_white_overprint`. +- **EPS export and Discard White Overprint:** the help page describes Discard White Overprint as taking the overprint attribute off white objects in output, without changing the artwork ([white overprint](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/white-overprint.html)). EPS export and PostScript printing, composite and separated, now follow Discard White Overprint in Output (Document Setup), as PDF export does: a white fill or stroke marked to overprint knocks out while the setting is on and overprints while it is off. The same page says the setting covers process white and not spot white, so a white fill linked to a spot swatch that has a color keeps overprinting. The tiles of an overprinting pattern fill overprint with it. Evidence: `cmd::fileio::tests_eps::overprints_are_kept_or_discarded`, `tests::tiles_overprint_with_their_overprinting_pattern`, `tests::white_type_fills_knock_out_with_discard_white_overprint`, `tests::spot_white_fills_overprint_with_discard_white_overprint`, `print::tests::white_overprints_knock_out_on_postscript_plates_with_discard_white_overprint`. - **Save PDF custom flattener settings:** the help page describes the Advanced section's flattener preset for PDF 1.3 saves of transparent art, with a Custom button for adjusting the flattener settings, and says neither is available at PDF 1.4 and later ([PDF options](https://helpx.adobe.com/illustrator/using/pdf-options.html)). Save PDF › Advanced now has Custom… beside Flattener preset, enabled for PDF 1.3, PDF/X-1a and PDF/X-3. It opens Custom Transparency Flattener Options on the settings the save would use: the raster/vector balance, both resolutions, the text and stroke outline switches and Anti-alias Rasters; Clip Complex Regions shows on, as the PDF 1.3 writer always clips, overprints are kept only with Overprint set to Preserve, and Preserve Alpha Transparency shows off, as PDF 1.3 rasters keep no alpha. OK goes back to Save PDF with the preset shown as [Custom] and the save flattens with those settings; settings equal to the preset's leave its name, choosing a preset drops them, and Cancel goes back unchanged. PDF presets keep the flattener preset but not these settings, and Save Preset… says so while they are set. `ui.savePdfDialog` keeps a `flattener` it is given. The [Custom] label, the Cancel behavior, Anti-alias Rasters, the editor's absence from the PDF preset editor and the ranges (balance 0 to 100, resolutions 1 to 2400 ppi) are VectorCraft's own. Evidence: `dialogs::save_pdf::tests::custom_is_enabled_where_the_save_flattens`, `custom_starts_from_the_preset_and_cancel_goes_back_unchanged`, `custom_options_are_written_until_a_preset_is_chosen`, `custom_options_equal_to_the_preset_leave_its_name`, `custom_shows_alpha_as_the_pdf_1_3_writer_drops_it`, `save_preset_says_it_leaves_the_custom_flattener_options_out`, `save_pdf_opens_with_the_flattener_options_given_and_refuses_bad_ones`. - **Raster export backgrounds (#6125):** a raster export draws its background under the finished art, and blend modes read only the art below them, as on the canvas. An Outer Glow in Screen mode on the bare page shows in a PNG on white and in a JPEG. Flatten Transparency puts its white under the finished art the same way. Evidence: `tests::file::a_screen_outer_glow_is_in_raster_exports`, `tests::objectfx::a_screen_outer_glow_on_the_bare_page_shows_on_a_background`, `tests::knockout::page_knockout_and_isolated_blending`, `tests::knockout::no_blend_mode_reads_the_background`, `tests::cmykflatten::every_blend_mode_flattens_to_the_canvas_pixels_in_cmyk`.