Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What happened to "HelveticaNeue-Italic" on iOS 7.0.3

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"]

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

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

Anyone else see this?

---- New Information ----

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

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.

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];

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???

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];

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!

like image 457
Scott Sarnikowski Avatar asked Oct 22 '13 20:10

Scott Sarnikowski


3 Answers

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);
}

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.

enter image description here

like image 61
Mike Vosseller Avatar answered Oct 21 '22 06:10

Mike Vosseller


This is a bug in iOS 7.0.3.

If you are explicitly using HelveticaNeue-Italic, then you can create it using this workaround:

UIFont* font = (__bridge_transfer UIFont*)CTFontCreateWithName(CFSTR("HelveticaNeue-Italic"), fontSize, NULL);

Note, however, that this workaround will only work on iOS 7; it is not deployable to iOS 6 (because CTFontRef and UIFont were not toll-free bridged on iOS 6). However, on iOS 6 you can just use your regular font lookup code.

like image 31
Dave DeLong Avatar answered Oct 21 '22 08:10

Dave DeLong


It is my belief that it is a bug. I have filed it as such with Apple. Sadly for me, my app is now crashing. The font is used in a 3rd party library I am using. Many folks on Twitter are reporting problems.

like image 4
David Lari Avatar answered Oct 21 '22 08:10

David Lari