aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNipun Garg2019-06-23 05:51:45 +0530
committerEugene Sandulenko2019-09-03 17:16:56 +0200
commita427871168fe23340b483b921b40722ac084b4bb (patch)
treea37478a21743054990c677df01f4e772dc88179c
parentae872f35691773d412ac7bfff39d9e35f42b65d8 (diff)
downloadscummvm-rg350-a427871168fe23340b483b921b40722ac084b4bb.tar.gz
scummvm-rg350-a427871168fe23340b483b921b40722ac084b4bb.tar.bz2
scummvm-rg350-a427871168fe23340b483b921b40722ac084b4bb.zip
HDB: Add loadFont()
-rw-r--r--engines/hdb/draw-manager.cpp47
-rw-r--r--engines/hdb/draw-manager.h1
2 files changed, 48 insertions, 0 deletions
diff --git a/engines/hdb/draw-manager.cpp b/engines/hdb/draw-manager.cpp
index 113f063076..e505759768 100644
--- a/engines/hdb/draw-manager.cpp
+++ b/engines/hdb/draw-manager.cpp
@@ -395,6 +395,53 @@ int DrawMan::animateTile(int tileIndex) {
return _tLookupArray[tileIndex].animIndex;
}
+bool DrawMan::loadFont(const char *string) {
+ Common::SeekableReadStream *stream = g_hdb->_fileMan->findFirstData(string, TYPE_FONT);
+ if (!stream)
+ return false;
+
+ // Loading _fontHeader
+ _fontHeader.type = stream->readUint16LE();
+ _fontHeader.numChars = stream->readUint16LE();
+ _fontHeader.height = stream->readUint16LE();
+ _fontHeader.kerning = stream->readUint16LE();
+ _fontHeader.leading = stream->readUint16LE();
+
+ // Loading _charInfoBlocks & creating character surfaces
+ CharInfo *cInfo;
+ int startPos = stream->pos(); // Position after _fontHeader
+ int curPos; // Position after reading cInfo
+ uint16 *ptr;
+ for (int i = 0; i < _fontHeader.numChars;i++) {
+ cInfo = new CharInfo;
+ cInfo->width = stream->readUint16LE();
+ cInfo->offset = stream->readUint16LE();
+ curPos = stream->pos();
+
+ _fontSurfaces[i].create(cInfo->width, _fontHeader.height, g_hdb->_format);
+
+ // Go to character location
+ stream->seek(startPos+cInfo->offset);
+
+ for (uint y = 0; y < _fontHeader.height; y++) {
+ ptr = (uint16 *)_fontSurfaces[i].getBasePtr(0, y);
+ for (uint x = 0; x < cInfo->width; x++) {
+ *ptr = TO_LE_16(stream->readUint16LE());
+ ptr++;
+ }
+ }
+
+ stream->seek(curPos);
+
+ _charInfoBlocks.push_back(cInfo);
+ }
+
+ // Loading _fontGfx
+ _fontGfx = stream->readUint16LE();
+
+ return true;
+}
+
// Calculates pixel width of a string
void DrawMan::getDimensions(const char *string, int *pixelsWide, int *lines) {
if (!string) {
diff --git a/engines/hdb/draw-manager.h b/engines/hdb/draw-manager.h
index db09c172cc..3bfb3d72d3 100644
--- a/engines/hdb/draw-manager.h
+++ b/engines/hdb/draw-manager.h
@@ -117,6 +117,7 @@ public:
// Font Functions
+ bool loadFont(const char *string);
void getDimensions(const char *string, int *pixelsWide, int *lines);
void setTextEdges(int left, int right, int top, int bottom);
void getTextEdges(int *left, int *right, int *top, int *bottom);