aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui/macfontmanager.cpp
diff options
context:
space:
mode:
authorEugene Sandulenko2016-10-12 19:16:57 +0200
committerEugene Sandulenko2016-10-12 19:17:29 +0200
commit2cb0e45c630e568ef7a4c7b5f0f195f0d67f92ce (patch)
tree735fd99860bc419fe3b0958ee3c80532c9a8b883 /graphics/macgui/macfontmanager.cpp
parenta89deafcad58912ce4c41490d226ce0da23830f3 (diff)
downloadscummvm-rg350-2cb0e45c630e568ef7a4c7b5f0f195f0d67f92ce.tar.gz
scummvm-rg350-2cb0e45c630e568ef7a4c7b5f0f195f0d67f92ce.tar.bz2
scummvm-rg350-2cb0e45c630e568ef7a4c7b5f0f195f0d67f92ce.zip
GRAPHICS: Further work on BDF font scaling
Diffstat (limited to 'graphics/macgui/macfontmanager.cpp')
-rw-r--r--graphics/macgui/macfontmanager.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index ce9493580b..52e82584c7 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -127,6 +127,7 @@ void MacFontManager::loadFonts() {
}
FontMan.assignFontToName(fontName, font);
+ macfont->setBdfFont(font);
_fontRegistry.setVal(fontName, macfont);
debug(2, " %s", fontName.c_str());
@@ -150,7 +151,7 @@ const Font *MacFontManager::getFont(MacFont macFont) {
font = FontMan.getFontByName(macFont.getName());
if (!font) {
- warning("Cannot load font %s", macFont.getName().c_str());
+ warning("Cannot load font '%s'", macFont.getName().c_str());
font = FontMan.getFontByName(MacFont(kMacFontChicago, 12).getName());
}
@@ -219,7 +220,7 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
// Now half size
name = getFontName(macFont.getId(), macFont.getSize() / 2, macFont.getSlant());
- if (_fontRegistry.contains(name)) {
+ if (_fontRegistry.contains(name) && !_fontRegistry[name]->isGenerated()) {
generateFont(macFont, *_fontRegistry[name]);
return;
@@ -230,7 +231,7 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
// First we gather all font sizes for this font
Common::Array<int> sizes;
for (Common::HashMap<Common::String, MacFont *>::iterator i = _fontRegistry.begin(); i != _fontRegistry.end(); ++i) {
- if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == macFont.getSlant())
+ if (i->_value->getId() == macFont.getId() && i->_value->getSlant() == macFont.getSlant() && !i->_value->isGenerated())
sizes.push_back(i->_value->getSize());
}
@@ -251,7 +252,7 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
}
if (candidate != 1000) {
- generateFont(macFont, MacFont(macFont.getId(), candidate, macFont.getSlant()));
+ generateFont(macFont, *_fontRegistry[getFontName(macFont.getId(), candidate, macFont.getSlant())]);
return;
}
@@ -260,17 +261,18 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
}
void MacFontManager::generateFont(MacFont toFont, MacFont fromFont) {
- debugN("Found font substitute for font %s ", getFontName(fromFont));
- debug("as %s", getFontName(toFont));
-
- Graphics::BdfFont *bdfFont = (Graphics::BdfFont *)getFont(fromFont);
+ debugN("Found font substitute for font '%s' ", getFontName(toFont));
+ debug("as '%s'", getFontName(fromFont));
- Graphics::BdfFont *font = Graphics::BdfFont::scaleFont(bdfFont, toFont.getSize());
+ Graphics::BdfFont *font = Graphics::BdfFont::scaleFont(fromFont.getBdfFont(), toFont.getSize());
toFont.setGenerated(true);
+ toFont.setBdfFont(font);
FontMan.assignFontToName(getFontName(toFont), font);
- _fontRegistry.setVal(getFontName(toFont), &toFont);
+ _fontRegistry.setVal(getFontName(toFont), new MacFont(toFont));
+
+ debug("Generated font '%s'", getFontName(toFont));
}
} // End of namespace Graphics