Search code examples
ioscocos2d-xcocos2d-js

What is the correct way to use a custom font in IOS?


I have been trying to use a custom font[1] in my game and I have managed to use it in Android and web but not in IOS.

I have my xcode project like this:

http://discuss.cocos2d-x.org/uploads/default/9079/0e7bfa08016642fa.png

But I have tried writing only Soup of Justice in xcode but that did not work.

In my cocos studio project I have in resource.js:

font: 'res/Fonts/Soup of Justice.ttf' and it's preloaded in the main.js

Then my calls of cc.LabelTTF : var label = new cc.LabelTTF("Prueba" , "Soup of Justice", 50); but i have also tried var label = new cc.LabelTTF("Prueba" , 'res/Fonts/Soup of Justice.ttf', 50);

Any help would be welcome!

[1] http://www.dafont.com/es/soup-of-justice.font


Solution

  • This is the link that should help you, and get you on roll...

    1. Add the font to your project
    2. Include the names of the fonts in your PList under key under key "Fonts provided by application"
    3. Use the Fonts with correct name.

    Use the code written below to print all the fonts and search for the one you want to use.

    for (NSString* family in [UIFont familyNames])
    {
        NSLog(@"%@", family);
    
        for (NSString* name in [UIFont fontNamesForFamilyName: family])
        {
            NSLog(@"  %@", name);
        }
    }