Feature: Variable GUI scale.

GUI scale is now variable from 100% to 500%, and no longer restricted to
powers-of-2.
This commit is contained in:
Peter Nelson
2021-04-20 11:49:20 +01:00
committed by PeterN
parent 13d271217f
commit 9666e46739
22 changed files with 175 additions and 205 deletions

View File

@@ -65,18 +65,19 @@ void FreeTypeFontCache::SetFontSize(FontSize fs, FT_Face face, int pixels)
{
if (pixels == 0) {
/* Try to determine a good height based on the minimal height recommended by the font. */
int scaled_height = ScaleFontTrad(this->GetDefaultFontHeight(this->fs));
int scaled_height = ScaleGUITrad(this->GetDefaultFontHeight(this->fs));
pixels = scaled_height;
TT_Header *head = (TT_Header *)FT_Get_Sfnt_Table(this->face, ft_sfnt_head);
if (head != nullptr) {
/* Font height is minimum height plus the difference between the default
* height for this font size and the small size. */
int diff = scaled_height - ScaleFontTrad(this->GetDefaultFontHeight(FS_SMALL));
pixels = Clamp(std::min<uint>(head->Lowest_Rec_PPEM, MAX_FONT_MIN_REC_SIZE) + diff, scaled_height, MAX_FONT_SIZE);
int diff = scaled_height - ScaleGUITrad(this->GetDefaultFontHeight(FS_SMALL));
/* Clamp() is not used as scaled_height could be greater than MAX_FONT_SIZE, which is not permitted in Clamp(). */
pixels = std::min(std::max(std::min<int>(head->Lowest_Rec_PPEM, MAX_FONT_MIN_REC_SIZE) + diff, scaled_height), MAX_FONT_SIZE);
}
} else {
pixels = ScaleFontTrad(pixels);
pixels = ScaleGUITrad(pixels);
}
this->used_size = pixels;