Skip to content

Commit

Permalink
GRAPHICS: Differentiate Mac fonts by slant
Browse files Browse the repository at this point in the history
  • Loading branch information
sev- committed Oct 7, 2016
1 parent ee476e9 commit db05a94
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 4 deletions.
20 changes: 17 additions & 3 deletions graphics/macgui/macfontmanager.cpp
Expand Up @@ -56,7 +56,7 @@ void MacFontManager::loadFonts() {

Common::String fontName;
if (font->getFamilyName() && *font->getFamilyName()) {
fontName = Common::String::format("%s-%d", font->getFamilyName(), font->getFontSize());
fontName = Common::String::format("%s-%s-%d", font->getFamilyName(), font->getFontSlant(), font->getFontSize());
} else { // Get it from the file name
fontName = (*it)->getName();

Expand Down Expand Up @@ -147,13 +147,27 @@ static const char *const fontNames[] = {
"New Century Schoolbook"
};

const char *MacFontManager::getFontName(int id, int size) {
const char *MacFontManager::getFontName(int id, int size, int slant) {
static char name[128];
const char *sslant;

switch (slant) {
case kMacFontItalic:
sslant = "I";
break;
case kMacFontBold:
sslant = "B";
break;
case kMacFontRegular:
default:
sslant = "R";
break;
}

if (id > ARRAYSIZE(fontNames))
return NULL;

snprintf(name, 128, "%s-%d", fontNames[id], size);
snprintf(name, 128, "%s-%s-%d", fontNames[id], sslant, size);

return name;
}
Expand Down
8 changes: 7 additions & 1 deletion graphics/macgui/macfontmanager.h
Expand Up @@ -31,6 +31,12 @@ enum {
kMacFontChicago = 0
};

enum {
kMacFontRegular,
kMacFontBold,
kMacFontItalic
};

class MacFont {
public:
MacFont(int id = kMacFontChicago, int size = 12, FontManager::FontUsage fallback = Graphics::FontManager::kBigGUIFont) {
Expand Down Expand Up @@ -79,7 +85,7 @@ class MacFontManager {
* @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);
const char *getFontName(int id, int size, int slant = kMacFontRegular);

private:
bool _builtInFonts;
Expand Down

0 comments on commit db05a94

Please sign in to comment.