Comment 20 for bug 166678

Revision history for this message
Adrian Johnson (ajohnson-redneon) wrote :

I suspect the problem is in the following code in ui/dialog/print.cpp draw_page():

        cairo_t *cr = gtk_print_context_get_cairo_context (context);
        cairo_surface_t *surface = cairo_get_target(cr);

then further down:

        bool ret = ctx->setSurfaceTarget (surface, true);

GTK print rotates the cairo context when landscape is selected in the print dialog. If you use the context from gtk_print_context_get_cairo_context() to draw on it should just work. The problem is the surface if obtained from the context and passed to the cairo renderer. Cairo surfaces do not store a transformation matrix. This is only in the context. So the above code is ignoring the CTM set by GTK print.

The fix would be to either pass the context to the cairo renderer instead of the surface or get the CTM from the context ( cairo_get_matrix() ) and pass the CTM matrix along with the surface to the cairo renderer. In the cairo renderer after calling cairo_create(), call cairo_set_matrix() to apply the GTK print CTM to the context.

Also, the Win32 hack can be removed from that function as the current Gtk+ in the Win32 builds is using the win32 printing surface.