GNOME Bugzilla – Bug 488833
Use cairo_win32_printing_surface_t for printing on win32
Last modified: 2008-04-01 20:46:46 UTC
It will be in cairo 1.6.
Created attachment 99752 [details] [review] untested patch I'm not sure if both instances of cairo_win32_surface_create() need to be changed. Alex should know. Tor, can you check too?
The second one is for generating a EMF file when doing print preview. I think its right to use a printing surface there too, as we should do the same ops in both print and print preview.
You definitely want to use the win32_printing surface when generating EMF files. Using the win32 surface to create EMF files has the same issues as using the win32 surface for printing. However I'm not sure what the benefit of using EMF for print previews is when using cairo. Cairo is designed to provide identical output on all surfaces. Using the win32 surface to display a preview on the display will provide more optimal results since playing back the EMF is not going to give you any antialising except for text (win32 fonts only).
(In reply to comment #3) > Cairo is designed to provide identical output on all surfaces. Sans the different default font options on different surfaces. Gtk-printing does turn off metrics hinting though, so should be safe.
Behdad: Can I ask for some clarification. Does your comment "It will be in cairo 1.6" mean; * the function cairo_win32_printing_surface() will be in Cairo 1.6 and should be made use of? OR * The fix for this bug will be in Cairo 1.6, which will force GTK to make use of the cairo_win32_printing_surface() function, and therefore GTK doesn't need to be patched, but just to wait for Cairo 1.6? Cheers, Rygle.
(In reply to comment #5) > Behdad: Can I ask for some clarification. Does your comment "It will be in > cairo 1.6" mean; > > * the function cairo_win32_printing_surface() will be in Cairo 1.6 and should > be made use of? > OR > * The fix for this bug will be in Cairo 1.6, which will force GTK to make use > of the cairo_win32_printing_surface() function, and therefore GTK doesn't need > to be patched, but just to wait for Cairo 1.6? > > Cheers, > > Rygle. The former.
Thanks Behdad. Are you aware of anyone who has tested your patch? Or a build of gtk for windows that uses it? It's a bit over my head to patch it myself, but I am willing to test a windows build against Inkscape 0.46 dev. Since starting to use the Gnome common print dialog, Inkscape 0.46dev for windows (not linux) has a bug which seems to link to this one, where it outputs print with blocks of white or black (see https://bugs.launchpad.net/inkscape/+bug/179988). Some of this may be in the Inkscape code (cairo_win32_printing_surface_create() needs a non-null HDC?), but if possible I am keen to try a build of GTK with your patch to test it. Thanks. Rygle.
No I'm not. I was hoping that Tor or Adrian can test it so this can be committed.
I'll try to test tonight or tomorrow since I have an interest in this one as well.
Cody, I would love to test any GTK dll's if you're able to build them. The build process looks pretty scary for mingw newbs! Thanks, Rygle.
I should have also said that in Inkscape, we've currently got a hack that directly uses the cairo_win32_printing_surface by bypassing GTK, but it is a hack and not ideal. Adrian has stated that he thinks this patch will fix the problem properly, but is unable to build a patched GTK at present. If anyone is able to build patched binaries and you're stuck for a temporary place to put them, mediafire.com would be a great spot. Thanks again for any help. Rygle.
Hi guys, Looks like this won't get fixed for a while, but for Inkscape 0.46 Win32, we're using some code like the following to bypass GTK if it doesn't use the win32 printing surface. This code is called on printing, and checks if the surface returned by gtkprint is of type CAIRO_SURFACE_TYPE_WIN32 before substituting it with win32_printing_surface. The code will work correctly if gtkprint returns some other surface like pdf. It will also ensure that when gtkprint is fixed to use the surface of type CAIRO_SURFACE_TYPE_WIN32_PRINTING, the workaround will be bypassed. ========= #ifdef WIN32 if (cairo_surface_get_type (surface) == CAIRO_SURFACE_TYPE_WIN32) { HDC dc = cairo_win32_surface_get_dc (surface); surface = _cairo_win32_printing_surface_create (dc); } #endif ========= That goes on to directly call cairo_win32_printing_surface_t, but will default back to the GTK print routines if GTK says it's already using that surface. Hopefully you guys can fix this soon, but until then hopefully this code helps someone else.
I just tried applying Behdad's patch as-is (to gtk-2-12 branch, since that's what I've been building--is that a problem do you think?), and it doesn't seem to be working as expected. I'll attach two PDFs below to show the output I'm getting. I've got my printer driver set to use PDFCreator, so I suppose maybe it's at fault. I can try plugging a real printer into this machine if you want.
Created attachment 108333 [details] gtk-demo print output without patch This is what I got from gtk-demo's print demo using gtk-2-12 branch without Behdad's patch.
Created attachment 108334 [details] gtk-demo print output WITH patch This is what I got from gtk-demo's print demo using gtk-2-12 branch WITH Behdad's patch. It seems to be empty. I'm using Cairo 1.5.14 for this.. gtk-2-12 branch (if you think it's important, I can build trunk to test).
Created attachment 108366 [details] [review] Fixed patch This appears to fix the issues with the previous patch. Can I commit this one?
Created attachment 108369 [details] [review] Updated comment Dom asked me to change this comment as well, so here's a revised patch.
Created attachment 108373 [details] [review] Removed some debugging output
I think this is ready to commit. Tor said it was okay with him. Can Behdad or Alex or someone approve it first? Should I only commit this to trunk? I'm assuming because of the change in Cairo version that it can't be committed to stable branches right?
2008-04-01 Cody Russell <bratsche@gnome.org> * configure.in: Bump required Cairo to 1.5.2. * gtk/gtkprintoperation-win32.c: Add support for using the new cairo_win32_printing_surface for printing. (#488833)