PDF export: warn about spot stops in freeform gradients without points

A freeform gradient whose field has no points of its own takes its
colors from the stops, so spot-linked stops in it are written in
process colors too. The export now warns in that case, as it does for
the other gradients drawn as images.
This commit is contained in:
dotCooCoo
2026-11-04 20:36:11 +07:00
committed by bflatastic
parent 9a2f1e5eb7
commit dd41552c30
2 changed files with 17 additions and 1 deletions
+16
View File
@@ -321,3 +321,19 @@ fn spot_gradients_drawn_as_images_warn() {
assert!(pdf.contains("/Subtype/Image") && !pdf.contains("/Separation"), "a process Perceptual gradient");
assert!(!spot_warning(&warnings), "{warnings:?}");
}
#[test]
fn freeform_gradients_without_points_warn_about_spot_stops() {
let (mut s, id) = setup();
run(&mut s, "paint.editGradient", with(ink_to_white(100.0), json!({"kind": "freeform"})));
// A freeform field with no points of its own: the colors come from the stops, the first
// linked to the spot swatch.
let mut g = gradient(&s, id);
g.freeform = Some(vectorcraft_color::Freeform::default());
g.gradient.stops[0].swatch = Some("Ink".into());
let d = std::sync::Arc::make_mut(&mut s.doc_mut().unwrap().doc);
d.node_mut(id).unwrap().appearance.set_fill(Paint::Gradient(Box::new(g)));
let (pdf, warnings) = pdf_of(&s);
assert!(pdf.contains("/Subtype/Image"), "an image");
assert!(warnings.iter().any(|w| w.contains("spot colors in gradients exported as images")), "{warnings:?}");
}
+1 -1
View File
@@ -431,7 +431,7 @@ impl Exporter<'_> {
/// in process colors, so the spot inks have no plate of their own.
fn warn_spot_image(&mut self, g: &vectorcraft_color::GradientPaint) {
let doc = self.doc;
let from_stops = g.gradient.kind != GradientKind::Freeform || g.freeform.is_none();
let from_stops = g.gradient.kind != GradientKind::Freeform || !g.has_freeform_points();
if from_stops && g.gradient.stops.iter().any(|s| s.swatch.as_deref().is_some_and(|n| doc.swatch(n).is_some_and(|w| w.spot))) {
self.warn(
"spot colors in gradients exported as images (freeform or dithered gradients, and Perceptual ones with RGB or Lab stops or too many stops) are written in process colors",