在 Cocos2d 中使用自定义字体自定义、字体、Cocos2d

2023-09-06 09:17:32 作者:想喝牛奶

如何在我的 Cocos2d iPhone 应用程序中使用自定义 TTF 字体?

How do I use custom TTF fonts in my Cocos2d iPhone apps?

推荐答案

我搜索了一段时间,并决定发布为想要实现的人的问答.

I searched for this for a while and decided to post as question and answer for people wanting to implement.

解决方法很简单.

找到您想要的字体并下载它们.本网站拥有大量免费字体.

将字体文件添加到您的项目中.

Add the font files to your project.

以下面的数组为例,将字体名称添加到您的 info.plist 文件中.

Add the font names to your info.plist file using the array below as an example.

查找字体名称;双击字体文件并使用窗口标题中显示的字体名称.在这个例子中是动作人"

Find the font's name; Double click the font file and use the font name shown in the title of the window. In this example it is "Action Man"

按照您通常的方式使用字体名称:

To use the font name the way you would normally:

CCLabel* myLabel = [CCLabel labelWithString:@"Some Text" fontName:@"Action Man" fontSize:18];

将此添加到您的 info.plist 文件中:

Add this to your info.plist file:

<key>UIAppFonts</key>
<array>
    <string>Action Man Bold.ttf</string>
    <string>AdineKirnberg-S.ttf</string>
</array>