diff options
author | Filippos Karapetis | 2015-01-12 02:37:27 +0200 |
---|---|---|
committer | Filippos Karapetis | 2015-01-12 02:37:53 +0200 |
commit | 3f4c924c9e6b26260e06d385a71b874d32371903 (patch) | |
tree | 31d58e10ce8ce46bcd9abb3d39357fe3e517c6eb | |
parent | dc6c1a5cab2d27cd367b54b08d1cb0189c163fc8 (diff) | |
download | scummvm-rg350-3f4c924c9e6b26260e06d385a71b874d32371903.tar.gz scummvm-rg350-3f4c924c9e6b26260e06d385a71b874d32371903.tar.bz2 scummvm-rg350-3f4c924c9e6b26260e06d385a71b874d32371903.zip |
ZVISION: Check for all the required fonts before starting a game
-rw-r--r-- | engines/zvision/text/truetype_font.cpp | 19 | ||||
-rw-r--r-- | engines/zvision/text/truetype_font.h | 19 | ||||
-rw-r--r-- | engines/zvision/zvision.cpp | 30 |
3 files changed, 48 insertions, 20 deletions
diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp index 622a02a6a8..5cb09226e8 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 b5fac4af8a..f63e09b1fc 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 b42906fef3..103839158a 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. " |