diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index ae04d45b7b..1cfd582c0d 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -380,7 +380,7 @@ bool HandleBootstrap() /* Initialise the font cache. */ InitializeUnicodeGlyphMap(); /* Next "force" finding a suitable non-sprite font as the local font is missing. */ - CheckForMissingGlyphs(false); + CheckForMissingGlyphs(); /* Initialise the palette. The biggest step is 'faking' some recolour sprites. * This way the mauve and gray colours work and we can show the user interface. */ diff --git a/src/fontcache/spritefontcache.cpp b/src/fontcache/spritefontcache.cpp index 0ed1cff34e..8d67237266 100644 --- a/src/fontcache/spritefontcache.cpp +++ b/src/fontcache/spritefontcache.cpp @@ -94,6 +94,7 @@ void InitializeUnicodeGlyphMap(FontSize fs) SetUnicodeGlyph(fs, unicode_map.code, 0); } else { SpriteID sprite = base + key - ASCII_LETTERSTART; + if (!SpriteExists(sprite)) continue; SetUnicodeGlyph(fs, unicode_map.code, sprite); } } diff --git a/src/strings.cpp b/src/strings.cpp index f4ff461bc7..b4050dca0c 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -2356,15 +2356,14 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher { * mean it might use characters that are not in the * font, which is the whole reason this check has * been added. - * @param base_font Whether to look at the base font as well. * @param searcher The methods to use to search for strings to check. * If nullptr the loaded language pack searcher is used. */ -void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) +void CheckForMissingGlyphs(MissingGlyphSearcher *searcher) { static LanguagePackGlyphSearcher pack_searcher; if (searcher == nullptr) searcher = &pack_searcher; - bool bad_font = !base_font || searcher->FindMissingGlyphs(); + bool bad_font = searcher->FindMissingGlyphs(); #if defined(WITH_FREETYPE) || defined(_WIN32) || defined(WITH_COCOA) if (bad_font) { /* We found an unprintable character... lets try whether we can find @@ -2390,7 +2389,7 @@ void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) ShowErrorMessage(GetEncodedString(STR_JUST_RAW_STRING, std::move(err_str)), {}, WL_WARNING); } - if (bad_font && base_font) { + if (bad_font) { /* 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 */ diff --git a/src/strings_func.h b/src/strings_func.h index 7bb9ae99ff..e883504b41 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -195,6 +195,6 @@ public: bool FindMissingGlyphs(); }; -void CheckForMissingGlyphs(bool base_font = true, MissingGlyphSearcher *search = nullptr); +void CheckForMissingGlyphs(MissingGlyphSearcher *search = nullptr); #endif /* STRINGS_FUNC_H */ diff --git a/src/textfile_gui.cpp b/src/textfile_gui.cpp index 75650c52ef..4c3f31d49b 100644 --- a/src/textfile_gui.cpp +++ b/src/textfile_gui.cpp @@ -923,7 +923,7 @@ void TextfileWindow::LoadText(std::string_view buf) this->AfterLoadText(); this->ReflowContent(); - CheckForMissingGlyphs(true, this); + CheckForMissingGlyphs(this); /* The font may have changed when searching for glyphs, so ensure widget sizes are updated just in case. */ this->ReInit();