From 195fd0dc60cc895539ac6c04ff83b6f99f739830 Mon Sep 17 00:00:00 2001 From: PeterN Date: Sun, 24 Feb 2019 16:27:44 +0000 Subject: Fix #7266: Reorder reinitialization of caches when changing font zoom level. (#7273) --- src/fontcache.cpp | 6 +++--- src/gfx.cpp | 3 ++- src/settings_gui.cpp | 5 ++--- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 604cc7374..2811f1798 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -421,6 +421,9 @@ FreeTypeFontCache::~FreeTypeFontCache() */ void FreeTypeFontCache::ClearFontCache() { + /* Font scaling might have changed, determine font size anew if it was automatically selected. */ + if (this->face != NULL) this->SetFontSize(this->fs, this->face, this->req_size); + if (this->glyph_to_sprite == NULL) return; for (int i = 0; i < 256; i++) { @@ -438,9 +441,6 @@ void FreeTypeFontCache::ClearFontCache() this->glyph_to_sprite = NULL; Layouter::ResetFontCache(this->fs); - - /* GUI scaling might have changed, determine font size anew if it was automatically selected. */ - if (this->face != NULL) this->SetFontSize(this->fs, this->face, this->req_size); } FreeTypeFontCache::GlyphEntry *FreeTypeFontCache::GetGlyphPtr(GlyphID key) diff --git a/src/gfx.cpp b/src/gfx.cpp index 0f050971c..7a6b827b7 100644 --- a/src/gfx.cpp +++ b/src/gfx.cpp @@ -1131,13 +1131,14 @@ TextColour GetContrastColour(uint8 background, uint8 threshold) */ void LoadStringWidthTable(bool monospace) { + ClearFontCache(); + for (FontSize fs = monospace ? FS_MONO : FS_BEGIN; fs < (monospace ? FS_END : FS_MONO); fs++) { for (uint i = 0; i != 224; i++) { _stringwidth_table[fs][i] = GetGlyphWidth(fs, i + 32); } } - ClearFontCache(); ReInitAllWindows(); } diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index a15f2ff58..a31c3afa4 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -556,16 +556,15 @@ struct GameOptionsWindow : Window { GfxClearSpriteCache(); _gui_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index); UpdateCursorSize(); - LoadStringWidthTable(); UpdateAllVirtCoords(); + ReInitAllWindows(); break; case WID_GO_FONT_ZOOM_DROPDOWN: - GfxClearSpriteCache(); _font_zoom = (ZoomLevel)(ZOOM_LVL_OUT_4X - index); ClearFontCache(); + LoadStringWidthTable(); UpdateAllVirtCoords(); - ReInitAllWindows(); break; case WID_GO_BASE_GRF_DROPDOWN: -- cgit v1.2.3-70-g09d2