Fix font height cache when changing GUI scaling.
This commit is contained in:
@@ -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
|
||||
|
@@ -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:
|
||||
|
@@ -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;
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user