[Scummvm-git-logs] scummvm master -> b2fd3ccacc5a8f97ad2f9d387bb77e9b63074799

dreammaster paulfgilbert at gmail.com
Thu Feb 20 03:51:26 UTC 2020


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:
b2fd3ccacc ULTIMA8: Implement the toUnicode method


Commit: b2fd3ccacc5a8f97ad2f9d387bb77e9b63074799
    https://github.com/scummvm/scummvm/commit/b2fd3ccacc5a8f97ad2f9d387bb77e9b63074799
Author: Paul Gilbert (dreammaster at scummvm.org)
Date: 2020-02-19T19:51:08-08:00

Commit Message:
ULTIMA8: Implement the toUnicode method

Changed paths:
    common/ustr.h
    engines/ultima/ultima8/graphics/fonts/tt_font.cpp


diff --git a/common/ustr.h b/common/ustr.h
index 46d5753..07d3136 100644
--- a/common/ustr.h
+++ b/common/ustr.h
@@ -156,6 +156,11 @@ public:
 		return _str[idx];
 	}
 
+	/** Set character c at position p, replacing the previous character there. */
+	void setChar(value_type c, uint32 p) {
+		_str[p] = c;
+	}
+
 	/**
 	 * Removes the value at position p from the string.
 	 * Using this on decomposed characters will not remove the whole
diff --git a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
index b1ded4b..9c6adb1 100644
--- a/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
+++ b/engines/ultima/ultima8/graphics/fonts/tt_font.cpp
@@ -87,32 +87,18 @@ int TTFont::getBaselineSkip() {
 	return 0;
 }
 
-#ifdef TODO
-template<class T>
-static uint16 *toUnicode(const Std::string &text, uint16 bullet) {
-	Std::string::size_type l = T::length(text);
-	Common::U32String unicodeText = new uint16[l + 1];
-	Std::string::const_iterator iter = text.begin();
-	for (unsigned int i = 0; i < l; ++i) {
-		uint32 u = T::unicode(iter);
-		if (u > 0xFFFF) {
-			perr.Print("Warning: unicode character out of range for SDL_ttf: %x\n", u);
-			unicodeText[i] = '?';
-		} else if (u == 64) {
-			unicodeText[i] = bullet;
-		} else {
-			unicodeText[i] = u;
-		}
-	}
-	unicodeText[l] = 0;
-	return unicodeText;
-}
-#else
 template<class T>
 static Common::U32String toUnicode(const Std::string &text, uint16 bullet) {
-	return Common::U32String(text);
+	Std::string::size_type len = T::length(text);
+	Common::U32String result = Common::U32String(text.c_str(), len);
+
+	for (uint idx = 0; idx < result.size(); ++idx) {
+		if (result[idx] == '@')
+			result.setChar(bullet, idx);
+	}
+
+	return result;
 }
-#endif
 
 void TTFont::getStringSize(const Std::string &text, int32 &width, int32 &height) {
 	// convert to unicode




More information about the Scummvm-git-logs mailing list