Skip to content

Commit 904fbbd

Browse files
fix: fall back to default DPI when GTK returns 0 on Linux (#50488)
GetDefaultPrinterDPI() creates a blank GtkPrintSettings and reads its resolution, which returns 0 for uninitialized settings. With DPI=0, SetPrintableAreaIfValid() computes a zero scale factor, producing empty page dimensions that fail PrintMsgPrintParamsIsValid(). Fall back to kDefaultPdfDpi (72) when GTK returns 0, matching the existing Windows fallback pattern when CreateDC fails. Co-authored-by: trop[bot] <37223003+trop[bot]@users.noreply.github.com> Co-authored-by: Shelley Vohr <shelley.vohr@gmail.com>
1 parent 36c88a4 commit 904fbbd

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

shell/browser/printing/printing_utils.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@ gfx::Size GetDefaultPrinterDPI(const std::u16string& device_name) {
5959
GtkPrintSettings* print_settings = gtk_print_settings_new();
6060
int dpi = gtk_print_settings_get_resolution(print_settings);
6161
g_object_unref(print_settings);
62+
if (dpi <= 0)
63+
dpi = printing::kDefaultPdfDpi;
6264
return {dpi, dpi};
6365
#endif
6466
}

0 commit comments

Comments
 (0)