Code review changes for pull request #2102

We should only load the 'MarkerFelt-Wide' fallback font in 'CCImage.mm, _initWithString()' if the user is attempting to load a custom font, not when the user is attempting to load a system font. If the user is trying to load a system font then give back the default system font instead.
This commit is contained in:
Darragh Coy 2013-03-04 22:24:28 -08:00
parent df3c449b4f
commit f84a4e2e08
1 changed files with 6 additions and 5 deletions

View File

@ -228,14 +228,15 @@ static bool _initWithString(const char * pText, cocos2d::CCImage::ETextAlign eAl
}
else
{
CCLOGERROR("Error! Failed to load the font '%s'! A default system font will be used instead.", pFontName);
if (!_isValidFontName(pFontName))
{
// Attempted to load a non system font. Attempt this fallback first before the default system font:
CCLOGERROR("Error! Failed to load the custom font '%s'! A default font will be used instead.", pFontName);
font = [UIFont fontWithName: @"MarkerFelt-Wide" size:nSize];
}
// Try this font first
font = [UIFont fontWithName: @"MarkerFelt-Wide" size:nSize];
if (!font)
{
// If that fails then just try a plain system font
font = [UIFont systemFontOfSize:nSize];
}