-
Notifications
You must be signed in to change notification settings - Fork 1.2k
fix(qt): handle pixel-sized fonts when scaling widgets #7315
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -579,14 +579,21 @@ void updateFonts() | |
| ++nUpdatable; | ||
|
|
||
| QFont font = w->font(); | ||
| assert(font.pointSize() > 0); | ||
| double font_size = font.pointSizeF(); | ||
| if (font_size <= 0 && font.pixelSize() > 0) { | ||
| font_size = font.pixelSize() * 72.0 / w->logicalDpiY(); | ||
| font.setPointSizeF(font_size); | ||
| } | ||
| if (font_size <= 0) { | ||
| continue; | ||
| } | ||
|
Comment on lines
+583
to
+589
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💬 Nitpick: logicalDpiY() result is cached for the lifetime of the widget
source: ['claude'] |
||
| font.setFamily(qApp->font().family()); | ||
| font.setWeight(g_font_registry.GetWeightNormal()); | ||
| font.setStyleName(qApp->font().styleName()); | ||
| font.setStyle(qApp->font().style()); | ||
|
|
||
| // Insert/Get the default font size of the widget | ||
| auto itDefault = mapWidgetDefaultFontSizes.emplace(w, font.pointSize()); | ||
| auto itDefault = mapWidgetDefaultFontSizes.emplace(w, font_size); | ||
|
|
||
| auto it = mapFontUpdates.find(w); | ||
| if (it != mapFontUpdates.end()) { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💬 Nitpick: setPointSizeF on line 585 is redundant
The local
fontis either fully replaced bygetFont(...)on line 604 (when an entry exists in mapFontUpdates) or has its size overwritten bysetPointSizeF(GetScaledFontSize(...))on line 606. The explicitfont.setPointSizeF(font_size)on line 585 has no observable effect on the font ultimately stored in mapWidgetFonts or compared at line 609. Removing it would tighten the code; keeping it is harmless as a defensive normalization.source: ['claude']