【COCOS2DX-游戏开发之三二】Use Custom TTF Font(官方文档)

来源:互联网 发布:linux 开启ssh服务 编辑:程序博客网 时间:2024/05/16 01:46
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 to CCLabelTTF create an instance of CCLabelTTF. On other platforms, you should use full name.


CCLabeTTF* label = NULL;#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)    label = CCLabeTTF::create("HelloWorld", "fonts/A Damn Mess.ttf", 32);#else    label = CCLabeTTF::create("HelloWorld", "A Damn Mess", 32);#endif

如果传入错误的话,通过CCLabelTTF的getContentSize()来获得字符串的高度通常是错误的

官方文档入口

0 0