mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 22:39:07 +00:00
Merge pull request #9148 from dotCooCoo/fix/white-spot-ink-overprints
Overprint: a white spot ink keeps overprinting with Discard White Overprint on
This commit is contained in:
+83
-20
@@ -293,8 +293,15 @@ pub fn is_white(p: &Paint) -> bool {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether `p` is paper white: white ([`is_white`]) and not a tint above 0% of one of the spot
|
||||
/// inks `spots` ([`Document::spot_ink_names`]). The white of a spot swatch (an opaque white ink,
|
||||
/// for example) is an ink of its own; a 0% tint puts no ink down.
|
||||
pub fn is_paper_white(p: &Paint, spots: &BTreeSet<String>) -> bool {
|
||||
is_white(p) && !matches!(p, Paint::Solid { swatch: Some(name), tint, .. } if *tint > 0.0 && spots.contains(name))
|
||||
}
|
||||
|
||||
/// Discard White Overprint (Document Setup) as output applies it: whether it is on, and the spot
|
||||
/// inks a white tint of which still overprints ([`Document::spot_ink`]).
|
||||
/// inks a white tint of which still overprints ([`Document::spot_ink_names`]).
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct DiscardWhite {
|
||||
on: bool,
|
||||
@@ -304,8 +311,13 @@ pub struct DiscardWhite {
|
||||
impl DiscardWhite {
|
||||
/// The document's setting and spot inks.
|
||||
pub fn of(doc: &Document) -> Self {
|
||||
let spot_inks = doc.swatches_iter().map(|s| &s.name).filter(|n| doc.swatch(n).is_some_and(|s| s.spot && s.paint.color().is_some()));
|
||||
Self { on: doc.setup.discard_white_overprint, spot_inks: spot_inks.cloned().collect() }
|
||||
Self::printing(doc, |_| true)
|
||||
}
|
||||
|
||||
/// The document's setting when only the spot inks for which `spot` is true print as spot
|
||||
/// inks: a white of another one (converted to process inks) is paper white.
|
||||
pub fn printing(doc: &Document, spot: impl Fn(&str) -> bool) -> Self {
|
||||
Self { on: doc.setup.discard_white_overprint, spot_inks: doc.spot_ink_names().into_iter().filter(|n| spot(n)).collect() }
|
||||
}
|
||||
|
||||
/// The setting `on`, with no spot inks.
|
||||
@@ -314,32 +326,31 @@ impl DiscardWhite {
|
||||
}
|
||||
|
||||
/// Whether `p` loses its overprint: the setting is on and `p` is paper white
|
||||
/// ([`is_white`]), not a tint above 0% of a spot ink, which prints as that ink.
|
||||
/// ([`Self::paper_white`]), not a tint above 0% of a spot ink, which prints as that ink.
|
||||
pub fn discards(&self, p: &Paint) -> bool {
|
||||
let spot = matches!(p, Paint::Solid { swatch: Some(name), tint, .. } if *tint > 0.0 && self.spot_inks.contains(name));
|
||||
self.on && is_white(p) && !spot
|
||||
self.on && self.paper_white(p)
|
||||
}
|
||||
|
||||
/// Whether `p` is paper white with these spot inks ([`is_paper_white`]), whether the setting
|
||||
/// is on or off: an overprinting paper white puts no ink down.
|
||||
pub fn paper_white(&self, p: &Paint) -> bool {
|
||||
is_paper_white(p, &self.spot_inks)
|
||||
}
|
||||
}
|
||||
|
||||
impl Document {
|
||||
/// The names of the spot swatches that a color linked by name prints as: a name whose first
|
||||
/// swatch ([`Document::swatch`]) is not a solid spot color is left out.
|
||||
pub fn spot_ink_names(&self) -> BTreeSet<String> {
|
||||
let mut seen = BTreeSet::new();
|
||||
self.swatches_iter().filter(|s| seen.insert(s.name.as_str()) && s.spot && s.paint.color().is_some()).map(|s| s.name.clone()).collect()
|
||||
}
|
||||
|
||||
/// The names of the spot swatches.
|
||||
pub fn spot_names(&self) -> Vec<String> {
|
||||
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()))
|
||||
}
|
||||
|
||||
/// Whether Discard White Overprint (Document Setup) takes the overprint off `p`
|
||||
/// ([`DiscardWhite::discards`]).
|
||||
pub fn discards_white_overprint(&self, p: &Paint) -> bool {
|
||||
self.setup.discard_white_overprint && is_white(p) && !self.spot_ink(p)
|
||||
}
|
||||
|
||||
/// 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) {
|
||||
@@ -488,6 +499,58 @@ mod tests {
|
||||
assert!(OverprintBlack { spot: true, ..Default::default() }.apply(&mut n, &spots), "Include Spot Blacks takes it");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_white_spot_ink_overprints_under_discard_white() {
|
||||
let mut d = Document::new(100.0, 100.0);
|
||||
let white = Color::cmyk(0.0, 0.0, 0.0, 0.0);
|
||||
d.swatches.push(vectorcraft_color::Swatch { name: "Opaque White".into(), paint: Paint::solid(white), global: true, spot: true });
|
||||
d.swatches.push(vectorcraft_color::Swatch { name: "Process White".into(), paint: Paint::solid(white), global: true, spot: false });
|
||||
let spot = Paint::Solid { color: white, swatch: Some("Opaque White".into()), tint: 1.0 };
|
||||
let process = Paint::Solid { color: white, swatch: Some("Process White".into()), tint: 1.0 };
|
||||
let paper = Paint::solid(white);
|
||||
assert!(d.setup.discard_white_overprint, "on by default");
|
||||
d.swatches.push(vectorcraft_color::Swatch {
|
||||
name: "Red Ink".into(),
|
||||
paint: Paint::solid(Color::cmyk(0.0, 1.0, 1.0, 0.0)),
|
||||
global: true,
|
||||
spot: true,
|
||||
});
|
||||
// A 0% tint of a spot ink resolves to white and puts no ink down.
|
||||
let no_red = Paint::Solid { color: white, swatch: Some("Red Ink".into()), tint: 0.0 };
|
||||
let no_white = Paint::Solid { color: white, swatch: Some("Opaque White".into()), tint: 0.0 };
|
||||
let half_white = Paint::Solid { color: white, swatch: Some("Opaque White".into()), tint: 0.5 };
|
||||
let discard = DiscardWhite::of(&d);
|
||||
assert!(discard.discards(&paper), "paper white knocks out");
|
||||
assert!(discard.discards(&process), "so does a global process white");
|
||||
assert!(!discard.discards(&spot) && !discard.discards(&half_white), "a white spot ink is an ink");
|
||||
assert!(discard.discards(&no_red) && discard.discards(&no_white), "a 0% tint of a spot ink is paper white");
|
||||
assert!(!is_paper_white(&spot, &d.spot_ink_names()) && is_paper_white(&paper, &d.spot_ink_names()));
|
||||
let converted = DiscardWhite::printing(&d, |n| n != "Opaque White");
|
||||
assert!(converted.discards(&spot), "a white spot ink printed as process inks is paper white");
|
||||
// A spot swatch after a process one of the same name: a link finds the process one.
|
||||
d.swatches.push(vectorcraft_color::Swatch { name: "Process White".into(), paint: Paint::solid(white), global: true, spot: true });
|
||||
assert!(DiscardWhite::of(&d).discards(&process), "the first swatch of the name decides");
|
||||
// A spot swatch without a solid color prints a linked solid as its own process color.
|
||||
d.swatches.push(vectorcraft_color::Swatch { name: "Empty".into(), paint: Paint::None, global: true, spot: true });
|
||||
let empty = Paint::Solid { color: white, swatch: Some("Empty".into()), tint: 1.0 };
|
||||
assert!(DiscardWhite::of(&d).discards(&empty), "so it is paper white");
|
||||
d.setup.discard_white_overprint = false;
|
||||
assert!(!DiscardWhite::of(&d).discards(&paper), "off: white overprints too");
|
||||
|
||||
// The previews and plates darken the spot ink and leave paper white knocking out.
|
||||
let blend = |fill: Paint| {
|
||||
let mut n = Node::path(NodeId(1), Default::default(), Appearance::basic(fill, Paint::None, 0.0));
|
||||
if let Some(f) = n.appearance.fill_mut() {
|
||||
f.overprint = true;
|
||||
}
|
||||
let mut a = Arc::new(n);
|
||||
darken_overprints(&mut a, &discard, &BTreeMap::new());
|
||||
a.appearance.fill().map(|f| f.blend)
|
||||
};
|
||||
assert_eq!(blend(spot), Some(BlendMode::Darken));
|
||||
assert_eq!(blend(paper), Some(BlendMode::Normal));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn apply_deep_copies_only_the_nodes_that_change() {
|
||||
let k = cmyk(0.0, 0.0, 0.0, 1.0);
|
||||
@@ -560,7 +623,7 @@ mod tests {
|
||||
};
|
||||
let spot = linked("White Ink", 0.5);
|
||||
assert_eq!(blend(spot.clone(), spot.clone()), (BlendMode::Darken, Some(BlendMode::Darken)));
|
||||
assert!(doc.spot_ink(&spot) && !discard.discards(&spot));
|
||||
assert!(!discard.paper_white(&spot) && !discard.discards(&spot));
|
||||
for knocks_out in [linked("White Ink", 0.0), linked("Paper", 1.0), Paint::solid(white)] {
|
||||
assert!(discard.discards(&knocks_out), "{knocks_out:?}");
|
||||
assert_eq!(blend(knocks_out.clone(), knocks_out.clone()).0, BlendMode::Normal, "{knocks_out:?}");
|
||||
|
||||
@@ -52,7 +52,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"Print Ink Fixes",
|
||||
["Object", "Plug-ins", "Color Effects"],
|
||||
None,
|
||||
"{scope?: \"selection\" (the selection, or `ids`; by default, the document while nothing is selected) | \"document\" (every layer), inkLimit?: total ink % 1..400 (0 or left out: off), excludePureBlack?: true (black-only and grey colours keep their ink), removeWhiteOverprint?: false (white fills and strokes, and colorized images with a white color, stop overprinting), overprintBlack?: black % 1..100 (black-only and grey fills and strokes this dark or darker overprint, as edit.colors.overprintBlack; 0 or left out: off), textOnly?: false (Overprint Black on type only), fill?: true, stroke?: true, ids?: [id…]} prepare a CMYK document's inks for print as one undo step: CMYK colours (solid, gradient stops, gradient meshes) with more total ink than inkLimit are scaled down to it (colours of spot swatches and Registration stay), white overprint is removed and black overprint set. Refused in RGB documents (File › Document Color Mode › CMYK Color first). On a path directly in a graph series, the graph also stores a paint the ink limit changes on the topmost visible fill or stroke, and on a graph label the new paint of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {changed, inkLimited: paints and meshes scaled, whiteOverprintRemoved: objects, blackOverprinted: objects}",
|
||||
"{scope?: \"selection\" (the selection, or `ids`; by default, the document while nothing is selected) | \"document\" (every layer), inkLimit?: total ink % 1..400 (0 or left out: off), excludePureBlack?: true (black-only and grey colours keep their ink), removeWhiteOverprint?: false (white fills and strokes, and colorized images with a white color, stop overprinting; a white linked to a spot swatch at a tint above 0% is an ink and keeps it), overprintBlack?: black % 1..100 (black-only and grey fills and strokes this dark or darker overprint, as edit.colors.overprintBlack; 0 or left out: off), textOnly?: false (Overprint Black on type only), fill?: true, stroke?: true, ids?: [id…]} prepare a CMYK document's inks for print as one undo step: CMYK colours (solid, gradient stops, gradient meshes) with more total ink than inkLimit are scaled down to it (colours of spot swatches and Registration stay), white overprint is removed and black overprint set. Refused in RGB documents (File › Document Color Mode › CMYK Color first). On a path directly in a graph series, the graph also stores a paint the ink limit changes on the topmost visible fill or stroke, and on a graph label the new paint of its characters and rows for every label of its kind, and on a graph's axis line, tick mark or radar ring its rows for every line of its kind (docs/mcp.md) → {changed, inkLimited: paints and meshes scaled, whiteOverprintRemoved: objects, blackOverprinted: objects}",
|
||||
has_doc,
|
||||
print_fixes::run
|
||||
),
|
||||
|
||||
@@ -1,14 +1,15 @@
|
||||
//! Print Ink Fixes (`addon.color.printFixes`, Object › Plug-ins › Color Effects › Print Ink
|
||||
//! Fixes…): a CMYK document's inks made ready for print in one undo step. Colours with more total
|
||||
//! ink than the limit are scaled down to it, white fills and strokes stop overprinting, and black
|
||||
//! ink than the limit are scaled down to it, paper white fills and strokes stop overprinting, and black
|
||||
//! ones start to, as Edit › Edit Colors › Overprint Black sets it.
|
||||
|
||||
use std::collections::BTreeSet;
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde_json::{Value, json};
|
||||
use vectorcraft_color::Color;
|
||||
use vectorcraft_color::swatch::REGISTRATION;
|
||||
use vectorcraft_doc::overprint::{OverprintBlack, is_white};
|
||||
use vectorcraft_doc::overprint::{OverprintBlack, is_paper_white};
|
||||
use vectorcraft_doc::{ColorMode, Node, NodeKind};
|
||||
|
||||
use super::super::super::colorcmds::{Recolor, Scope, keeping_series_paint};
|
||||
@@ -78,8 +79,9 @@ impl Fixes {
|
||||
}
|
||||
|
||||
/// Remove white overprint from `n`'s own fills and strokes and its characters': true when
|
||||
/// that changed anything.
|
||||
fn unset_white(&self, n: &mut Node) -> bool {
|
||||
/// that changed anything. A white linked to one of the spot inks `inks` is an ink and keeps
|
||||
/// overprinting ([`is_paper_white`]).
|
||||
fn unset_white(&self, n: &mut Node, inks: &BTreeSet<String>) -> bool {
|
||||
let mut changed = false;
|
||||
let mut off = |aimed: bool, white: bool, flag: &mut bool| {
|
||||
if aimed && white && *flag {
|
||||
@@ -89,31 +91,32 @@ impl Fixes {
|
||||
};
|
||||
for it in &mut n.appearance.items {
|
||||
let aimed = if it.is_fill() { self.fill } else { self.stroke };
|
||||
let white = is_white(it.paint());
|
||||
let white = is_paper_white(it.paint(), inks);
|
||||
off(aimed, white, it.overprint_mut());
|
||||
}
|
||||
if let NodeKind::Text(t) = &mut n.kind {
|
||||
for r in &mut t.runs {
|
||||
off(self.fill, is_white(&r.style.fill), &mut r.style.overprint_fill);
|
||||
off(self.stroke, is_white(&r.style.stroke), &mut r.style.overprint_stroke);
|
||||
off(self.fill, is_paper_white(&r.style.fill, inks), &mut r.style.overprint_fill);
|
||||
off(self.stroke, is_paper_white(&r.style.stroke, inks), &mut r.style.overprint_stroke);
|
||||
}
|
||||
}
|
||||
// A colorized image's color is its fill.
|
||||
if n.colorize_overprints() {
|
||||
let white = n.extras().colorize.as_deref().is_some_and(is_white);
|
||||
let white = n.extras().colorize.as_deref().is_some_and(|p| is_paper_white(p, inks));
|
||||
off(self.fill, white, &mut n.extras_mut().colorize_overprint);
|
||||
}
|
||||
changed
|
||||
}
|
||||
|
||||
/// The overprint fixes on `n` and everything inside it: (objects whose white overprint was
|
||||
/// removed, objects set to overprint black).
|
||||
fn overprint(&self, n: &mut Node, black: &OverprintBlack, spots: &[String]) -> (usize, usize) {
|
||||
let white = usize::from(self.remove_white_overprint && self.unset_white(n));
|
||||
/// removed, objects set to overprint black). `spots`: the document's spot swatch names; `inks`:
|
||||
/// those that linked colors print as ([`vectorcraft_doc::Document::spot_ink_names`]).
|
||||
fn overprint(&self, n: &mut Node, black: &OverprintBlack, spots: &[String], inks: &BTreeSet<String>) -> (usize, usize) {
|
||||
let white = usize::from(self.remove_white_overprint && self.unset_white(n, inks));
|
||||
let blacks = self.overprint_black > 0.0 && (!self.text_only || matches!(n.kind, NodeKind::Text(_)));
|
||||
let mut counts = (white, usize::from(blacks && black.apply(n, spots)));
|
||||
for c in n.children_mut().into_iter().flatten().filter(|c| !c.is_ruler_guide()) {
|
||||
let (w, b) = self.overprint(Arc::make_mut(c), black, spots);
|
||||
let (w, b) = self.overprint(Arc::make_mut(c), black, spots, inks);
|
||||
counts = (counts.0 + w, counts.1 + b);
|
||||
}
|
||||
counts
|
||||
@@ -159,10 +162,10 @@ pub(super) fn run(s: &mut Session, p: &Value) -> Result<Value> {
|
||||
if !fixes.remove_white_overprint && fixes.overprint_black <= 0.0 {
|
||||
return Ok(ink);
|
||||
}
|
||||
let spots = d.spot_names();
|
||||
let (spots, inks) = (d.spot_names(), d.spot_ink_names());
|
||||
for id in &ids {
|
||||
if let Some(n) = d.node_mut(*id) {
|
||||
let (w, b) = fixes.overprint(n, &black, &spots);
|
||||
let (w, b) = fixes.overprint(n, &black, &spots, &inks);
|
||||
(white, blacks) = (white + w, blacks + b);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,6 +101,20 @@ fn white_overprint_goes_and_black_overprint_comes_at_the_threshold() {
|
||||
assert_eq!(s.execute(C, &json!({"overprintBlack": 90, "fill": false})).unwrap()["changed"], 0);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_white_spot_ink_keeps_its_overprint() {
|
||||
let white = cmyk(0.0, 0.0, 0.0, 0.0);
|
||||
let (mut s, ids) = doc(&[(white.clone(), true), (white.clone(), true)]);
|
||||
s.execute("swatch.new", &json!({"name": "Opaque White", "color": white, "spot": true})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [ids[1].0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"swatch": "Opaque White"})).unwrap();
|
||||
s.execute("select.none", &json!({})).unwrap();
|
||||
assert!(fill(&s, ids[1]).1, "the swatch keeps the overprint");
|
||||
let v = s.execute(C, &json!({"removeWhiteOverprint": true})).unwrap();
|
||||
assert_eq!(v["whiteOverprintRemoved"], 1, "{v}");
|
||||
assert_eq!([fill(&s, ids[0]).1, fill(&s, ids[1]).1], [false, true], "paper white stops; the spot white is an ink");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn bad_requests_and_rgb_documents_are_refused() {
|
||||
let (mut s, ids) = doc(&[(cmyk(100.0, 100.0, 100.0, 100.0), true)]);
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -776,6 +776,15 @@ fn overprint_black_and_print_fixes_reach_a_colorized_images_color() {
|
||||
let v = s.execute("addon.color.printFixes", &json!({"removeWhiteOverprint": true})).unwrap();
|
||||
assert_eq!(v["whiteOverprintRemoved"], 1, "{v}");
|
||||
assert!(!overprints(&s), "white knocks out again");
|
||||
// A white spot ink is an ink: Remove White Overprint leaves its overprint.
|
||||
s.execute("swatch.new", &json!({"name": "Opaque White", "color": {"c": 0, "m": 0, "y": 0, "k": 0}, "spot": true})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [id.0]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"swatch": "Opaque White"})).unwrap();
|
||||
s.execute("object.setOverprint", &json!({"fill": true})).unwrap();
|
||||
assert!(overprints(&s), "the spot white overprints");
|
||||
let v = s.execute("addon.color.printFixes", &json!({"removeWhiteOverprint": true})).unwrap();
|
||||
assert_eq!(v["whiteOverprintRemoved"], 0, "{v}");
|
||||
assert!(overprints(&s), "the spot white keeps overprinting");
|
||||
}
|
||||
|
||||
/// A flattening for a file that writes colorized images in their ink (EPS) keeps the image, and
|
||||
|
||||
@@ -482,6 +482,13 @@ fn discard_white_overprint_keeps_white_overprints_in_overprint_preview() {
|
||||
s.execute("document.setup", &json!({"discardWhiteOverprint": false})).unwrap();
|
||||
let [r, g, b, _] = centre(&s);
|
||||
assert!(r > 200 && g < 60 && b < 60, "a white overprint vanishes: {:?}", [r, g, b]);
|
||||
// A white spot ink is an ink: it overprints with the option on too.
|
||||
s.execute("document.setup", &json!({"discardWhiteOverprint": true})).unwrap();
|
||||
s.execute("swatch.new", &json!({"name": "Opaque White", "color": {"c": 0, "m": 0, "y": 0, "k": 0}, "spot": true})).unwrap();
|
||||
s.execute("select.set", &json!({"ids": [white]})).unwrap();
|
||||
s.execute("paint.setFill", &json!({"swatch": "Opaque White"})).unwrap();
|
||||
let [r, g, b, _] = centre(&s);
|
||||
assert!(r > 200 && g < 60 && b < 60, "the spot white overprints: {:?}", [r, g, b]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -607,7 +607,9 @@ impl<'a> Scene<'a> {
|
||||
// (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.discards_white_overprint(p);
|
||||
let discarded = !self.plate
|
||||
&& 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);
|
||||
self.overprint_off(on);
|
||||
|
||||
@@ -114,6 +114,9 @@ pub(crate) struct Exporter<'a> {
|
||||
/// Overprinting characters' fills and strokes are drawn with Darken, as a separation's plate
|
||||
/// draws its overprinting fills and strokes ([`vectorcraft_doc::overprint::darken_overprints`]).
|
||||
pub darken_overprints: bool,
|
||||
/// Document Setup → Discard White Overprint as it applies to the document's paints, read from
|
||||
/// the document on first use ([`Self::paper_white`]).
|
||||
discard_white: Option<vectorcraft_doc::overprint::DiscardWhite>,
|
||||
/// An overprinting fill or stroke was drawn so.
|
||||
pub overprinted: bool,
|
||||
/// Characters with neither fill nor stroke, or whose fill is drawn as art (outlines filled
|
||||
|
||||
@@ -64,6 +64,7 @@ impl<'a> Exporter<'a> {
|
||||
mask_art_left_out: false,
|
||||
overprint: false,
|
||||
darken_overprints: false,
|
||||
discard_white: None,
|
||||
overprinted: false,
|
||||
invisible: false,
|
||||
inline_depth: 0,
|
||||
|
||||
@@ -523,12 +523,11 @@ impl Exporter<'_> {
|
||||
}
|
||||
|
||||
/// Draw image `im` of node `n` colorized with `p` ([`Self::colorized_image`]), overprinting
|
||||
/// when its color does ([`Node::colorize_overprints`]). A white color that is not a spot ink
|
||||
/// ([`Document::spot_ink`]) and overprints (Discard White Overprint off) puts no ink down, so
|
||||
/// it paints nothing.
|
||||
/// when its color does ([`Node::colorize_overprints`]). A paper white color ([`Self::paper_white`])
|
||||
/// that overprints (Discard White Overprint off) puts no ink down, so it paints nothing.
|
||||
fn colorized(&mut self, s: &mut Surface, n: &Node, im: &vectorcraft_doc::ImageObject, p: &Paint) {
|
||||
let overprint = n.colorize_overprints() && self.overprint;
|
||||
if overprint && !self.doc.setup.discard_white_overprint && !self.doc.spot_ink(p) && vectorcraft_doc::overprint::is_white(p) {
|
||||
if overprint && !self.doc.setup.discard_white_overprint && self.paper_white(p) {
|
||||
return;
|
||||
}
|
||||
match self.colorized_image(im, p, !n.extras().pixelated, overprint) {
|
||||
@@ -634,11 +633,10 @@ impl Exporter<'_> {
|
||||
}
|
||||
|
||||
/// Draw a fill or stroke of `paint` with `draw`: as a form marked to overprint when it
|
||||
/// `overprints`, paints and overprints are kept (but not a white one with Discard White
|
||||
/// Overprint, [`Document::discards_white_overprint`]).
|
||||
/// `overprints`, paints and overprints are kept (but not a paper white one with Discard White
|
||||
/// Overprint, [`Self::discards_white`]).
|
||||
pub(super) fn overprinting(&mut self, s: &mut Surface, overprints: bool, paint: &Paint, draw: impl FnOnce(&mut Self, &mut Surface)) {
|
||||
let white = || self.doc.discards_white_overprint(paint);
|
||||
if overprints && self.overprint && !paint.is_none() && !white() {
|
||||
if overprints && self.overprint && !paint.is_none() && !self.discards_white(paint) {
|
||||
self.overprinted = true;
|
||||
crate::forms::form(s, Mark::Overprint, |s| draw(self, s));
|
||||
} else {
|
||||
@@ -647,11 +645,10 @@ impl Exporter<'_> {
|
||||
}
|
||||
|
||||
/// [`Self::overprinting`] for a character fill or stroke, which has no blend mode of its own:
|
||||
/// with [`Self::darken_overprints`] an overprinting one is drawn with Darken (not a white one
|
||||
/// with Discard White Overprint).
|
||||
/// with [`Self::darken_overprints`] an overprinting one is drawn with Darken (not a paper
|
||||
/// white one with Discard White Overprint).
|
||||
pub(super) fn char_overprinting(&mut self, s: &mut Surface, overprints: bool, paint: &Paint, draw: impl FnOnce(&mut Self, &mut Surface)) {
|
||||
let white = self.doc.discards_white_overprint(paint);
|
||||
if overprints && self.darken_overprints && !paint.is_none() && !white {
|
||||
if overprints && self.darken_overprints && !paint.is_none() && !self.discards_white(paint) {
|
||||
s.push_blend_mode(krilla::blend::BlendMode::Darken);
|
||||
self.overprinting(s, overprints, paint, draw);
|
||||
s.pop();
|
||||
@@ -660,6 +657,26 @@ impl Exporter<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Whether paint `p` knocks out where it overprints under Document Setup → Discard White
|
||||
/// Overprint ([`vectorcraft_doc::overprint::DiscardWhite::discards`]).
|
||||
fn discards_white(&mut self, p: &Paint) -> bool {
|
||||
self.doc.setup.discard_white_overprint && self.paper_white(p)
|
||||
}
|
||||
|
||||
/// Whether paint `p` is paper white ([`vectorcraft_doc::overprint::DiscardWhite::paper_white`]):
|
||||
/// white, and not a tint above 0% of one of the document's spot inks. The spot ink names are
|
||||
/// read only for a white linked to a swatch.
|
||||
fn paper_white(&mut self, p: &Paint) -> bool {
|
||||
if !vectorcraft_doc::overprint::is_white(p) {
|
||||
return false;
|
||||
}
|
||||
if !matches!(p, Paint::Solid { swatch: Some(_), .. }) {
|
||||
return true;
|
||||
}
|
||||
let doc = self.doc;
|
||||
self.discard_white.get_or_insert_with(|| vectorcraft_doc::overprint::DiscardWhite::of(doc)).paper_white(p)
|
||||
}
|
||||
|
||||
/// Is `p` a paint PDF has no paint for when it paints a fill (`fill`) or a stroke, which
|
||||
/// [`Self::area`] draws as art: a pattern swatch or a gradient drawn as pixels
|
||||
/// ([`vectorcraft_color::GradientPaint::draws_as_pixels`]), but not a Perceptual one of spot
|
||||
|
||||
@@ -238,7 +238,7 @@ 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 (white ones that `discard_white` knocks out
|
||||
/// 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,
|
||||
/// 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
|
||||
@@ -296,7 +296,7 @@ impl<'a> Separator<'a> {
|
||||
/// ink the plate below shows through instead of being knocked out.
|
||||
pub fn plate(&self, plate: &str) -> Document {
|
||||
let mut d = self.doc.clone();
|
||||
let discard_white = DiscardWhite::of(self.doc);
|
||||
let discard_white = DiscardWhite::printing(&d, |n| !self.converts(n));
|
||||
let mut colorized = BTreeSet::new();
|
||||
let nodes = d.layers.iter_mut().chain(d.symbols.iter_mut().map(|s| &mut s.art)).chain(d.patterns.iter_mut().flat_map(|p| p.art.iter_mut()));
|
||||
for n in nodes {
|
||||
|
||||
@@ -399,6 +399,16 @@ fn a_white_spot_ink_image_overprints_with_discard_white_overprint() {
|
||||
assert_eq!(p.layers[0].children().unwrap()[0].visible, name == "White Ink", "{name}");
|
||||
}
|
||||
}
|
||||
// Printed as process inks, the white ink is paper white: the image knocks out on every plate.
|
||||
let converted = serde_json::json!({"output": {"mode": "separations", "inks": [{"name": "White Ink", "convertToProcess": true}]}});
|
||||
let settings: PrintSettings = serde_json::from_value(converted).unwrap();
|
||||
for postscript in [true, false] {
|
||||
let job = plan(&d, &PrintOptions { settings: settings.clone(), postscript, ..Default::default() }).unwrap();
|
||||
assert!(!job.plates.is_empty());
|
||||
for p in &job.plates {
|
||||
assert!(p.layers[0].children().unwrap()[0].visible, "a converted white ink knocks out");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// An overprinting colorized image whose pixels don't take its color (a color preview of its
|
||||
|
||||
@@ -352,6 +352,28 @@ fn white_overprint_is_discarded_as_the_document_setup_says() {
|
||||
assert_eq!(overprints(&d, json!({})).1, 3);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_white_spot_ink_keeps_overprinting_under_discard_white_overprint() {
|
||||
let white = Color::cmyk(0.0, 0.0, 0.0, 0.0);
|
||||
let mut d = overprinting(white);
|
||||
d.swatches.push(vectorcraft_color::Swatch { name: "Opaque White".into(), paint: Paint::solid(white), global: true, spot: true });
|
||||
let paint = |d: &mut Document, p: &Paint| {
|
||||
for n in std::sync::Arc::make_mut(&mut d.layers[0]).children_mut().into_iter().flatten() {
|
||||
let n = std::sync::Arc::make_mut(n);
|
||||
if let Some(f) = n.appearance.fill_mut().filter(|f| f.overprint) {
|
||||
f.paint = p.clone();
|
||||
}
|
||||
if let NodeKind::Text(t) = &mut n.kind {
|
||||
t.runs.iter_mut().for_each(|r| r.style.fill = p.clone());
|
||||
}
|
||||
}
|
||||
};
|
||||
paint(&mut d, &Paint::solid(white));
|
||||
assert_eq!(overprints(&d, json!({})).1, 1, "paper white fills and characters knock out");
|
||||
paint(&mut d, &Paint::Solid { color: white, swatch: Some("Opaque White".into()), tint: 1.0 });
|
||||
assert_eq!(overprints(&d, json!({})).1, 3, "a white spot ink overprints, characters too");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn pdf_a_overprint_mode_is_0() {
|
||||
let r = export(&overprinting(RED), json!({"standard": "pdfA2b", "compression": {"compressText": false}}));
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use serde_json::json;
|
||||
use vectorcraft_color::{Color, Freeform, FreeformPoint, Gradient, GradientKind, GradientPaint, GradientStop, Paint, Swatch};
|
||||
use vectorcraft_color::{BlendMode, Color, Freeform, FreeformPoint, Gradient, GradientKind, GradientPaint, GradientStop, Paint, Swatch};
|
||||
use vectorcraft_doc::{Appearance, Artboard, Document, LayerColor, Node, NodeKind};
|
||||
use vectorcraft_geom::{Rect, shapes};
|
||||
use vectorcraft_testkit::raster::render_region;
|
||||
@@ -903,6 +903,47 @@ fn overprinting_near_blacks_linked_to_a_missing_swatch_keep_the_cyan_on_postscri
|
||||
assert_eq!(drawn(true, 3), (3, 1, 1), "PostScript Black plate: every black, not the faint fill");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn a_white_spot_ink_keeps_overprinting_on_plates_and_in_simulated_composites() {
|
||||
// With Discard White Overprint on (the default), a paper white square over cyan knocks the
|
||||
// cyan out; one in a white spot ink overprints: it puts no cyan down, so the cyan plate draws
|
||||
// nothing for it, and Simulate composites it with Darken.
|
||||
let white = Color::cmyk(0.0, 0.0, 0.0, 0.0);
|
||||
let square = |paint: Paint| {
|
||||
let mut n =
|
||||
Node::path(vectorcraft_doc::NodeId(0), shapes::rectangle(Rect::new(10.0, 15.0, 30.0, 35.0)), Appearance::basic(paint, Paint::None, 0.0));
|
||||
if let Some(f) = n.appearance.fill_mut() {
|
||||
f.overprint = true;
|
||||
}
|
||||
let mut d = over_cyan(vec![n]);
|
||||
d.swatches.push(Swatch { name: "Opaque White".into(), paint: Paint::solid(white), global: true, spot: true });
|
||||
d
|
||||
};
|
||||
let (paper, spot) = (square(Paint::solid(white)), square(Paint::Solid { color: white, swatch: Some("Opaque White".into()), tint: 1.0 }));
|
||||
assert!(paper.setup.discard_white_overprint);
|
||||
let cyan_fills = |d: &Document, output: serde_json::Value| {
|
||||
let opts = PrintOptions { settings: settings(json!({"output": output})), ..Default::default() };
|
||||
let p = plan(d, &opts).unwrap();
|
||||
let mut count = 0;
|
||||
p.plates[0].walk(|n| count += usize::from(n.appearance.fill().is_some_and(|f| !f.paint.is_none())));
|
||||
count
|
||||
};
|
||||
let seps = json!({"mode": "separations"});
|
||||
assert_eq!((cyan_fills(&paper, seps.clone()), cyan_fills(&spot, seps)), (2, 1), "paper white knocks out; the spot white leaves the cyan");
|
||||
// The white ink printed as process inks is paper white.
|
||||
let converted = json!({"mode": "separations", "inks": [{"name": "Opaque White", "convertToProcess": true}]});
|
||||
assert_eq!(cyan_fills(&spot, converted), 2, "a converted spot white knocks out");
|
||||
assert_eq!(cyan_fills(&spot, json!({"mode": "separations", "spotsToProcess": true})), 2, "so does one with every spot converted");
|
||||
let blends = |d: &Document| {
|
||||
let opts = PrintOptions { settings: settings(json!({"advanced": {"overprints": "simulate"}})), ..Default::default() };
|
||||
let p = plan(d, &opts).unwrap();
|
||||
let mut out = vec![];
|
||||
p.doc.walk(|n| out.extend(n.appearance.fill().filter(|f| f.paint.color() == Some(white)).map(|f| f.blend)));
|
||||
out
|
||||
};
|
||||
assert_eq!((blends(&paper), blends(&spot)), (vec![BlendMode::Normal], vec![BlendMode::Darken]));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn an_overprinting_fill_keeps_its_faint_ink_on_pdf_plates() {
|
||||
// 0.4% cyan beside 100% K, set to overprint: a PDF plate draws it with Darken, a PostScript
|
||||
|
||||
@@ -36,7 +36,7 @@ use vectorcraft_color::{Color, Paint, Swatch, SwatchGroup};
|
||||
pub use vectorcraft_doc::inks::{Inks, Link, Plate, inks, map_document_colors, map_node_colors, plates, spot_color};
|
||||
use vectorcraft_doc::inks::{StopPlates, map_node_inks, stop_inks};
|
||||
use vectorcraft_doc::overprint::{DiscardWhite, darken_overprints};
|
||||
use vectorcraft_doc::{AppearanceItem, Document, ImageBlob, Node, NodeId, Shared};
|
||||
use vectorcraft_doc::{AppearanceItem, Document, ImageBlob, Node, NodeId, NodeKind, Shared};
|
||||
use vello_cpu::Pixmap;
|
||||
use vello_cpu::color::PremulRgba8;
|
||||
|
||||
@@ -392,6 +392,8 @@ impl Fit {
|
||||
/// one of them while they are kept.
|
||||
pub(crate) struct Prepared {
|
||||
inputs: Inputs,
|
||||
/// The swatches `inputs.discard_white` was read from, while Discard White Overprint is on.
|
||||
spots: Option<SpotSwatches>,
|
||||
layers: (Vec<Arc<Node>>, Vec<Arc<Node>>),
|
||||
art: (Vec<Arc<Node>>, Vec<Arc<Node>>),
|
||||
}
|
||||
@@ -407,6 +409,14 @@ struct Inputs {
|
||||
plates: Option<Plates>,
|
||||
}
|
||||
|
||||
/// The document's swatches and swatch groups, which name its spot inks ([`DiscardWhite`]): while
|
||||
/// they are unchanged, the spot ink names are not read again.
|
||||
#[derive(PartialEq)]
|
||||
struct SpotSwatches {
|
||||
swatches: Shared<Vec<Swatch>>,
|
||||
groups: Shared<Vec<SwatchGroup>>,
|
||||
}
|
||||
|
||||
/// A hash of `images`' keys and the address of each one's bytes and whether they are a preview
|
||||
/// ([`ImageBlob::is_proxy`]): it changes when an image is added, removed or given other bytes,
|
||||
/// without reading any pixels.
|
||||
@@ -445,7 +455,7 @@ impl PartialEq for Plates {
|
||||
/// print it ([`plate_color`]).
|
||||
struct How<'a> {
|
||||
doc: &'a Document,
|
||||
discard_white: DiscardWhite,
|
||||
discard_white: &'a DiscardWhite,
|
||||
/// Separations Preview: the color settings, the proof setup and the visible plates.
|
||||
plates: Option<(&'a Cms, &'a ProofSetup, &'a [String])>,
|
||||
}
|
||||
@@ -454,12 +464,33 @@ impl How<'_> {
|
||||
/// Whether [`Self::apply`] can change `n`: with Separations Preview any node, else a node with
|
||||
/// an overprinting fill or stroke, or a colorized image whose color overprints.
|
||||
fn changes(&self, n: &Node) -> bool {
|
||||
self.plates.is_some() || n.appearance.items.iter().any(|i| i.overprint()) || n.colorize_overprints()
|
||||
self.plates.is_some() || n.appearance.items.iter().any(|i| i.overprint()) || n.colorize_overprints() || self.white_characters(n)
|
||||
}
|
||||
|
||||
/// Change the fills, strokes and other colors of node `a`, which holds no members.
|
||||
/// Whether type `n` has an overprinting character fill or stroke that Discard White Overprint
|
||||
/// knocks out ([`DiscardWhite::discards`]).
|
||||
fn white_characters(&self, n: &Node) -> bool {
|
||||
let white = |r: &vectorcraft_doc::TextRun| {
|
||||
(r.style.overprint_fill && self.discard_white.discards(&r.style.fill))
|
||||
|| (r.style.overprint_stroke && self.discard_white.discards(&r.style.stroke))
|
||||
};
|
||||
matches!(&n.kind, NodeKind::Text(t) if t.runs.iter().any(white))
|
||||
}
|
||||
|
||||
/// Change the fills, strokes and other colors of node `a`, which holds no members. Character
|
||||
/// fills and strokes that Discard White Overprint knocks out stop overprinting, judged on
|
||||
/// their own colors before Separations Preview maps them to the visible plates; the renderer
|
||||
/// darkens the others.
|
||||
fn apply(&self, a: &mut Arc<Node>) {
|
||||
darken_overprints(a, &self.discard_white, &self.doc.images);
|
||||
darken_overprints(a, self.discard_white, &self.doc.images);
|
||||
if self.white_characters(a)
|
||||
&& let NodeKind::Text(t) = &mut Arc::make_mut(a).kind
|
||||
{
|
||||
for r in &mut t.runs {
|
||||
r.style.overprint_fill &= !self.discard_white.discards(&r.style.fill);
|
||||
r.style.overprint_stroke &= !self.discard_white.discards(&r.style.stroke);
|
||||
}
|
||||
}
|
||||
if let Some((c, proof, visible)) = self.plates {
|
||||
map_node_inks(Arc::make_mut(a), &mut |col, sw, plates| plate_color(self.doc, c, proof, visible, col, sw, plates));
|
||||
}
|
||||
@@ -477,8 +508,10 @@ pub(crate) fn prepare<'a>(doc: &'a Document, opts: &RenderOptions, kept: &mut Op
|
||||
}
|
||||
let seps = opts.proof.as_ref().and_then(|p| p.separations.as_ref().map(|s| (p, s)));
|
||||
let c = cms::active();
|
||||
let spots = doc.setup.discard_white_overprint.then(|| SpotSwatches { swatches: doc.swatches.clone(), groups: doc.swatch_groups.clone() });
|
||||
let read = kept.as_ref().filter(|k| k.spots == spots).map(|k| k.inputs.discard_white.clone());
|
||||
let inputs = Inputs {
|
||||
discard_white: DiscardWhite::of(doc),
|
||||
discard_white: read.unwrap_or_else(|| DiscardWhite::of(doc)),
|
||||
images: images_state(&doc.images),
|
||||
plates: seps.map(|(proof, _)| Plates {
|
||||
proof: proof.clone(),
|
||||
@@ -490,7 +523,7 @@ pub(crate) fn prepare<'a>(doc: &'a Document, opts: &RenderOptions, kept: &mut Op
|
||||
}),
|
||||
};
|
||||
let earlier = kept.take().filter(|k| k.inputs == inputs);
|
||||
let how = How { doc, discard_white: inputs.discard_white.clone(), plates: seps.map(|(proof, visible)| (&*c, proof, visible.as_slice())) };
|
||||
let how = How { doc, discard_white: &inputs.discard_white, plates: seps.map(|(proof, visible)| (&*c, proof, visible.as_slice())) };
|
||||
let none = (vec![], vec![]);
|
||||
let (layers, art) = earlier.as_ref().map_or((&none, &none), |k| (&k.layers, &k.art));
|
||||
let made_layers = prepare_list(&doc.layers, &layers.0, &layers.1, &how);
|
||||
@@ -507,7 +540,7 @@ pub(crate) fn prepare<'a>(doc: &'a Document, opts: &RenderOptions, kept: &mut Op
|
||||
}
|
||||
Cow::Owned(d)
|
||||
};
|
||||
*kept = Some(Prepared { inputs, layers: (doc.layers.clone(), made_layers), art: (symbol_art, made_art) });
|
||||
*kept = Some(Prepared { inputs, spots, layers: (doc.layers.clone(), made_layers), art: (symbol_art, made_art) });
|
||||
out
|
||||
}
|
||||
|
||||
|
||||
@@ -2205,6 +2205,74 @@ fn rasters_follow_the_view_options() {
|
||||
draws_as_new(&mut d, &isolated, &on_white, unchanged);
|
||||
}
|
||||
|
||||
/// Overprinting white characters over red in Overprint Preview: paper white knocks out while
|
||||
/// Discard White Overprint is on and vanishes into the red when it is turned off; a white spot ink
|
||||
/// overprints with it on. In Separations Preview paper white characters knock the plate out too.
|
||||
#[test]
|
||||
fn overprinting_white_characters_follow_discard_white_overprint() {
|
||||
let _fonts = fonts_steady();
|
||||
use vectorcraft_doc::text::{CharStyle, TextObject};
|
||||
let white = Color::cmyk(0.0, 0.0, 0.0, 0.0);
|
||||
let typed = || {
|
||||
let mut d = Document::new(200.0, 100.0);
|
||||
d.swatches.push(vectorcraft_color::Swatch { name: "Opaque White".into(), paint: Paint::solid(white), global: true, spot: true });
|
||||
let red =
|
||||
filled(&mut d, vectorcraft_geom::shapes::rectangle(Rect::new(0.0, 0.0, 200.0, 100.0)), Paint::solid(Color::rgb(1.0, 0.0, 0.0)), vec![]);
|
||||
let style = CharStyle { size: 50.0, fill: Paint::solid(white), overprint_fill: true, ..Default::default() };
|
||||
let text = Node::new(d.alloc_id(), NodeKind::Text(Box::new(TextObject::point(vectorcraft_geom::Point::new(10.0, 70.0), "Hamburg", style))));
|
||||
with_art(d, vec![red, text])
|
||||
};
|
||||
let overprints = RenderOptions { overprint_preview: true, background: Some([255, 255, 255, 255]), ..Default::default() };
|
||||
draws_as_new(&mut typed(), &overprints, &overprints, |d| d.setup.discard_white_overprint = false);
|
||||
draws_as_new(&mut typed(), &overprints, &overprints, |d| {
|
||||
let text = d.layers[0].children().unwrap()[1].id;
|
||||
if let Some(NodeKind::Text(t)) = d.node_mut(text).map(|n| &mut n.kind) {
|
||||
t.runs.iter_mut().for_each(|r| r.style.fill = Paint::Solid { color: white, swatch: Some("Opaque White".into()), tint: 1.0 });
|
||||
}
|
||||
});
|
||||
// Knocking out shows the white of the characters; overprinting leaves only the red.
|
||||
let whites = |d: &Document, opts: &RenderOptions| {
|
||||
Renderer::new().render(d, 200, 100, Affine::IDENTITY, opts).pixels.chunks(4).filter(|p| p[0] > 250 && p[1] > 250 && p[2] > 250).count()
|
||||
};
|
||||
let mut d = typed();
|
||||
assert!(whites(&d, &overprints) > 0, "paper white knocks out");
|
||||
d.setup.discard_white_overprint = false;
|
||||
assert_eq!(whites(&d, &overprints), 0, "with the option off it overprints");
|
||||
let mut d = typed();
|
||||
let text = d.layers[0].children().unwrap()[1].id;
|
||||
if let Some(NodeKind::Text(t)) = d.node_mut(text).map(|n| &mut n.kind) {
|
||||
t.runs.iter_mut().for_each(|r| r.style.fill = Paint::Solid { color: white, swatch: Some("Opaque White".into()), tint: 1.0 });
|
||||
}
|
||||
assert_eq!(whites(&d, &overprints), 0, "a white spot ink overprints");
|
||||
// Separations Preview: paper white characters over cyan knock the Cyan plate out.
|
||||
let mut d = Document::new(200.0, 100.0);
|
||||
let cyan =
|
||||
filled(&mut d, vectorcraft_geom::shapes::rectangle(Rect::new(0.0, 0.0, 200.0, 100.0)), Paint::solid(Color::cmyk(1.0, 0.0, 0.0, 0.0)), vec![]);
|
||||
let style = CharStyle { size: 50.0, fill: Paint::solid(white), overprint_fill: true, ..Default::default() };
|
||||
let text = Node::new(d.alloc_id(), NodeKind::Text(Box::new(TextObject::point(vectorcraft_geom::Point::new(10.0, 70.0), "Hamburg", style))));
|
||||
let mut d = with_art(d, vec![cyan, text]);
|
||||
let seps = RenderOptions { background: Some([255, 255, 255, 255]), ..proof_views(&["Cyan"]).1 };
|
||||
assert!(whites(&d, &seps) > 0, "paper white knocks the Cyan plate out");
|
||||
d.setup.discard_white_overprint = false;
|
||||
assert_eq!(whites(&d, &seps), 0, "with the option off the cyan shows through");
|
||||
// Magenta characters over cyan, with only the Cyan plate shown: they put none of it down, so
|
||||
// the cyan shows through them, as if they were not there.
|
||||
let magenta = |with_text: bool| {
|
||||
let mut d = Document::new(200.0, 100.0);
|
||||
let cyan = filled(
|
||||
&mut d,
|
||||
vectorcraft_geom::shapes::rectangle(Rect::new(0.0, 0.0, 200.0, 100.0)),
|
||||
Paint::solid(Color::cmyk(1.0, 0.0, 0.0, 0.0)),
|
||||
vec![],
|
||||
);
|
||||
let style = CharStyle { size: 50.0, fill: Paint::solid(Color::cmyk(0.0, 1.0, 0.0, 0.0)), overprint_fill: true, ..Default::default() };
|
||||
let text = Node::new(d.alloc_id(), NodeKind::Text(Box::new(TextObject::point(vectorcraft_geom::Point::new(10.0, 70.0), "Hamburg", style))));
|
||||
let d = with_art(d, if with_text { vec![cyan, text] } else { vec![cyan] });
|
||||
Renderer::new().render(&d, 200, 100, Affine::IDENTITY, &proof_views(&["Cyan"]).1).pixels
|
||||
};
|
||||
assert!(magenta(true) == magenta(false), "the characters leave the cyan plate as it is");
|
||||
}
|
||||
|
||||
/// A document for the proof previews: a cyan square, a magenta circle over it whose black stroke
|
||||
/// overprints, a white square over the cyan one that overprints, a blurred rectangle in spot color
|
||||
/// `Spot`, and an instance of symbol `S`, a group holding a yellow square.
|
||||
@@ -2273,8 +2341,8 @@ fn proof_previews_keep_their_art_between_frames() {
|
||||
|
||||
/// With Overprint Preview or Separations Preview on, a renderer draws what a new renderer draws
|
||||
/// after a change to the art or to what the previews read: an object recolored, Discard White
|
||||
/// Overprint turned off, a symbol's art recolored (its instance shows the plates of the new art),
|
||||
/// the spot color redefined, a spot color in a color group redefined, the Spot Colors option set
|
||||
/// Overprint turned off, an overprinting white's swatch made a spot color, a symbol's art
|
||||
/// recolored (its instance shows the plates of the new art), the spot color redefined, a spot color in a color group redefined, the Spot Colors option set
|
||||
/// to CMYK values, a plate hidden, Simulate Paper Color, another proof profile, and one preview
|
||||
/// after the other.
|
||||
#[test]
|
||||
@@ -2296,6 +2364,19 @@ fn proof_previews_draw_changes_as_a_new_renderer_does() {
|
||||
for opts in [&overprint, &separations] {
|
||||
draws_as_new(&mut proof_doc(), opts, opts, recolor_square);
|
||||
draws_as_new(&mut proof_doc(), opts, opts, |d| d.setup.discard_white_overprint = false);
|
||||
// The overprinting white square's swatch becomes a spot color, a white ink.
|
||||
let mut linked = proof_doc();
|
||||
let white = Color::cmyk(0.0, 0.0, 0.0, 0.0);
|
||||
linked.swatches.push(vectorcraft_color::Swatch { name: "White".into(), paint: Paint::solid(white), global: true, spot: false });
|
||||
let square = linked.layers[0].children().unwrap()[2].id;
|
||||
if let Some(f) = linked.node_mut(square).unwrap().appearance.fill_mut() {
|
||||
f.paint = Paint::Solid { color: white, swatch: Some("White".into()), tint: 1.0 };
|
||||
}
|
||||
draws_as_new(&mut linked, opts, opts, |d| {
|
||||
if let Some(s) = d.swatch_mut("White") {
|
||||
s.spot = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
draws_as_new(&mut proof_doc(), &separations, &separations, recolor_symbol);
|
||||
draws_as_new(&mut proof_doc(), &separations, &separations, |d| {
|
||||
|
||||
+13
-5
@@ -5176,10 +5176,18 @@ printed plates an image whose pixels do not take its color (a preview of its fil
|
||||
pixels. Older files that listed Overprint Black objects in the document get the flags on load.
|
||||
PDF export writes them with `advanced.overprint: "preserve"` (the default): each overprinting fill and stroke sets a
|
||||
graphics state with `/OP true /op true /OPM 1` (`/OPM 0` in PDF/A). With `discardWhiteOverprint` (`document.setup`, on by
|
||||
default) white ones knock out instead, but not a tint above 0% of a spot swatch, which prints as that ink;
|
||||
`"discard"` writes none. EPS export (`overprints: "preserve"`, the default) turns
|
||||
overprinting on for a colorized image's color as it does for fills and strokes, except a white color with
|
||||
`discardWhiteOverprint` on, which knocks out unless it is such a spot tint. PDF export writes an overprinting
|
||||
default) paper white ones knock out instead; `"discard"` writes none. Paper white is solid white that is not a spot
|
||||
white. Spot white objects keep overprinting
|
||||
([white overprint](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/white-overprint.html),
|
||||
[reference, White Overprint](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=650)).
|
||||
These are VectorCraft's own rules: a spot white is a white linked to a solid spot swatch at a tint above 0% (an opaque
|
||||
white ink, for example), so a 0% tint of a spot swatch is paper white, and so is a spot white that printed separations
|
||||
convert to process inks. A spot white's fills, strokes, characters and colorized image colors keep overprinting in PDF
|
||||
export, Overprint Preview, Separations Preview and printed separations, its fills, strokes and colorized image colors
|
||||
keep overprinting in composite print with Overprints set to Simulate, and Print Ink Fixes' `removeWhiteOverprint`
|
||||
leaves it overprinting. EPS export (`overprints: "preserve"`, the default) turns overprinting on for a colorized image's
|
||||
color as it does for fills and strokes, except a paper white color with `discardWhiteOverprint` on, which knocks out;
|
||||
EPS export applies `discardWhiteOverprint` to nothing else. PDF export writes an overprinting
|
||||
colorized image in a gray or CMYK color in only the process inks the color puts down, and EPS export does too (one
|
||||
DeviceN image at Level 3, one Separation image per ink at Level 2). The previews and printed separations show a
|
||||
colorized image knocking out when it has a visible effect of its own other than a warp or a geometry effect (a drop
|
||||
@@ -15672,7 +15680,7 @@ document's inks for print, as one undo step:
|
||||
| `scope` | `selection`, `document` (the selection, or the document while nothing is selected) | What it fixes; `ids` stand for the selection |
|
||||
| `inkLimit` | total ink % 1…400, 0 off (off) | CMYK colours (solid, gradient stops, gradient meshes) with more ink than this are scaled down to it; colours of spot swatches and Registration stay |
|
||||
| `excludePureBlack` | bool (true) | Black-only CMYK and grey colours keep their ink |
|
||||
| `removeWhiteOverprint` | bool (false) | White fills and strokes, characters' and the white color of a colorized image stop overprinting |
|
||||
| `removeWhiteOverprint` | bool (false) | White fills and strokes, characters' and the white color of a colorized image stop overprinting; a white linked to a spot swatch at a tint above 0% is an ink and keeps overprinting |
|
||||
| `overprintBlack` | black % 1…100, 0 off (off) | Black-only and grey fills and strokes this dark or darker overprint, as `edit.colors.overprintBlack` sets it (not spot-linked or rich blacks) |
|
||||
| `textOnly` | bool (false) | Overprint Black on type only |
|
||||
| `fill`, `stroke` | bool (true) | Which paints the fixes reach |
|
||||
|
||||
@@ -2409,6 +2409,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
- On a PostScript plate, an overprinting gradient that puts the plate's ink down in some places and none in others leaves the ink below where it puts none: the stretches between stops of paper white and the padding past an end that is painted paper white (with the end stop's color at Level 2 and the color of the stretch next to it in a Level 3 smooth shading, which differ when two stops share the end's offset) are clipped out of a linear, radial or diamond gradient, the wedges of paper white out of a conic one, and the cells whose 8-bit samples carry none of the plate's ink out of a freeform one (masked at Level 3, clipped at Level 2). This holds for fills, strokes and characters, and on spot plates. Where the gradient puts ink down, its amount replaces the ink below as before. A stop or point with up to half a percent of another ink in a color that counts as black puts none down, as a solid fill of that color does. PDF plates are unchanged. These are VectorCraft's own rules. Evidence: `print::tests::an_overprinting_gradient_keeps_the_ink_below_where_it_puts_none_on_a_postscript_plate`, `print::tests::an_overprinting_gradient_with_a_hard_stop_at_an_end_keeps_the_ink_below_on_a_postscript_plate`, `print::tests::overprinting_gradient_strokes_type_freeforms_and_spot_inks_keep_the_ink_below_on_postscript_plates` and `print::tests::an_overprinting_freeform_gradient_leaves_out_the_cells_its_samples_write_without_ink_on_a_postscript_plate` (`vectorcraft-eps`), `tests::print::a_near_black_stop_of_an_overprinting_gradient_puts_no_cyan_on_postscript_plates`.
|
||||
- The Print dialog's Graphics section's Fonts setting now reaches PostScript output, with the three choices [the help page](https://help.adobe.com/archive/en_US/illustrator/cs3/illustrator_cs3_help.pdf#page=418) describes: Subset (the default) sends each page Type 3 fonts holding only the glyphs that page shows, Complete sends every glyph of each font once before the first page (an error past 64 MB), and None sends no font and asks for the printer's own by its PostScript name, with a note naming each one. Type in a gradient or pattern, color glyphs, glyphs bent along a curved path, ruby, a glyph without a name under None, and fonts whose license forbids embedding (or allows only whole embedding, under Subset) print as outlines as before, the license cases with a warning. PDF print still embeds subsets of the fonts whose licenses allow it and draws the others as outlines, and None or Complete adds a note saying so. The outlines-as-fallback and the size limit are VectorCraft's own rules. Evidence: `print::tests::subset_downloads_used_glyphs_once_per_page`, `print::tests::complete_downloads_whole_font_once_before_pages`, `print::tests::none_references_font_without_downloading_it`, `print::tests::forbidden_font_stays_art_with_a_note`, `print::tests::complete_large_font_fails_before_partial_output` (`vectorcraft-eps`), `tests::printps::the_fonts_setting_chooses_how_type_is_sent`, `tests::print::non_subset_font_choices_report_pdf_subset_output` (`vectorcraft-pdf`). Print scores and hours are unchanged.
|
||||
- The Print dialog's Output section has Overprint Black under Convert All Spot Colors to Process, off by default and available with Separations ([Print color separations](https://helpx.adobe.com/illustrator/using/printing-color-separations.html) lists it among the separation options): black art then leaves the inks under it on the other plates (`print.setup {settings: {output: {overprintBlack: true}}}`, kept with the document and in print presets). Solid 100% K or 100% gray fills, strokes and characters (to within half a percent, as Edit › Edit Colors › Overprint Black counts them), and gradients whose every stop (every color point of a freeform gradient) is, overprint; rich, RGB, Lab, spot-linked and lighter blacks are not marked, paints already set to overprint keep that setting, and only the printed copy is marked. These limits are VectorCraft's own rules. Characters set to overprint now also leave the inks below them on printed PDF plates, a type object's own fill in a PDF is drawn with its blending mode, and Edit › Edit Colors › Overprint Black counts a gradient with a stop linked to a spot swatch as a spot black, as it counts a solid one, and a freeform gradient by the color points it draws from. On a plate, an overprinting paint that puts none of that plate's ink down is drawn as nothing; on PostScript plates so is up to half a percent of another ink in a color that counts as black, and any other faint ink stays on the plate. A black linked to a swatch the document lacks separates from its own values, so on PostScript plates it counts as an unlinked black (VectorCraft's own rule). Evidence: `print::overprint_black_keeps_the_inks_under_solid_black_on_separations`, `print::overprint_black_keeps_the_cyan_under_near_and_freeform_blacks_on_postscript_plates`, `print::overprint_black_keeps_the_cyan_under_a_near_black_linked_to_a_missing_swatch_on_postscript_plates`, `print::overprinting_near_blacks_linked_to_a_missing_swatch_keep_the_cyan_on_postscript_plates`, `print::overprinting_paints_keep_their_faint_ink_on_postscript_plates`, `print::overprinting_type_leaves_the_inks_below_on_separations`, `print::a_type_objects_own_black_fill_overprints_on_separations`, `tests::print::overprint_black_is_saved_with_the_setup_and_in_presets`, `overprint::tests::a_gradient_with_a_spot_linked_stop_is_black_only_with_spot`, `overprint::tests::a_freeform_gradient_is_black_when_every_point_is`. Print scores and hours are unchanged.
|
||||
- With Discard White Overprint on, spot white objects keep overprinting and only paper white knocks out ([white overprint](https://helpx.adobe.com/illustrator/desktop/manage-colors/apply-transparency-and-blending/white-overprint.html), [reference, White Overprint](https://web.archive.org/web/20210601162814/https://helpx.adobe.com/pdf/illustrator_reference.pdf#page=650)). These are VectorCraft's own rules: a spot white is a white linked to a solid spot swatch at a tint above 0% (an opaque white ink, for example), so a 0% tint of a spot swatch is paper white, and so is a spot white that printed separations convert to process inks. A spot white's fills, strokes and characters keep overprinting in PDF export, Overprint Preview, Separations Preview and printed separations, its fills and strokes keep overprinting in composite print with Overprints set to Simulate, and Print Ink Fixes' Remove White Overprint leaves it overprinting. Overprint Preview and Separations Preview now also show overprinting paper white characters knocking out while the option is on, as PDF export writes them. EPS export keeps every overprint, as before. Evidence: `overprint::tests::a_white_spot_ink_overprints_under_discard_white`, `tests::layers::a_white_spot_ink_keeps_overprinting_under_discard_white_overprint` and `tests::print::a_white_spot_ink_keeps_overprinting_on_plates_and_in_simulated_composites` (`vectorcraft-pdf`), `cmd::addons::color::print_fixes::tests::a_white_spot_ink_keeps_its_overprint`, `tests::docsetup::discard_white_overprint_keeps_white_overprints_in_overprint_preview`, `tests::memory::proof_previews_draw_changes_as_a_new_renderer_does`, `tests::memory::overprinting_white_characters_follow_discard_white_overprint`. Print scores and hours are unchanged.
|
||||
- The Print dialog's General section (and the print preset editor) has a link button after Scale W and H, as the Custom scale has one on [the help page](https://helpx.adobe.com/illustrator/desktop/save-and-export/export-files-to-different-formats/print-documents-in-illustrator.html), where turning it off scales the width and height apart. While it is on, typing either percentage sets the other, and turning it on sets H to W. It is on for new settings, dimmed with the fields unless Scaling is Custom or a tiling choice, toggled with a click, Space or Enter, and named with its on or off state for screen readers. W and H take 1–1000% in the fields. The link is kept with the document's print settings and in print presets (`print.setup {settings: {scale: {linked}}}`); settings saved without it read it as off, so they print as before. Its default, the tiling choices and the agent rules are VectorCraft's own. Evidence: `print::the_scale_link_is_on_for_new_settings_and_off_for_a_saved_scale_without_it`, `tests::print::the_scale_link_keeps_width_and_height_equal`, `tests::print::a_scale_saved_without_the_link_keeps_its_width_and_height`, `dialogs::tests_print::the_scale_link_keeps_scale_width_and_height_equal`, `dialogs::tests_print::a_print_preset_keeps_the_scale_link`. Print scores and hours are unchanged.
|
||||
- A PDF, PDF-compatible `.ai` or `.ait` opened from its pages or its editing copy opens with the File Info that its XMP packet and its document information dictionary give: the title (`dc:title`, its `x-default` item first, else Info `Title`), the author, description, keywords, copyright status, notice and URL, and the created and modified dates, the XMP packet's value where both give one (`crates/pdf/src/tests/file_info.rs`, `crates/engine/src/tests/fileinfo.rs`). An SVG opens with the title of its root `<title>`. The title is File Info's alone (`DocMetadata::title`): the document's name stays the file's name with its extension, a file that gives no title leaves File Info with that name, and exports (PDF, SVG, PNG, EPS, `.ai`) and native saves carry it; changing the title in File Info sets the document's name as before (#3626).
|
||||
- PDF export and PDF-compatible `.ai` and `.ait` saves write the document's File Info created date as the file's creation date, or the time of writing when the document has none, and the time of writing as its modification date; the page information mark still prints the time of writing (`crates/engine/src/tests/fileinfo.rs`, `crates/pdf/src/tests.rs`, `crates/pdf/src/tests/marks.rs`).
|
||||
@@ -2522,7 +2523,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
|
||||
The undo histories of all the open documents together keep their steps within a quarter of the installed memory on the same systems (at least 64 MiB, and at most a quarter of the address space in a 32-bit build), within 1 GiB where the installed memory can't be read, and within 256 MiB in the web build; past that budget the oldest steps of any open document are dropped first, but each document keeps its last eight undo steps and its next eight redo steps. Closing a document frees its share for the others.
|
||||
With `--deep`, each memory row of `vectorcraft-cli perf` also gives the peak so far: the peak working set on Windows and the peak resident memory (`VmHWM`) on Linux. A new last row gives the memory after the SVG export and the save → open → save at the end of the run.
|
||||
The renderer composes the two ink planes of a CMYK document that shows transparency into screen colors on up to as many threads as it rasterizes with, instead of on one. At 2880 × 1800 on 8 threads, a page of 300 shapes at 20% to 90% opacity takes 30 ms a frame instead of 55 ms, and 50,000 paths with one at 99% opacity take 258 ms instead of 361 ms (`vectorcraft-cli bench`), with the same pixels.
|
||||
With Overprint Preview or Separations Preview on, the renderer keeps the art it prepared for the preview from one frame to the next. It prepares again the objects that changed, and all of the art when Discard White Overprint changes or, with Separations Preview, when the plates shown, the proof setup, the swatches, the Spot Colors option or the color settings change or a profile is loaded. It draws the other objects from the art, geometry and stroke outlines it kept for them.
|
||||
With Overprint Preview or Separations Preview on, the renderer keeps the art it prepared for the preview from one frame to the next. It prepares again the objects that changed, and all of the art when Discard White Overprint changes, when a swatch becomes or stops being a spot color while it is on, or, with Separations Preview, when the plates shown, the proof setup, the swatches, the Spot Colors option or the color settings change or a profile is loaded. It draws the other objects from the art, geometry and stroke outlines it kept for them.
|
||||
Pathfinder › Merge and the `pathfinder.merge` group effect find the faces of every fill in a few contour passes over the arrangement, as Trim and Crop do, instead of one pass for each distinct fill. The output paths and their order are the same. With 8,000 squares that do not touch, each with its own fill, Merge takes 72 to 107 ms instead of 17 to 32 s (release build).
|
||||
The Pathfinder panel, Offset Path, Clean Up, Divide Objects Below, Make and Release Blend, Envelope Distort's Make and Release, Repeat (Radial, Grid, Mirror and Release), Vector Halftone, New and Redefine Symbol, Delete Symbol, erasing with the Symbol Sprayer, Rasterize, Convert to Artboards, Flatten Transparency, Clear Guides, Shape Builder, Live Paint, Release Image Trace, Make and Release Opacity Mask, Delete with direct-selected anchor points, Remove Anchor Points, Cut Path, and the Shaper, Knife, Eraser, Path Eraser, Line Cut, Rectangle Cut, Mirror & Cut and Blob Brush tools add and remove objects in one pass over each layer or group they change, and Outline Stroke and Expand write each new object in the place of the object it replaces (#1429).
|
||||
Cut Path at Selected Anchor Points (`path.cutAtAnchors`) selects the cut ends with one selection call, which skips paths already selected through a hash set, instead of adding each cut path in turn and searching the paths already added. The selection is the same, every field (`selecting_cut_ends_matches_adding_them_one_by_one`). With the 8 middle anchors of each of 5,000 open paths of 10 anchors selected, building the selection of 40,000 cut ends takes 9.7 ms instead of 232 ms of CPU time, and with 2,000 paths 3.2 ms instead of 39 ms; at 500 paths both take 3 ms or less (medians of 7 runs, `cargo run --release -p vectorcraft-engine --example cut_path_select_bench`). Scores and hours unchanged.
|
||||
|
||||
Reference in New Issue
Block a user