From 3f4c924c9e6b26260e06d385a71b874d32371903 Mon Sep 17 00:00:00 2001 From: Filippos Karapetis Date: Mon, 12 Jan 2015 02:37:27 +0200 Subject: ZVISION: Check for all the required fonts before starting a game --- engines/zvision/text/truetype_font.cpp | 19 ------------------- engines/zvision/text/truetype_font.h | 19 +++++++++++++++++++ engines/zvision/zvision.cpp | 30 +++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 20 deletions(-) (limited to 'engines/zvision') 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. " -- cgit v1.2.3