Patch #612277: text rendering crash + spacing issue

svn-id: r4983
This commit is contained in:
Max Horn
2002-09-20 23:40:55 +00:00
parent 1917ea9a77
commit b91da0e29f
2 changed files with 11 additions and 9 deletions
+10 -8
View File
@@ -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];
}
}
}