UIFont fontWithName:限制为每个家庭加载2个变体 [英] UIFont fontWithName: limited to loading 2 variations per family

查看:84
本文介绍了UIFont fontWithName:限制为每个家庭加载2个变体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

此问题与与自定义字体显示错误非常相似*自定义字体,除了我需要同时使用这个家庭的三种字体。我使用Myriad Pro,就像这个问题,但我需要使用Bold,Semibold和Regular。

This question is extremely similar to UILabel with custom font displays *wrong* custom font, except I need to use three fonts from this family simultaneously. I am using Myriad Pro, just like that question, but I need to use Bold, Semibold, and Regular.

目前,当我尝试通过宏定义使用Bold as:

Currently, when I try to use Bold via a macro defined as:

#define MYRIAD_BOLD(x) [UIFont fontWithName:@"MyriadPro-Bold" size:(x)]

..它给了我Semibold。如果我从plist条目中删除应用程序提供的字体的semibold(就像上面链接的类似问题的答案),正确返回Bold,但(显然)Semibold不再可用。

..it gives me Semibold. If I remove Semibold from the plist entries for "Fonts provided by application" (as is the "answer" for the similar question linked above), Bold is correctly returned, but (obviously) Semibold is no longer usable.

有关我为什么(似乎)被限制为两个自定义字体的任何想法? (来自同一个家庭,至少?)

Any ideas as to why I would (seemingly) be limited to two custom fonts at once? (from the same family, at least?)

BTW,这里是NSLog输出 [UIFont fontNamesForFamilyName:@Myriad Pro]

BTW, here is the NSLog output for [UIFont fontNamesForFamilyName:@"Myriad Pro"]:

Myriad Pro字体名称:(
MyriadPro-Semibold,
MyriadPro -Regular,
MyriadPro-Bold

谢谢!

推荐答案

在一个奇怪但有点预期的解决方法,我发现我可以使用第三个变体打开编辑器中的字体(我只是抓住了第一个我发现)和更改家族名称,将其重新打包为一个otf,并将新文件添加到应用程序plist。我留下了 fontName 相同。

In a bizarre but somewhat anticipated workaround, I found that I could actually use a third variation by opening the font up in an editor (I just grabbed the first one I found) and changing the family name, repackaging it as an otf, and adding the new file to the application plist. I left the fontName the same.

奇怪的部分是它仍然加载相同的字体名称,并显示Myriad Pro的 + fontNamesForFamilyName:响应之下。

The bizarre part is that it still loads with the same font name and shows up under the +fontNamesForFamilyName: response for Myriad Pro.

这篇关于UIFont fontWithName:限制为每个家庭加载2个变体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆