From b1055a3c86028d517d54fbae0bef9c500facf8c7 Mon Sep 17 00:00:00 2001 From: md5 Date: Wed, 2 Mar 2011 20:38:21 +0200 Subject: [PATCH] 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. --- engines/sci/graphics/frameout.cpp | 2 ++ engines/sci/graphics/text16.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/engines/sci/graphics/frameout.cpp b/engines/sci/graphics/frameout.cpp index 87acfdeeb30..fbfd140e6b9 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 21605ccb8e8..d7a92042ebe 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++; }