简体   繁体   English

从外部路径加载TTF字体

[英]Load TTF font from external path

I was wondering that how to load a TTF font from a absolute file path, not relative, which is usually done with [UIFont fontWithName:@"xyz"]; 我想知道如何从绝对文件路径加载TTF字体,而不是相对的,这通常用[UIFont fontWithName:@“xyz”]来完成;

In cocos2d we can do it by using CCLabelBMFont that takes file as parameter, but when use CCLabelTTF it takes the name of font, not the file name. 在cocos2d中,我们可以使用CCLabelBMFont将文件作为参数来实现,但是当使用CCLabelTTF时,它采用字体的名称,而不是文件名。

Is there any workaround to load an external font not embedded with the application but downloaded from some resource as per need ? 是否有任何解决方法来加载未嵌入应用程序但根据需要从某些资源下载的外部字体?

Yes, you can do this. 是的,你可以这样做。

Just copy the font to your project and add this reference in your info.plist. 只需将字体复制到项目中,然后在info.plist中添加此引用即可。 Then you can reference the font name just like any other system font. 然后,您可以像任何其他系统字体一样引用字体名称。

在此输入图像描述

if I did well understand your question, maybe this post Can I embed a custom font in an iPhone application? 如果我很好理解你的问题,也许这篇文章我可以在iPhone应用程序中嵌入自定义字体吗? will give you an answer. 会给你一个答案。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM