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) }; /* 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]; 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 #ifdef WITH_FREETYPE
#include <ft2build.h> #include <ft2build.h>
#include FT_FREETYPE_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 extern int font_height_cache[FS_END]; ///< Cache of font heights
void UpdateFontHeightCache();
/** Font cache for basic fonts. */ /** Font cache for basic fonts. */
class FontCache { class FontCache {
private: private:

View File

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

View File

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