From db8c3d16e8371bd58024970b8da793bef9d66ede Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 3 May 2024 11:25:01 +0400 Subject: [PATCH] Fix adjustment of size for modified fonts. --- ui/style/style_core_font.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/ui/style/style_core_font.cpp b/ui/style/style_core_font.cpp index fc5e3ee..5d15790 100644 --- a/ui/style/style_core_font.cpp +++ b/ui/style/style_core_font.cpp @@ -314,8 +314,7 @@ struct Metrics { [[nodiscard]] FontResolveResult ResolveFont( const QString &family, FontFlags flags, - int size, - bool skipSizeAdjustment) { + int size) { auto font = QFont(); const auto monospace = (flags & FontFlag::Monospace) != 0; @@ -334,7 +333,7 @@ struct Metrics { } font.setPixelSize(size); - const auto adjust = !skipSizeAdjustment && (overriden || system); + const auto adjust = (overriden || system); const auto metrics = ComputeMetrics(font, adjust); font.setPixelSize(metrics.pixelSize); @@ -354,13 +353,14 @@ struct Metrics { font.setUnderline(flags & FontFlag::Underline); font.setStrikeOut(flags & FontFlag::StrikeOut); + const auto index = (family == Custom) ? 0 : RegisterFontFamily(family); return { .font = font, .ascent = metrics.ascent, .height = metrics.height, .iascent = int(base::SafeRound(metrics.ascent)), .iheight = int(base::SafeRound(metrics.height)), - .requestedFamily = RegisterFontFamily(family), + .requestedFamily = index, .requestedSize = size, .requestedFlags = flags, }; @@ -506,8 +506,7 @@ void Font::init( ResolveFont( family ? FontFamilies[family] : Custom, flags, - size, - family != 0), + size), modified)).first; QtFontsKeys.emplace(QtFontKey(i->second->data.f), key); } @@ -515,7 +514,7 @@ void Font::init( } OwnedFont::OwnedFont(const QString &custom, FontFlags flags, int size) -: _data(ResolveFont(custom, flags, size, false), nullptr) { +: _data(ResolveFont(custom, flags, size), nullptr) { _font._data = &_data; }