mirror of
https://github.com/libretro/scummvm.git
synced 2024-12-12 03:56:20 +00:00
GRAPHICS: Move genLocalizedFontFilename() to FontManager class
It was defined in ThemeEngine class , but I moved it to make it possible to use localized font in other places.
This commit is contained in:
parent
592cca5402
commit
6b13782967
@ -21,6 +21,7 @@
|
||||
|
||||
#include "graphics/font.h"
|
||||
#include "graphics/fontman.h"
|
||||
#include "common/translation.h"
|
||||
|
||||
DECLARE_SINGLETON(Graphics::FontManager);
|
||||
|
||||
@ -90,4 +91,30 @@ 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
|
||||
|
@ -74,6 +74,15 @@ 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;
|
||||
|
||||
|
||||
|
@ -561,7 +561,7 @@ bool ThemeEngine::addFont(TextData textId, const Common::String &file) {
|
||||
if (file == "default") {
|
||||
_texts[textId]->_fontPtr = _font;
|
||||
} else {
|
||||
Common::String localized = genLocalizedFontFilename(file);
|
||||
Common::String localized = FontMan.genLocalizedFontFilename(file);
|
||||
// Try built-in fonts
|
||||
_texts[textId]->_fontPtr = FontMan.getFontByName(localized);
|
||||
|
||||
@ -1468,32 +1468,6 @@ Common::String ThemeEngine::genCacheFilename(const Common::String &filename) con
|
||||
return Common::String();
|
||||
}
|
||||
|
||||
Common::String ThemeEngine::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
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************
|
||||
* Static Theme XML functions
|
||||
|
@ -539,7 +539,6 @@ protected:
|
||||
const Graphics::Font *loadFontFromArchive(const Common::String &filename);
|
||||
const Graphics::Font *loadCachedFontFromArchive(const Common::String &filename);
|
||||
Common::String genCacheFilename(const Common::String &filename) const;
|
||||
Common::String genLocalizedFontFilename(const Common::String &filename) const;
|
||||
|
||||
/**
|
||||
* Actual Dirty Screen handling function.
|
||||
|
Loading…
Reference in New Issue
Block a user