Using custom fonts in Cocos2d

前端 未结 3 1672
旧巷少年郎
旧巷少年郎 2020-12-23 22:12

How do I use custom TTF fonts in my Cocos2d iPhone apps?

3条回答
  •  醉梦人生
    2020-12-23 23:05

    In Cocos2D, you can include the font file with your resources and then in fontName: simply supply the filename. For example:

    CCLabelTTF *label = [CCLabelTTF labelWithString:@"whatever" fontName:@"FONTNAME.ttf" fontSize:18];
    

    This is often easier than the method Hanaan has posted.

    You should use the exact same file name capitalisation as the filename.

    You do not need to add fonts to your info.plist if you are only using it in Cocos2D bits.

    If, like Confused, you find that the font works on the simulator but not the device, it is probably a file name capitalisation mistake. The iPhone is case-sensitive, the simulator is not.

提交回复
热议问题