From 41c8f19eb3e9cc422b77755882c0a1bfeeb85530 Mon Sep 17 00:00:00 2001 From: Robin Watts Date: Thu, 21 Sep 2017 18:22:48 +0100 Subject: Disallow overprinting if CMYK spaces mismatch. Testing tests/Ghent_V3.0/132_ICCbasedOverPrint.pdf shows that we were incorrectly allowing performing the overprint magic in the case where we were rendering to a CMYK pixmap in a different CMYK space. This is not allowed. --- source/fitz/draw-device.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'source') diff --git a/source/fitz/draw-device.c b/source/fitz/draw-device.c index 8adef1a3..4b098d57 100644 --- a/source/fitz/draw-device.c +++ b/source/fitz/draw-device.c @@ -496,6 +496,7 @@ resolve_color(fz_context *ctx, fz_overprint *op, const float *color, fz_colorspa int i; int n = dest->n - dest->alpha; fz_colorspace *model = dest->colorspace; + int devn; if (colorspace == NULL && model != NULL) fz_throw(ctx, FZ_ERROR_GENERIC, "color destination requires source color"); @@ -503,12 +504,19 @@ resolve_color(fz_context *ctx, fz_overprint *op, const float *color, fz_colorspa if (color_params == NULL) color_params = fz_default_color_params(ctx); + devn = fz_colorspace_is_device_n(ctx, colorspace); + /* We can only overprint when enabled, and when we are in a subtractive colorspace */ if (!color_params || color_params->op == 0 || !fz_colorspace_is_subtractive(ctx, dest->colorspace)) op = NULL; + /* If we are in a CMYK space (i.e. not a devn one, given we know we are subtractive at this point), + * then we only overprint if it's the same space as the destination. */ + /* FIXME: Possibly we need a better equivalency test here. */ + else if (!devn && colorspace != dest->colorspace) + op = NULL; if (n == 0) i = 0; - else if (fz_colorspace_is_device_n(ctx, colorspace) && colors_supported(ctx, colorspace, dest)) + else if (devn && colors_supported(ctx, colorspace, dest)) { fz_convert_separation_colors(ctx, color_params, dest->colorspace, dest->seps, colorfv, colorspace, color); for (i = 0; i < n; i++) -- cgit v1.2.3