diff options
Diffstat (limited to 'graphics/macgui')
-rw-r--r-- | graphics/macgui/macfontmanager.cpp | 54 | ||||
-rw-r--r-- | graphics/macgui/macfontmanager.h | 1 |
2 files changed, 54 insertions, 1 deletions
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp index c6e8d7e4a7..721f1a703e 100644 --- a/graphics/macgui/macfontmanager.cpp +++ b/graphics/macgui/macfontmanager.cpp @@ -22,7 +22,9 @@ #include "common/archive.h" #include "common/stream.h" #include "common/unzip.h" +#include "common/macresman.h" #include "graphics/fonts/bdf.h" +#include "graphics/fonts/macfont.h" #include "graphics/macgui/macfontmanager.h" @@ -80,7 +82,7 @@ MacFontManager::MacFontManager() { loadFonts(); } -void MacFontManager::loadFonts() { +void MacFontManager::loadFontsBDF() { Common::Archive *dat; dat = Common::makeZipArchive("classicmacfonts.dat"); @@ -138,6 +140,56 @@ void MacFontManager::loadFonts() { delete dat; } +void MacFontManager::loadFonts() { + Common::Archive *dat; + + dat = Common::makeZipArchive("classicmacfonts.dat"); + + if (!dat) { + warning("Could not find classicmacfonts.dat. Falling back to built-in fonts"); + _builtInFonts = true; + + return; + } + + Common::ArchiveMemberList list; + dat->listMembers(list); + + for (Common::ArchiveMemberList::iterator it = list.begin(); it != list.end(); ++it) { + Common::SeekableReadStream *stream = dat->createReadStreamForMember((*it)->getName()); + + Common::MacResManager *fontFile = new Common::MacResManager(); + + if (!fontFile->loadFromMacBinary(*stream)) + error("Could not open %s as a resource fork", (*it)->getName().c_str()); + + Common::MacResIDArray fonds = fontFile->getResIDArray(MKTAG('F','O','N','D')); + if (fonds.size() > 0) { + for (Common::Array<uint16>::iterator iterator = fonds.begin(); iterator != fonds.end(); ++iterator) { + Common::SeekableReadStream *fond = fontFile->getResource(MKTAG('F', 'O', 'N', 'D'), *iterator); + + Graphics::MacFontFamily fontFamily; + fontFamily.load(*fond); + + Common::Array<Graphics::MacFontFamily::AsscEntry> *assoc = fontFamily.getAssocTable(); + + for (uint i = 0; i < assoc->size(); i++) { + debug("size: %d style: %d id: %d", (*assoc)[i]._fontSize, (*assoc)[i]._fontSize, + (*assoc)[i]._fontID); + } + + delete fond; + } + } + + delete stream; + } + + _builtInFonts = false; + + delete dat; +} + const Font *MacFontManager::getFont(MacFont macFont) { const Font *font = 0; diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h index c098d797ed..117e884d96 100644 --- a/graphics/macgui/macfontmanager.h +++ b/graphics/macgui/macfontmanager.h @@ -121,6 +121,7 @@ public: int getFontIdByName(Common::String name); private: + void loadFontsBDF(); void loadFonts(); void generateFontSubstitute(MacFont &macFont); |