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.
This commit is contained in:
dotCooCoo
2026-11-23 04:57:10 -08:00
parent 5a82ba3742
commit 1d2c274466
3 changed files with 27 additions and 3 deletions
+7
View File
@@ -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) {
+5 -3
View File
@@ -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);
+15
View File
@@ -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);