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);
|
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 boxShadow = (uint16)textCast->boxShadow;
|
||||||
uint16 borderSize = (uint16)textCast->borderSize;
|
uint16 borderSize = (uint16)textCast->borderSize;
|
||||||
|
|
|
@ -249,16 +249,21 @@ void MacFontManager::loadFonts(Common::MacResManager *fontFile) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const Font *MacFontManager::getFont(MacFont macFont) {
|
const Font *MacFontManager::getFont(MacFont macFont) {
|
||||||
|
Common::String name;
|
||||||
const Font *font = 0;
|
const Font *font = 0;
|
||||||
|
|
||||||
if (!_builtInFonts) {
|
if (!_builtInFonts) {
|
||||||
if (macFont.getName().empty())
|
if (macFont.getName().empty()) {
|
||||||
macFont.setName(getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant()));
|
name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant());
|
||||||
|
macFont.setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (!_fontRegistry.contains(macFont.getName())) {
|
if (!_fontRegistry.contains(macFont.getName())) {
|
||||||
// Let's try to generate name
|
// Let's try to generate name
|
||||||
if (macFont.getSlant() != kMacFontRegular)
|
if (macFont.getSlant() != kMacFontRegular) {
|
||||||
macFont.setName(getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant(), true));
|
name = getFontName(macFont.getId(), macFont.getSize(), macFont.getSlant(), true);
|
||||||
|
macFont.setName(name);
|
||||||
|
}
|
||||||
|
|
||||||
if (!_fontRegistry.contains(macFont.getName()))
|
if (!_fontRegistry.contains(macFont.getName()))
|
||||||
generateFontSubstitute(macFont);
|
generateFontSubstitute(macFont);
|
||||||
|
@ -303,8 +308,7 @@ void MacFontManager::clearFontMapping() {
|
||||||
_extraFontIds.clear();
|
_extraFontIds.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MacFontManager::getFontName(int id, int size, int slant, bool tryGen) {
|
const Common::String MacFontManager::getFontName(int id, int size, int slant, bool tryGen) {
|
||||||
static char name[128];
|
|
||||||
Common::String n;
|
Common::String n;
|
||||||
|
|
||||||
if (_extraFontNames.contains(id)) {
|
if (_extraFontNames.contains(id)) {
|
||||||
|
@ -327,12 +331,10 @@ const char *MacFontManager::getFontName(int id, int size, int slant, bool tryGen
|
||||||
slant = 0;
|
slant = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(name, 128, "%s-%d-%d", n.c_str(), slant, size);
|
return Common::String::format("%s-%d-%d", n.c_str(), slant, size);
|
||||||
|
|
||||||
return name;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MacFontManager::getFontName(MacFont &font) {
|
const Common::String MacFontManager::getFontName(MacFont &font) {
|
||||||
return getFontName(font.getId(), font.getSize(), font.getSlant());
|
return getFontName(font.getId(), font.getSize(), font.getSlant());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -375,7 +377,7 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sizes.empty()) {
|
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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -400,13 +402,13 @@ void MacFontManager::generateFontSubstitute(MacFont &macFont) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
|
void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
|
||||||
debugN("Found font substitute for font '%s' ", getFontName(toFont));
|
debugN("Found font substitute for font '%s' ", getFontName(toFont).c_str());
|
||||||
debug("as '%s'", getFontName(fromFont));
|
debug("as '%s'", getFontName(fromFont).c_str());
|
||||||
|
|
||||||
MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize());
|
MacFONTFont *font = Graphics::MacFONTFont::scaleFont(fromFont.getFont(), toFont.getSize());
|
||||||
|
|
||||||
if (!font) {
|
if (!font) {
|
||||||
warning("Failed to generate font '%s'", getFontName(toFont));
|
warning("Failed to generate font '%s'", getFontName(toFont).c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
toFont.setGenerated(true);
|
toFont.setGenerated(true);
|
||||||
|
@ -415,7 +417,7 @@ void MacFontManager::generateFont(MacFont &toFont, MacFont &fromFont) {
|
||||||
FontMan.assignFontToName(getFontName(toFont), font);
|
FontMan.assignFontToName(getFontName(toFont), font);
|
||||||
_fontRegistry.setVal(getFontName(toFont), new MacFont(toFont));
|
_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
|
} // End of namespace Graphics
|
||||||
|
|
|
@ -123,8 +123,8 @@ public:
|
||||||
* @param size size of the font
|
* @param size size of the font
|
||||||
* @return the font name or NULL if ID goes beyond the mapping
|
* @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 Common::String getFontName(int id, int size, int slant = kMacFontRegular, bool tryGen = false);
|
||||||
const char *getFontName(MacFont &font);
|
const Common::String getFontName(MacFont &font);
|
||||||
int getFontIdByName(Common::String name);
|
int getFontIdByName(Common::String name);
|
||||||
|
|
||||||
void loadFonts(Common::SeekableReadStream *stream);
|
void loadFonts(Common::SeekableReadStream *stream);
|
||||||
|
|
|
@ -391,14 +391,11 @@ const Font *MacMenu::getMenuFont() {
|
||||||
return _wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
|
return _wm->_fontMan->getFont(Graphics::MacFont(kMacFontChicago, 12));
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *MacMenu::getAcceleratorString(MacMenuSubItem *item, const char *prefix) {
|
const Common::String MacMenu::getAcceleratorString(MacMenuSubItem *item, const char *prefix) {
|
||||||
static char res[20];
|
if (item->shortcut == 0)
|
||||||
*res = 0;
|
return Common::String();
|
||||||
|
|
||||||
if (item->shortcut != 0)
|
return Common::String::format("%s%c%c", prefix, (_wm->_fontMan->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut);
|
||||||
sprintf(res, "%s%c%c", prefix, (_wm->_fontMan->hasBuiltInFonts() ? '^' : '\x11'), item->shortcut);
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int MacMenu::calculateMenuWidth(MacMenuItem *menu) {
|
int MacMenu::calculateMenuWidth(MacMenuItem *menu) {
|
||||||
|
|
|
@ -86,7 +86,7 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const Font *getMenuFont();
|
const Font *getMenuFont();
|
||||||
const char *getAcceleratorString(MacMenuSubItem *item, const char *prefix);
|
const Common::String getAcceleratorString(MacMenuSubItem *item, const char *prefix);
|
||||||
int calculateMenuWidth(MacMenuItem *menu);
|
int calculateMenuWidth(MacMenuItem *menu);
|
||||||
void calcMenuBounds(MacMenuItem *menu);
|
void calcMenuBounds(MacMenuItem *menu);
|
||||||
void renderSubmenu(MacMenuItem *menu);
|
void renderSubmenu(MacMenuItem *menu);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue