Fix font height cache when changing GUI scaling.

This commit is contained in:
Jonathan G Rennison
2016-01-03 14:52:30 +00:00
parent 726b5cb4f6
commit 30d8cb2d4c
4 changed files with 13 additions and 0 deletions

View File

@@ -189,6 +189,13 @@ bool SpriteFontCache::GetDrawGlyphShadow()
/* static */ FontCache *FontCache::caches[FS_END] = { new SpriteFontCache(FS_NORMAL), new SpriteFontCache(FS_SMALL), new SpriteFontCache(FS_LARGE), new SpriteFontCache(FS_MONO) };
int font_height_cache[FS_END];
void UpdateFontHeightCache()
{
for (int i = 0; i < FS_END; i++) {
font_height_cache[i] = FontCache::Get((FontSize) i)->GetHeight();
}
}
#ifdef WITH_FREETYPE
#include <ft2build.h>
#include FT_FREETYPE_H

View File

@@ -21,6 +21,8 @@ static const GlyphID SPRITE_GLYPH = 1U << 30;
extern int font_height_cache[FS_END]; ///< Cache of font heights
void UpdateFontHeightCache();
/** Font cache for basic fonts. */
class FontCache {
private:

View File

@@ -1080,12 +1080,14 @@ static bool InvalidateVehTimetableWindow(int32 p1)
static bool ZoomMinMaxChanged(int32 p1)
{
extern void ConstrainAllViewportsZoom();
extern void UpdateFontHeightCache();
ConstrainAllViewportsZoom();
GfxClearSpriteCache();
if (_settings_client.gui.zoom_min > _gui_zoom) {
/* Restrict GUI zoom if it is no longer available. */
_gui_zoom = _settings_client.gui.zoom_min;
UpdateCursorSize();
UpdateFontHeightCache();
LoadStringWidthTable();
}
return true;

View File

@@ -528,9 +528,11 @@ struct GameOptionsWindow : Window {
break;
case WID_GO_GUI_ZOOM_DROPDOWN:
extern void UpdateFontHeightCache();
GfxClearSpriteCache();
_gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index);
UpdateCursorSize();
UpdateFontHeightCache();
LoadStringWidthTable();
break;