GRAPHICS: MACGUI: Make use of Common::String::format (#1454)
This commit is contained in:
parent
2c1661bff2
commit
2097c33b57
5 changed files with 25 additions and 26 deletions
|
@ -772,7 +772,7 @@ void Frame::renderText(Graphics::ManagedSurface &surface, uint16 spriteId, Commo
|
|||
|
||||
Graphics::MacFont *macFont = new Graphics::MacFont(textCast->fontId, textCast->fontSize, textCast->textSlant);
|
||||
|
||||
debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont));
|
||||
debugC(3, kDebugText, "renderText: x: %d y: %d w: %d h: %d font: '%s'", x, y, width, height, _vm->_wm->_fontMan->getFontName(*macFont).c_str());
|
||||
|
||||
uint16 boxShadow = (uint16)textCast->boxShadow;
|
||||
uint16 borderSize = (uint16)textCast->borderSize;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue