From cb57bef3f01b7ec60eb0eae0ee68cd56cb3a9b1f Mon Sep 17 00:00:00 2001 From: John Preston Date: Fri, 26 Apr 2024 20:16:20 +0400 Subject: [PATCH] Allow a bit more font size adjusting. --- ui/style/style_core_font.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/ui/style/style_core_font.cpp b/ui/style/style_core_font.cpp index 9e8f320..b290c5b 100644 --- a/ui/style/style_core_font.cpp +++ b/ui/style/style_core_font.cpp @@ -169,7 +169,13 @@ bool LoadCustomFont(const QString &filePath) { const auto nowHeight = metrics.height(); const auto nowCap = metrics.capHeight(); if (nowHeight > desiredHeight || nowCap > desiredCap) { - return (size + shift - 1); + const auto heightBetter = (nowHeight - desiredHeight) + < (desiredHeight - currentHeight); + const auto capBetter = (nowCap - desiredCap) + < (desiredCap - currentCap); + return (heightBetter && capBetter) + ? (size + shift) + : (size + shift - 1); } currentHeight = nowHeight; currentCap = nowCap; @@ -183,7 +189,13 @@ bool LoadCustomFont(const QString &filePath) { const auto nowHeight = metrics.height(); const auto nowCap = metrics.capHeight(); if (nowHeight < desiredHeight || nowCap < desiredCap) { - return (size - shift + 1); + const auto heightBetter = (desiredHeight - nowHeight) + < (currentHeight - desiredHeight); + const auto capBetter = (desiredCap - nowCap) + < (currentCap - desiredCap); + return (heightBetter && capBetter) + ? (size - shift) + : (size - shift + 1); } currentHeight = nowHeight; currentCap = nowCap;