From: Ben Pfaff Date: Thu, 13 May 2010 04:25:37 +0000 (-0700) Subject: cairo: Apply margins to pages added with xr_driver_next_page(). X-Git-Tag: v0.7.5~29 X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=46314efbf9cb7131ed36e3611f79ce3f55e6f570;p=pspp-builds.git cairo: Apply margins to pages added with xr_driver_next_page(). This properly adds margins to pages printed by the GUI. --- diff --git a/src/output/cairo.c b/src/output/cairo.c index 897d25af..674d9148 100644 --- a/src/output/cairo.c +++ b/src/output/cairo.c @@ -205,7 +205,7 @@ xr_allocate (const char *name, int device_type, struct string_map *o) xr->line_gutter = XR_POINT; xr->line_space = XR_POINT; xr->line_width = XR_POINT / 2; - xr->page_number = 1; + xr->page_number = 0; return xr; } @@ -302,13 +302,12 @@ xr_create (const char *file_name, enum settings_output_devices device_type, xr->cairo = cairo_create (surface); cairo_surface_destroy (surface); - cairo_translate (xr->cairo, - xr_to_pt (xr->left_margin), - xr_to_pt (xr->top_margin)); - if (!xr_set_cairo (xr, xr->cairo)) goto error; + cairo_save (xr->cairo); + xr_driver_next_page (xr, xr->cairo); + if (xr->width / (xr->font_height / 2) < MIN_WIDTH) { error (0, 0, _("The defined page is not wide enough to hold at least %d " @@ -431,7 +430,9 @@ xr_submit (struct output_driver *driver, const struct output_item *output_item) xr_driver_output_item (xr, output_item); while (xr_driver_need_new_page (xr)) { + cairo_restore (xr->cairo); cairo_show_page (xr->cairo); + cairo_save (xr->cairo); xr_driver_next_page (xr, xr->cairo); } } @@ -450,6 +451,11 @@ xr_submit (struct output_driver *driver, const struct output_item *output_item) void xr_driver_next_page (struct xr_driver *xr, cairo_t *cairo) { + if (cairo != NULL) + cairo_translate (cairo, + xr_to_pt (xr->left_margin), + xr_to_pt (xr->top_margin)); + xr->page_number++; xr->cairo = cairo; xr->y = 0;