[Scummvm-cvs-logs] scummvm master -> f364756bcfa952e85c2111270ffda15c9809a4b8

bluegr bluegr at gmail.com
Mon Dec 22 01:54:01 CET 2014


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

Summary:
c2d83d287f ZVISION: Allow dumping any file type via the new "dumpfiles" command
f364756bcf ZVISION: Add support for GNU Freefont fonts. Also, cleanup font loading


Commit: c2d83d287faec2bdfd6fac7d665c156670c7b7f7
    https://github.com/scummvm/scummvm/commit/c2d83d287faec2bdfd6fac7d665c156670c7b7f7
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-22T02:50:34+02:00

Commit Message:
ZVISION: Allow dumping any file type via the new "dumpfiles" command

Changed paths:
    engines/zvision/core/console.cpp
    engines/zvision/core/console.h



diff --git a/engines/zvision/core/console.cpp b/engines/zvision/core/console.cpp
index 0789f8d..07d3114 100644
--- a/engines/zvision/core/console.cpp
+++ b/engines/zvision/core/console.cpp
@@ -52,7 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) {
 	registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale));
 	registerCmd("location", WRAP_METHOD(Console, cmdLocation));
 	registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile));
-	registerCmd("dumpallscripts", WRAP_METHOD(Console, cmdDumpAllScripts));
+	registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles));
 }
 
 bool Console::cmdLoadVideo(int argc, const char **argv) {
@@ -237,12 +237,17 @@ bool Console::cmdDumpFile(int argc, const char **argv) {
 	return true;
 }
 
-bool Console::cmdDumpAllScripts(int argc, const char **argv) {
+bool Console::cmdDumpFiles(int argc, const char **argv) {
 	Common::String fileName;
 	Common::SeekableReadStream *in;
 
+	if (argc != 2) {
+		debugPrintf("Use %s <file extension> to dump all files with a specific extension\n", argv[0]);
+		return true;
+	}
+
 	SearchManager::MatchList fileList;
-	_engine->getSearchManager()->listMembersWithExtension(fileList, "scr");
+	_engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]);
 
 	for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) {
 		fileName = iter->_value.name;
diff --git a/engines/zvision/core/console.h b/engines/zvision/core/console.h
index 7e27fe8..a7bd88e 100644
--- a/engines/zvision/core/console.h
+++ b/engines/zvision/core/console.h
@@ -46,7 +46,7 @@ private:
 	bool cmdSetPanoramaScale(int argc, const char **argv);
 	bool cmdLocation(int argc, const char **argv);
 	bool cmdDumpFile(int argc, const char **argv);
-	bool cmdDumpAllScripts(int argc, const char **argv);
+	bool cmdDumpFiles(int argc, const char **argv);
 };
 
 } // End of namespace ZVision


Commit: f364756bcfa952e85c2111270ffda15c9809a4b8
    https://github.com/scummvm/scummvm/commit/f364756bcfa952e85c2111270ffda15c9809a4b8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-22T02:52:55+02:00

Commit Message:
ZVISION: Add support for GNU Freefont fonts. Also, cleanup font loading

The Freefont fonts can just be dropped into the extras ScummVM folder,
to get the game working under non-Windows systems

Changed paths:
    engines/zvision/graphics/truetype_font.cpp



diff --git a/engines/zvision/graphics/truetype_font.cpp b/engines/zvision/graphics/truetype_font.cpp
index 2dbd7ca..5c8aa03 100644
--- a/engines/zvision/graphics/truetype_font.cpp
+++ b/engines/zvision/graphics/truetype_font.cpp
@@ -54,105 +54,68 @@ 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;
-	if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) {
-		if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
-			newFontName = "timesbi.ttf";
-		else if (_style & STTF_BOLD)
-			newFontName = "timesbd.ttf";
-		else if (_style & STTF_ITALIC)
-			newFontName = "timesi.ttf";
-		else
-			newFontName = "times.ttf";
-
-	} else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) {
-		if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
-			newFontName = "courbi.ttf";
-		else if (_style & STTF_BOLD)
-			newFontName = "courbd.ttf";
-		else if (_style & STTF_ITALIC)
-			newFontName = "couri.ttf";
-		else
-			newFontName = "cour.ttf";
-
-	} else if (fontName.matchString("*century schoolbook*", true)) {
-		if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
-			newFontName = "censcbkbi.ttf";
-		else if (_style & STTF_BOLD)
-			newFontName = "censcbkbd.ttf";
-		else if (_style & STTF_ITALIC)
-			newFontName = "censcbki.ttf";
-		else
-			newFontName = "censcbk.ttf";
-
-	} else if (fontName.matchString("*garamond*", true)) {
-		if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
-			newFontName = "garabi.ttf";
-		else if (_style & STTF_BOLD)
-			newFontName = "garabd.ttf";
-		else if (_style & STTF_ITALIC)
-			newFontName = "garai.ttf";
-		else
-			newFontName = "gara.ttf";
-
-	} else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) {
-		if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC))
-			newFontName = "arialbi.ttf";
-		else if (_style & STTF_BOLD)
-			newFontName = "arialbd.ttf";
-		else if (_style & STTF_ITALIC)
-			newFontName = "ariali.ttf";
-		else
-			newFontName = "arial.ttf";
+	Common::String freeFontName;
+
+	for (int i = 0; i < ARRAYSIZE(systemFonts); i++) {
+		if (fontName.matchString(systemFonts[i].zorkFont, true)) {
+			newFontName = systemFonts[i].fontBase;
+			freeFontName = systemFonts[i].freeFontBase;
+
+			if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) {
+				newFontName += "bi";
+				freeFontName += "Bold";
+				freeFontName += systemFonts[i].freeFontItalicName;
+			} else if (_style & STTF_BOLD) {
+				newFontName += "bd";
+				freeFontName += "Bold";
+			} else if (_style & STTF_ITALIC) {
+				newFontName += "i";
+				freeFontName += systemFonts[i].freeFontItalicName;
+			}
 
-	} else {
+			newFontName += ".ttf";
+			freeFontName += ".ttf";
+			break;
+		}
+	}
+
+	if (newFontName.empty()) {
 		debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
 		newFontName = "arial.ttf";
+		freeFontName = "FreeSans.ttf";
 	}
 
 	bool sharp = (_style & STTF_SHARP) == STTF_SHARP;
 
-	Common::File *file = _engine->getSearchManager()->openFile(newFontName);
-
-	if (!file) {
-		Common::SeekableReadStream *themeFile = nullptr;
-		if (ConfMan.hasKey("themepath")) {
-			Common::FSNode themePath(ConfMan.get("themepath"));
-			if (themePath.exists()) {
-				Common::FSNode scummModern = themePath.getChild("scummmodern.zip");
-				if (scummModern.exists()) {
-					themeFile = scummModern.createReadStream();
-				}
-			}
-		}
-		if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan.
-			themeFile = SearchMan.createReadStreamForMember("scummmodern.zip");
-		}
-		if (themeFile) {
-			Common::Archive *themeArchive = Common::makeZipArchive(themeFile);
-			if (themeArchive->hasFile("FreeSans.ttf")) {
-				Common::SeekableReadStream *stream = nullptr;
-				stream = themeArchive->createReadStreamForMember("FreeSans.ttf");
-				Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
-				if (_newFont) {
-					if (!_font)
-						delete _font;
-					_font = _newFont;
-				}
-				if (stream)
-					delete stream;
-			}
-			delete themeArchive;
-			themeArchive = nullptr;
-		}
-	} else {
-		Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
-		if (_newFont) {
-			if (!_font)
-				delete _font;
-			_font = _newFont;
-		}
-		delete file;
+	Common::File file;
+	if (!file.open(newFontName) && !file.open(freeFontName))
+		error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str());
+
+	Graphics::Font *_newFont = Graphics::loadTTFFont(file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display
+	if (_newFont) {
+		if (!_font)
+			delete _font;
+		_font = _newFont;
 	}
 
 	_fntName = fontName;






More information about the Scummvm-git-logs mailing list