发生了什么“HelveticaNeue-Italic”在iOS 7.0.3上 [英] What happened to "HelveticaNeue-Italic" on iOS 7.0.3

查看:132
本文介绍了发生了什么“HelveticaNeue-Italic”在iOS 7.0.3上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

刚刚将我的iPod touch升级到iOS 7.0.3并且HelveticaNeue-Italic似乎已经消失了。当我在电话上查询:

Just upgraded my iPod touch to iOS 7.0.3 and "HelveticaNeue-Italic" seems to have disappeared. When I query on the phone with:

[UIFont fontNamesForFamilyName:@"Helvetica Neue"]

我得到以下fontNames(13):

I get the following fontNames (13):

HelveticaNeue-BoldItalic,
HelveticaNeue-Light,
HelveticaNeue-UltraLightItalic,
HelveticaNeue-CondensedBold,
HelveticaNeue-MediumItalic,
HelveticaNeue-Thin,
HelveticaNeue-Medium,
HelveticaNeue-ThinItalic,
HelveticaNeue-LightItalic,
HelveticaNeue-UltraLight,
HelveticaNeue-Bold,
HelveticaNeue,
HelveticaNeue-CondensedBlack

当我在模拟器中运行相同的查询时,我得到(14):

When I do the same query running in the simulator I get (14):

HelveticaNeue-BoldItalic,
HelveticaNeue-Light,
**HelveticaNeue-Italic,**
HelveticaNeue-UltraLightItalic,
HelveticaNeue-CondensedBold,
HelveticaNeue-MediumItalic,
HelveticaNeue-Thin,
HelveticaNeue-Medium,
HelveticaNeue-Thin_Italic,
HelveticaNeue-LightItalic,
HelveticaNeue-UltraLight,
HelveticaNeue-Bold,
HelveticaNeue,
HelveticaNeue-CondensedBlack

其他人看到这个吗?

----新信息----

我回到WWDC 2013视频使用带有文本工具包的字体,有趣的部分从12:22开始。演示者以OS X中的MetaFonts为例进行讨论。他说的是调用的字体如下:

I went back to the WWDC 2013 video "Using Font with Text Kit" and the interesting part starts at 12:22. The presenter talks about "MetaFonts" in OS X as an example. What he says is that the font under calls like:

+ (NSFont *)messageFontOfSize:(CGFloat)fontSize

不保证在版本甚至不同用途中返回相同的基础字体。他的榜样是Lucinda Grande。他似乎并没有说使用HelveticaNeue-Italic可能会从版本转移到版本。

are not guaranteed to return the same underlying font across versions or even different uses. His example was Lucinda Grande. He did not seem to be saying that using "HelveticaNeue-Italic" could go away from version to version.

所以我在iOS 7中构建了一个实验。我创建了我的字体使用以下代码:

So I constructed an experiment in iOS 7. I created my font with the following code:

UIFontDescriptor *fontDescriptor = [UIFontDescriptor fontDescriptorWithName:@"Helvetica Neue" size:16.0];
UIFontDescriptor *symbolicFontDescriptor = [fontDescriptor fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic];

UIFont *fontWithDescriptor = [UIFont fontWithDescriptor:symbolicFontDescriptor size:16.0];

我确实为fontWithDescriptor获得了有效的UIFont,当我查询fontName的字体时: / p>

I did get a valid UIFont back for fontWithDescriptor and when I queried the font for the fontName with:

[fontWithDescriptor fontName]

我回来了......

I got back...

HelveticaNeue-Italic

Go figure ???

Go figure???

所以7.0.3的可能答案似乎是上面的代码。

So a possible answer to 7.0.3 seems to be the code above.

----进一步调整----

---- Further Tweak ----

虽然解决方案适用于上述,但我不要认为它是正式的。我已切换到以下解决方案

Although the solution worked above, I don't think it is formally correct. I have switched to the following solution

    UIFontDescriptor *fontDescriptor = [[UIFontDescriptor alloc] init];

    UIFontDescriptor *fontDescriptorForHelveticaNeue = [fontDescriptor fontDescriptorWithFamily:@"Helvetica Neue"];
    UIFontDescriptor *symbolicFontDescriptor = [fontDescriptorForHelveticaNeue fontDescriptorWithSymbolicTraits:UIFontDescriptorTraitItalic];

    textFont = [UIFont fontWithDescriptor:symbolicFontDescriptor size:textFontPointSize];

这似乎做了所有正确的事情。我尝试使用另一种字体系列的前一种方法,它似乎与fontName和fontFamily混淆。希望这会有所帮助!

This appears to do all the right things. I tried the previous approach with another font family and it seemed to get confused with a the fontName and the fontFamily. Hope this helps!

推荐答案

这是一个Apple bug。它是在iOS 7.0.3中引入的,从iOS 7.0.4开始尚未修复。它似乎在iOS 7.1的开发人员预览中得到修复。以下是解决问题的代码(由Apple在开发论坛中提供):

This is an Apple bug. It was introduced in iOS 7.0.3 and has not yet been fixed as of iOS 7.0.4. It appears to be fixed in the developer preview of iOS 7.1. Here is code (provided by Apple in the dev forums) to workaround the issue:

#import <CoreText/CoreText.h>

CGFloat size = 14;
UIFont *font = [UIFont fontWithName:@"HelveticaNeue-Italic" size:size];
if (font == nil && ([UIFontDescriptor class] != nil)) {
    font = (__bridge_transfer UIFont*)CTFontCreateWithName(CFSTR("HelveticaNeue-Italic"), size, NULL);
}

值得注意的是,在当前版本的Xcode(5.0.1)中(5A2053))此字体未在Interface Builder的字体下拉列表中列为选项。因此,如果您之前使用此字体配置了标签,您会注意到ui被混淆,并且标签最终在运行时被分配了一些其他字体和大小(请参阅下面的ui screencap)。对于在storyboards / xib中配置的标签,您需要在代码中重置字体。

It is also worth noting that in the current version of Xcode (5.0.1 (5A2053)) this font is not listed as an option in the Font drop down list in Interface Builder. So if you previously configured a label with this font you will notice that the ui is confused and the label ends up being assigned some other font and size at runtime (see ui screencap below). For labels configured in storyboards/xibs you will need to reset the font in code.

供参考这里是对论坛中问题的讨论。

For reference here is the discussion of the issue in the dev forums.

这篇关于发生了什么“HelveticaNeue-Italic”在iOS 7.0.3上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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