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

athrxx athrxx at scummvm.org
Mon Aug 16 16:24:13 UTC 2021


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:
f35b1f1125 SCUMM: (COMI) - add comment and some cleanup


Commit: f35b1f112581c4c34dfd592ac99bcb737a20914c
    https://github.com/scummvm/scummvm/commit/f35b1f112581c4c34dfd592ac99bcb737a20914c
Author: athrxx (athrxx at scummvm.org)
Date: 2021-08-16T18:23:09+02:00

Commit Message:
SCUMM: (COMI) - add comment and some cleanup

- removed obsolete (and incorrectly implemented) COMI Chinese handling
- some preparations to make it easier if we would want to get rid of SmushFont::getStringWidth() in favour of this

Changed paths:
    engines/scumm/charset.cpp
    engines/scumm/charset.h


diff --git a/engines/scumm/charset.cpp b/engines/scumm/charset.cpp
index f0c6cf87d9..7c53c63a85 100644
--- a/engines/scumm/charset.cpp
+++ b/engines/scumm/charset.cpp
@@ -455,22 +455,18 @@ int CharsetRendererClassic::getCharWidth(uint16 chr) {
 	return spacing;
 }
 
-int CharsetRenderer::getStringWidth(int arg, const byte *text) {
+int CharsetRenderer::getStringWidth(int arg, const byte *text, uint strLenMax) {
 	if (_vm->_game.id == GID_CMI) {
-		int numBytesMax = 100000; // Also hardcoded in the exe
+		// SCUMM7 games actually use the same implemention (minus the strLenMax parameter). If
+		// any text placement bugs in one of these games come up it might be worth to look at
+		// that. Or simply for the fact that we could get rid of SmushFont::getStringWidth()...
+		if (!strLenMax)
+			return 0;
+
 		int maxWidth = 0;
 		int width = 0;
 
-		while (*text && numBytesMax) {
-			// Some localizations may override colors
-			// See credits in Chinese COMI
-			if (_vm->_language == Common::ZH_TWN &&
-				text[0] == '^') {
-				if (text[1] == 'c') {
-					text += 4;
-				}
-			}
-
+		while (*text && strLenMax) {
 			while (text[0] == '^') {
 				switch (text[1]) {
 				case 'f':
@@ -491,7 +487,7 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) {
 			if (is2ByteCharacter(_vm->_language, *text)) {
 				width += _vm->_2byteWidth + (_vm->_language != Common::JA_JPN ? 1 : 0);
 				++text;
-				--numBytesMax;
+				--strLenMax;
 			} else if (*text == '\n') {
 				maxWidth = MAX<int>(width, maxWidth);
 				width = 0;
@@ -500,7 +496,7 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) {
 			}
 
 			++text;
-			--numBytesMax;
+			--strLenMax;
 		}
 
 		return MAX<int>(width, maxWidth);
@@ -532,7 +528,7 @@ int CharsetRenderer::getStringWidth(int arg, const byte *text) {
 					break;
 			}
 		} else {
-			if (chr == '@' && !(_vm->_game.id == GID_CMI && _vm->_language == Common::ZH_TWN))
+			if (chr == '@')
 				continue;
 			if (chr == 255 || (_vm->_game.version <= 6 && chr == 254)) {
 				chr = text[pos++];
diff --git a/engines/scumm/charset.h b/engines/scumm/charset.h
index d436213a39..e4c781d5e8 100644
--- a/engines/scumm/charset.h
+++ b/engines/scumm/charset.h
@@ -97,7 +97,7 @@ public:
 	virtual void printChar(int chr, bool ignoreCharsetMask) = 0;
 	virtual void drawChar(int chr, Graphics::Surface &s, int x, int y) {}
 
-	int getStringWidth(int a, const byte *str);
+	int getStringWidth(int a, const byte *str, uint strLenMax = 100000);
 	void addLinebreaks(int a, byte *str, int pos, int maxwidth);
 	void translateColor();
 




More information about the Scummvm-git-logs mailing list