diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index 98a7e8320c4..1d37ee03623 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -195,30 +195,4 @@ const Font *FontManager::getFontByUsage(FontUsage usage) const { return 0; } -Common::String FontManager::genLocalizedFontFilename(const Common::String &filename) const { -#ifndef USE_TRANSLATION - return filename; -#else - // We will transform the font filename in the following way: - // name.bdf - // will become: - // name-charset.bdf - // Note that name should not contain any dot here! - - // In the first step we look for the dot. In case there is none we will - // return the normal filename. - Common::String::const_iterator dot = Common::find(filename.begin(), filename.end(), '.'); - if (dot == filename.end()) - return filename; - - // Put the translated font filename string back together. - Common::String result(filename.begin(), dot); - result += '-'; - result += TransMan.getCurrentCharset(); - result += dot; - - return result; -#endif -} - } // End of namespace Graphics diff --git a/graphics/fontman.h b/graphics/fontman.h index 34eecb95f94..84ab7c27111 100644 --- a/graphics/fontman.h +++ b/graphics/fontman.h @@ -105,15 +105,6 @@ public: */ const Font *getFontByUsage(FontUsage usage) const; - /** - * Get the localized font for the current TranslationManager charset from the - * non localized font name - * - * @param filename the non-localized font file name. - * @return The localized font file name. - */ - Common::String genLocalizedFontFilename(const Common::String &filename) const; - //const Font *getFontBySize(int size???) const; private: diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 216f42e2501..f43bf458bd1 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -544,47 +544,22 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &language, const if (file == "default") { _texts[textId]->_fontPtr = _font; } else { - Common::String localized = FontMan.genLocalizedFontFilename(file); - - // Try localized fonts - _texts[textId]->_fontPtr = loadFont(localized, scalableFile, pointsize, textId == kTextDataDefault); + _texts[textId]->_fontPtr = loadFont(file, scalableFile, pointsize, textId == kTextDataDefault); if (!_texts[textId]->_fontPtr) { - warning("Failed to load localized font '%s'", localized.c_str()); - // Try standard fonts - _texts[textId]->_fontPtr = loadFont(file, scalableFile, pointsize, textId == kTextDataDefault); - - if (!_texts[textId]->_fontPtr) { - error("Couldn't load font '%s'/'%s'", file.c_str(), scalableFile.c_str()); -#ifdef USE_TRANSLATION - TransMan.setLanguage("en"); - Common::TextToSpeechManager *ttsMan; - if ((ttsMan = g_system->getTextToSpeechManager()) != nullptr) - ttsMan->setLanguage("en"); -#endif // USE_TRANSLATION - - // No font, cleanup TextDrawData - delete _texts[textId]; - _texts[textId] = nullptr; - - return false; // fall-back attempt failed - } - // Success in fall-back attempt to standard (non-localized) font. - // However, still returns false here, probably to avoid ugly / garbage glyphs side-effects - // FIXME If we return false anyway why would we attempt the fall-back in the first place? + warning("Couldn't load font '%s'/'%s'", file.c_str(), scalableFile.empty()? "(none)" : scalableFile.c_str()); #ifdef USE_TRANSLATION TransMan.setLanguage("en"); Common::TextToSpeechManager *ttsMan; if ((ttsMan = g_system->getTextToSpeechManager()) != nullptr) ttsMan->setLanguage("en"); #endif // USE_TRANSLATION - // Returning true here, would allow falling back to standard fonts for the missing ones, - // but that leads to "garbage" glyphs being displayed on screen for non-Latin languages + // No font, cleanup TextDrawData delete _texts[textId]; _texts[textId] = nullptr; - return false; + return false; // fall-back attempt failed } } @@ -1733,7 +1708,12 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename, cons if (!scalableFilename.empty()) font = loadScalableFont(scalableFilename, pointsize, fontName); - if (!font) + // We can use non-scalable fonts, but only for English + bool allowNonScalable = true; +#ifdef USE_TRANSLATION + allowNonScalable = TransMan.currentIsBuiltinLanguage(); +#endif + if (!font && allowNonScalable) font = loadFont(filename, fontName); // If the font is successfully loaded store it in the font manager.