diff options
Diffstat (limited to 'graphics')
-rw-r--r-- | graphics/macgui/macfontmanager.cpp | 34 | ||||
-rw-r--r-- | graphics/macgui/macfontmanager.h | 2 |
2 files changed, 32 insertions, 4 deletions
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp index cf7ec4094e..f57cc9b919 100644 --- a/graphics/macgui/macfontmanager.cpp +++ b/graphics/macgui/macfontmanager.cpp @@ -74,6 +74,17 @@ static const char *const fontNames[] = { "New Century Schoolbook" }; +static const char *const fontStyleSuffixes[] = { + "", + "Bold", + "Italic", + "Underline", + "Outline", + "Shadow", + "Condense", + "Extend" +}; + MacFontManager::MacFontManager() { for (uint i = 0; i < ARRAYSIZE(fontNames); i++) if (fontNames[i]) @@ -244,8 +255,14 @@ const Font *MacFontManager::getFont(MacFont macFont) { if (macFont.getName().empty()) macFont.setName(getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant())); - if (!_fontRegistry.contains(macFont.getName())) - generateFontSubstitute(macFont); + if (!_fontRegistry.contains(macFont.getName())) { + // Let's try to generate name + if (macFont.getSlant() != kMacFontRegular) + macFont.setName(getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant(), true)); + + if (!_fontRegistry.contains(macFont.getName())) + generateFontSubstitute(macFont); + } font = FontMan.getFontByName(macFont.getName()); @@ -286,7 +303,7 @@ void MacFontManager::clearFontMapping() { _extraFontIds.clear(); } -const char *MacFontManager::getFontName(int id, int size, int slant) { +const char *MacFontManager::getFontName(int id, int size, int slant, bool tryGen) { static char name[128]; Common::String n; @@ -299,6 +316,17 @@ const char *MacFontManager::getFontName(int id, int size, int slant) { n = fontNames[0]; // Fallback to Chicago } + if (tryGen && slant != kMacFontRegular) { + for (int i = 0; i < 7; i++) { + if (slant & (1 << i)) { + n += ' '; + n += fontStyleSuffixes[i + 1]; + } + } + + slant = 0; + } + snprintf(name, 128, "%s-%d-%d", n.c_str(), slant, size); return name; diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h index 07407e2655..c154b8ba66 100644 --- a/graphics/macgui/macfontmanager.h +++ b/graphics/macgui/macfontmanager.h @@ -123,7 +123,7 @@ public: * @param size size of the font * @return the font name or NULL if ID goes beyond the mapping */ - const char *getFontName(int id, int size, int slant = kMacFontRegular); + const char *getFontName(int id, int size, int slant = kMacFontRegular, bool tryGen = false); const char *getFontName(MacFont &font); int getFontIdByName(Common::String name); |