From 0e7ccb896dafb69664fb313c63bdb8fbe0ea82d1 Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Mon, 28 Jun 2010 15:17:10 +0000 Subject: [PATCH] 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 --- common/translation.cpp | 4 + common/translation.h | 5 + graphics/fontman.cpp | 28 +- gui/ThemeEngine.cpp | 39 +- gui/ThemeEngine.h | 1 + gui/themes/default.inc | 1574 ++++++++++---------- gui/themes/scummclassic.zip | Bin 56607 -> 57409 bytes gui/themes/scummclassic/classic_gfx.stx | 20 +- gui/themes/scummmodern.zip | Bin 163899 -> 158996 bytes gui/themes/scummmodern/scummmodern_gfx.stx | 20 +- 10 files changed, 891 insertions(+), 800 deletions(-) diff --git a/common/translation.cpp b/common/translation.cpp index 3c5ff4d3c7b..093f26510fb 100644 --- a/common/translation.cpp +++ b/common/translation.cpp @@ -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()); } diff --git a/common/translation.h b/common/translation.h index 0722ae44aef..277ac6f5c48 100644 --- a/common/translation.h +++ b/common/translation.h @@ -121,6 +121,11 @@ public: */ const TLangArray getSupportedLanguages() const; + /** + * Returns charset specified by selected translation language + */ + const char *getCurrentCharset(); + private: Common::String _syslang; }; diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp index 808dbafa1a9..c6972cfaabe 100644 --- a/graphics/fontman.cpp +++ b/graphics/fontman.cpp @@ -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; diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index 8f4f767a949..0691f8351d8 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 diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h index 5f474f1a88a..f0d4e2585d2 100644 --- a/gui/ThemeEngine.h +++ b/gui/ThemeEngine.h @@ -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. diff --git a/gui/themes/default.inc b/gui/themes/default.inc index 9554bdf7991..086fecc123f 100644 --- a/gui/themes/default.inc +++ b/gui/themes/default.inc @@ -1,4 +1,781 @@ "" +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " +" " " " " " " " " " " " +" " " " +" " " " +" " " " " " " " " " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " -" " diff --git a/gui/themes/scummclassic.zip b/gui/themes/scummclassic.zip index 67b3d7c0411c0e671395f37829a5970d13d62c35..27362daf4ad8cc59a6e522c1fdda4440506f0566 100644 GIT binary patch delta 1091 zcmbQgi}~OIX5IjAW)=|!5V*B@_C(%bA%&3JHv3mxUCS29zyQLM43pp8k>1#RkvYan zA)} z>!+7y>X&4s=B5@yB$9Iyi;FXp^(TM0Bgw6x!lj_ApyHWgr2yiqDVQ1<8d)e985kPq z8kp%C87deVS{a*J8Jk5Zq-Ex%=jWtl<|#~`pr^8VUwcT%g6pB;J z6gJ1OL?hQnpGH?7=V;2C@64pW~NMTR2CCX%gjjysY=cXGOK`?Hu(apo*iYTPrk>hz>R98 z)MR-!kxa^r<;+Y0xwRy&x-UK})w$$W(2_kU5b)q3(QfX#RNoJmNeqM2YPU>WvB#q4r z5*f3d^Rb_Kb*NqS{n6p5tKVPje^^ag+@Q>J- z_W_}Jvn*>x2rna(2s7LVlO69HDWH0Rfq@_FKL}XT7{)O9)_vI|R97%C2%#uy*J5Bu z&PgmT&P + + + H@GmG;6fq)Vlif6!&6ezLNYylI z!Gnkzu?$)i1y8Lg5^)7Rco0!fO7&p@D?|pOU zuvs!=&6X1Kft$B z-XHLL{9z9tpnO0GhJ|1_N~L5vp`@f_nzD1vxWzd15Y_J_k2gOvtOF=a$XIE}_`CwW zU28G*--swujSFu4h3x)^ve}aYcFmk3v%JyzcdCqY&3I&oDPv&J zV+?xGu38eU(MzrMTP^teaH&YzNLlV^0r^R7!@#S~`FlJkhF1d&uQoOvL*xIgr3oqb zdp~7a_LRFndEC~qe0kesGXo(S@CzYc2!^6m6|>anJdSQ#n|j1lwmZOkyW`Sg8^`%p z**LCKQqmg7x(1PJhK=JWr5qbQjTX#|rM8806JX{qq9*qBCbBP-k|~j{q>KMh%J#Dq zmyEMdH&H`T0~B}l+20oP_Et7#Cp%7g>1_iWHm;M=m76P zcrKarFMDwa^LTuOeJkL3g&hE(iu*FL9&fkY+ZFi*HAnhXb5IJ~0nD(KFMx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wZFesUsYrF&05&Ee(hh+GlkyQ_y6T&-DqUg*VJ*gsTte; z`s@`QKV9?Q9C&Ze{_&^jf0*o)T*I`6Df5@@f8uogR8Uy9e8u989UD%`h2a^+<{7%a z_`wWamr2OQRcGtzf%`~Xym^KmT|8!{o?NqJ<4qkKZd!BR+BNIfb}TO*n5m~0KWx*% z{?#+}hUsI|PsF3I|HJGLe(>Ul!8IWLSc<(X^_ad*wZALlc%pvh6*a>7*vemhe9KjE z%T;|lfA(pa;qLk=eQTb%?J~XZxyKjpFr$>NGo??^#Sd=M(`U=qaiz06Ts4q z>(;MbH+0d#lRAsXbm(#B_|X*4=+Gy8Wu(vB>9u$3>f?rf?5=_^Yhm%wDm`vo_cZ8O zd*j-n+X=(iReIc{ch6Cl;fD3A7k6|FWh?Z)Uc5_Cy&S3HPdfDY$%Wq6XU`q;(KV@A z>QhM8EdTCO6yp`TzL;O73zMpY#l3o_*WRtucc|i|({$amO60@+TfX*gUGS1BKE6_) zIH}sXa6*}jy<2acsD*9xJ;y(jFTS=)7v}AI?&YRMH$MGzy8-F)BAi}(w>EuKvwr#F WbxYfw0sKIo)lkDV242~sf&T!@JTfr= diff --git a/gui/themes/scummmodern/scummmodern_gfx.stx b/gui/themes/scummmodern/scummmodern_gfx.stx index 3ed915200a5..ad41475a96f 100644 --- a/gui/themes/scummmodern/scummmodern_gfx.stx +++ b/gui/themes/scummmodern/scummmodern_gfx.stx @@ -106,16 +106,28 @@ + + +