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

This commit is contained in:
Filippos Karapetis 2015-01-12 02:37:27 +02:00
parent dc6c1a5cab
commit 3f4c924c9e
3 changed files with 48 additions and 20 deletions

View File

@ -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;

View File

@ -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

View File

@ -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. "