Skip to content
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/qt/guiutil_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Comment on lines +583 to +586
Copy link
Copy Markdown
Author

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 font is either fully replaced by getFont(...) on line 604 (when an entry exists in mapFontUpdates) or has its size overwritten by setPointSizeF(GetScaledFontSize(...)) on line 606. The explicit font.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']

if (font_size <= 0) {
continue;
}
Comment on lines +583 to +589
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💬 Nitpick: logicalDpiY() result is cached for the lifetime of the widget

w->logicalDpiY() correctly reports the DPI of the widget's current screen, but the derived point-size is then cached in mapWidgetDefaultFontSizes as the widget's 'default font size'. If the widget later migrates to a screen with a different DPI, the cached value will no longer correspond to the original pixel size. The same caching limitation exists in the pre-PR code paths, so this is not a regression — just a corner case worth noting.

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()) {
Expand Down
Loading