CCLabelTTF Font Problem

I’m trying to change the font used by CCLabelTTF with lots of different custom fonts but it won’t change

My setup :

Thanks for your help.


Untitled-1.jpg (26.5 KB)


Untitled-2.jpg (30.4 KB)


Untitled-3.jpg (23.2 KB)


Untitled-4.jpg (37.1 KB)

HI, Are you sure the font file (Calculator.ttf) is actually bundled with your app? May be you should add your font file to Xcode as a references folder (blue folder in Xcode instead of yellow one).

Calculator.ttf located in /Resources/Fonts/Calculator.ttf

What do you mean?

Have you try to add the font to Xcode as a “references folder”. If you don’t do so then the font folder is flatten and Calculator.ttf is added without the “Fonts” folder (but in the root of your app bundle). You can open your app bundle to double-check that Calculator.ttf is actually added as Fonts/Calculator.ttf.

You can also try to clean up the derived data and remove the app from your device to force Xcode to create a fresh app bundle.

If you are on iOS you need to create the label without the “.ttf” on the end of the font name string, Android with “.ttf”. It is a strange quirk!

iOS:

m_myLabel = CCLabelTTF::create( "This is a test", "myfontname", 24 );
addChild( m_myLabel, 99 );

Android:

m_myLabel = CCLabelTTF::create( "This is a test", "myfontname.ttf", 24 );
addChild( m_myLabel, 99 );

Checking project name in target list and problem solved!. Thanks laurent.

Hi Suicidal,
my problem is same like you, but you solved,
may i know how you do that?
“Checking project name in target list” ?

Select the font in project explorer then change target membership of the font in file inspector.