After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 590861 - cups_printer_create_cairo_surface() sets a fallback resolution of 0 dpi
cups_printer_create_cairo_surface() sets a fallback resolution of 0 dpi
Status: RESOLVED FIXED
Product: gtk+
Classification: Platform
Component: Printing
unspecified
Other Linux
: Normal normal
: ---
Assigned To: gtk-bugs
Depends on:
Blocks:
 
 
Reported: 2009-08-05 14:42 UTC by Chris Wilson
Modified: 2009-08-30 01:36 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Ensure that a fallback resolution is set if we fail to parse the ppd. (3.66 KB, patch)
2009-08-05 15:05 UTC, Chris Wilson
none Details | Review
Use DPI instead of LPI for printing fallback resolution (1.22 KB, patch)
2009-08-05 15:06 UTC, Chris Wilson
none Details | Review
return meaningful default values for lpi and resolution (7.74 KB, patch)
2009-08-24 14:39 UTC, Marek Kašík
accepted-commit_now Details | Review

Description Chris Wilson 2009-08-05 14:42:22 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:
  • #0 _cairo_error
    at ../../src/cairo.c line 93
  • #1 cups_printer_create_cairo_surface
    at /build/buildd/gtk+2.0-2.17.6/modules/printbackends/cups/gtkprintbackendcups.c line 416
  • #2 _gtk_printer_create_cairo_surface
    at /build/buildd/gtk+2.0-2.17.6/gtk/gtkprinter.c line 924
  • #3 IA__gtk_print_job_get_surface
    at /build/buildd/gtk+2.0-2.17.6/gtk/gtkprintjob.c line 510
  • #4 finish_print
    at /build/buildd/gtk+2.0-2.17.6/gtk/gtkprintoperation-unix.c line 521
  • #5 handle_print_response
    at /build/buildd/gtk+2.0-2.17.6/gtk/gtkprintoperation-unix.c line 601
  • #6 _gtk_print_operation_platform_backend_run_dialog
    at /build/buildd/gtk+2.0-2.17.6/gtk/gtkprintoperation-unix.c line 819
  • #7 IA__gtk_print_operation_run
    at /build/buildd/gtk+2.0-2.17.6/gtk/gtkprintoperation.c line 3063

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
Comment 1 Chris Wilson 2009-08-05 15:05:41 UTC
Created attachment 139947 [details] [review]
Ensure that a fallback resolution is set if we fail to parse the ppd.
Comment 2 Chris Wilson 2009-08-05 15:06:08 UTC
Created attachment 139948 [details] [review]
Use DPI instead of LPI for printing fallback resolution
Comment 3 Adrian Johnson 2009-08-09 04:01:41 UTC
(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.

Comment 4 Marek Kašík 2009-08-24 14:39:54 UTC
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 5 Matthias Clasen 2009-08-28 21:29:02 UTC
Comment on attachment 141559 [details] [review]
return meaningful default values for lpi and resolution

Patch makes sense to me