Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
GRAPHICS: Further work on MacFont loading
  • Loading branch information
sev- committed Jan 18, 2017
1 parent cc82d8f commit 0b3d7d3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 17 deletions.
28 changes: 16 additions & 12 deletions graphics/macgui/macfontmanager.cpp
Expand Up @@ -129,7 +129,7 @@ void MacFontManager::loadFontsBDF() {
}

FontMan.assignFontToName(fontName, font);
macfont->setBdfFont(font);
macfont->setFont(font);
_fontRegistry.setVal(fontName, macfont);

debug(2, " %s", fontName.c_str());
Expand Down Expand Up @@ -177,26 +177,30 @@ void MacFontManager::loadFonts() {
debug("size: %d style: %d id: %d", (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle,
(*assoc)[i]._fontID);

Common::SeekableReadStream *fontstream = fontFile->getResource(MKTAG('N', 'F', 'N', 'T'), (*assoc)[i]._fontID);
Common::SeekableReadStream *fontstream;
MacFont *macfont;
Graphics::MacFONTFont *font;
Common::String fontName;

if (fontstream) {
font = new Graphics::MacFONTFont;
font->loadFont(*fontstream);

delete fontstream;

if ((fontstream = fontFile->getResource(MKTAG('N', 'F', 'N', 'T'), (*assoc)[i]._fontID))) {
fontName = fontFile->getResName(MKTAG('N', 'F', 'N', 'T'), (*assoc)[i]._fontID);
} else if ((fontstream = fontFile->getResource(MKTAG('F', 'O', 'N', 'T'), (*assoc)[i]._fontID))) {
fontName = fontFile->getResName(MKTAG('F', 'O', 'N', 'T'), (*assoc)[i]._fontID);
} else {
fontstream = fontFile->getResource(MKTAG('F', 'O', 'N', 'T'), (*assoc)[i]._fontID);
warning("Unknown FontId: %d", (*assoc)[i]._fontID);

continue;
}

font = new Graphics::MacFONTFont;
font->loadFont(*fontstream);

delete fontstream;

macfont = new MacFont(_fontNames.getVal(fontName, kMacFontNonStandard), (*assoc)[i]._fontSize, (*assoc)[i]._fontStyle);

FontMan.assignFontToName(fontName, font);
//macfont->setBdfFont(font);
macfont->setFont(font);
_fontRegistry.setVal(fontName, macfont);

debug(2, " %s", fontName.c_str());
Expand Down Expand Up @@ -347,14 +351,14 @@ void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
debugN("Found font substitute for font '%s' ", getFontName(toFont));
debug("as '%s'", getFontName(fromFont));

Graphics::BdfFont *font = Graphics::BdfFont::scaleFont(fromFont.getBdfFont(), toFont.getSize());
Graphics::BdfFont *font = NULL; // = Graphics::BdfFont::scaleFont(fromFont.getFont(), toFont.getSize());

if (!font) {
warning("Failed to generate font '%s'", getFontName(toFont));
}

toFont.setGenerated(true);
toFont.setBdfFont(font);
toFont.setFont(font);

FontMan.assignFontToName(getFontName(toFont), font);
_fontRegistry.setVal(getFontName(toFont), new MacFont(toFont));
Expand Down
10 changes: 5 additions & 5 deletions graphics/macgui/macfontmanager.h
Expand Up @@ -57,7 +57,7 @@ enum {
kMacFontExtend = 64
};

class BdfFont;
class Font;

class MacFont {
public:
Expand All @@ -67,7 +67,7 @@ class MacFont {
_slant = slant;
_fallback = fallback;
_generated = false;
_bdfFont = NULL;
_font = NULL;
}

int getId() { return _id; };
Expand All @@ -79,8 +79,8 @@ class MacFont {
FontManager::FontUsage getFallback() { return _fallback; }
bool isGenerated() { return _generated; }
void setGenerated(bool gen) { _generated = gen; }
BdfFont *getBdfFont() { return _bdfFont; }
void setBdfFont(BdfFont *bdfFont) { _bdfFont = bdfFont; }
Font *getFont() { return _font; }
void setFont(Font *font) { _font = font; }

private:
int _id;
Expand All @@ -90,7 +90,7 @@ class MacFont {
FontManager::FontUsage _fallback;

bool _generated;
BdfFont *_bdfFont;
Font *_font;
};

class MacFontManager {
Expand Down

0 comments on commit 0b3d7d3

Please sign in to comment.