diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 4a43592edd..f33a72b015 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -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 #include FT_FREETYPE_H diff --git a/src/fontcache.h b/src/fontcache.h index 2cb7efea5a..c5a165e929 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -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: diff --git a/src/settings.cpp b/src/settings.cpp index d9fd8e6981..76c52c396c 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -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; diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 16ab4580c2..27d8f6b851 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -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;