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 been searching through the forums and although I have found some mentions [2][3][4] I can not make it work.
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);
for (NSString* family in [UIFont familyNames])
{
NSLog(@"%@", family);
for (NSString* name in [UIFont fontNamesForFamilyName: family])
{
NSLog(@" %@", name);
}
}
I found the real name of my font that it was soupofjustice.
Then I have in my project ios and in my project of the cocos ide the font added in resources. (I think in cocos ide it’s not needed but I am targeting web also so I have to preload it, still I have not tried without this so I mention it just in case).
Then in my main I have something like this:
var font = 'FontCrossy';
if (cc.sys.isNative) {
if(cc.sys.os == cc.sys.OS_ANDROID) {
font = 'res/Fonts/Soup of Justice.ttf';
}
else {
font = 'SoupofJustice';
}
}
csky.global_constants.FONT = font;
And for the cc.LabelTTF:
var label = new cc.LabelTTF("text",csky.global_constants.FONT, 50);