Skip to content

Commit

Permalink
Allow a bit more font size adjusting.
Browse files Browse the repository at this point in the history
  • Loading branch information
john-preston committed Apr 26, 2024
1 parent 6d1014f commit cb57bef
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions ui/style/style_core_font.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit cb57bef

Please sign in to comment.