Allow a bit more font size adjusting.

This commit is contained in:
John Preston 2024-04-26 20:16:20 +04:00
parent 6d1014fa8f
commit cb57bef3f0

View file

@ -169,7 +169,13 @@ bool LoadCustomFont(const QString &filePath) {
const auto nowHeight = metrics.height(); const auto nowHeight = metrics.height();
const auto nowCap = metrics.capHeight(); const auto nowCap = metrics.capHeight();
if (nowHeight > desiredHeight || nowCap > desiredCap) { 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; currentHeight = nowHeight;
currentCap = nowCap; currentCap = nowCap;
@ -183,7 +189,13 @@ bool LoadCustomFont(const QString &filePath) {
const auto nowHeight = metrics.height(); const auto nowHeight = metrics.height();
const auto nowCap = metrics.capHeight(); const auto nowCap = metrics.capHeight();
if (nowHeight < desiredHeight || nowCap < desiredCap) { 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; currentHeight = nowHeight;
currentCap = nowCap; currentCap = nowCap;