diff options
Diffstat (limited to 'engines/sci/engine/kgraphics.cpp')
-rw-r--r-- | engines/sci/engine/kgraphics.cpp | 24 |
1 files changed, 20 insertions, 4 deletions
diff --git a/engines/sci/engine/kgraphics.cpp b/engines/sci/engine/kgraphics.cpp index c7a2a26c3d..6c96266922 100644 --- a/engines/sci/engine/kgraphics.cpp +++ b/engines/sci/engine/kgraphics.cpp @@ -18,9 +18,6 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. * - * $URL$ - * $Id$ - * */ #include "common/system.h" @@ -363,10 +360,29 @@ reg_t kTextSize(EngineState *s, int argc, reg_t *argv) { } else #endif g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight); - + + // One of the game texts in LB2 German contains loads of spaces in + // its end. We trim the text here, otherwise the graphics code will + // attempt to draw a very large window (larger than the screen) to + // show the text, and crash. + // Fixes bug #3306417. + if (textWidth >= g_sci->_gfxScreen->getDisplayWidth() || + textHeight >= g_sci->_gfxScreen->getDisplayHeight()) { + // TODO: Is this needed for SCI32 as well? + if (g_sci->_gfxText16) { + warning("kTextSize: string would be too big to fit on screen. Trimming it"); + text.trim(); + // Copy over the trimmed string... + s->_segMan->strcpy(argv[1], text.c_str()); + // ...and recalculate bounding box dimensions + g_sci->_gfxText16->kernelTextSize(g_sci->strSplit(text.c_str(), sep).c_str(), font_nr, maxwidth, &textWidth, &textHeight); + } + } + debugC(kDebugLevelStrings, "GetTextSize '%s' -> %dx%d", text.c_str(), textWidth, textHeight); dest[2] = make_reg(0, textHeight); dest[3] = make_reg(0, textWidth); + return s->r_acc; } |