Hi everyone. I'm using CCFontDefinition in some parts of my code. In my own computer, where the fonts are already installed in my catalog, this issue does not happen, but it looks, in other Mac's where the fonts still are not copied, the CCLabelTTF can not use it.
As I tested, this works in Cocos2D for iOS devices, but not for Mac.
This issue does not happen if you use CCLabelTTF with the method labelWithString:fontSize:fontName using there the name of the font including the ttf extension file.
So here is, something that works:
// create and initialize a Label
CCLabelTTF *label2 = [CCLabelTTF labelWithString:@"This is a test" fontName:@"AlteHaasGrotesk_Bold.ttf" fontSize:20];
// position the label on the center of the screen
label2.position = ccp( size.width /2 , size.height/2 );
// add the label as a child to this Layer
And next code, result is blank:
CCFontDefinition *fontType2 = [[CCFontDefinition alloc] init];
fontType2.alignment = kCCTextAlignmentLeft;
fontType2.vertAlignment = kCCVerticalTextAlignmentBottom;
fontType2.shadowOffset = CGSizeMake(1,-1);
CCLabelTTF *label2 = [CCLabelTTF labelWithString:[NSString stringWithFormat:@"This is a test"] fontDefinition:fontType2];
[label2 enableStrokeWithColor:ccc3(0,0,0) size:1 updateImage:true];
I've got added this fonts as resources in the project. The font is present at Copy Bundled Resources section of the project. And I also addded UIAppFonts to the info.plist.
So I guess all the steps should I do are done, but in a Mac computer without fonts installed, fontDefinition does not work. I will try to remove my fonts from my computer right now, and debug the own Cocos2D code.
Any suggestion is appreciated.
Thank you very much.