From e0f92f61eb3fdf40f32f130a8e17fe91d56c6e88 Mon Sep 17 00:00:00 2001 From: Paul Gilbert Date: Wed, 24 Mar 2010 11:46:09 +0000 Subject: Bugfixes for correctly getting string lengths and cropping drawn text svn-id: r48376 --- engines/m4/font.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'engines/m4') diff --git a/engines/m4/font.cpp b/engines/m4/font.cpp index edc904f928..f8dec65412 100644 --- a/engines/m4/font.cpp +++ b/engines/m4/font.cpp @@ -159,10 +159,11 @@ int32 Font::write(M4Surface *surface, const char *text, int x, int y, int width, } */ + int right; if (width > 0) - width = MIN(surface->width(), x + width); + right = MIN(surface->width(), x + width + 1); else - width = surface->width(); + right = surface->width(); x++; y++; @@ -197,7 +198,7 @@ int32 Font::write(M4Surface *surface, const char *text, int x, int y, int width, if (charWidth > 0) { - if (xPos + charWidth >= width) + if (xPos + charWidth > right) return xPos; uint8 *charData = &_charData[_charOffs[theChar]]; @@ -258,7 +259,7 @@ int32 Font::getWidth(const char *text, int spaceWidth) { custom_ascii_converter(out_string); // call it with the string } */ - int width = 0; + int width = -spaceWidth; // Accomodate final character not needing spacing while (*text) width += _charWidths[*text++ & 0x7F] + spaceWidth; return width; -- cgit v1.2.3