diff options
author | Einar Johan Trøan Sømåen | 2013-11-15 15:27:50 +0100 |
---|---|---|
committer | Einar Johan Trøan Sømåen | 2013-11-15 15:27:50 +0100 |
commit | eceaf7f8cbccb984ad3878d94549d92ccc10a492 (patch) | |
tree | 9d64cf0588e1b2a09bca046422d7931e8df210c0 /engines/wintermute/base | |
parent | 441632de7018d4fc8b9043d66ff3caeb5f76da1e (diff) | |
download | scummvm-rg350-eceaf7f8cbccb984ad3878d94549d92ccc10a492.tar.gz scummvm-rg350-eceaf7f8cbccb984ad3878d94549d92ccc10a492.tar.bz2 scummvm-rg350-eceaf7f8cbccb984ad3878d94549d92ccc10a492.zip |
WINTERMUTE: Add bold-font support for FreeSans.ttf (and only FreeSans for now).
This is mostly a quick fix to solve the rather common case of wanting
to use bold Arial. This will not handle the user adding the actual Arial.ttf
file to the folder yet, but atleast it solves the common case of having
to fallback to FreeSans.
Diffstat (limited to 'engines/wintermute/base')
-rw-r--r-- | engines/wintermute/base/font/base_font_truetype.cpp | 17 | ||||
-rw-r--r-- | engines/wintermute/base/font/base_font_truetype.h | 2 |
2 files changed, 14 insertions, 5 deletions
diff --git a/engines/wintermute/base/font/base_font_truetype.cpp b/engines/wintermute/base/font/base_font_truetype.cpp index 55481c7c03..d6f09141c9 100644 --- a/engines/wintermute/base/font/base_font_truetype.cpp +++ b/engines/wintermute/base/font/base_font_truetype.cpp @@ -568,13 +568,22 @@ bool BaseFontTT::initFont() { return STATUS_FAILED; } #ifdef USE_FREETYPE2 + Common::String fallbackFilename; + // Handle Bold atleast for the fallback-case. + // TODO: Handle italic. (Needs a test-case) + if (_isBold) { + fallbackFilename = "FreeSansBold.ttf"; + } else { + fallbackFilename = "FreeSans.ttf"; + } + Common::SeekableReadStream *file = BaseFileManager::getEngineInstance()->openFile(_fontFile); if (!file) { if (Common::String(_fontFile) != "arial.ttf") { warning("%s has no replacement font yet, using FreeSans for now (if available)", _fontFile); } // Fallback1: Try to find FreeSans.ttf - file = SearchMan.createReadStreamForMember("FreeSans.ttf"); + file = SearchMan.createReadStreamForMember(fallbackFilename); } if (file) { @@ -601,9 +610,9 @@ bool BaseFontTT::initFont() { } if (themeFile) { Common::Archive *themeArchive = Common::makeZipArchive(themeFile); - if (themeArchive->hasFile("FreeSans.ttf")) { + if (themeArchive->hasFile(fallbackFilename)) { file = nullptr; - file = themeArchive->createReadStreamForMember("FreeSans.ttf"); + file = themeArchive->createReadStreamForMember(fallbackFilename); _deletableFont = Graphics::loadTTFFont(*file, 96, _fontHeight); // Use the same dpi as WME (96 vs 72). _font = _deletableFont; } @@ -618,7 +627,7 @@ bool BaseFontTT::initFont() { // Fallback3: Try to ask FontMan for the FreeSans.ttf ScummModern.zip uses: if (!_font) { // Really not desireable, as we will get a font with dpi-72 then - Common::String fontName = Common::String::format("%s-%s@%d", "FreeSans.ttf", "ASCII", _fontHeight); + Common::String fontName = Common::String::format("%s-%s@%d", fallbackFilename.c_str(), "ASCII", _fontHeight); warning("Looking for %s", fontName.c_str()); _font = FontMan.getFontByName(fontName); } diff --git a/engines/wintermute/base/font/base_font_truetype.h b/engines/wintermute/base/font/base_font_truetype.h index 2d7ebba691..7a96cdf1b7 100644 --- a/engines/wintermute/base/font/base_font_truetype.h +++ b/engines/wintermute/base/font/base_font_truetype.h @@ -135,7 +135,7 @@ private: size_t _maxCharWidth; size_t _maxCharHeight; -public: +private: bool _isBold; bool _isItalic; bool _isUnderline; |