From 141c1b4a7ee176330dbc80a4f61d0f9275682f17 Mon Sep 17 00:00:00 2001 From: John Preston Date: Thu, 2 May 2024 18:52:50 +0400 Subject: [PATCH] Use same size for styled fonts. --- ui/style/style_core_font.cpp | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/ui/style/style_core_font.cpp b/ui/style/style_core_font.cpp index af0928c..488edfc 100644 --- a/ui/style/style_core_font.cpp +++ b/ui/style/style_core_font.cpp @@ -251,15 +251,12 @@ struct Metrics { const auto adjusted = [&](int size, const QFontMetricsF &metrics) { const auto full = metrics.tightBoundingRect(Full); - const auto desiredTightAscent = -desiredFull.y(); const auto desiredTightHeight = desiredFull.height(); - const auto ascentAdd = basicMetrics.ascent() - desiredTightAscent; const auto heightAdd = basicMetrics.height() - desiredTightHeight; - const auto tightAscent = -full.y(); const auto tightHeight = full.height(); return Metrics{ .pixelSize = size, - .ascent = tightAscent + ascentAdd, + .ascent = basicMetrics.ascent(), .height = tightHeight + heightAdd, }; }; @@ -337,6 +334,10 @@ struct Metrics { } font.setPixelSize(size); + const auto adjust = (overriden && !skipSizeAdjustment); + const auto metrics = ComputeMetrics(font, adjust); + font.setPixelSize(metrics.pixelSize); + font.setWeight((flags & (FontFlag::Bold | FontFlag::Semibold)) ? QFont::DemiBold : QFont::Normal); @@ -353,10 +354,6 @@ struct Metrics { font.setUnderline(flags & FontFlag::Underline); font.setStrikeOut(flags & FontFlag::StrikeOut); - const auto adjust = (overriden && !skipSizeAdjustment); - const auto metrics = ComputeMetrics(font, adjust); - font.setPixelSize(metrics.pixelSize); - return { .font = font, .ascent = metrics.ascent,