diff options
Diffstat (limited to 'gui/ThemeEngine.cpp')
-rw-r--r-- | gui/ThemeEngine.cpp | 39 |
1 files changed, 37 insertions, 2 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 8f4f767a94..0691f8351d 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -568,10 +568,17 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file) { if (file == "default") { _texts[textId]->_fontPtr = _font; } else { - _texts[textId]->_fontPtr = FontMan.getFontByName(file); + Common::String localized = genLocalizedFontFilename(file.c_str()); + // Try built-in fonts + _texts[textId]->_fontPtr = FontMan.getFontByName(localized); if (!_texts[textId]->_fontPtr) { - _texts[textId]->_fontPtr = loadFont(file); + // First try to load localized font + _texts[textId]->_fontPtr = loadFont(localized); + + // Fallback to non-localized font + if (!_texts[textId]->_fontPtr) + _texts[textId]->_fontPtr = loadFont(file); if (!_texts[textId]->_fontPtr) error("Couldn't load font '%s'", file.c_str()); @@ -1495,6 +1502,34 @@ Common::String ThemeEngine::genCacheFilename(const char *filename) { return Common::String(); } +Common::String ThemeEngine::genLocalizedFontFilename(const char *filename) { +#ifndef USE_TRANSLATION + return Common::String(filename); +#else + + Common::String result; + bool pointPassed = false; + + for (const char *p = filename; *p != 0; p++) { + if (!pointPassed) { + if (*p != '.') { + result += *p; + } else { + result += "-"; + result += TransMan.getCurrentCharset(); + result += *p; + + pointPassed = true; + } + } else { + result += *p; + } + } + + return result; +#endif +} + /********************************************************** * Static Theme XML functions |