How to Use Custom TTF Font on iOS

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_第1张图片
  • Add full name of customer ttf into your application's info.plist
    How to Use Custom TTF Font on iOS_第2张图片
  • 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).

你可能感兴趣的:(How to Use Custom TTF Font on iOS)