Unified
Split
Showing
with
63 additions
and 95 deletions.
- +8 −3 engines/zvision/core/console.cpp
- +1 −1 engines/zvision/core/console.h
- +54 −91 engines/zvision/graphics/truetype_font.cpp
| @@ -52,7 +52,7 @@ Console::Console(ZVision *engine) : GUI::Debugger(), _engine(engine) { | ||
| registerCmd("setpanoramascale", WRAP_METHOD(Console, cmdSetPanoramaScale)); | ||
| registerCmd("location", WRAP_METHOD(Console, cmdLocation)); | ||
| registerCmd("dumpfile", WRAP_METHOD(Console, cmdDumpFile)); | ||
| registerCmd("dumpallscripts", WRAP_METHOD(Console, cmdDumpAllScripts)); | ||
| registerCmd("dumpfiles", WRAP_METHOD(Console, cmdDumpFiles)); | ||
| } | ||
|
|
||
| bool Console::cmdLoadVideo(int argc, const char **argv) { | ||
| @@ -237,12 +237,17 @@ bool Console::cmdDumpFile(int argc, const char **argv) { | ||
| return true; | ||
| } | ||
|
|
||
| bool Console::cmdDumpAllScripts(int argc, const char **argv) { | ||
| bool Console::cmdDumpFiles(int argc, const char **argv) { | ||
| Common::String fileName; | ||
| Common::SeekableReadStream *in; | ||
|
|
||
| if (argc != 2) { | ||
| debugPrintf("Use %s <file extension> to dump all files with a specific extension\n", argv[0]); | ||
| return true; | ||
| } | ||
|
|
||
| SearchManager::MatchList fileList; | ||
| _engine->getSearchManager()->listMembersWithExtension(fileList, "scr"); | ||
| _engine->getSearchManager()->listMembersWithExtension(fileList, argv[1]); | ||
|
|
||
| for (SearchManager::MatchList::iterator iter = fileList.begin(); iter != fileList.end(); ++iter) { | ||
| fileName = iter->_value.name; | ||
| @@ -46,7 +46,7 @@ class Console : public GUI::Debugger { | ||
| bool cmdSetPanoramaScale(int argc, const char **argv); | ||
| bool cmdLocation(int argc, const char **argv); | ||
| bool cmdDumpFile(int argc, const char **argv); | ||
| bool cmdDumpAllScripts(int argc, const char **argv); | ||
| bool cmdDumpFiles(int argc, const char **argv); | ||
| }; | ||
|
|
||
| } // End of namespace ZVision | ||
| @@ -54,105 +54,68 @@ 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; | ||
| if (fontName.matchString("*times new roman*", true) || fontName.matchString("*times*", true)) { | ||
| if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) | ||
| newFontName = "timesbi.ttf"; | ||
| else if (_style & STTF_BOLD) | ||
| newFontName = "timesbd.ttf"; | ||
| else if (_style & STTF_ITALIC) | ||
| newFontName = "timesi.ttf"; | ||
| else | ||
| newFontName = "times.ttf"; | ||
|
|
||
| } else if (fontName.matchString("*courier new*", true) || fontName.matchString("*courier*", true) || fontName.matchString("*ZorkDeath*", true)) { | ||
| if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) | ||
| newFontName = "courbi.ttf"; | ||
| else if (_style & STTF_BOLD) | ||
| newFontName = "courbd.ttf"; | ||
| else if (_style & STTF_ITALIC) | ||
| newFontName = "couri.ttf"; | ||
| else | ||
| newFontName = "cour.ttf"; | ||
|
|
||
| } else if (fontName.matchString("*century schoolbook*", true)) { | ||
| if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) | ||
| newFontName = "censcbkbi.ttf"; | ||
| else if (_style & STTF_BOLD) | ||
| newFontName = "censcbkbd.ttf"; | ||
| else if (_style & STTF_ITALIC) | ||
| newFontName = "censcbki.ttf"; | ||
| else | ||
| newFontName = "censcbk.ttf"; | ||
|
|
||
| } else if (fontName.matchString("*garamond*", true)) { | ||
| if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) | ||
| newFontName = "garabi.ttf"; | ||
| else if (_style & STTF_BOLD) | ||
| newFontName = "garabd.ttf"; | ||
| else if (_style & STTF_ITALIC) | ||
| newFontName = "garai.ttf"; | ||
| else | ||
| newFontName = "gara.ttf"; | ||
|
|
||
| } else if (fontName.matchString("*arial*", true) || fontName.matchString("*ZorkNormal*", true)) { | ||
| if ((_style & (STTF_BOLD | STTF_ITALIC)) == (STTF_BOLD | STTF_ITALIC)) | ||
| newFontName = "arialbi.ttf"; | ||
| else if (_style & STTF_BOLD) | ||
| newFontName = "arialbd.ttf"; | ||
| else if (_style & STTF_ITALIC) | ||
| newFontName = "ariali.ttf"; | ||
| else | ||
| newFontName = "arial.ttf"; | ||
| Common::String freeFontName; | ||
|
|
||
| for (int i = 0; i < ARRAYSIZE(systemFonts); i++) { | ||
| if (fontName.matchString(systemFonts[i].zorkFont, true)) { | ||
| newFontName = systemFonts[i].fontBase; | ||
| freeFontName = systemFonts[i].freeFontBase; | ||
|
|
||
| if ((_style & STTF_BOLD) && (_style & STTF_ITALIC)) { | ||
| newFontName += "bi"; | ||
| freeFontName += "Bold"; | ||
| freeFontName += systemFonts[i].freeFontItalicName; | ||
| } else if (_style & STTF_BOLD) { | ||
| newFontName += "bd"; | ||
| freeFontName += "Bold"; | ||
| } else if (_style & STTF_ITALIC) { | ||
| newFontName += "i"; | ||
| freeFontName += systemFonts[i].freeFontItalicName; | ||
| } | ||
|
|
||
| } else { | ||
| newFontName += ".ttf"; | ||
| freeFontName += ".ttf"; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| if (newFontName.empty()) { | ||
| debug("Could not identify font: %s. Reverting to Arial", fontName.c_str()); | ||
| newFontName = "arial.ttf"; | ||
| freeFontName = "FreeSans.ttf"; | ||
| } | ||
|
|
||
| bool sharp = (_style & STTF_SHARP) == STTF_SHARP; | ||
|
|
||
| Common::File *file = _engine->getSearchManager()->openFile(newFontName); | ||
|
|
||
| if (!file) { | ||
| Common::SeekableReadStream *themeFile = nullptr; | ||
| if (ConfMan.hasKey("themepath")) { | ||
| Common::FSNode themePath(ConfMan.get("themepath")); | ||
| if (themePath.exists()) { | ||
| Common::FSNode scummModern = themePath.getChild("scummmodern.zip"); | ||
| if (scummModern.exists()) { | ||
| themeFile = scummModern.createReadStream(); | ||
| } | ||
| } | ||
| } | ||
| if (!themeFile) { // Fallback : Search for ScummModern.zip in SearchMan. | ||
| themeFile = SearchMan.createReadStreamForMember("scummmodern.zip"); | ||
| } | ||
| if (themeFile) { | ||
| Common::Archive *themeArchive = Common::makeZipArchive(themeFile); | ||
| if (themeArchive->hasFile("FreeSans.ttf")) { | ||
| Common::SeekableReadStream *stream = nullptr; | ||
| stream = themeArchive->createReadStreamForMember("FreeSans.ttf"); | ||
| Graphics::Font *_newFont = Graphics::loadTTFFont(*stream, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display | ||
| if (_newFont) { | ||
| if (!_font) | ||
| delete _font; | ||
| _font = _newFont; | ||
| } | ||
| if (stream) | ||
| delete stream; | ||
| } | ||
| delete themeArchive; | ||
| themeArchive = nullptr; | ||
| } | ||
| } else { | ||
| Graphics::Font *_newFont = Graphics::loadTTFFont(*file, point, 60, (sharp ? Graphics::kTTFRenderModeMonochrome : Graphics::kTTFRenderModeNormal)); // 66 dpi for 640 x 480 on 14" display | ||
| if (_newFont) { | ||
| if (!_font) | ||
| delete _font; | ||
| _font = _newFont; | ||
| } | ||
| delete file; | ||
| Common::File file; | ||
| if (!file.open(newFontName) && !file.open(freeFontName)) | ||
| error("Unable to open font file %s (free alternative: %s)", newFontName.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) { | ||
| if (!_font) | ||
| delete _font; | ||
| _font = _newFont; | ||
| } | ||
|
|
||
| _fntName = fontName; | ||
Showing you all comments on commits in this comparison.
This comment has been minimized.
This comment has been minimized.
|
I really like these changes. Very clean |