Using custom fonts in Cocos2d

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

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

3条回答
  •  清歌不尽
    2020-12-23 22:59

    I searched for this for a while and decided to post as question and answer for people wanting to implement.

    The solution is quite easy.

    1. Find the fonts you want and download them. This website has a huge collection of free fonts.

    2. Add the font files to your project. alt text

    3. Add the font names to your info.plist file using the array below as an example.

    4. Find the font's name; Double click the font file and use the font name shown in the title of the window. In this example it is "Action Man"

    alt text

    To use the font name the way you would normally:

    CCLabel* myLabel = [CCLabel labelWithString:@"Some Text" fontName:@"Action Man" fontSize:18];
    

    Add this to your info.plist file:

    UIAppFonts
    
        Action Man Bold.ttf
        AdineKirnberg-S.ttf
    
    

提交回复
热议问题