aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
authorThierry Crozat2011-05-22 15:43:35 +0100
committerThierry Crozat2011-06-06 23:20:09 +0100
commit6b13782967b8b775c359b0ff54e7a17534248dbe (patch)
treed290ff1a2523c5d26ae4ad96942d32ac50808c3c /graphics
parent592cca5402f9162fc70b48f40b95faec44341bd0 (diff)
downloadscummvm-rg350-6b13782967b8b775c359b0ff54e7a17534248dbe.tar.gz
scummvm-rg350-6b13782967b8b775c359b0ff54e7a17534248dbe.tar.bz2
scummvm-rg350-6b13782967b8b775c359b0ff54e7a17534248dbe.zip
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.
Diffstat (limited to 'graphics')
-rw-r--r--graphics/fontman.cpp27
-rw-r--r--graphics/fontman.h9
2 files changed, 36 insertions, 0 deletions
diff --git a/graphics/fontman.cpp b/graphics/fontman.cpp
index 08f2ce990b..27fe21ab97 100644
--- a/graphics/fontman.cpp
+++ b/graphics/fontman.cpp
@@ -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
diff --git a/graphics/fontman.h b/graphics/fontman.h
index a388c64bf6..e502c9517e 100644
--- a/graphics/fontman.h
+++ b/graphics/fontman.h
@@ -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;