aboutsummaryrefslogtreecommitdiff
path: root/engines/saga/font.cpp
diff options
context:
space:
mode:
authorMatthew Hoops2011-06-03 01:14:16 -0400
committerMatthew Hoops2011-06-03 01:14:16 -0400
commit224c71e483e09931ba386555ff3b436b9defe63d (patch)
tree8e6178331a7bbd3ee1be318d3fc7a7c7f478468f /engines/saga/font.cpp
parentd4c92983920cfe3b25a22d91e12c750e591b917e (diff)
parent547fd1bdcabcba0e741eb31100ba99ff73399d24 (diff)
downloadscummvm-rg350-224c71e483e09931ba386555ff3b436b9defe63d.tar.gz
scummvm-rg350-224c71e483e09931ba386555ff3b436b9defe63d.tar.bz2
scummvm-rg350-224c71e483e09931ba386555ff3b436b9defe63d.zip
Merge remote branch 'upstream/master' into pegasus
Diffstat (limited to 'engines/saga/font.cpp')
-rw-r--r--engines/saga/font.cpp32
1 files changed, 32 insertions, 0 deletions
diff --git a/engines/saga/font.cpp b/engines/saga/font.cpp
index a5363909ff..8c3f4d7c42 100644
--- a/engines/saga/font.cpp
+++ b/engines/saga/font.cpp
@@ -40,6 +40,10 @@ 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);
}
@@ -48,6 +52,18 @@ Font::Font(SagaEngine *vm) : _vm(vm) {
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
}
@@ -104,9 +120,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);
@@ -150,7 +174,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