aboutsummaryrefslogtreecommitdiff
path: root/graphics
diff options
context:
space:
mode:
Diffstat (limited to 'graphics')
-rw-r--r--graphics/sjis.cpp20
-rw-r--r--graphics/sjis.h7
2 files changed, 16 insertions, 11 deletions
diff --git a/graphics/sjis.cpp b/graphics/sjis.cpp
index 9f5def8f10..e6ad08e14c 100644
--- a/graphics/sjis.cpp
+++ b/graphics/sjis.cpp
@@ -245,18 +245,20 @@ bool FontSjisSVM::loadData() {
}
uint32 version = data->readUint32BE();
- if (version != 1) {
+ if (version != 2) {
delete data;
return false;
}
- uint numChars = data->readUint16BE();
+ uint numChars16x16 = data->readUint16BE();
+ /*uint numChars8x16 = */data->readUint16BE();
- _fontData = new uint16[numChars * 16];
- assert(_fontData);
+ _fontData16x16 = new uint16[numChars16x16 * 16];
+ assert(_fontData16x16);
+ _fontData16x16Size = numChars16x16 * 16;
+
+ for (uint i = 0; i < _fontData16x16Size; ++i)
+ _fontData16x16[i] = data->readUint16BE();
- for (uint i = 0; i < numChars * 16; ++i)
- _fontData[i] = data->readUint16BE();
-
bool retValue = !data->err();
delete data;
return retValue;
@@ -285,7 +287,9 @@ const uint16 *FontSjisSVM::getCharData(uint16 c) const {
if (index < 0 || index >= 0xBC || base < 0)
return 0;
- return _fontData + (base * 0xBC + index) * 16;
+ const uint offset = (base * 0xBC + index) * 16;
+ assert(offset + 16 <= _fontData16x16Size);
+ return _fontData16x16 + offset;
}
} // end of namespace Graphics
diff --git a/graphics/sjis.h b/graphics/sjis.h
index 93279d0dd5..6e975b5afd 100644
--- a/graphics/sjis.h
+++ b/graphics/sjis.h
@@ -168,8 +168,8 @@ private:
*/
class FontSjisSVM : public FontSJIS16x16 {
public:
- FontSjisSVM() : _fontData(0) {}
- ~FontSjisSVM() { delete[] _fontData; }
+ FontSjisSVM() : _fontData16x16(0), _fontData16x16Size(0) {}
+ ~FontSjisSVM() { delete[] _fontData16x16; }
/**
* Load the font data from "SJIS.FNT".
@@ -177,7 +177,8 @@ public:
bool loadData();
private:
- uint16 *_fontData;
+ uint16 *_fontData16x16;
+ uint _fontData16x16Size;
const uint16 *getCharData(uint16 c) const;
};