aboutsummaryrefslogtreecommitdiff
path: root/engines/zvision/text/truetype_font.cpp
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/text/truetype_font.cpp
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/text/truetype_font.cpp')
-rw-r--r--engines/zvision/text/truetype_font.cpp44
1 files changed, 36 insertions, 8 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) {