aboutsummaryrefslogtreecommitdiff
path: root/engines/sci/graphics
diff options
context:
space:
mode:
authormd52011-03-02 20:38:21 +0200
committermd52011-03-02 20:38:21 +0200
commitb1055a3c86028d517d54fbae0bef9c500facf8c7 (patch)
treec425d645d0babc6249b8e703b0d40b32fe7774f6 /engines/sci/graphics
parentba42c6ff7db37266062d8a03e83a2ff96714b8af (diff)
downloadscummvm-rg350-b1055a3c86028d517d54fbae0bef9c500facf8c7.tar.gz
scummvm-rg350-b1055a3c86028d517d54fbae0bef9c500facf8c7.tar.bz2
scummvm-rg350-b1055a3c86028d517d54fbae0bef9c500facf8c7.zip
SCI: Fixed bug #3040161 - "LONGBOW: Textbox glitch"
GetLongest() could exceed the maximum width with the very last character of a word. The same fix has been applied to the SCI32 code.
Diffstat (limited to 'engines/sci/graphics')
-rw-r--r--engines/sci/graphics/frameout.cpp2
-rw-r--r--engines/sci/graphics/text16.cpp2
2 files changed, 4 insertions, 0 deletions
diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp
index 87acfdeeb3..fbfd140e6b 100644
--- a/engines/sci/graphics/frameout.cpp
+++ b/engines/sci/graphics/frameout.cpp
@@ -337,6 +337,8 @@ static int16 GetLongest(const char *text, int16 maxWidth, GfxFont *font) {
maxChars = curCharCount; // return count up to (but not including) breaking space
break;
}
+ if (width + font->getCharWidth(curChar) > maxWidth)
+ break;
width += font->getCharWidth(curChar);
curCharCount++;
}
diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp
index 21605ccb8e..d7a92042eb 100644
--- a/engines/sci/graphics/text16.cpp
+++ b/engines/sci/graphics/text16.cpp
@@ -204,6 +204,8 @@ int16 GfxText16::GetLongest(const char *text, int16 maxWidth, GuiResourceId orgF
maxChars = curCharCount; // return count up to (but not including) breaking space
break;
}
+ if (width + _font->getCharWidth(curChar) > maxWidth)
+ break;
width += _font->getCharWidth(curChar);
curCharCount++;
}