From 5a7c2e0df54b2987cf60adc536a822fdb23bd58d Mon Sep 17 00:00:00 2001 From: md5 Date: Sun, 13 Mar 2011 17:50:40 +0200 Subject: SCI: Fixed regression of rev b1055a3c86. Japanese games should work again --- engines/sci/graphics/text16.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'engines/sci') diff --git a/engines/sci/graphics/text16.cpp b/engines/sci/graphics/text16.cpp index d7a92042eb..6269a58492 100644 --- a/engines/sci/graphics/text16.cpp +++ b/engines/sci/graphics/text16.cpp @@ -204,21 +204,24 @@ 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) + // Sometimes this can go off the screen, like for example bug #3040161. + // However, we only perform this for non-Japanese games, as these require + // special handling, done after this loop. + if (width + _font->getCharWidth(curChar) > maxWidth && g_sci->getLanguage() != Common::JA_JPN) break; width += _font->getCharWidth(curChar); curCharCount++; } + + // Text without spaces, probably Kanji/Japanese if (maxChars == 0) { - // Text w/o space, supposingly kanji maxChars = curCharCount; uint16 nextChar; // We remove the last char only, if maxWidth was actually equal width // before adding the last char. Otherwise we won't get the same cutting - // as in sierra pc98 sci. Note: changing the while() instead will NOT - // WORK. it would break all sorts of regular sci games. + // as in sierra pc98 sci. if (maxWidth == (width - _font->getCharWidth(curChar))) { maxChars--; if (curChar > 0xFF) -- cgit v1.2.3