Skip to content
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

Windows GUI: Use native font size from new API, not 120% of old API #8359

Open
wants to merge 1 commit into
base: master
from

Conversation

@jimbo1qaz
Copy link

commented Sep 11, 2019

Not sure if this code is actually better in practice, but it's more "correct" than before, I think. There's no visual difference at 9pt and 96dpi, and probably minimal difference at higher DPIs. Maybe it affects users who customize their font sizes?

Code was copied from Qt library's dev branch's QWindowsFontDatabase, which (unlike the 5.x branch) uses SPI_GETNONCLIENTMETRICS to get the right font on Vista and up.

I commented out the lines about qFont.setWeight(QPlatformFontDatabase::weightFromInteger(logFont.lfWeight)) (so this code won't support bold). This touches more existing code than necessary and may not be the best fit in the codebase (unsure if this code is unfitting, proof-of-concept, or actually good encapsulation). I tested that it works at 100% and 175% DPI scaling.

If I divide by 96 instead of GetDeviceCaps(), both -lfHeight and Qt's "point size" are multiplied by the DPI scaling, resulting in erroneously large text.

maybe @spycrab can review?

Windows GUI: Use native font size from new API, not 120% of old API
Code was copied from Qt library's dev branch's QWindowsFontDatabase,
which (unlike the 5.x branch) uses SPI_GETNONCLIENTMETRICS
to get the right font on Vista and up.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
1 participant
You can’t perform that action at this time.