[Scummvm-cvs-logs] scummvm master -> 3f4c924c9e6b26260e06d385a71b874d32371903

bluegr bluegr at gmail.com
Mon Jan 12 01:39:00 CET 2015


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:
3f4c924c9e ZVISION: Check for all the required fonts before starting a game


Commit: 3f4c924c9e6b26260e06d385a71b874d32371903
    https://github.com/scummvm/scummvm/commit/3f4c924c9e6b26260e06d385a71b874d32371903
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2015-01-12T02:37:53+02:00

Commit Message:
ZVISION: Check for all the required fonts before starting a game

Changed paths:
    engines/zvision/text/truetype_font.cpp
    engines/zvision/text/truetype_font.h
    engines/zvision/zvision.cpp



diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp
index 622a02a..5cb0922 100644
--- a/engines/zvision/text/truetype_font.cpp
+++ b/engines/zvision/text/truetype_font.cpp
@@ -54,25 +54,6 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint st
 }
 
 bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) {
-	struct FontStyle {
-		const char *zorkFont;
-		const char *fontBase;
-		const char *freeFontBase;
-		const char *freeFontItalicName;
-	};
-
-	const FontStyle systemFonts[] = {
-		{ "*times new roman*",	  "times",   "FreeSerif", "Italic"  },
-		{ "*times*",		  "times",   "FreeSerif", "Italic"  },
-		{ "*century schoolbook*", "censcbk", "FreeSerif", "Italic"  },
-		{ "*garamond*", 	  "gara",    "FreeSerif", "Italic"  },
-		{ "*courier new*",	  "cour",    "FreeMono",  "Oblique" },
-		{ "*courier*",		  "cour",    "FreeMono",  "Oblique" },
-		{ "*ZorkDeath*",	  "cour",    "FreeMono",  "Oblique" },
-		{ "*arial*",		  "arial",   "FreeSans",  "Oblique" },
-		{ "*ZorkNormal*",	  "arial",   "FreeSans",  "Oblique" },
-	};
-
 	Common::String newFontName;
 	Common::String freeFontName;
 
diff --git a/engines/zvision/text/truetype_font.h b/engines/zvision/text/truetype_font.h
index b5fac4a..f63e09b 100644
--- a/engines/zvision/text/truetype_font.h
+++ b/engines/zvision/text/truetype_font.h
@@ -34,6 +34,25 @@ struct Surface;
 
 namespace ZVision {
 
+struct FontStyle {
+	const char *zorkFont;
+	const char *fontBase;
+	const char *freeFontBase;
+	const char *freeFontItalicName;
+};
+
+const FontStyle systemFonts[] = {
+	{ "*times new roman*",	  "times",   "FreeSerif", "Italic"  },
+	{ "*times*",		  "times",   "FreeSerif", "Italic"  },
+	{ "*century schoolbook*", "censcbk", "FreeSerif", "Italic"  },
+	{ "*garamond*", 	  "gara",    "FreeSerif", "Italic"  },
+	{ "*courier new*",	  "cour",    "FreeMono",  "Oblique" },
+	{ "*courier*",		  "cour",    "FreeMono",  "Oblique" },
+	{ "*ZorkDeath*",	  "cour",    "FreeMono",  "Oblique" },
+	{ "*arial*",		  "arial",   "FreeSans",  "Oblique" },
+	{ "*ZorkNormal*",	  "arial",   "FreeSans",  "Oblique" },
+};
+
 class ZVision;
 
 // Styled TTF
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index b42906f..1038391 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -243,8 +243,36 @@ Common::Error ZVision::run() {
 	if (ConfMan.hasKey("save_slot"))
 		_saveManager->loadGame(ConfMan.getInt("save_slot"));
 
+	bool foundAllFonts = true;
+
 	// Before starting, make absolutely sure that the user has copied the needed fonts
-	if (!Common::File::exists("arial.ttf") && !Common::File::exists("FreeSans.ttf") && !_searchManager->hasFile("arial.ttf")  && !_searchManager->hasFile("FreeSans.ttf") ) {
+	for (int i = 0; i < ARRAYSIZE(systemFonts); i++) {
+		Common::String freeFontBoldItalic = Common::String("Bold") + systemFonts[i].freeFontItalicName;
+		
+		const char *fontSuffixes[4] = { "", "bd", "i", "bi" };
+		const char *freeFontSuffixes[4] = { "", "Bold", systemFonts[i].freeFontItalicName, freeFontBoldItalic.c_str() };
+
+		for (int j = 0; j < 4; j++) {
+			Common::String fontName = systemFonts[i].fontBase;
+			fontName += fontSuffixes[j];
+			fontName += ".ttf";
+
+			Common::String freeFontName = systemFonts[i].freeFontBase;
+			freeFontName += freeFontSuffixes[j];
+			freeFontName += ".ttf";
+
+			if (!Common::File::exists(fontName) && !Common::File::exists(freeFontName) &&
+				!_searchManager->hasFile(fontName) && !_searchManager->hasFile(freeFontName)) {
+				foundAllFonts = false;
+				break;
+			}
+		}
+
+		if (!foundAllFonts)
+			break;
+	}
+
+	if (!foundAllFonts) {
 		GUI::MessageDialog dialog(
 				"Before playing this game, you'll need to copy the required "
 				"fonts into ScummVM's extras directory, or into the game directory. "






More information about the Scummvm-git-logs mailing list