aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tsage/graphics.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/engines/tsage/graphics.cpp b/engines/tsage/graphics.cpp
index f0a5973e6b..171167c2ea 100644
--- a/engines/tsage/graphics.cpp
+++ b/engines/tsage/graphics.cpp
@@ -1254,7 +1254,11 @@ void GfxFont::setFontNumber(uint32 fontNumber) {
if (!_fontData)
_fontData = g_resourceManager->getResource(RES_FONT, _fontNumber, 0);
- _numChars = READ_LE_UINT16(_fontData + 4);
+ // Since some TsAGE game versions don't have a valid character count at offset 4, use the offset of the
+ // first charactre data to calculate the number of characters in the offset table preceeding it
+ _numChars = (READ_LE_UINT32(_fontData + 12) - 12) / 4;
+ assert(_numChars <= 256);
+
_fontSize.y = READ_LE_UINT16(_fontData + 6);
_fontSize.x = READ_LE_UINT16(_fontData + 8);
_bpp = READ_LE_UINT16(_fontData + 10);