[cairo] Printer orientation bug in Win32

Ian ian at underpressuredivers.com
Mon Feb 21 21:48:28 PST 2011


Hi,

I recently reported a bug against GTK in Win32 that printing long lines to a
printer in landscape mode results in text at the end of the lines not
getting printed (https://bugzilla.gnome.org/show_bug.cgi?id=642655) but
having just spent some time debugging it, it turns out to be a Cairo bug.

The bug is in function cairo_win32_printing_surface_create() in
cairo_win32_printing_surface.c which sets up surface->extents.width and
surface->extents.height from a call to the Windows API GetClipBox()
function. That returns the extents correct for portrait orientation, but
does not swap them around when printing in landscape (GetClipBox returns the
same in both cases). So when printing to an 8.5" x 11" sheet in landscape
mode _cairo_gstate_transform_glyphs_to_backend() gets the width as 8.5" and
drops glyphs outside that (plus a safety margin).

What I'm not sure of is how to fix it. I think that
cairo_win32_printing_surface_create() needs to swap the width/height when
the printer mode is landscape, but I can't find a way to get at that. I
think it  is provided by the Windows API DocumentProperties() function, but
DocumentProperties is not supported in the GNU Win32 API.

Anyone got any ideas?

Ian



More information about the cairo mailing list