diff options
author | RichieSams | 2013-09-16 00:11:52 -0500 |
---|---|---|
committer | RichieSams | 2013-09-16 00:17:15 -0500 |
commit | a2c36a16b52d5bccbfdc141e3f75bfca9aa8535a (patch) | |
tree | 0723145127e61c925b22c7968a01cd9b74b77054 | |
parent | d59cf9fda66f8bcd89f12248d7337727d708f425 (diff) | |
download | scummvm-rg350-a2c36a16b52d5bccbfdc141e3f75bfca9aa8535a.tar.gz scummvm-rg350-a2c36a16b52d5bccbfdc141e3f75bfca9aa8535a.tar.bz2 scummvm-rg350-a2c36a16b52d5bccbfdc141e3f75bfca9aa8535a.zip |
ZVISION: Fix parseTag font name logic
-rw-r--r-- | engines/zvision/string_manager.cpp | 96 | ||||
-rw-r--r-- | engines/zvision/string_manager.h | 4 |
2 files changed, 53 insertions, 47 deletions
diff --git a/engines/zvision/string_manager.cpp b/engines/zvision/string_manager.cpp index 1cc3c15fd2..4c4fc7b168 100644 --- a/engines/zvision/string_manager.cpp +++ b/engines/zvision/string_manager.cpp @@ -114,15 +114,15 @@ void StringManager::parseStrFile(const Common::String &fileName) { } } -void StringManager::parseTag(const Common::String &tagString, const Common::String &textString, uint lineNumber) { +void StringManager::parseTag(const Common::String &tagString, uint lineNumber) { Common::StringTokenizer tokenizer(tagString); Common::String token = tokenizer.nextToken(); Common::String fontName; bool bold = false; - Graphics::TextAlign align = Graphics::kTextAlignLeft; - int point = 12; + Graphics::TextAlign align = _lastStyle.align; + int point = _lastStyle.font != nullptr ? _lastStyle.font->_fontHeight : 12; int red = 0; int green = 0; int blue = 0; @@ -155,56 +155,60 @@ void StringManager::parseTag(const Common::String &tagString, const Common::Stri token = tokenizer.nextToken(); } - Common::String newFontName; - if (fontName.matchString("times new roman", true)) { - if (bold) { - newFontName = "timesbd.ttf"; - } else { - newFontName = "times.ttf"; - } - } else if (fontName.matchString("courier new", true)) { - if (bold) { - newFontName = "courbd.ttf"; - } else { - newFontName = "cour.ttf"; - } - } else if (fontName.matchString("century schoolbook", true)) { - if (bold) { - newFontName = "censcbkbd.ttf"; - } else { - newFontName = "censcbk.ttf"; - } - } else if (fontName.matchString("times new roman", true)) { - if (bold) { - newFontName = "courbd.ttf"; + TextFragment fragment = _inGameText->fragments.back(); + + if (fontName.empty()) { + fragment.style.font = _lastStyle.font; + } else { + Common::String newFontName; + if (fontName.matchString("*times new roman*", true)) { + if (bold) { + newFontName = "timesbd.ttf"; + } else { + newFontName = "times.ttf"; + } + } else if (fontName.matchString("*courier new*", true)) { + if (bold) { + newFontName = "courbd.ttf"; + } else { + newFontName = "cour.ttf"; + } + } else if (fontName.matchString("*century schoolbook*", true)) { + if (bold) { + newFontName = "censcbkbd.ttf"; + } else { + newFontName = "censcbk.ttf"; + } + } else if (fontName.matchString("*garamond*", true)) { + if (bold) { + newFontName = "garabd.ttf"; + } else { + newFontName = "gara.ttf"; + } } else { - newFontName = "cour.ttf"; + debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); + if (bold) { + newFontName = "zorknorm.ttf"; + } else { + newFontName = "arial.ttf"; + } } - } else { - debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); - if (bold) { - newFontName = "zorknorm.ttf"; + + Common::String fontKey = Common::String::format("%s-%d", newFontName.c_str(), point); + if (_fonts.contains(fontKey)) { + fragment.style.font = _fonts[fontKey]; } else { - newFontName = "arial.ttf"; + fragment.style.font = new TruetypeFont(_engine, point); + fragment.style.font->loadFile(newFontName); + _fonts[fontKey] = fragment.style.font; } } - // Push an empty TextFragment onto the end of the list - // Creating the TextFragement before filling it prevents extra data copying during creation - _inGameText->fragments.push_back(TextFragment()); - TextFragment *fragment = &_inGameText->fragments.back(); - - Common::String fontKey = Common::String::format("%s-&d", newFontName.c_str(), point); - if (_fonts.contains(fontKey)) { - fragment->style.font = _fonts[fontKey]; - } else { - fragment->style.font = new TruetypeFont(_engine, point); - fragment->style.font->loadFile(newFontName); - } + fragment.style.align = align; + fragment.style.color = _pixelFormat565.ARGBToColor(0, red, green, blue); + _inGameText[lineNumber].fragments.push_back(fragment); - fragment->style.align = align; - fragment->style.color = _pixelFormat565.ARGBToColor(0, red, green, blue); - fragment->text = textString; + _lastStyle = fragment.style; } Common::String StringManager::readWideLine(Common::SeekableReadStream &stream) { diff --git a/engines/zvision/string_manager.h b/engines/zvision/string_manager.h index a214c6c625..e3539a732c 100644 --- a/engines/zvision/string_manager.h +++ b/engines/zvision/string_manager.h @@ -68,13 +68,15 @@ private: static const Graphics::PixelFormat _pixelFormat565; + TextStyle _lastStyle; + public: void initialize(ZVisionGameId gameId); StringManager::TextStyle getTextStyle(uint stringNumber); private: void parseStrFile(const Common::String &fileName); - void parseTag(const Common::String &tagString, const Common::String &textString, uint lineNumber); + void parseTag(const Common::String &tagString, uint lineNumber); static Common::String readWideLine(Common::SeekableReadStream &stream); }; |