aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohannes Schickel2010-08-01 19:31:18 +0000
committerJohannes Schickel2010-08-01 19:31:18 +0000
commit2095ce31bde18f6b3a153d7479467eb13ed009ff (patch)
tree4f529ae7eee162e4b42b7f27fae2caeaa169e020
parent4423ad9333c000861fafb485c975dbac47e154ac (diff)
downloadscummvm-rg350-2095ce31bde18f6b3a153d7479467eb13ed009ff.tar.gz
scummvm-rg350-2095ce31bde18f6b3a153d7479467eb13ed009ff.tar.bz2
scummvm-rg350-2095ce31bde18f6b3a153d7479467eb13ed009ff.zip
GUI: Fix loading BDF fonts from theme archives.
svn-id: r51585
-rw-r--r--gui/ThemeEngine.cpp21
-rw-r--r--gui/ThemeEngine.h1
2 files changed, 19 insertions, 3 deletions
diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp
index b491b12065..3a50b2c69c 100644
--- a/gui/ThemeEngine.cpp
+++ b/gui/ThemeEngine.cpp
@@ -1451,6 +1451,20 @@ const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &fil
if (_themeArchive)
stream = _themeArchive->createReadStreamForMember(filename);
if (stream) {
+ font = Graphics::NewFont::loadFont(*stream);
+ delete stream;
+ }
+
+ return font;
+}
+
+const Graphics::Font *ThemeEngine::loadCachedFontFromArchive(const Common::String &filename) {
+ Common::SeekableReadStream *stream = 0;
+ const Graphics::Font *font = 0;
+
+ if (_themeArchive)
+ stream = _themeArchive->createReadStreamForMember(filename);
+ if (stream) {
font = Graphics::NewFont::loadFromCache(*stream);
delete stream;
}
@@ -1464,13 +1478,14 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
Common::File fontFile;
if (!cacheFilename.empty()) {
- if (fontFile.open(cacheFilename))
+ if (fontFile.open(cacheFilename)) {
font = Graphics::NewFont::loadFromCache(fontFile);
+ }
if (font)
return font;
- if ((font = loadFontFromArchive(cacheFilename)))
+ if ((font = loadCachedFontFromArchive(cacheFilename)))
return font;
}
@@ -1485,7 +1500,7 @@ const Graphics::Font *ThemeEngine::loadFont(const Common::String &filename) {
if (font) {
if (!cacheFilename.empty()) {
- if (!Graphics::NewFont::cacheFontData(*(const Graphics::NewFont*)font, cacheFilename)) {
+ if (!Graphics::NewFont::cacheFontData(*(const Graphics::NewFont *)font, cacheFilename)) {
warning("Couldn't create cache file for font '%s'", filename.c_str());
}
}
diff --git a/gui/ThemeEngine.h b/gui/ThemeEngine.h
index f736559def..73181b74a6 100644
--- a/gui/ThemeEngine.h
+++ b/gui/ThemeEngine.h
@@ -540,6 +540,7 @@ protected:
const Graphics::Font *loadFont(const Common::String &filename);
const Graphics::Font *loadFontFromArchive(const Common::String &filename);
+ const Graphics::Font *loadCachedFontFromArchive(const Common::String &filename);
Common::String genCacheFilename(const char *filename);
Common::String genLocalizedFontFilename(const char *filename);