GRAPHICS: Remove obsolete genLocalizedFontFilename FontManager
This function supported loading alternative bdf fonts when we were using 8 bits encodings for the translations. Now that we are using unicode for all language, this is no longer needed.
This commit is contained in:
parent
6043a4e40c
commit
f3829243a1
3 changed files with 10 additions and 65 deletions
|
@ -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
|
||||
|
|
|
@ -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:
|
||||
|
|
|
@ -544,18 +544,10 @@ 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);
|
||||
|
||||
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());
|
||||
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;
|
||||
|
@ -569,23 +561,6 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &language, const
|
|||
|
||||
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?
|
||||
#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 true;
|
||||
|
@ -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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue