[Scummvm-git-logs] scummvm master -> 086963fd239db247e36a35cac2c19b2ce62f138f

sev- sev at scummvm.org
Fri Oct 7 19:43:41 CEST 2016


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
086963fd23 GRAPHICS: Search for font substitution for MacFonts


Commit: 086963fd239db247e36a35cac2c19b2ce62f138f
    https://github.com/scummvm/scummvm/commit/086963fd239db247e36a35cac2c19b2ce62f138f
Author: Eugene Sandulenko (sev at scummvm.org)
Date: 2016-10-07T19:42:55+02:00

Commit Message:
GRAPHICS: Search for font substitution for MacFonts

Changed paths:
    engines/wage/world.cpp
    graphics/macgui/macfontmanager.cpp
    graphics/macgui/macfontmanager.h



diff --git a/engines/wage/world.cpp b/engines/wage/world.cpp
index 100517b..90d6897 100644
--- a/engines/wage/world.cpp
+++ b/engines/wage/world.cpp
@@ -206,7 +206,7 @@ bool World::loadWorld(Common::MacResManager *resMan) {
 			scene->_textBounds = readRect(res);
 			int fontType = res->readUint16BE();
 			int fontSize = res->readUint16BE();
-			scene->_font = new Graphics::MacFont(fontType, fontSize, Graphics::FontManager::kConsoleFont);
+			scene->_font = new Graphics::MacFont(fontType, fontSize, Graphics::kMacFontRegular, Graphics::FontManager::kConsoleFont);
 
 			Common::String text;
 			while (res->pos() < res->size()) {
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index 03fcb41..97da1a6 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -72,6 +72,7 @@ void MacFontManager::loadFonts() {
 		}
 
 		FontMan.assignFontToName(fontName, font);
+		_fontRegistry.setVal(fontName, font);
 
 		debug(2, " %s", fontName.c_str());
 	}
@@ -86,7 +87,10 @@ const Font *MacFontManager::getFont(MacFont macFont) {
 
 	if (!_builtInFonts) {
 		if (macFont.getName().empty())
-			macFont.setName(getFontName(macFont.getId(), macFont.getSize()));
+			macFont.setName(getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant()));
+
+		if (!_fontRegistry.contains(macFont.getName()))
+			generateFontSubstitute(macFont);
 
 		font = FontMan.getFontByName(macFont.getName());
 
@@ -172,4 +176,26 @@ const char *MacFontManager::getFontName(int id, int size, int slant) {
 	return name;
 }
 
+const char *MacFontManager::getFontName(MacFont &font) {
+	return getFontName(font.getId(), font.getSize(), font.getSlant());
+}
+
+void MacFontManager::generateFontSubstitute(MacFont &macFont) {
+	if (_fontRegistry.contains(getFontName(macFont.getId(), macFont.getSize() * 2, macFont.getSlant()))) {
+		generateFont(macFont, MacFont(macFont.getId(), macFont.getSize() * 2, macFont.getSlant()));
+
+		return;
+	}
+
+	if (_fontRegistry.contains(getFontName(macFont.getId(), macFont.getSize() / 2, macFont.getSlant()))) {
+		generateFont(macFont, MacFont(macFont.getId(), macFont.getSize() / 2, macFont.getSlant()));
+
+		return;
+	}
+}
+
+void MacFontManager::generateFont(MacFont fromFont, MacFont toFont) {
+	warning("Found font substitute from font %s to %s", getFontName(fromFont), getFontName(toFont));
+}
+
 } // End of namespace Graphics
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index 568c153..a263ab5 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -37,16 +37,20 @@ enum {
 	kMacFontItalic
 };
 
+class BdfFont;
+
 class MacFont {
 public:
-	MacFont(int id = kMacFontChicago, int size = 12, FontManager::FontUsage fallback = Graphics::FontManager::kBigGUIFont) {
+	MacFont(int id = kMacFontChicago, int size = 12, int slant = kMacFontRegular, FontManager::FontUsage fallback = Graphics::FontManager::kBigGUIFont) {
 		_id = id;
 		_size = size;
+		_slant = slant;
 		_fallback = fallback;
 	}
 
 	int getId() { return _id; };
 	int getSize() { return _size; }
+	int getSlant() { return _slant; }
 	Common::String getName() { return _name; }
 	void setName(Common::String &name) { _name = name; }
 	void setName(const char *name) { _name = name; }
@@ -55,6 +59,7 @@ public:
 private:
 	int _id;
 	int _size;
+	int _slant;
 	Common::String _name;
 	FontManager::FontUsage _fallback;
 };
@@ -86,9 +91,14 @@ private:
 	 * @return the font name or NULL if ID goes beyond the mapping
 	 */
 	const char *getFontName(int id, int size, int slant = kMacFontRegular);
+	const char *getFontName(MacFont &font);
+
+	void generateFontSubstitute(MacFont &macFont);
+	void generateFont(MacFont fromFont, MacFont toFont);
 
 private:
 	bool _builtInFonts;
+	Common::HashMap<Common::String, BdfFont *> _fontRegistry;
 };
 
 } // End of namespace Graphics





More information about the Scummvm-git-logs mailing list