[cairo-commit] src/cairo-ps-surface.c
Adrian Johnson
ajohnson at kemper.freedesktop.org
Fri Jan 10 16:21:01 PST 2014
src/cairo-ps-surface.c | 40 +++++++++++++++++++++++++++++++++++++++-
1 file changed, 39 insertions(+), 1 deletion(-)
New commits:
commit 26d0edbc35504624cbe96e95e338351e219bb262
Author: Adrian Johnson <ajohnson at redneon.com>
Date: Sat Jan 11 10:42:33 2014 +1030
ps: use setpagedevice to set page size
https://bugs.freedesktop.org/show_bug.cgi?id=73452
diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 4fc9990..5dd33fa 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -335,7 +335,38 @@ _cairo_ps_surface_emit_header (cairo_ps_surface_t *surface)
" cairo_store_point /cairo_font where { pop cairo_selectfont } if } bind def\n"
"/g { setgray } bind def\n"
"/rg { setrgbcolor } bind def\n"
- "/d1 { setcachedevice } bind def\n");
+ "/d1 { setcachedevice } bind def\n"
+ "/cairo_set_page_size {\n"
+ " %% Change paper size, but only if different from previous paper size otherwise\n"
+ " %% duplex fails. PLRM specifies a tolerance of 5 pts when matching paper size\n"
+ " %% so we use the same when checking if the size changes.\n"
+ " /setpagedevice where {\n"
+ " pop currentpagedevice\n"
+ " /PageSize known {\n"
+ " 2 copy\n"
+ " currentpagedevice /PageSize get aload pop\n"
+ " exch 4 1 roll\n"
+ " sub abs 5 gt\n"
+ " 3 1 roll\n"
+ " sub abs 5 gt\n"
+ " or\n"
+ " } {\n"
+ " true\n"
+ " } ifelse\n"
+ " {\n"
+ " 2 array astore\n"
+ " 2 dict begin\n"
+ " /PageSize exch def\n"
+ " /ImagingBBox null def\n"
+ " currentdict end\n"
+ " setpagedevice\n"
+ " } {\n"
+ " pop pop\n"
+ " } ifelse\n"
+ " } {\n"
+ " pop\n"
+ " } ifelse\n"
+ "} def\n");
_cairo_output_stream_printf (surface->final_stream,
"%%%%EndProlog\n");
@@ -4551,6 +4582,13 @@ _cairo_ps_surface_set_bounding_box (void *abstract_surface,
x1, y1, x2, y2);
}
+ if (!surface->eps) {
+ _cairo_output_stream_printf (surface->stream,
+ "%f %f cairo_set_page_size\n",
+ ceil(surface->width),
+ ceil(surface->height));
+ }
+
_cairo_output_stream_printf (surface->stream,
"%%%%EndPageSetup\n"
"q %d %d %d %d rectclip q\n",
More information about the cairo-commit
mailing list