[Scummvm-cvs-logs] scummvm master -> 16f1b51e2a98be9c48b51e55d7b73a8ddd0adede

lordhoto lordhoto at gmail.com
Thu May 5 20:09:08 CEST 2011


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
16f1b51e2a GUI: Clean up localized font filename generation.


Commit: 16f1b51e2a98be9c48b51e55d7b73a8ddd0adede
    https://github.com/scummvm/scummvm/commit/16f1b51e2a98be9c48b51e55d7b73a8ddd0adede
Author: Johannes Schickel (lordhoto at scummvm.org)
Date: 2011-05-05T11:07:37-07:00

Commit Message:
GUI: Clean up localized font filename generation.

Changed paths:
    gui/ThemeEngine.cpp



diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index 78ea43a..7fe4054 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






More information about the Scummvm-git-logs mailing list