GNOME Bugzilla – Bug 590861
cups_printer_create_cairo_surface() sets a fallback resolution of 0 dpi
Last modified: 2009-08-30 01:36:04 UTC
http://bugs.freedesktop.org/show_bug.cgi?id=23067 is a bug report where gerbv is hitting a cairo assertion after attempting to process a fallback image with 0 size. Stacktrace of originating error:
+ Trace 216801
Quite clearly cups_printer_create_cairo_surface() is setting a fallback resolution of 0 which it retrieves from gtk_print_settings_get_printer_lpi(). It looks like that value is being feed from the ppd file, but I'm not sure. The other question if why use lpi here and not gtk_print_settings_get_printer_resolution_[xy] which is in dpi, as expected by cairo. The commmit that introduce this (instead of hardcoding a value of 300 dpi) was commit a3b07ac981ec10d286c98a8cbf39cb83d6763d2f Author: Marek Kasik <mkasik@redhat.com> Date: Thu Oct 30 16:24:27 2008 +0000 Bug 339714 - Set printer dpi on cairo ps/pdf surfaces when printing 2008-10-30 Marek Kasik <mkasik@redhat.com> Bug 339714 - Set printer dpi on cairo ps/pdf surfaces when printing * gtk/gtk.symbols * gtk/gtkprintsettings.c * gtk/gtkprintsettings.h * docs/reference/gtk/gtk-sections.txt * modules/printbackends/file/gtkprintbackendfile.c * modules/printbackends/test/gtkprintbackendtest.c * modules/printbackends/cups/gtkprintbackendcups.c * modules/printbackends/lpr/gtkprintbackendlpr.c: Added lpi (lines per inch) setting to GtkPrintSettings and support for anamorphic dpi. Surface fallback resolution is set to 2*lpi. svn path=/trunk/; revision=21733
Created attachment 139947 [details] [review] Ensure that a fallback resolution is set if we fail to parse the ppd.
Created attachment 139948 [details] [review] Use DPI instead of LPI for printing fallback resolution
(In reply to comment #0) > It looks like that value is being feed from the ppd file, but I'm not sure. Yes it is coming from the ppd file. > The > other question if why use lpi here and not > gtk_print_settings_get_printer_resolution_[xy] which is in dpi, as expected by > cairo. cairo_surface_set_fallback_resolution() is expecting pixels per inch, not dots per inch. See http://en.wikipedia.org/wiki/Dots_per_inch for an explanation of the difference between ppi and dpi. See the comments in bug 339714 for the rationale behind the switch to lpi. The patch in comment 1 for sanity checking the lpi value looks fine. I don't agree with the patch in comment 2 because lpi is the correct value to use to determine the fallback resolution.
Created attachment 141559 [details] [review] return meaningful default values for lpi and resolution Hi, this patch changes default values returned by gtk_print_settings_get_printer_lpi() and gtk_print_settings_get_resolution{_x, _y}(). New values are 150 for lpi and 300 for resolution (instead of 0). It also changes some checks from "!= 0" to "> 0". Regards Marek
Comment on attachment 141559 [details] [review] return meaningful default values for lpi and resolution Patch makes sense to me