aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision
diff options
context:
space:
mode:
authorFilippos Karapetis2015-01-13 03:07:53 +0200
committerFilippos Karapetis2015-01-13 03:08:35 +0200
commit1b829b95b42e1123c8079e8d7628307ba5a9103f (patch)
treea8ccad5d5ed409094f9301cf8252281f1ccb990f /engines/zvision
parentb247515c587e1b9da4765b7108ce2ae0321f13c5 (diff)
downloadscummvm-rg350-1b829b95b42e1123c8079e8d7628307ba5a9103f.tar.gz
scummvm-rg350-1b829b95b42e1123c8079e8d7628307ba5a9103f.tar.bz2
scummvm-rg350-1b829b95b42e1123c8079e8d7628307ba5a9103f.zip
ZVISION: Add support for Liberation Fonts
These look better than the GNU FreeType fonts, and are thus preferred over them. Many thanks to eriktorbjorn for his work on the different fonts available Also, this commit cleans up the font style array, moving it back into the CPP file
Diffstat (limited to 'engines/zvision')
-rw-r--r--engines/zvision/text/truetype_font.cpp44
-rw-r--r--engines/zvision/text/truetype_font.h13
-rw-r--r--engines/zvision/zvision.cpp31
3 files changed, 59 insertions, 29 deletions
diff --git a/engines/zvision/text/truetype_font.cpp b/engines/zvision/text/truetype_font.cpp
index 5cb09226e8..9f4fbe797b 100644
--- a/engines/zvision/text/truetype_font.cpp
+++ b/engines/zvision/text/truetype_font.cpp
@@ -36,6 +36,22 @@
namespace ZVision {
+const FontStyle systemFonts[] = {
+ { "*times new roman*", "times", "FreeSerif", "Italic", "LiberationSerif" },
+ { "*times*", "times", "FreeSerif", "Italic", "LiberationSerif" },
+ { "*century schoolbook*", "censcbk", "FreeSerif", "Italic", "LiberationSerif" },
+ { "*garamond*", "gara", "FreeSerif", "Italic", "LiberationSerif" },
+ { "*courier new*", "cour", "FreeMono", "Oblique", "LiberationMono" },
+ { "*courier*", "cour", "FreeMono", "Oblique", "LiberationMono" },
+ { "*ZorkDeath*", "cour", "FreeMono", "Oblique", "LiberationMono" },
+ { "*arial*", "arial", "FreeSans", "Oblique", "LiberationSans" },
+ { "*ZorkNormal*", "arial", "FreeSans", "Oblique", "LiberationSans" }
+};
+
+const FontStyle getSystemFont(int fontIndex) {
+ return systemFonts[fontIndex];
+}
+
StyledTTFont::StyledTTFont(ZVision *engine) {
_engine = engine;
_style = 0;
@@ -56,26 +72,35 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point, uint st
bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) {
Common::String newFontName;
Common::String freeFontName;
+ Common::String liberationFontName;
- for (int i = 0; i < ARRAYSIZE(systemFonts); i++) {
- if (fontName.matchString(systemFonts[i].zorkFont, true)) {
- newFontName = systemFonts[i].fontBase;
- freeFontName = systemFonts[i].freeFontBase;
+ for (int i = 0; i < FONT_COUNT; i++) {
+ FontStyle curFont = getSystemFont(i);
+ if (fontName.matchString(curFont.zorkFont, true)) {
+ newFontName = curFont.fontBase;
+ freeFontName = curFont.freeFontBase;
+ liberationFontName = curFont.liberationFontBase;
if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) {
newFontName += "bi";
freeFontName += "Bold";
- freeFontName += systemFonts[i].freeFontItalicName;
+ freeFontName += curFont.freeFontItalicName;
+ liberationFontName += "-BoldItalic";
} else if (_style & STTF_BOLD) {
newFontName += "bd";
freeFontName += "Bold";
+ liberationFontName += "-Bold";
} else if (_style & STTF_ITALIC) {
newFontName += "i";
- freeFontName += systemFonts[i].freeFontItalicName;
+ freeFontName += curFont.freeFontItalicName;
+ liberationFontName += "-Italic";
+ } else {
+ liberationFontName += "-Regular";
}
newFontName += ".ttf";
freeFontName += ".ttf";
+ liberationFontName += ".ttf";
break;
}
}
@@ -84,13 +109,16 @@ bool StyledTTFont::loadFont(const Common::String &fontName, int32 point) {
debug("Could not identify font: %s. Reverting to Arial", fontName.c_str());
newFontName = "arial.ttf";
freeFontName = "FreeSans.ttf";
+ liberationFontName = "LiberationSans-Regular.ttf";
}
bool sharp = (_style & STTF_SHARP) == STTF_SHARP;
Common::File file;
- if (!file.open(newFontName) && !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, newFontName) && !_engine->getSearchManager()->openFile(file, freeFontName))
- error("Unable to open font file %s (free alternative: %s)", newFontName.c_str(), freeFontName.c_str());
+ if (!file.open(newFontName) && !_engine->getSearchManager()->openFile(file, newFontName) &&
+ !file.open(liberationFontName) && !_engine->getSearchManager()->openFile(file, liberationFontName) &&
+ !file.open(freeFontName) && !_engine->getSearchManager()->openFile(file, freeFontName))
+ error("Unable to open font file %s (Liberation Font alternative: %s, FreeFont alternative: %s)", newFontName.c_str(), liberationFontName.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) {
diff --git a/engines/zvision/text/truetype_font.h b/engines/zvision/text/truetype_font.h
index f63e09b1fc..6fbb1f0504 100644
--- a/engines/zvision/text/truetype_font.h
+++ b/engines/zvision/text/truetype_font.h
@@ -39,19 +39,10 @@ struct FontStyle {
const char *fontBase;
const char *freeFontBase;
const char *freeFontItalicName;
+ const char *liberationFontBase;
};
-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" },
-};
+#define FONT_COUNT 9
class ZVision;
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index 103839158a..f9973d2280 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -236,6 +236,8 @@ void ZVision::initialize() {
getTimerManager()->installTimerProc(&fpsTimerCallback, 1000000, this, "zvisionFPS");
}
+extern const FontStyle getSystemFont(int fontIndex);
+
Common::Error ZVision::run() {
initialize();
@@ -246,23 +248,30 @@ Common::Error ZVision::run() {
bool foundAllFonts = true;
// Before starting, make absolutely sure that the user has copied the needed fonts
- for (int i = 0; i < ARRAYSIZE(systemFonts); i++) {
- Common::String freeFontBoldItalic = Common::String("Bold") + systemFonts[i].freeFontItalicName;
+ for (int i = 0; i < FONT_COUNT; i++) {
+ FontStyle curFont = getSystemFont(i);
+ Common::String freeFontBoldItalic = Common::String("Bold") + curFont.freeFontItalicName;
const char *fontSuffixes[4] = { "", "bd", "i", "bi" };
- const char *freeFontSuffixes[4] = { "", "Bold", systemFonts[i].freeFontItalicName, freeFontBoldItalic.c_str() };
+ const char *freeFontSuffixes[4] = { "", "Bold", curFont.freeFontItalicName, freeFontBoldItalic.c_str() };
+ const char *liberationFontSuffixes[4] = { "-Regular", "-Bold", "-Italic", "-BoldItalic" };
for (int j = 0; j < 4; j++) {
- Common::String fontName = systemFonts[i].fontBase;
+ Common::String fontName = curFont.fontBase;
fontName += fontSuffixes[j];
fontName += ".ttf";
- Common::String freeFontName = systemFonts[i].freeFontBase;
+ Common::String freeFontName = curFont.freeFontBase;
freeFontName += freeFontSuffixes[j];
freeFontName += ".ttf";
- if (!Common::File::exists(fontName) && !Common::File::exists(freeFontName) &&
- !_searchManager->hasFile(fontName) && !_searchManager->hasFile(freeFontName)) {
+ Common::String liberationFontName = curFont.liberationFontBase;
+ liberationFontName += liberationFontSuffixes[j];
+ liberationFontName += ".ttf";
+
+ if (!Common::File::exists(fontName) && !_searchManager->hasFile(fontName) &&
+ !Common::File::exists(liberationFontName) && !_searchManager->hasFile(liberationFontName) &&
+ !Common::File::exists(freeFontName) && !_searchManager->hasFile(freeFontName)) {
foundAllFonts = false;
break;
}
@@ -278,9 +287,11 @@ Common::Error ZVision::run() {
"fonts into ScummVM's extras directory, or into the game directory. "
"On Windows, you'll need the following font files from the Windows "
"font directory: Times New Roman, Century Schoolbook, Garamond, "
- "Courier New and Arial. Alternatively, you can download the GNU "
- "FreeFont package. You'll need all the fonts from that package, "
- "i.e., FreeMono, FreeSans and FreeSerif."
+ "Courier New and Arial. Alternatively, you can download the "
+ "Liberation Fonts or the GNU FreeFont package. You'll need all the "
+ "fonts from the font package you choose, i.e., LiberationMono, "
+ "LiberationSans and LiberationSerif, or FreeMono, FreeSans and "
+ "FreeSerif respectively."
);
dialog.runModal();
quitGame();