diff options
| author | Max Horn | 2002-09-20 23:40:55 +0000 |
|---|---|---|
| committer | Max Horn | 2002-09-20 23:40:55 +0000 |
| commit | b91da0e29f4fbe2d9873a4f45e532af46d1c2b8e (patch) | |
| tree | 4a9d87b6c8cb647cbcab1d3538a3c3cc3df3e74e | |
| parent | 1917ea9a774880510d23ff053a476ea65d02eb5f (diff) | |
| download | scummvm-rg350-b91da0e29f4fbe2d9873a4f45e532af46d1c2b8e.tar.gz scummvm-rg350-b91da0e29f4fbe2d9873a4f45e532af46d1c2b8e.tar.bz2 scummvm-rg350-b91da0e29f4fbe2d9873a4f45e532af46d1c2b8e.zip | |
Patch #612277: text rendering crash + spacing issue
svn-id: r4983
| -rw-r--r-- | scumm/scumm.h | 2 | ||||
| -rw-r--r-- | scumm/string.cpp | 18 |
2 files changed, 11 insertions, 9 deletions
diff --git a/scumm/scumm.h b/scumm/scumm.h index 1b2342bf04..70fbea7751 100644 --- a/scumm/scumm.h +++ b/scumm/scumm.h @@ -220,7 +220,7 @@ struct CharsetRenderer { void drawBits(); void printChar(int chr); void printCharOld(int chr); - int getSpacing(char chr, byte *charset); + int getSpacing(byte chr, byte *charset); int getStringWidth(int a, byte *str, int pos); void addLinebreaks(int a, byte *str, int pos, int maxwidth); }; diff --git a/scumm/string.cpp b/scumm/string.cpp index 02cf806d57..cd74b7658c 100644 --- a/scumm/string.cpp +++ b/scumm/string.cpp @@ -71,6 +71,7 @@ int CharsetRenderer::getStringWidth(int arg, byte *text, int pos) } width += getSpacing(chr, ptr); } + return width; } @@ -125,6 +126,7 @@ void CharsetRenderer::addLinebreaks(int a, byte *str, int pos, int maxwidth) if (chr == ' ') lastspace = pos - 1; + curw += getSpacing(chr, ptr); if (lastspace == -1) continue; @@ -1019,20 +1021,20 @@ void CharsetRenderer::drawBits() } // do spacing for variable width old-style font -int CharsetRenderer::getSpacing(char chr, byte *ptr) +int CharsetRenderer::getSpacing(byte chr, byte *charset) { - int spacing; + int spacing = 0; if (_vm->_features & GF_OLD256) { - spacing = *(ptr - 11 + chr); + spacing = *(charset - 11 + chr); } else { - int offs = READ_LE_UINT32(ptr + chr * 4 + 4); + int offs = READ_LE_UINT32(charset + chr * 4 + 4); if (offs) { - spacing = ptr[offs]; - if (ptr[offs + 2] >= 0x80) { - spacing += ptr[offs + 2] - 0x100; + spacing = charset[offs]; + if (charset[offs + 2] >= 0x80) { + spacing += charset[offs + 2] - 0x100; } else { - spacing += ptr[offs + 2]; + spacing += charset[offs + 2]; } } } |
