Community
Participate
Working Groups
20060717 Printer.getDPI() currently returns a constant: 72 x 72. This is even for printers that can print 300 x 300 or 600 x 600 DPI. This may be the reason that fonts print large and lines print 'fat' on GTK+, but I needed to do this because when I return the correct DPI, 'pixel' coordinates passed to draw routines are not correct for printer. (And I do not want to change every draw routine in GC at this time). There is some kind of 'resolution' problem that needs to be fixed. This is partly (but not completely) because of http://bugzilla.gnome.org/show_bug.cgi?id=346245 Still need to figure out the problem here.
Note that even the GTK+ Printing Demo prints using a large font.
I made some tests and seems that if the Printer.getDPI() method returns same value than the Display.getDPI() method, the fonts are printed in the correct size.
Using gtk+-2.10.12 On my system, using debug in eclipse, at a breakpoint in Printer.getDPI() I get: OS.gtk_print_settings_get_resolution(settings) returns (int) 300 This seems to imply gtk_print_settings_get_resolution(settings) has been fixed, but the method OS.gtk_page_setup_get_paper_width (pageSetup, OS.GTK_UNIT_PIXEL) still returns a bogus value (actually points). Looks like possible hack may now be available to use OS.gtk_page_setup_get_paper_width (pageSetup, OS.GTK_UNIT_INCH) * OS.gtk_print_settings_get_resolution(settings) to get the true page size in pixels and OS.gtk_print_settings_get_resolution(settings) to get the DPI.
Actually I think to get the DPI you need: int jobSettings = OS._gtk_print_job_get_settings(printJob); int resolution = OS.gtk_print_settings_get_resolution(jobSettings); But this only seems to work for real printers and not print to file.
*** Bug 260661 has been marked as a duplicate of this bug. ***
Created attachment 156403 [details] a patch to test If the OS.gtk_print_settings_get_resolution returns 0, I try to get the dpi from cairo surface (http://www.cairographics.org/manual/cairo-surface.html#cairo-surface-get-fallback-resolution) which should work even when printing to file.
Praveen, can you have a look at this, please? Consider the patch, and also read all comments, including in the dup. Thanks!
(In reply to comment #7) > Praveen, can you have a look at this, please? Consider the patch, and also read > all comments, including in the dup. Thanks! Any progress on this bug ?
Ping. This is a real problem on Linux. I'd really appreciate it if anybody on the SWT team could devote some time to fixing this. I'll buy a curry for whoever fixes this!
Created attachment 163532 [details] Patch v01 For unknown reason, the patch submitted by Mariot Chauvin (in comment#6) doesn't work on my machine, though the way problem fixed appears to be fair enough. I tried various ways of fixing this problem and then, realized that having DPI set to 96 (Cairo default resolution) make the printer to correctly print the data with the appropriate font size. So, I have modified patch from comment#6 to make the printer working on both Printer and PrintToFile. Thanks Mariot for your patch ! I have tested Printer using these code changes on couple of machines and the Printing appears to be fine from a self-hosted Eclipse and snippets. Carolyn, please review this patch and post your comments. Thanks.
As an eclispse user (who is very gratified that you have fixed this bug!) how to apply the Patch? Thanks -Mike
It's not fixed yet. :) Praveen, I think it's important to use cairo_surface_get_fallback_resolution. Can you find out why it is not working on your machine? I suspect that it is because it is only available in Cairo 1.8. What version of Cairo do you have?
(In reply to comment #12) > It's not fixed yet. :) > Can you find out why it is not working on your machine? I suspect that it is > because it is only available in Cairo 1.8. What version of Cairo do you have? I have Cairo 1.8.2 installed already on my machine. Even in that case, fallback resolution is returned as '0'. If we use the resulotion as 300, then the font size printed on the paper is quite low and not clear. So, I don't think we can use higher resolution with the existing mechanism to render the printed paper correcly. Why do you think that the problem is not fixed with the existing patch ? I can see the fonts are being rendered correctly as expected on the printed paper.
Hello, is someone still working on the patch ? It would be nice if I can use Eclipse for printing source code. Best, Danny.
Created attachment 181664 [details] patch for the fix Now that gtk bug https://bugzilla.gnome.org/show_bug.cgi?id=346252 is fixed (since GTK 2.17.11) and I can accurately get the printer's resolution, I can do the correct scaling to fix this problem.
fixed > 20101025. This is now in HEAD, and it will be in Eclipse 3.7 M3.
The fix for this bug breaks scaling in GEF/Draw2d. I reported the issue in Bug 362999.