From 0a4a75b0afbeeab6be1eb7ccfd03ef603a4646b9 Mon Sep 17 00:00:00 2001 From: rubidium Date: Sun, 20 Nov 2011 11:52:11 +0000 Subject: [PATCH] (svn r23273) -Codechange: allow passing a MissingGlyphSearcher to CheckForMissingGlyphs (default to the language pack strings) --- src/bootstrap_gui.cpp | 2 +- src/openttd.cpp | 4 ++-- src/settings_gui.cpp | 2 +- src/strings.cpp | 11 +++++++---- src/strings_func.h | 2 +- 5 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/bootstrap_gui.cpp b/src/bootstrap_gui.cpp index 1de4417cf0..6c3b981446 100644 --- a/src/bootstrap_gui.cpp +++ b/src/bootstrap_gui.cpp @@ -234,7 +234,7 @@ bool HandleBootstrap() /* Initialise the freetype font code. */ InitializeUnicodeGlyphMap(); /* Next "force" finding a suitable freetype font as the local font is missing. */ - CheckForMissingGlyphsInLoadedLanguagePack(false); + CheckForMissingGlyphs(false); /* 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/openttd.cpp b/src/openttd.cpp index 28fb91d7a3..98025a4ab6 100644 --- a/src/openttd.cpp +++ b/src/openttd.cpp @@ -334,7 +334,7 @@ static void LoadIntroGame(bool load_newgrfs = true) _cursor.fix_at = false; CheckForMissingSprites(); - CheckForMissingGlyphsInLoadedLanguagePack(); + CheckForMissingGlyphs(); /* Play main theme */ if (_music_driver->IsSongPlaying()) ResetMusic(); @@ -810,7 +810,7 @@ int ttd_main(int argc, char *argv[]) LoadIntroGame(false); - CheckForMissingGlyphsInLoadedLanguagePack(); + CheckForMissingGlyphs(); ScanNewGRFFiles(scanner); diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp index 1a8f080d1e..dbf537fef9 100644 --- a/src/settings_gui.cpp +++ b/src/settings_gui.cpp @@ -495,7 +495,7 @@ struct GameOptionsWindow : Window { case GOW_LANG_DROPDOWN: // Change interface language ReadLanguagePack(&_languages[index]); DeleteWindowByClass(WC_QUERY_STRING); - CheckForMissingGlyphsInLoadedLanguagePack(); + CheckForMissingGlyphs(); UpdateAllVirtCoords(); ReInitAllWindows(); break; diff --git a/src/strings.cpp b/src/strings.cpp index 3054dcdaf2..dd549bdfc2 100644 --- a/src/strings.cpp +++ b/src/strings.cpp @@ -1833,11 +1833,14 @@ class LanguagePackGlyphSearcher : public MissingGlyphSearcher { * 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 NULL the loaded language pack searcher is used. */ -void CheckForMissingGlyphsInLoadedLanguagePack(bool base_font) +void CheckForMissingGlyphs(bool base_font, MissingGlyphSearcher *searcher) { - LanguagePackGlyphSearcher searcher; - bool bad_font = !base_font || searcher.FindMissingGlyphs(NULL); + static LanguagePackGlyphSearcher pack_searcher; + if (searcher == NULL) searcher = &pack_searcher; + bool bad_font = !base_font || searcher->FindMissingGlyphs(NULL); #ifdef WITH_FREETYPE if (bad_font) { /* We found an unprintable character... lets try whether we can find @@ -1845,7 +1848,7 @@ void CheckForMissingGlyphsInLoadedLanguagePack(bool base_font) FreeTypeSettings backup; memcpy(&backup, &_freetype, sizeof(backup)); - bad_font = !SetFallbackFont(&_freetype, _langpack->isocode, _langpack->winlangid, &searcher); + bad_font = !SetFallbackFont(&_freetype, _langpack->isocode, _langpack->winlangid, searcher); memcpy(&_freetype, &backup, sizeof(backup)); diff --git a/src/strings_func.h b/src/strings_func.h index d1916fe7ea..19c374e6df 100644 --- a/src/strings_func.h +++ b/src/strings_func.h @@ -232,6 +232,6 @@ public: bool FindMissingGlyphs(const char **str); }; -void CheckForMissingGlyphsInLoadedLanguagePack(bool base_font = true); +void CheckForMissingGlyphs(bool base_font = true, MissingGlyphSearcher *search = NULL); #endif /* STRINGS_FUNC_H */