Print: faint ink on paints marked to overprint is kept on PostScript plates

A PostScript plate drew an overprinting fill, stroke or character as
nothing when it put up to half a percent of that plate's ink down, so a
faint ink was lost from the plate. Now only a paint with no ink on the
plate is drawn as nothing, on PostScript and PDF plates alike. The one
exception is a color that counts as 100% black and is not linked to a
spot swatch or Registration: on a PostScript plate, up to half a percent
of another ink in it still counts as none, so a near black set to
overprint keeps the ink below it.
This commit is contained in:
dotCooCoo
2026-11-16 15:38:42 -08:00
parent 97a1a363b8
commit 79fdf113a5
3 changed files with 94 additions and 10 deletions
+19 -8
View File
@@ -9,7 +9,7 @@ use vectorcraft_color::cms::{self, Cms, Model, ProfileKind};
use vectorcraft_color::swatch::REGISTRATION;
use vectorcraft_color::{BlendMode, Color, GradientKind, Paint};
use vectorcraft_doc::inks::{Link, StopPlates, inks, plates, spot_color, stop_inks, visit_node_colors};
use vectorcraft_doc::overprint::{darken_overprints, is_white};
use vectorcraft_doc::overprint::{darken_overprints, is_black_ink, is_white};
use vectorcraft_doc::{AppearanceItem, ColorMode, Document, ImageBlob, Node, NodeKind};
use super::{DEFAULT_FREQUENCY, PrintInk, PrintSettings};
@@ -135,17 +135,26 @@ impl<'a> Separator<'a> {
/// Whether paint `p` puts none of ink `plate` down: a solid color, a gradient whose every stop
/// does, or a freeform gradient with color points whose every point does (points carry no
/// swatch link). On PostScript plates, to within half a percent (the other inks a black may
/// carry and still count as black, [`vectorcraft_doc::overprint::is_black_ink`]).
/// swatch link). Any ink above zero puts ink down, except on PostScript plates for a color that
/// counts as 100% black ([`vectorcraft_doc::overprint::is_black_ink`], as
/// [`vectorcraft_doc::overprint::OverprintBlack::default`] judges it) and is not linked to a
/// spot swatch, to Registration or to a swatch the document lacks: up to the half a percent of
/// another ink such a black may carry counts as none.
fn no_ink(&self, plate: &str, p: &Paint) -> bool {
let none = if self.postscript { 0.005 } else { 0.0 };
let process = |swatch: Option<&str>| swatch.is_none_or(|n| n != REGISTRATION && self.doc.swatch(n).is_some_and(|w| !w.spot));
let none = |c: &Color, process: bool, ink: f32| ink <= 0.0 || (self.postscript && process && ink <= 0.005 && is_black_ink(c, 1.0, false));
match p {
Paint::Solid { color, swatch, tint } => self.ink(plate, color, swatch.as_deref().map(|s| (s, *tint))) <= none,
Paint::Solid { color, swatch, tint } => {
none(color, process(swatch.as_deref()), self.ink(plate, color, swatch.as_deref().map(|s| (s, *tint))))
}
Paint::Gradient(g) => match g.freeform.as_ref().filter(|f| g.gradient.kind == GradientKind::Freeform && !f.points.is_empty()) {
Some(f) => f.points.iter().all(|pt| self.ink(plate, &pt.color, None) <= none),
Some(f) => f.points.iter().all(|pt| none(&pt.color, true, self.ink(plate, &pt.color, None))),
None => {
!g.gradient.stops.is_empty()
&& g.gradient.stops.iter().all(|s| self.stop_ink(plate, &s.color, s.swatch.as_deref().map(|n| (n, s.tint)), s.plates) <= none)
&& g.gradient.stops.iter().all(|s| {
let ink = self.stop_ink(plate, &s.color, s.swatch.as_deref().map(|n| (n, s.tint)), s.plates);
none(&s.color, s.plates.is_none() && process(s.swatch.as_deref()), ink)
})
}
},
_ => false,
@@ -156,7 +165,9 @@ impl<'a> Separator<'a> {
/// 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 with `discard_white` aside, which
/// knock out). A writer without blending modes (PostScript) then keeps the ink below them,
/// where it would draw their Darken as a knockout.
/// 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).
fn clear_inkless_overprints(&self, plate: &str, a: &mut Arc<Node>, discard_white: bool) {
let inkless = |overprint: bool, p: &Paint| overprint && !p.is_none() && !(discard_white && is_white(p)) && self.no_ink(plate, p);
let n = Arc::make_mut(a);
+74 -1
View File
@@ -725,7 +725,7 @@ fn overprint_black_keeps_the_cyan_under_near_and_freeform_blacks_on_postscript_p
#[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
// plate draws it as nothing (it has no blending modes).
// plate (it has no blending modes) draws it as nothing, since the color counts as black.
let mut square = Node::path(
vectorcraft_doc::NodeId(0),
shapes::rectangle(Rect::new(10.0, 15.0, 30.0, 35.0)),
@@ -745,6 +745,79 @@ fn an_overprinting_fill_keeps_its_faint_ink_on_pdf_plates() {
assert_eq!((fills(false), fills(true)), (2, 1), "the cyan plate as PDF, as PostScript");
}
#[test]
fn overprinting_paints_keep_their_faint_ink_on_postscript_plates() {
// 0.4% cyan in a color that is not black, set to overprint, on a fill, a stroke, a character
// fill, a linear gradient's stop and a freeform gradient's point: the cyan plate draws it on
// PDF and PostScript plates alike. A magenta with no cyan at all draws as nothing.
let faint = Color::cmyk(0.004, 0.5, 0.0, 0.0);
let magenta = Color::cmyk(0.0, 0.5, 0.0, 0.0);
let square = |x: f64, fill: Paint, stroke: Paint| {
let mut n =
Node::path(vectorcraft_doc::NodeId(0), shapes::rectangle(Rect::new(x, 15.0, x + 20.0, 35.0)), Appearance::basic(fill, stroke, 2.0));
if let Some(f) = n.appearance.fill_mut() {
f.overprint = true;
}
if let Some(s) = n.appearance.stroke_mut() {
s.overprint = true;
}
n
};
let linear = GradientPaint::new(Gradient::new(GradientKind::Linear, vec![GradientStop::new(0.0, faint), GradientStop::new(1.0, magenta)]));
let mut freeform =
GradientPaint::new(Gradient::new(GradientKind::Freeform, vec![GradientStop::new(0.0, magenta), GradientStop::new(1.0, magenta)]));
let points = vec![FreeformPoint::new(kurbo::Point::new(105.0, 20.0), magenta), FreeformPoint::new(kurbo::Point::new(115.0, 30.0), faint)];
freeform.freeform = Some(Freeform { points, ..Default::default() });
let style = vectorcraft_doc::CharStyle { fill: Paint::solid(faint), overprint_fill: true, ..Default::default() };
let text = vectorcraft_doc::TextObject::point(vectorcraft_geom::Point::new(20.0, 60.0), "Hi", style);
let d = over_cyan(vec![
square(10.0, Paint::solid(faint), Paint::None),
square(40.0, Paint::None, Paint::solid(faint)),
square(70.0, Paint::Gradient(Box::new(linear)), Paint::None),
square(100.0, Paint::Gradient(Box::new(freeform)), Paint::None),
square(130.0, Paint::solid(magenta), Paint::None),
Node::new(vectorcraft_doc::NodeId(0), NodeKind::Text(Box::new(text))),
// A black linked to the spot swatch at a 0.4% tint: 0.4% on the spot plate, none on the cyan.
square(160.0, Paint::Solid { color: Color::cmyk(0.0, 0.0, 0.0, 1.0), swatch: Some("Ink".into()), tint: 0.004 }, Paint::None),
]);
let opts = PrintOptions { settings: settings(json!({"output": {"mode": "separations"}})), postscript: true, ..Default::default() };
let p = plan(&d, &opts).unwrap();
let mut spot = vec![];
p.plates[4].walk(|n| {
spot.extend(n.appearance.fill().and_then(|f| f.paint.color()).map(|c| match c {
Color::Gray { k } => (k * 1000.0).round(),
c => panic!("{c:?}"),
}))
});
assert!(spot.contains(&4.0), "the PostScript spot plate draws the spot tint: {spot:?}");
// The fills, strokes and character fills the cyan plate draws, and the gray of the solid fills.
let drawn = |postscript: bool| {
let opts = PrintOptions { settings: settings(json!({"output": {"mode": "separations"}})), postscript, ..Default::default() };
let p = plan(&d, &opts).unwrap();
let (mut fills, mut strokes, mut chars, mut grays) = (0, 0, 0, vec![]);
p.plates[0].walk(|n| {
if let Some(f) = n.appearance.fill().filter(|f| !f.paint.is_none()) {
fills += 1;
if let Some(Color::Gray { k }) = f.paint.color() {
grays.push((k * 1000.0).round());
}
}
strokes += usize::from(n.appearance.stroke().is_some_and(|s| !s.paint.is_none()));
if let NodeKind::Text(t) = &n.kind {
chars += t.runs.iter().filter(|r| !r.style.fill.is_none()).count();
}
});
(fills, strokes, chars, grays)
};
for postscript in [false, true] {
let (fills, strokes, chars, grays) = drawn(postscript);
let at = if postscript { "PostScript" } else { "PDF" };
assert_eq!((strokes, chars), (1, 1), "{at}: the stroke and the character fill");
assert_eq!(fills, 4, "{at}: the cyan, the faint fill and both gradients, not the magenta");
assert_eq!(grays, [1000.0, 4.0], "{at}: the cyan and the faint fill's 0.4%");
}
}
#[test]
fn overprinting_type_leaves_the_inks_below_on_separations() {
let style = vectorcraft_doc::CharStyle { fill: Paint::solid(Color::cmyk(0.0, 0.0, 0.0, 1.0)), ..Default::default() };
+1 -1
View File
@@ -2006,7 +2006,7 @@ Moved from the ROADMAP's "Shipped so far" on 2026-10-10. Update it when a featur
- The Place dialog has a Show Import Options checkbox after Link, Template and Replace ([Place multiple files in a document](https://helpx.adobe.com/illustrator/desktop/add-and-import-files/import-other-file-types/place-multiple-files-in-a-document.html)). On (VectorCraft's default, saved with the preferences), each PDF, DXF or text file asks for its import options before it is placed, also in the place cursor; off (`file.place {showImportOptions: false}`), it is placed with the options last confirmed for its format, and only an encrypted PDF asks, for its password. Text Import Options now starts from the options confirmed last (`crates/ui-egui/src/tests/place.rs`).
- Separations Preview shows placed and embedded raster images on the visible plates, as it shows vector art (#4153): an RGB image's pixels are separated into process inks with the proof setup's intent, a CMYK image shows its own inks, a hidden plate's ink leaves the image, and with one plate visible the image shows that plate's ink as a grey. Raster images carry no spot ink, so a spot plate shown alone shows them as paper; a colorized image shows its color's plates. Emoji and other bitmap glyphs follow the same rule. The plate-filtered pixels and their reduced-size copies are kept apart from the image's own pixels, for each set of visible plates, proof setup and color settings, and with the preview off nothing changes. Evidence: `tests::colorize::separations_preview_shows_an_rgb_images_process_inks`, `separations_preview_shows_a_cmyk_images_own_inks`, `separations_preview_keeps_an_images_pixels_per_plate_set`. Print preview fidelity remains the open gap, so scores and hours are unchanged.
- Desktop print transport uses `craft-print` for CUPS and modern Windows. Sheet composition, copies, separations and colour management remain in VectorCraft. The Print dialog's Media list also carries the Japanese papers — JIS B4 257 × 364 mm, JIS B5 182 × 257 mm and JIS B6 128 × 182 mm beside the ISO B4/B5 (250 × 353 and 176 × 250 mm, kept so settings and presets saved before them keep their paper), and はがき 100 × 148 mm, 往復はがき 148 × 200 mm, 封筒 長形3号 120 × 235 mm, 長形4号 90 × 225 mm, 角形2号 240 × 332 mm, 角形3号 216 × 277 mm and 四六判 127 × 188 mm; the JSON id or the dialog label names a paper, any case and spacing (`B5 (JIS)` or `b5jis`) (`crates/pdf/src/print/settings.rs`, `crates/pdf/src/tests/print.rs`). The print-preview and physical-device fidelity gaps remain, so 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 knock out, 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. 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::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.
- 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 knock out, 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. 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::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.
- 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`).
- PDF export and PDF-compatible `.ai` and `.ait` saves write File Info's copyright notice, URL and status to the XMP packet (`dc:rights`, `xmpRights:WebStatement`, `xmpRights:Marked`), so a PDF or `.ai` opened from its pages keeps them (`crates/pdf/src/tests/file_info.rs`, `crates/engine/src/tests/fileinfo.rs`).