mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-11-25 20:01:07 +01:00
Merge pull request #9141 from dotCooCoo/fix/eps-discard-white-overprint
EPS: white fills and strokes knock out with Discard White Overprint
This commit is contained in:
8 files changed
+243
-19
No files matched your search
@@ -33,7 +33,7 @@ pub fn specs() -> Vec<CommandSpec> {
|
||||
"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)|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
|
||||
)]
|
||||
|
||||
@@ -212,11 +212,29 @@ fn flattening_cropped_art_keeps_the_art_under_its_hidden_part() {
|
||||
fn overprints_are_kept_or_discarded() {
|
||||
let mut s = session(100.0, 100.0, 1);
|
||||
let id = s.execute("shape.rectangle", &json!({"x": 10, "y": 10, "width": 30, "height": 30})).unwrap()["id"].as_u64().unwrap();
|
||||
s.execute("paint.setFill", &json!({"ids": [id], "color": {"c": 100, "m": 0, "y": 0, "k": 0}})).unwrap();
|
||||
s.execute("attributes.set", &json!({"ids": [id], "overprintFill": true})).unwrap();
|
||||
let kept = postscript(&b64(&s.execute("document.exportEps", &json!({"previewFormat": "none"})).unwrap()));
|
||||
assert!(kept.contains("true op\n"), "{kept}");
|
||||
let dropped = postscript(&b64(&s.execute("document.exportEps", &json!({"previewFormat": "none", "overprints": "discard"})).unwrap()));
|
||||
assert!(!dropped.contains("true op"));
|
||||
|
||||
// A white fill or stroke that overprints knocks out with Discard White Overprint (on by
|
||||
// default), and overprints without it, as in PDF export.
|
||||
let white = json!({"c": 0, "m": 0, "y": 0, "k": 0});
|
||||
let filled = [json!({"ids": [id], "color": white}), json!({"ids": [id], "none": true})];
|
||||
let stroked = [json!({"ids": [id], "none": true}), json!({"ids": [id], "color": white})];
|
||||
for (i, [fill, stroke]) in [filled, stroked].iter().enumerate() {
|
||||
s.execute("paint.setFill", fill).unwrap();
|
||||
s.execute("paint.setStroke", stroke).unwrap();
|
||||
s.execute("attributes.set", &json!({"ids": [id], "overprintFill": i == 0, "overprintStroke": i == 1})).unwrap();
|
||||
s.execute("document.setup", &json!({"discardWhiteOverprint": true})).unwrap();
|
||||
let knocked_out = postscript(&b64(&s.execute("document.exportEps", &json!({"previewFormat": "none"})).unwrap()));
|
||||
assert!(!knocked_out.contains("true op"), "{i}: {knocked_out}");
|
||||
s.execute("document.setup", &json!({"discardWhiteOverprint": false})).unwrap();
|
||||
let overprinted = postscript(&b64(&s.execute("document.exportEps", &json!({"previewFormat": "none"})).unwrap()));
|
||||
assert!(overprinted.contains("true op\n"), "{i}: {overprinted}");
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
@@ -132,6 +132,15 @@ fn over(under: Option<Paint>, 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,
|
||||
|
||||
+42
-13
@@ -298,6 +298,8 @@ pub(crate) struct Scene<'a> {
|
||||
/// The gradient being painted overprints on a plate: where it is paper white it puts none of
|
||||
/// the plate's ink down, and the plate below it is left as it is ([`Self::inked_spans`]).
|
||||
keep_below: bool,
|
||||
/// Overprinting is on in the page's graphics state ([`Self::overprint_on`]).
|
||||
overprinting: bool,
|
||||
/// The print job's fonts: type in a solid fill is shown through them (`None`: drawn as
|
||||
/// outlines).
|
||||
fonts: Option<&'a RefCell<FontJob>>,
|
||||
@@ -336,6 +338,7 @@ impl<'a> Scene<'a> {
|
||||
nest: 0,
|
||||
plate: false,
|
||||
keep_below: false,
|
||||
overprinting: false,
|
||||
fonts: None,
|
||||
used: UsedGlyphs::new(),
|
||||
used_order: vec![],
|
||||
@@ -535,11 +538,30 @@ impl<'a> Scene<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
/// Turn overprinting on for one paint (when overprints are preserved); `false` when it stays off.
|
||||
/// 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 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
|
||||
}
|
||||
|
||||
/// Whether `paint` is a tint above 0% of a spot swatch with a solid color, which the page writes
|
||||
/// as a Separation ink of its own ([`Self::spot_space`]); a link is judged by the first swatch of
|
||||
/// its name.
|
||||
fn spot_ink(&self, paint: &Paint) -> bool {
|
||||
matches!(paint, Paint::Solid { swatch: Some(name), tint, .. } if *tint > 0.0 && self.doc.swatch(name).is_some_and(|s| s.spot && s.paint.color().is_some()))
|
||||
}
|
||||
|
||||
/// Turn overprinting on for one paint (when overprints are preserved); `false` when it stays off
|
||||
/// or is already on (a pattern's tiles inside an overprinting pattern fill).
|
||||
fn overprint_on(&mut self, overprint: bool) -> bool {
|
||||
let on = overprint && self.o.overprint == Overprint::Preserve;
|
||||
let on = overprint && self.o.overprint == Overprint::Preserve && !self.overprinting;
|
||||
if on {
|
||||
self.line("true op");
|
||||
self.overprinting = true;
|
||||
}
|
||||
on
|
||||
}
|
||||
@@ -547,6 +569,7 @@ impl<'a> Scene<'a> {
|
||||
fn overprint_off(&mut self, on: bool) {
|
||||
if on {
|
||||
self.line("false op");
|
||||
self.overprinting = false;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -611,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),
|
||||
@@ -729,7 +754,8 @@ impl<'a> Scene<'a> {
|
||||
match item {
|
||||
AppearanceItem::Fill(fl) if fl.visible && !fl.paint.is_none() => {
|
||||
self.note_item(fl.opacity, fl.blend);
|
||||
self.fill(bp, rule, &fl.paint, bounds, fl.overprint);
|
||||
let overprint = self.overprints(fl.overprint, &fl.paint);
|
||||
self.fill(bp, rule, &fl.paint, bounds, overprint);
|
||||
}
|
||||
AppearanceItem::Stroke(st) if st.visible && !st.paint.is_none() && st.width > 0.0 && st.width.is_finite() => {
|
||||
self.stroke(bp, rule, st, bounds);
|
||||
@@ -812,6 +838,7 @@ impl<'a> Scene<'a> {
|
||||
return;
|
||||
}
|
||||
self.note_item(st.opacity, st.blend);
|
||||
let overprint = self.overprints(st.overprint, &st.paint);
|
||||
let paint_bounds = st.paint_bounds(bounds);
|
||||
let area_paint = match &st.paint {
|
||||
Paint::Pattern { .. } => true,
|
||||
@@ -822,7 +849,7 @@ impl<'a> Scene<'a> {
|
||||
// The area the stroke paints, as Outline Stroke makes it, painted with the pattern's
|
||||
// tiles or the freeform's image.
|
||||
let region = stroke::outline_region(&PathData::from_bezpath(bp), rule, st).to_bezpath();
|
||||
self.fill(®ion, FillRule::NonZero, &st.paint, paint_bounds, st.overprint);
|
||||
self.fill(®ion, FillRule::NonZero, &st.paint, paint_bounds, overprint);
|
||||
return;
|
||||
}
|
||||
let w = stroke::for_writer(bp, st);
|
||||
@@ -847,7 +874,7 @@ impl<'a> Scene<'a> {
|
||||
};
|
||||
match &w.shape {
|
||||
WrittenShape::Stroke { width } => {
|
||||
let on = self.overprint_on(st.overprint);
|
||||
let on = self.overprint_on(overprint);
|
||||
self.line_style(st, *width);
|
||||
match &st.paint {
|
||||
Paint::Solid { color, swatch, tint } => {
|
||||
@@ -861,7 +888,7 @@ impl<'a> Scene<'a> {
|
||||
self.line("q");
|
||||
push_path(&mut self.body, bp);
|
||||
self.line("strokepath W");
|
||||
self.paint_overprinting(st.overprint, p, paint_bounds, w.reach(st, bounds));
|
||||
self.paint_overprinting(overprint, p, paint_bounds, w.reach(st, bounds));
|
||||
self.line("Q");
|
||||
}
|
||||
}
|
||||
@@ -874,14 +901,14 @@ impl<'a> Scene<'a> {
|
||||
push_path(&mut self.body, &ws.clip);
|
||||
self.body.push_str(clip_op(FillRule::NonZero));
|
||||
for (shape, paint) in &ws.slices {
|
||||
self.fill(shape, FillRule::NonZero, paint, shape.bounding_box(), st.overprint);
|
||||
self.fill(shape, FillRule::NonZero, paint, shape.bounding_box(), overprint);
|
||||
}
|
||||
self.line("Q");
|
||||
}
|
||||
}
|
||||
WrittenShape::Fill(outlines) => {
|
||||
for o in outlines {
|
||||
self.fill(o, FillRule::NonZero, &st.paint, paint_bounds, st.overprint);
|
||||
self.fill(o, FillRule::NonZero, &st.paint, paint_bounds, overprint);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -989,12 +1016,13 @@ impl<'a> Scene<'a> {
|
||||
if bp.elements().is_empty() {
|
||||
continue;
|
||||
}
|
||||
let overprint = self.overprints(run.style.overprint_fill, &run.style.fill);
|
||||
if fonts.is_none() {
|
||||
self.fill(&bp, FillRule::NonZero, &run.style.fill, layout.bounds, run.style.overprint_fill);
|
||||
self.fill(&bp, FillRule::NonZero, &run.style.fill, layout.bounds, overprint);
|
||||
} else {
|
||||
self.show(&shown, &run.style.fill, run.style.overprint_fill);
|
||||
self.show(&shown, &run.style.fill, overprint);
|
||||
if !art.elements().is_empty() {
|
||||
self.fill(&art, FillRule::NonZero, &run.style.fill, layout.bounds, run.style.overprint_fill);
|
||||
self.fill(&art, FillRule::NonZero, &run.style.fill, layout.bounds, overprint);
|
||||
}
|
||||
}
|
||||
if run.style.has_stroke() {
|
||||
@@ -1014,7 +1042,8 @@ impl<'a> Scene<'a> {
|
||||
match item {
|
||||
AppearanceItem::Fill(fl) if fl.visible && !fl.paint.is_none() => {
|
||||
self.note_item(fl.opacity, fl.blend);
|
||||
self.fill(bp, FillRule::NonZero, &fl.paint, tb, fl.overprint);
|
||||
let overprint = self.overprints(fl.overprint, &fl.paint);
|
||||
self.fill(bp, FillRule::NonZero, &fl.paint, tb, overprint);
|
||||
}
|
||||
AppearanceItem::Stroke(st) if st.visible && !st.paint.is_none() && st.width > 0.0 && st.width.is_finite() => {
|
||||
self.stroke(bp, FillRule::NonZero, st, tb);
|
||||
|
||||
@@ -448,6 +448,106 @@ fn spot_colours_are_separations_and_overprints_are_kept_or_dropped() {
|
||||
assert!(!page_of(&d, &EpsOptions { overprint: Overprint::Discard, ..opts(&d) }).contains("true op"));
|
||||
}
|
||||
|
||||
/// Whether overprinting is on at each fill a page paints, by its `true op` and `false op` lines.
|
||||
fn overprint_at_fills(page: &str) -> Vec<bool> {
|
||||
let mut on = false;
|
||||
let mut fills = vec![];
|
||||
for line in page.lines() {
|
||||
match line {
|
||||
"true op" => on = true,
|
||||
"false op" => on = false,
|
||||
l if l == "f" || l.ends_with(" f") || l.ends_with(" f*") || l == "f*" => fills.push(on),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
fills
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn tiles_overprint_with_their_overprinting_pattern() {
|
||||
// A rectangle filled with an overprinting pattern whose tile is a white square marked to
|
||||
// overprint and then a cyan one that is not.
|
||||
let mut d = doc_with(|_| vec![]);
|
||||
let square = |d: &mut Document, paint: Paint, overprint: bool| {
|
||||
let mut n = path(d, shapes::rectangle(Rect::new(0.0, 0.0, 10.0, 10.0)), paint, Paint::None, 0.0);
|
||||
if let Some(AppearanceItem::Fill(f)) = n.appearance.items.first_mut() {
|
||||
f.overprint = overprint;
|
||||
}
|
||||
Arc::new(n)
|
||||
};
|
||||
let tile = vec![square(&mut d, Paint::solid(Color::WHITE), true), square(&mut d, Paint::solid(Color::cmyk(1.0, 0.0, 0.0, 0.0)), false)];
|
||||
d.patterns.push(vectorcraft_doc::PatternDef::new("tile", tile));
|
||||
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();
|
||||
// The whole pattern overprints, as in PDF export: the white square's own mark does not turn
|
||||
// overprinting off for the cyan square after it, and Discard White Overprint applies to the
|
||||
// pattern fill, not to its tiles.
|
||||
let fills = overprint_at_fills(&page_of(&d, &opts(&d)));
|
||||
assert!(!fills.is_empty() && fills.iter().all(|&on| on), "{fills:?}");
|
||||
// On a plate too.
|
||||
let plate = crate::scene::Scene::new(&d, &opts(&d)).on_plate(true).run();
|
||||
let fills = overprint_at_fills(&plate.body);
|
||||
assert!(!fills.is_empty() && fills.iter().all(|&on| on), "{fills:?}");
|
||||
}
|
||||
|
||||
/// A white character fill, and a white fill of the type object itself, marked to overprint knock
|
||||
/// out with Discard White Overprint and overprint without it.
|
||||
#[test]
|
||||
fn white_type_fills_knock_out_with_discard_white_overprint() {
|
||||
use vectorcraft_doc::{CharStyle, FillLayer, TextObject};
|
||||
let white = Paint::solid(Color::WHITE);
|
||||
let char_fill = CharStyle { size: 30.0, fill: white.clone(), overprint_fill: true, ..CharStyle::default() };
|
||||
let object_fill = CharStyle { size: 30.0, fill: Paint::None, ..CharStyle::default() };
|
||||
for (i, style) in [char_fill, object_fill].into_iter().enumerate() {
|
||||
let mut d = doc_with(|d| {
|
||||
let mut n = Node::new(d.alloc_id(), NodeKind::Text(Box::new(TextObject::point(Point::new(20.0, 100.0), "AB", style))));
|
||||
if i == 1 {
|
||||
n.appearance.items = vec![AppearanceItem::Fill(FillLayer { overprint: true, ..FillLayer::new(white.clone()) })];
|
||||
}
|
||||
vec![n]
|
||||
});
|
||||
let fills = overprint_at_fills(&page_of(&d, &opts(&d)));
|
||||
assert!(!fills.is_empty() && fills.iter().all(|&on| !on), "{i}: {fills:?}");
|
||||
d.setup.discard_white_overprint = false;
|
||||
let fills = overprint_at_fills(&page_of(&d, &opts(&d)));
|
||||
assert!(!fills.is_empty() && fills.iter().all(|&on| on), "{i}: {fills:?}");
|
||||
}
|
||||
}
|
||||
|
||||
/// Discard White Overprint applies to paper white only: a white fill linked to a spot swatch
|
||||
/// still overprints, at 100% and 50%; one linked to a global process swatch, at a 0% tint of a
|
||||
/// spot swatch, or to a spot swatch without a color (written as process) knocks out.
|
||||
#[test]
|
||||
fn spot_white_fills_overprint_with_discard_white_overprint() {
|
||||
let white = Paint::solid(Color::WHITE);
|
||||
let cases = [
|
||||
(true, white.clone(), 1.0, true),
|
||||
(true, white.clone(), 0.5, true),
|
||||
(false, white.clone(), 1.0, false),
|
||||
(true, white.clone(), 0.0, false),
|
||||
(true, Paint::None, 1.0, false),
|
||||
];
|
||||
for (spot, swatch, tint, overprints) in cases {
|
||||
let mut d = doc_with(|_| vec![]);
|
||||
d.swatches.push(Swatch { name: "White Ink".into(), paint: swatch, global: true, spot });
|
||||
let mut n = red_rect(&mut d);
|
||||
if let Some(AppearanceItem::Fill(f)) = n.appearance.items.first_mut() {
|
||||
f.paint = Paint::Solid { color: Color::WHITE, swatch: Some("White Ink".into()), tint };
|
||||
f.overprint = true;
|
||||
}
|
||||
let layer = d.layers[0].id;
|
||||
d.insert(Some(layer), 0, n).unwrap();
|
||||
assert!(d.setup.discard_white_overprint);
|
||||
let fills = overprint_at_fills(&page_of(&d, &opts(&d)));
|
||||
assert_eq!(fills, vec![overprints], "spot: {spot}, tint: {tint}, expected to overprint: {overprints}");
|
||||
}
|
||||
}
|
||||
|
||||
const GOLD: Color = Color::Cmyk { c: 0.0, m: 0.2, y: 0.8, k: 0.1 };
|
||||
const LEAF: Color = Color::Cmyk { c: 1.0, m: 0.0, y: 1.0, k: 0.0 };
|
||||
|
||||
@@ -1253,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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
+4
-1
@@ -10484,7 +10484,10 @@ without `useArtboards` (no central file when no art shows). `level: 3` (default)
|
||||
shadings and masks transparent image pixels out; `level: 2` writes gradients as bands of colour (as does
|
||||
`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"`. RGB documents are written in CMYK unless `cmykPostScript: false`. A freeform gradient is
|
||||
`overprints: "discard"`. With `discardWhiteOverprint` (`document.setup`, on by default) paper white ones knock out
|
||||
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
|
||||
from the picture" once for all such images.
|
||||
|
||||
@@ -809,6 +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 `<name>_<artboard>.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 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`.
|
||||
|
||||
Reference in new issue
Block a user