aboutsummaryrefslogtreecommitdiff
path: root/gui
diff options
context:
space:
mode:
authorJohannes Schickel2011-05-05 20:07:37 +0200
committerJohannes Schickel2011-05-05 20:07:37 +0200
commit16f1b51e2a98be9c48b51e55d7b73a8ddd0adede (patch)
treead92dbbfac34eec99abb12d41ce8b355069d5d23 /gui
parent0ef807146e5934f206f23650f5a2c51ef143be2e (diff)
downloadscummvm-rg350-16f1b51e2a98be9c48b51e55d7b73a8ddd0adede.tar.gz
scummvm-rg350-16f1b51e2a98be9c48b51e55d7b73a8ddd0adede.tar.bz2
scummvm-rg350-16f1b51e2a98be9c48b51e55d7b73a8ddd0adede.zip
GUI: Clean up localized font filename generation.
Diffstat (limited to 'gui')
-rw-r--r--gui/ThemeEngine.cpp31
1 files changed, 17 insertions, 14 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 78ea43ad79..7fe40542c2 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1475,20 +1475,23 @@ Common::String ThemeEngine::genLocalizedFontFilename(const Common::String &filen
#ifndef USE_TRANSLATION
return filename;
#else
- Common::String result;
- bool pointPassed = false;
-
- for (const char *p = filename.c_str(); *p != 0; p++) {
- if (!pointPassed && *p == '.') {
- result += "-";
- result += TransMan.getCurrentCharset();
- result += *p;
-
- pointPassed = true;
- } else {
- result += *p;
- }
- }
+ // 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