Skip to content

fix: fall back to default DPI when GTK returns 0 on Linux#50453

Merged
ckerr merged 1 commit intomainfrom
dpi-default-linux
Mar 25, 2026
Merged

fix: fall back to default DPI when GTK returns 0 on Linux#50453
ckerr merged 1 commit intomainfrom
dpi-default-linux

Conversation

@codebytere
Copy link
Copy Markdown
Member

Description of Change

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.

Checklist

Release Notes

Notes: none.

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.
@codebytere codebytere added semver/patch backwards-compatible bug fixes target/40-x-y PR should also be added to the "40-x-y" branch. target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. labels Mar 24, 2026
@electron-cation electron-cation bot added the new-pr 🌱 PR opened recently label Mar 24, 2026
@electron-cation electron-cation bot removed the new-pr 🌱 PR opened recently label Mar 25, 2026
@ckerr ckerr merged commit f6b43cb into main Mar 25, 2026
83 checks passed
@ckerr ckerr deleted the dpi-default-linux branch March 25, 2026 17:37
@release-clerk
Copy link
Copy Markdown

release-clerk bot commented Mar 25, 2026

No Release Notes

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 25, 2026

I have automatically backported this PR to "40-x-y", please check out #50488

@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 25, 2026

I have automatically backported this PR to "41-x-y", please check out #50489

@trop trop bot added in-flight/41-x-y and removed target/40-x-y PR should also be added to the "40-x-y" branch. labels Mar 25, 2026
@trop
Copy link
Copy Markdown
Contributor

trop bot commented Mar 25, 2026

I have automatically backported this PR to "42-x-y", please check out #50490

@trop trop bot added in-flight/42-x-y merged/41-x-y PR was merged to the "41-x-y" branch. and removed target/41-x-y PR should also be added to the "41-x-y" branch. target/42-x-y PR should also be added to the "42-x-y" branch. in-flight/41-x-y labels Mar 25, 2026
@trop trop bot added merged/42-x-y PR was merged to the "42-x-y" branch. merged/40-x-y PR was merged to the "40-x-y" branch. and removed in-flight/42-x-y in-flight/40-x-y labels Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged/40-x-y PR was merged to the "40-x-y" branch. merged/41-x-y PR was merged to the "41-x-y" branch. merged/42-x-y PR was merged to the "42-x-y" branch. semver/patch backwards-compatible bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants