From 1d2c2744665a17ab6fae9fbb0427e01cd7478cc5 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Mon, 23 Nov 2026 04:57:10 -0800 Subject: [PATCH] EPS: a colorized image in a white spot ink keeps overprinting Discard White Overprint removed the overprint of a colorized image whose color was white, even when that color was a tint of a spot swatch, which the EPS writer still writes as that spot ink. A spot white now keeps its overprint; process white still knocks out. Document::spot_ink tells a tint above 0% of a spot swatch with a solid color apart from paper white. --- crates/doc/src/overprint.rs | 7 +++++++ crates/eps/src/scene.rs | 8 +++++--- crates/eps/src/tests.rs | 15 +++++++++++++++ 3 files changed, 27 insertions(+), 3 deletions(-) diff --git a/crates/doc/src/overprint.rs b/crates/doc/src/overprint.rs index 8cc4565ff1..afe8ceedcc 100644 --- a/crates/doc/src/overprint.rs +++ b/crates/doc/src/overprint.rs @@ -299,6 +299,13 @@ impl Document { self.swatches_iter().filter(|s| s.spot).map(|s| s.name.clone()).collect() } + /// Whether `p` is a tint above 0% of a spot swatch with a solid color, which prints as an ink + /// of its own even when its color is white ([`is_white`]); a link is judged by the first + /// swatch of its name. + pub fn spot_ink(&self, p: &Paint) -> bool { + matches!(p, Paint::Solid { swatch: Some(name), tint, .. } if *tint > 0.0 && self.swatch(name).is_some_and(|s| s.spot && s.paint.color().is_some())) + } + /// Files from before per-fill/stroke overprint listed the objects marked Overprint Black /// under [`LEGACY_OVERPRINT_KEY`]: their 100% black fills and strokes overprint now. pub fn migrate_overprint_black(&mut self) { diff --git a/crates/eps/src/scene.rs b/crates/eps/src/scene.rs index c0e76b53a6..76c6181ced 100644 --- a/crates/eps/src/scene.rs +++ b/crates/eps/src/scene.rs @@ -582,10 +582,12 @@ impl<'a> Scene<'a> { && self.o.overprint == Overprint::Preserve && n.colorize_overprints() && vectorcraft_doc::overprint::is_white(p) => {} - // Off a plate, a white color knocks out with Discard White Overprint (a - // plate's colors come from the separator, which has applied it already). + // Off a plate, a white process color knocks out with Discard White Overprint + // (a plate's colors come from the separator, which has applied it already); a + // spot ink with a white color still overprints, as it is written as that ink. Some(p @ Paint::Solid { .. }) if blob.is_none_or(|b| b.gray_source().is_some()) => { - let discarded = !self.plate && self.doc.setup.discard_white_overprint && vectorcraft_doc::overprint::is_white(p); + let discarded = + !self.plate && self.doc.setup.discard_white_overprint && vectorcraft_doc::overprint::is_white(p) && !self.doc.spot_ink(p); let on = self.overprint_on(n.colorize_overprints() && !discarded); self.colorized_image(im, blob, p, on); self.overprint_off(on); diff --git a/crates/eps/src/tests.rs b/crates/eps/src/tests.rs index caafdc0f99..f505dbc0ec 100644 --- a/crates/eps/src/tests.rs +++ b/crates/eps/src/tests.rs @@ -1272,6 +1272,21 @@ fn a_plate_leaves_out_an_overprinting_image_without_its_ink() { assert!(body(true, false).contains("image"), "{}", body(true, false)); } +/// With Discard White Overprint on, an overprinting colorized image in a tint of a spot ink whose +/// color is white still overprints: it is written as that ink, which is not paper white. +#[test] +fn a_white_spot_ink_colorized_image_overprints_with_discard_white_overprint() { + let mut d = overprinting_colorized_doc(vec![0, 128, 255], Color::WHITE, true); + d.swatches.push(Swatch { name: "White Ink".into(), paint: Paint::solid(Color::WHITE), global: true, spot: true }); + let id = d.layers[0].children().unwrap()[0].id; + d.node_mut(id).unwrap().extras_mut().colorize = Some(Box::new(Paint::Solid { color: Color::WHITE, swatch: Some("White Ink".into()), tint: 0.5 })); + d.setup.discard_white_overprint = true; + for level in Level::ALL { + let ps = text(&export(&d, &EpsOptions { level, ..opts(&d) }, None, None).unwrap()); + assert!(ps.contains("(White Ink) cvn") && ps.contains("true op"), "{ps}"); + } +} + #[test] fn uncolorized_image_stays_on_original_eps_path() { let d = colorized_doc(vec![0, 128, 255], None);