Skip to content

[Win32] Use exact selected font size from FontDialog #2435

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

HeikoKlare
Copy link
Contributor

@HeikoKlare HeikoKlare commented Aug 21, 2025

The FontDialog implementation creates a font handle based on the selection in the dialog to extract information about the font size out of that created font. Due to point/pixel conversion and roundings that depend on the current DPI (affected by the primary monitor zoom), the resulting font size selected differs from what the user has selected. For example, when selecting a 10pt font, the result of the dialog will contain a height of 9.75pt on a 100% monitor and of 10.2pt on a 125% monitor.
At the same time, the dialog manages the logically selected size, i.e., in the given scenario the selected 10pt, which could be used instead.

This change replaces the complex and imprecise font height extraction logic with a simple read of the actual value selected by the user.

Note that this will not have any visible impact, as font sizes are rounded anyway, such that all the imprecise values (such as 9.75pt or 10.2pt) will still lead to a 10pt font.

How to reproduce

The behavior can be reproduced by any FontDialog, such as in Snippet133:

Without the change you will see 9.75pt on a 100% monitor, with the change you will see 10pt on a 100% (and any other) monitor.

The FontDialog implementation creates a font handle based on the
selection in the dialog to extract information about the font size out
of that created font. Due to point/pixel conversion and roundings that
depend on the current DPI (affected by the primary monitor zoom), the
resulting font size selected differs from what the user has selected.
For example, when selecting a 10pt font, the result of the dialog will
contain a height of 9.75pt on a 100% monitor and of 10.2pt on a 125%
monitor.
At the same time, the dialog manages the logically selected size, i.e.,
in the given scenario the selected 10pt, which could be used instead.

This change replaces the complex and imprecise font height extraction
logic with a simple read of the actual value selected by the user.
Copy link
Contributor

Test Results

   546 files  ±0     546 suites  ±0   31m 11s ⏱️ - 5m 1s
 4 426 tests ±0   4 409 ✅ ±0   17 💤 ±0  0 ❌ ±0 
16 750 runs  ±0  16 623 ✅ ±0  127 💤 ±0  0 ❌ ±0 

Results for commit 3359fd7. ± Comparison against base commit 93a484e.

@HeikoKlare HeikoKlare marked this pull request as ready for review August 21, 2025 10:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Imprecise selected font size from FontDialog
1 participant