From 477bcd89d716be372ebecc2b89381f4d9745f5e2 Mon Sep 17 00:00:00 2001 From: Adrian Johnson Date: Thu, 2 Feb 2012 22:58:06 +1030 Subject: [PATCH] ps: ensure shading domain is [ 0 1 ] Printing to a printer with an Adobe PostScript 3 interpreter fails with rangecheck when the shading domain is not [ 0 1 ]. Workaround this by using a type 3 function to map from [ 0 1] to the required domain. --- src/cairo-ps-surface.c | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c index f20bd4f56..62b7d64a6 100644 --- a/src/cairo-ps-surface.c +++ b/src/cairo-ps-surface.c @@ -3722,10 +3722,6 @@ _cairo_ps_surface_emit_gradient (cairo_ps_surface_t *surface, MAX (end.radius, 0)); } - _cairo_output_stream_printf (surface->stream, - " /Domain [ %f %f ]\n", - domain[0], domain[1]); - if (pattern->base.extend != CAIRO_EXTEND_NONE) { _cairo_output_stream_printf (surface->stream, " /Extend [ true true ]\n"); @@ -3734,8 +3730,22 @@ _cairo_ps_surface_emit_gradient (cairo_ps_surface_t *surface, " /Extend [ false false ]\n"); } + if (domain[0] == 0.0 && domain[1] == 1.0) { + _cairo_output_stream_printf (surface->stream, + " /Function CairoFunction\n"); + } else { + _cairo_output_stream_printf (surface->stream, + " /Function <<\n" + " /FunctionType 3\n" + " /Domain [ 0 1 ]\n" + " /Bounds [ ]\n" + " /Encode [ %f %f ]\n" + " /Functions [ CairoFunction ]\n" + " >>\n", + domain[0], domain[1]); + } + _cairo_output_stream_printf (surface->stream, - " /Function CairoFunction\n" " >>\n"); if (is_ps_pattern) {