diff options
author | Paul Gilbert | 2010-03-24 11:46:09 +0000 |
---|---|---|
committer | Paul Gilbert | 2010-03-24 11:46:09 +0000 |
commit | e0f92f61eb3fdf40f32f130a8e17fe91d56c6e88 (patch) | |
tree | 780d9454aa909c63f3cce59ef582f31f99831d13 | |
parent | 5d62e682cc20cc21315d6d7497da002b4022c805 (diff) | |
download | scummvm-rg350-e0f92f61eb3fdf40f32f130a8e17fe91d56c6e88.tar.gz scummvm-rg350-e0f92f61eb3fdf40f32f130a8e17fe91d56c6e88.tar.bz2 scummvm-rg350-e0f92f61eb3fdf40f32f130a8e17fe91d56c6e88.zip |
Bugfixes for correctly getting string lengths and cropping drawn text
svn-id: r48376
-rw-r--r-- | engines/m4/font.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
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; |