From 2095ce31bde18f6b3a153d7479467eb13ed009ff Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 1 Aug 2010 19:31:18 +0000 Subject: GUI: Fix loading BDF fonts from theme archives. svn-id: r51585 --- gui/ThemeEngine.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) (limited to 'gui/ThemeEngine.cpp') diff --git a/gui/ThemeEngine.cpp b/gui/ThemeEngine.cpp index b491b12065..3a50b2c69c 100644 --- a/gui/ThemeEngine.cpp +++ b/gui/ThemeEngine.cpp @@ -1448,6 +1448,20 @@ const Graphics::Font *ThemeEngine::loadFontFromArchive(const Common::String &fil Common::SeekableReadStream *stream = 0; const Graphics::Font *font = 0; + 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) { @@ -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()); } } -- cgit v1.2.3