如何在我的 iPhone 程序中添加 Copperplate Gothic Bold 字体?

发布于 2024-09-02 06:05:13 字数 555 浏览 7 评论 0原文

我需要在 cocos2d 层中显示一些文本。我向其中添加了 UITextView。我在文本视图中添加了文本。但是,为了通过( UIFont 类)设置字体,我无法做到这一点。我看到了 iPhone 支持的字体列表,在该列表中没有 Copperplate Gothic Bold。我是从网上下载的。它适用于 CCLabel 和 CCFontMenuItem。我怎样才能使它适用于 UILabel ?

* -[UILabel setFont:]、/SourceCache/UIKit/UIKit-963.10/UILabel.m:445 中断言失败 2010-05-19 16:07:43.282 testOfGameScreen[1155:207]
*
由于未捕获的异常“NSInternalInconsistencyException”而终止应用程序,原因:“无效参数不满足:字体!= nil” 2010-05-19 16:07:43.285 testOfGameScreen[1155:207] Stack:( 将

UIFont 与 Copperplate Gothic Bold 结合使用时出现上述错误
谢谢。

I need to display some text in cocos2d layer. I added UITextView to it. I added the text in the text View. But, for setting the font by ( UIFont class), I could not do it. I saw the list of supported fonts for iPhone, In that list Copperplate Gothic Bold is not there. I downloaded it from net. It is working good for CCLabel and CCFontMenuItem. How can I make it work for UILabel ?

* Assertion failure in -[UILabel setFont:], /SourceCache/UIKit/UIKit-963.10/UILabel.m:445
2010-05-19 16:07:43.282 testOfGameScreen[1155:207]
*
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Invalid parameter not satisfying: font != nil'
2010-05-19 16:07:43.285 testOfGameScreen[1155:207] Stack: (

I am getting the above error when using UIFont with Copperplate Gothic Bold
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

傲性难收 2024-09-09 06:05:13

显示 iphone 中尚不存在的字体并不是那么容易。开发人员有自己的解决方法,我可以与您分享一两个。

Zyngas 字体标签(http://github.com/zynga/FontLabel)是一种流行的方法。我没有任何个人经验,但谷歌搜索会告诉你这是一个可行的解决方案。

如果您尝试显示一两行文本,您可以尝试基于此的解决方案链接。显示的示例仅能够显示单行文本,但您可以轻松修改它以显示多行文本。请记住,此方法是将文本绘制为图像,您可能无法复制/粘贴它。

Displaying a font which does not already present in iphone is not so easy. Developers have their own workarounds and I can share with you one or two.

Zyngas Font label (http://github.com/zynga/FontLabel) is a popular method. I dont have any personal experience with it, but a google search will tell you that it is a workable solution.

If you are trying to display one or two lines of text, you can try a solution based on this link. The example shown is only capable of displaying single line text, but you can easily modify it to display multiline text. Please remember that this method is drawing the text as images and you may not be able to copy/paste it.

梦毁影碎の 2024-09-09 06:05:13

Cocos2D 示例项目中有许多示例可以实现此目的。
您可以使用 CCLabelTTF 来实现此目的。

        [CCLabelTTF labelWithString:@"my string" fontName:@"Helvetica-Bold" fontSize:20];

There are a number of examples in the Cocos2D example project that do this.
You can use CCLabelTTF for this.

        [CCLabelTTF labelWithString:@"my string" fontName:@"Helvetica-Bold" fontSize:20];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文