aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
Diffstat (limited to 'engines')
-rw-r--r--engines/saga/font.cpp36
-rw-r--r--engines/saga/font.h4
2 files changed, 39 insertions, 1 deletions
diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp
index 2434f7aad8..60e7c98e7a 100644
--- a/engines/saga/font.cpp
+++ b/engines/saga/font.cpp
@@ -43,14 +43,32 @@ Font::Font(SagaEngine *vm) : _vm(vm) {
_fonts.resize(_vm->getFontsCount());
for (i = 0; i < _vm->getFontsCount(); i++) {
+#ifdef __DS__
+ _fonts[i].outline.font = NULL;
+ _fonts[i].normal.font = NULL;
+#endif
loadFont(&_fonts[i], _vm->getFontDescription(i)->fontResourceId);
}
+
+
_fontMapping = 0;
}
Font::~Font() {
debug(8, "Font::~Font(): Freeing fonts.");
+
+#ifdef __DS__
+ for (int i = 0; i < _vm->getFontsCount(); i++) {
+ if (_fonts[i].outline.font) {
+ free(_fonts[i].outline.font);
+ }
+
+ if (_fonts[i].normal.font) {
+ free(_fonts[i].normal.font);
+ }
+ }
+#endif
}
@@ -107,9 +125,17 @@ void Font::loadFont(FontData *font, uint32 fontResourceId) {
error("Invalid font resource size");
}
+#ifndef __DS__
font->normal.font.resize(fontResourceData.size() - FONT_DESCSIZE);
memcpy(font->normal.font.getBuffer(), fontResourceData.getBuffer() + FONT_DESCSIZE, fontResourceData.size() - FONT_DESCSIZE);
-
+#else
+ if (font->normal.font) {
+ free(font->normal.font);
+ }
+
+ font->normal.font = (byte *) malloc(fontResourceData.size() - FONT_DESCSIZE);
+ memcpy(font->normal.font, fontResourceData.getBuffer() + FONT_DESCSIZE, fontResourceData.size() - FONT_DESCSIZE);
+#endif
// Create outline font style
createOutline(font);
@@ -153,7 +179,15 @@ void Font::createOutline(FontData *font) {
font->outline.header.rowLength = newRowLength;
// Allocate new font representation storage
+#ifdef __DS__
+ if (font->outline.font) {
+ free(font->outline.font);
+ }
+
+ font->outline.font = (byte *) calloc(newRowLength * font->outline.header.charHeight, 1);
+#else
font->outline.font.resize(newRowLength * font->outline.header.charHeight);
+#endif
// Generate outline font representation
diff --git a/engines/saga/font.h b/engines/saga/font.h
index 6f66545756..57e8278c46 100644
--- a/engines/saga/font.h
+++ b/engines/saga/font.h
@@ -120,7 +120,11 @@ struct FontCharEntry {
struct FontStyle {
FontHeader header;
FontCharEntry fontCharEntry[256];
+#ifndef __DS__
ByteArray font;
+#else
+ byte* font;
+#endif
};
struct FontData {