i18n: Add support for locale-dependent fonts
Currently it ws not decided where to put fonts, but if you put BDF files into themepath, they will get picked up. The font name has to contain same codepage specification as in the .po file, i.e. fixed5x8-iso-8859-5.bdf for Cyrillic codepage. In case the font does not exist, default will be used. All built in fonts get proper names. TODO: Currently there is a bug with our font cacher. Font clR6x12-iso-8859-5 is empty after loading from FCC file. Reason is unknown. svn-id: r50448
This commit is contained in:
parent
8410dbab53
commit
0e7ccb896d
10 changed files with 891 additions and 800 deletions
|
@ -130,6 +130,10 @@ const char *TranslationManager::getTranslation(const char *message) {
|
|||
return po2c_gettext(message);
|
||||
}
|
||||
|
||||
const char *TranslationManager::getCurrentCharset() {
|
||||
return po2c_getcharset();
|
||||
}
|
||||
|
||||
String TranslationManager::getTranslation(const String &message) {
|
||||
return po2c_gettext(message.c_str());
|
||||
}
|
||||
|
|
|
@ -121,6 +121,11 @@ public:
|
|||
*/
|
||||
const TLangArray getSupportedLanguages() const;
|
||||
|
||||
/**
|
||||
* Returns charset specified by selected translation language
|
||||
*/
|
||||
const char *getCurrentCharset();
|
||||
|
||||
private:
|
||||
Common::String _syslang;
|
||||
};
|
||||
|
|
|
@ -57,18 +57,28 @@ FontManager::~FontManager() {
|
|||
g_consolefont = 0;
|
||||
}
|
||||
|
||||
const char *builtinFontNames[] = {
|
||||
"builtinOSD",
|
||||
"builtinConsole",
|
||||
"builtinGUI",
|
||||
"builtinBigGUI",
|
||||
0
|
||||
const struct {
|
||||
const char *name;
|
||||
FontManager::FontUsage id;
|
||||
} builtinFontNames[] = {
|
||||
{ "builtinOSD", FontManager::kOSDFont },
|
||||
{ "builtinConsole", FontManager::kConsoleFont },
|
||||
{ "fixed5x8.bdf", FontManager::kConsoleFont },
|
||||
{ "fixed5x8-iso-8859-1.bdf", FontManager::kConsoleFont },
|
||||
{ "fixed5x8-ascii.bdf", FontManager::kConsoleFont },
|
||||
{ "clR6x12.bdf", FontManager::kGUIFont },
|
||||
{ "clR6x12-iso-8859-1.bdf", FontManager::kGUIFont },
|
||||
{ "clR6x12-ascii.bdf", FontManager::kGUIFont },
|
||||
{ "helvB12.bdf", FontManager::kBigGUIFont },
|
||||
{ "helvB12-iso-8859-1.bdf", FontManager::kBigGUIFont },
|
||||
{ "helvB12-ascii.bdf", FontManager::kBigGUIFont },
|
||||
{ 0, FontManager::kOSDFont }
|
||||
};
|
||||
|
||||
const Font *FontManager::getFontByName(const Common::String &name) const {
|
||||
for (int i = 0; builtinFontNames[i]; i++)
|
||||
if (!strcmp(name.c_str(), builtinFontNames[i]))
|
||||
return getFontByUsage((FontUsage)i);
|
||||
for (int i = 0; builtinFontNames[i].name; i++)
|
||||
if (!scumm_stricmp(name.c_str(), builtinFontNames[i].name))
|
||||
return getFontByUsage(builtinFontNames[i].id);
|
||||
|
||||
if (!_fontMap.contains(name))
|
||||
return 0;
|
||||
|
|
|
@ -568,9 +568,16 @@ 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) {
|
||||
// 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)
|
||||
|
@ -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
|
||||
|
|
|
@ -539,6 +539,7 @@ protected:
|
|||
const Graphics::Font *loadFont(const Common::String &filename);
|
||||
const Graphics::Font *loadFontFromArchive(const Common::String &filename);
|
||||
Common::String genCacheFilename(const char *filename);
|
||||
Common::String genLocalizedFontFilename(const char *filename);
|
||||
|
||||
/**
|
||||
* Actual Dirty Screen handling function.
|
||||
|
|
File diff suppressed because it is too large
Load diff
Binary file not shown.
|
@ -44,16 +44,28 @@
|
|||
|
||||
<fonts>
|
||||
<font id = 'text_default'
|
||||
file = 'default'
|
||||
file = 'helvb12.bdf'
|
||||
/>
|
||||
<font resolution = '320xY, 256x240'
|
||||
id = 'text_default'
|
||||
file = 'clR6x12.bdf'
|
||||
/>
|
||||
<font id = 'text_button'
|
||||
file = 'default'
|
||||
file = 'helvb12.bdf'
|
||||
/>
|
||||
<font resolution = '320xY, 256x240'
|
||||
id = 'text_button'
|
||||
file = 'clR6x12.bdf'
|
||||
/>
|
||||
<font id = 'text_normal'
|
||||
file = 'default'
|
||||
file = 'helvb12.bdf'
|
||||
/>
|
||||
<font resolution = '320xY, 256x240'
|
||||
id = 'text_normal'
|
||||
file = 'clR6x12.bdf'
|
||||
/>
|
||||
<font id = 'tooltip_normal'
|
||||
file = 'builtinConsole'
|
||||
file = 'fixed5x8.bdf'
|
||||
/>
|
||||
|
||||
<text_color id = 'color_normal'
|
||||
|
|
Binary file not shown.
|
@ -106,16 +106,28 @@
|
|||
|
||||
<fonts>
|
||||
<font id = 'text_default'
|
||||
file = 'default'
|
||||
file = 'helvb12.bdf'
|
||||
/>
|
||||
<font resolution = '320xY, 256x240'
|
||||
id = 'text_default'
|
||||
file = 'clR6x12.bdf'
|
||||
/>
|
||||
<font id = 'text_button'
|
||||
file = 'default'
|
||||
file = 'helvb12.bdf'
|
||||
/>
|
||||
<font resolution = '320xY, 256x240'
|
||||
id = 'text_button'
|
||||
file = 'clR6x12.bdf'
|
||||
/>
|
||||
<font id = 'text_normal'
|
||||
file = 'helvr12-l1.bdf'
|
||||
file = 'helvb12.bdf'
|
||||
/>
|
||||
<font resolution = '320xY, 256x240'
|
||||
id = 'text_normal'
|
||||
file = 'clR6x12.bdf'
|
||||
/>
|
||||
<font id = 'tooltip_normal'
|
||||
file = 'builtinConsole'
|
||||
file = 'fixed5x8.bdf'
|
||||
/>
|
||||
|
||||
<text_color id = 'color_normal'
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue