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

How to Use Custom TTF Font on iOS

  • Add full name of customer ttf into your application's info.plist

How to Use Custom TTF Font on iOS

  • 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).
上一篇:WPF开发经验


下一篇:idea maven打包 install 报错The packaging for this project did not assign a file to the build artifact