diff --git a/src/console_cmds.cpp b/src/console_cmds.cpp index f2e410492c..d7091ada19 100644 --- a/src/console_cmds.cpp +++ b/src/console_cmds.cpp @@ -2280,7 +2280,7 @@ DEF_CONSOLE_CMD(ConFont) FontCacheSubSetting *setting = GetFontCacheSubSetting(fs); /* Make sure all non sprite fonts are loaded. */ if (!setting->font.empty() && !fc->HasParent()) { - InitFontCache(fs == FS_MONO); + InitFontCache(); fc = FontCache::Get(fs); } IConsolePrint(CC_DEFAULT, "{} font:", FontSizeToName(fs)); diff --git a/src/fontcache.cpp b/src/fontcache.cpp index 039010dbb0..46bcb9769c 100644 --- a/src/fontcache.cpp +++ b/src/fontcache.cpp @@ -160,19 +160,7 @@ void SetFont(FontSize font_size, const std::string &font, uint size) if (!changed) return; - if (font_size != FS_MONO) { - /* Try to reload only the modified font. */ - FontCacheSettings backup = _fcsettings; - for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { - if (fs == font_size) continue; - FontCache *fc = FontCache::Get(fs); - GetFontCacheSubSetting(fs)->font = fc->HasParent() ? fc->GetFontName() : ""; - } - CheckForMissingGlyphs(); - _fcsettings = backup; - } else { - InitFontCache(true); - } + CheckForMissingGlyphs(); LoadStringWidthTable(); UpdateAllVirtCoords(); @@ -247,20 +235,20 @@ std::string GetFontCacheFontName(FontSize fs) /** * (Re)initialize the font cache related things, i.e. load the non-sprite fonts. - * @param monospace Whether to initialise the monospace or regular fonts. */ -void InitFontCache(bool monospace) +void InitFontCache() { FontCache::InitializeFontCaches(); for (FontSize fs = FS_BEGIN; fs < FS_END; fs++) { - if (monospace != (fs == FS_MONO)) continue; FontCache *fc = FontCache::Get(fs); - if (fc->HasParent()) delete fc; + + if (fc->HasParent()) { + delete fc; + } LoadFontHelper(fs); - } DebugPrintFontSettings("End of initFontCache()"); diff --git a/src/fontcache.h b/src/fontcache.h index c02fa0a66a..1050420ee4 100644 --- a/src/fontcache.h +++ b/src/fontcache.h @@ -229,7 +229,7 @@ std::string GetFontCacheFontName(FontSize fs); void DebugPrintFontSettings(const std::string &desc); bool GetFontAAState(); -void InitFontCache(bool monospace); +void InitFontCache(); void SetFont(FontSize fontsize, const std::string &font, uint size); void UninitFontCache(); diff --git a/src/openttd.cpp b/src/openttd.cpp index 25082be2c5..e50997e3f5 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -693,7 +693,7 @@ int openttd_main(std::span arguments) InitializeLanguagePacks(); /* Initialize the font cache */ - InitFontCache(false); + InitFontCache(); /* This must be done early, since functions use the SetWindowDirty* calls */ InitWindowSystem(); diff --git a/src/os/unix/font_unix.cpp b/src/os/unix/font_unix.cpp index 6ab1d99823..3f7d13928d 100644 --- a/src/os/unix/font_unix.cpp +++ b/src/os/unix/font_unix.cpp @@ -170,7 +170,7 @@ bool SetFallbackFont(FontCacheSettings *settings, const std::string &language_is if (best_font != nullptr) { ret = true; callback->SetFontNames(settings, best_font, &best_index); - InitFontCache(callback->Monospace()); + InitFontCache(); } /* Clean up the list of filenames. */ diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index fb5c08ec86..698835354c 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -767,9 +767,9 @@ struct GameOptionsWindow : Window { this->SetWidgetDisabledState(WID_GO_GUI_FONT_AA, _fcsettings.prefer_sprite); this->SetDirty(); - InitFontCache(false); - InitFontCache(true); ClearFontCache(); + InitFontCache(); + CheckForMissingGlyphs(); SetupWidgetDimensions(); UpdateAllVirtCoords(); diff --git a/src/strings.cpp b/src/strings.cpp index ac959f7ddd..061422bc60 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -2157,7 +2157,7 @@ const char *GetCurrentLanguageIsoCode() */ bool MissingGlyphSearcher::FindMissingGlyphs() { - InitFontCache(this->Monospace()); + InitFontCache(); this->Reset(); for (auto text = this->NextString(); text.has_value(); text = this->NextString()) { @@ -2290,7 +2290,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) /* Our fallback font does miss characters too, so keep the * user chosen font as that is more likely to be any good than * the wild guess we made */ - InitFontCache(searcher->Monospace()); + InitFontCache(); } } #endif