wrong path when using custom ttf font on ios

wrong path when using custom ttf font on ios
0.0 0


hi, i followd the ttf font’s test on ios and my version is 0.9.1
the test project works fine, but it doesn’t work for my project

NSString * fntName = [NSString stringWithUTF8String:pFontName];
CGSize dim;

// create the font
id font;
font = [UIFont fontWithName:fntName size:nSize];


the font is always null and my code logic is as same as the test project and my res path is correct.
besides, i have a question about the test project, why doesn’t the ttf font res ends with a .ttf suffix and begins with a /font prefix?
thank you~


Here’re some key points:

  1. on ios, the font name param mustn’t follow with .ttf subfix. Use just like

CCLabelTTF* pLabel = CCLabelTTF::labelWithString(“Hello World”, “Paint Boy”, 34); // Paint Boy is the ttf file name, Paint Boy.ttf

  1. locate your custom ttf file at the root of resources

In your case, your custom ttf obviously cannot be created by UIFont, go through it, your font will be created by line 353 in cocos2dx/platform/ios/CCImage_ios.mm

font = [[FontManager sharedManager] zFontWithName: fntName pointSize: nSize];