OSX ttf font loading

Hi everyone,

Whatever I tried, fonts are not loading on OSX. I use cocos2s-x 2.2.0 on OSX 10.9.
I tried any combination of the following steps. Nothing worked.

  • Under “Fonts provided by application” I tried with “fonts/myFont.ttf” (Folder reference)
  • Under “Fonts provided by application” I tried with “myFont.ttf” (Font added directly under Resources)
  • I tried CCLabelTTF::create(getStr(“freePlayDesc”), “myFont”,…
  • I tried CCLabelTTF::create(getStr(“freePlayDesc”), “fonts/myFont.ttf”,…

I have no problems loading these fonts on iOS or Android.

Any help is much appreciated!

in Xcode, select your project under “Target” > “Info” tab> “Font provied by application” > Item0> add “fonts/myFont.ttf” into Value column :smiley:
and in CCLabelTTF: create with “font name”, example: “font name” = “Times New Roman”

That’s exactly what I tried and it didn’t work.

In my case, I just registered my font in font book. (Simply, doule click on the font name)
And I can use it in cocos2dx.

Even though installing the font is not a solution, it still doesn’t load the font in the game.

Found and fixed the problem. The font name was different on OSX. While “PressStart2P” worked on iOS, on OSX I had to use “Press Start 2P”.