How to use custom fonts within iOS and Cocos2D

Recently I was working on an iOS project using the Cocos2d framework.  Cocos2d has a rather simple object called CCLabelTTF.  The CCLabelTTF object allows you to easily create text that you can write to your screen using a TTF font.

While working on this project I needed to implement a label with a custom font.  However, I quickly found that there are quite a few "gotchas" that may prevent your custom font from working in Cocos2d.  The really annoying part is that when these gotchas occur, the Cocos2d framework will only output a very generic message stating that your font couldn't be loaded.

This can be a bit problematic.  After banging my head against my keyboard for four hours, and after quite a few web searches, I found out that adding and using fonts to an iOS project can be rather tedious.  After reading through numerous support sites and web forum threads, it seems that my scenario hit almost every gotcha scenario that I could find.

After a few hours of adding/removing fonts and configuration keys, I eventually found the perfect setup.  Below is a link to a Q&A post I made on StackOverflow on this topic.  If you need to use custom fonts in your Cocos2d project, following these instructions should get your font in your project without any trouble.

No comments:

Post a Comment