summaryrefslogtreecommitdiff
path: root/src/fontcache.cpp
diff options
context:
space:
mode:
authorPeterN <peter@fuzzle.org>2019-02-23 16:07:25 +0000
committerGitHub <noreply@github.com>2019-02-23 16:07:25 +0000
commiteeae4512ae6b5286aff600d82e612fc10fef5a76 (patch)
treec69cf58bd931d8bfe326ad0e3b314ed74d46baad /src/fontcache.cpp
parent13962a84753f203c83d2fadf460043e032f066de (diff)
downloadopenttd-eeae4512ae6b5286aff600d82e612fc10fef5a76.tar.xz
Fix #7003: Freetype fonts were scaled by both GUI and Font zoom levels. (#7267)
Diffstat (limited to 'src/fontcache.cpp')
-rw-r--r--src/fontcache.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/src/fontcache.cpp b/src/fontcache.cpp
index 9b732ce1e..604cc7374 100644
--- a/src/fontcache.cpp
+++ b/src/fontcache.cpp
@@ -184,12 +184,12 @@ uint SpriteFontCache::GetGlyphWidth(GlyphID key)
{
SpriteID sprite = this->GetUnicodeGlyph(key);
if (sprite == 0) sprite = this->GetUnicodeGlyph('?');
- return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + ScaleGUITrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
+ return SpriteExists(sprite) ? GetSprite(sprite, ST_FONT)->width + ScaleFontTrad(this->fs != FS_NORMAL ? 1 : 0) : 0;
}
int SpriteFontCache::GetHeight() const
{
- return this->height * (1 << (ZOOM_LVL_OUT_4X - _font_zoom));
+ return ScaleFontTrad(this->height);
}
bool SpriteFontCache::GetDrawGlyphShadow()
@@ -282,21 +282,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 = ScaleGUITrad(_default_font_height[this->fs]);
+ int scaled_height = ScaleFontTrad(_default_font_height[this->fs]);
pixels = scaled_height;
TT_Header *head = (TT_Header *)FT_Get_Sfnt_Table(this->face, ft_sfnt_head);
if (head != NULL) {
/* Font height is minimum height plus the difference between the default
* height for this font size and the small size. */
- int diff = scaled_height - ScaleGUITrad(_default_font_height[FS_SMALL]);
+ int diff = scaled_height - ScaleFontTrad(_default_font_height[FS_SMALL]);
pixels = Clamp(min(head->Lowest_Rec_PPEM, 20) + diff, scaled_height, MAX_FONT_SIZE);
}
+ } else {
+ pixels = ScaleFontTrad(pixels);
}
-
- /* Apply user-specified font zoom. */
- pixels *= (1 << (ZOOM_LVL_OUT_4X - _font_zoom));
-
this->used_size = pixels;
FT_Error err = FT_Set_Pixel_Sizes(this->face, 0, pixels);