aboutsummaryrefslogtreecommitdiff
path: root/graphics/macgui
diff options
context:
space:
mode:
Diffstat (limited to 'graphics/macgui')
-rw-r--r--graphics/macgui/macfontmanager.cpp32
-rw-r--r--graphics/macgui/macfontmanager.h4
-rw-r--r--graphics/macgui/macmenu.cpp11
-rw-r--r--graphics/macgui/macmenu.h2
4 files changed, 24 insertions, 25 deletions
diff --git a/graphics/macgui/macfontmanager.cpp b/graphics/macgui/macfontmanager.cpp
index c3a96dc8fb..05bdddc840 100644
--- a/graphics/macgui/macfontmanager.cpp
+++ b/graphics/macgui/macfontmanager.cpp
@@ -249,16 +249,21 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
}
const Font *MacFontManager::getFont(MacFont macFont) {
+ Common::String name;
const Font *font = 0;
if (!_builtInFonts) {
- if (macFont.getName().empty())
- macFont.setName(getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant()));
+ if (macFont.getName().empty()) {
+ name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant());
+ macFont.setName(name);
+ }
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 (macFont.getSlant() != kMacFontRegular) {
+ name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant(), true);
+ macFont.setName(name);
+ }
if (!_fontRegistry.contains(macFont.getName()))
generateFontSubstitute(macFont);
@@ -303,8 +308,7 @@ void MacFontManager::clearFontMapping() {
_extraFontIds.clear();
}
-const char *MacFontManager::getFontName(int id, int size, int slant, bool tryGen) {
- static char name[128];
+const Common::String MacFontManager::getFontName(int id, int size, int slant, bool tryGen) {
Common::String n;
if (_extraFontNames.contains(id)) {
@@ -327,12 +331,10 @@ const char *MacFontManager::getFontName(int id, int size, int slant, bool tryGen
slant = 0;
}
- snprintf(name, 128, "%s-%d-%d", n.c_str(), slant, size);
-
- return name;
+ return Common::String::format("%s-%d-%d", n.c_str(), slant, size);
}
-const char *MacFontManager::getFontName(MacFont &font) {
+const Common::String MacFontManager::getFontName(MacFont &font) {
return getFontName(font.getId(), font.getSize(), font.getSlant());
}
@@ -375,7 +377,7 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
}
if (sizes.empty()) {
- debug(1, "No viable substitute found for font %s", getFontName(macFont));
+ debug(1, "No viable substitute found for font %s", getFontName(macFont).c_str());
return;
}
@@ -400,13 +402,13 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
}
void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
- debugN("Found font substitute for font '%s' ", getFontName(toFont));
- debug("as '%s'", getFontName(fromFont));
+ debugN("Found font substitute for font '%s' ", getFontName(toFont).c_str());
+ debug("as '%s'", getFontName(fromFont).c_str());
MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize());
if (!font) {
- warning("Failed to generate font '%s'", getFontName(toFont));
+ warning("Failed to generate font '%s'", getFontName(toFont).c_str());
}
toFont.setGenerated(true);
@@ -415,7 +417,7 @@ void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
FontMan.assignFontToName(getFontName(toFont), font);
_fontRegistry.setVal(getFontName(toFont), new MacFont(toFont));
- debug("Generated font '%s'", getFontName(toFont));
+ debug("Generated font '%s'", getFontName(toFont).c_str());
}
} // End of namespace Graphics
diff --git a/graphics/macgui/macfontmanager.h b/graphics/macgui/macfontmanager.h
index 0fb92ace52..ddd928234b 100644
--- a/graphics/macgui/macfontmanager.h
+++ b/graphics/macgui/macfontmanager.h
@@ -123,8 +123,8 @@ 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, bool tryGen = false);
- const char *getFontName(MacFont &font);
+ const Common::String getFontName(int id, int size, int slant = kMacFontRegular, bool tryGen = false);
+ const Common::String getFontName(MacFont &font);
int getFontIdByName(Common::String name);
void loadFonts(Common::SeekableReadStream *stream);
diff --git a/graphics/macgui/macmenu.cpp b/graphics/macgui/macmenu.cpp
index ac64f0cdae..45e05c5aa6 100644
--- a/graphics/macgui/macmenu.cpp
+++ b/graphics/macgui/macmenu.cpp
@@ -391,14 +391,11 @@ const Font *MacMenu::getMenuFont() {
return _wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
}
-const char *MacMenu::getAcceleratorString(MacMenuSubItem *item, const char *prefix) {
- static char res[20];
- *res = 0;
+const Common::String MacMenu::getAcceleratorString(MacMenuSubItem *item, const char *prefix) {
+ if (item->shortcut == 0)
+ return Common::String();
- if (item->shortcut != 0)
- sprintf(res, "%s%c%c", prefix, (_wm->_fontMan->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut);
-
- return res;
+ return Common::String::format("%s%c%c", prefix, (_wm->_fontMan->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut);
}
int MacMenu::calculateMenuWidth(MacMenuItem *menu) {
diff --git a/graphics/macgui/macmenu.h b/graphics/macgui/macmenu.h
index 36cd06a2ff..717a0ce835 100644
--- a/graphics/macgui/macmenu.h
+++ b/graphics/macgui/macmenu.h
@@ -86,7 +86,7 @@ private:
private:
const Font *getMenuFont();
- const char *getAcceleratorString(MacMenuSubItem *item, const char *prefix);
+ const Common::String getAcceleratorString(MacMenuSubItem *item, const char *prefix);
int calculateMenuWidth(MacMenuItem *menu);
void calcMenuBounds(MacMenuItem *menu);
void renderSubmenu(MacMenuItem *menu);