aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--common/macresman.h6
-rw-r--r--graphics/fonts/macfont.cpp20
-rw-r--r--graphics/fonts/macfont.h6
-rw-r--r--graphics/macgui/macfontmanager.cpp54
-rw-r--r--graphics/macgui/macfontmanager.h1
5 files changed, 72 insertions, 15 deletions
diff --git a/common/macresman.h b/common/macresman.h
index 05b2a875f4..1be825b7b4 100644
--- a/common/macresman.h
+++ b/common/macresman.h
@@ -176,6 +176,11 @@ public:
*/
MacResTagArray getResTagArray();
+ /**
+ * Load from stream in MacBinary format
+ */
+ bool loadFromMacBinary(SeekableReadStream &stream);
+
private:
SeekableReadStream *_stream;
String _baseFileName;
@@ -183,7 +188,6 @@ private:
bool load(SeekableReadStream &stream);
bool loadFromRawFork(SeekableReadStream &stream);
- bool loadFromMacBinary(SeekableReadStream &stream);
bool loadFromAppleDouble(SeekableReadStream &stream);
static String constructAppleDoubleName(String name);
diff --git a/graphics/fonts/macfont.cpp b/graphics/fonts/macfont.cpp
index 92b68b4f6d..5847cfd8f9 100644
--- a/graphics/fonts/macfont.cpp
+++ b/graphics/fonts/macfont.cpp
@@ -215,7 +215,7 @@ bool MacFontFamily::load(Common::SeekableReadStream &stream) {
}
- MacFont::MacFont() {
+ MacFONTFont::MacFONTFont() {
_fontType = 0;
_firstChar = 0;
_lastChar = 0;
@@ -236,11 +236,11 @@ bool MacFontFamily::load(Common::SeekableReadStream &stream) {
_style = 0;
}
- MacFont::~MacFont() {
+ MacFONTFont::~MacFONTFont() {
free(_bitImage);
}
-bool MacFont::loadFont(Common::SeekableReadStream &stream, MacFontFamily *family, int size, int style) {
+bool MacFONTFont::loadFont(Common::SeekableReadStream &stream, MacFontFamily *family, int size, int style) {
_family = family;
_size = size;
_style = style;
@@ -260,7 +260,7 @@ bool MacFont::loadFont(Common::SeekableReadStream &stream, MacFontFamily *family
_rowWords = stream.readUint16BE() * 2; // row width of bit image in 16-bit wds
if (getDepth(_fontType) != 1) {
- warning("MacFont: %dbpp fonts are not supported", getDepth(_fontType));
+ warning("MacFONTFont: %dbpp fonts are not supported", getDepth(_fontType));
return false;
}
@@ -332,15 +332,15 @@ bool MacFont::loadFont(Common::SeekableReadStream &stream, MacFontFamily *family
return true;
}
-int MacFont::getFontHeight() const {
+int MacFONTFont::getFontHeight() const {
return _fRectHeight;
}
-int MacFont::getMaxCharWidth() const {
+int MacFONTFont::getMaxCharWidth() const {
return _maxWidth;
}
-int MacFont::getCharWidth(uint32 chr) const {
+int MacFONTFont::getCharWidth(uint32 chr) const {
const Glyph *glyph = findGlyph(chr);
if (!glyph)
@@ -349,7 +349,7 @@ int MacFont::getCharWidth(uint32 chr) const {
return glyph->width;
}
-void MacFont::drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const {
+void MacFONTFont::drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) const {
assert(dst != 0);
assert(dst->format.bytesPerPixel == 1 || dst->format.bytesPerPixel == 2 || dst->format.bytesPerPixel == 4);
@@ -375,7 +375,7 @@ void MacFont::drawChar(Surface *dst, uint32 chr, int x, int y, uint32 color) con
}
}
-const MacFont::Glyph *MacFont::findGlyph(uint32 c) const {
+const MacFONTFont::Glyph *MacFONTFont::findGlyph(uint32 c) const {
if (_glyphs.empty())
return 0;
@@ -385,7 +385,7 @@ const MacFont::Glyph *MacFont::findGlyph(uint32 c) const {
return &_glyphs[c - _firstChar];
}
-int MacFont::getKerningOffset(uint32 left, uint32 right) const {
+int MacFONTFont::getKerningOffset(uint32 left, uint32 right) const {
if (_family) {
int kerning = _family->getKerningOffset(_style, left, right);
kerning *= _size;
diff --git a/graphics/fonts/macfont.h b/graphics/fonts/macfont.h
index ca1eb72abf..69164653b4 100644
--- a/graphics/fonts/macfont.h
+++ b/graphics/fonts/macfont.h
@@ -100,10 +100,10 @@ private:
/**
* Processing of Mac FONT/NFNT rResources
*/
-class MacFont : public Font {
+class MacFONTFont : public Font {
public:
- MacFont();
- virtual ~MacFont();
+ MacFONTFont();
+ virtual ~MacFONTFont();
virtual int getFontHeight() const;
virtual int getMaxCharWidth() const;
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);