How to Use Custom TTF Font on iOS¶
Cocos2d-x uses FontLabel to draw customer ttf font before v2.0.3(including v2.0.3). Now it uses UIFont directly to draw system fonts and customer ttf fonts.Now, inorder to use customer ttf font, you should do some more work. I will use TestCpp as example to describe the steps.
- Add your custom font files into your project using XCode as a resource
- Add full name of customer ttf into your application's info.plist
- Use ttf file in codes(only use font name without directory and .ttf)
Please refer to samples/TestCpp/Classes/FontTest/FontTest.cpp for detail information.
On iOS, use just pass font name(without relative path to Resources and file extension) to CCLabelTTF create an instance of CCLabelTTF. On other platforms, you should use full name(including relative path to Resources and file extension).