0
votes

I'm banging my head on this problem and can't figure out what's wrong. I have a button in one of my interface builder xibs that has an attributed string for the title that uses a custom font added to my app. Everything looks fine in the interface builder.

I'm 100% convinced I loaded the font (Montserrat) properly into my app. I can use it properly all over the code and in non attributed titles of controls and it works fine. I've also checked in the debugger and the font is listed properly:

(lldb) po [UIFont familyNames]

<__NSCFArray 0x7bb34e20>(
Thonburi,
...
Montserrat,
...
Bodoni 72 Smallcaps
)

(lldb) po [UIFont fontNamesForFamilyName:@"Montserrat"]

<__NSCFArray 0x7be75400>(
Montserrat-Regular,
Montserrat-Bold
)

I can also see in the xib file in a text editor, it looks like it should load Montserrat for the word "got":

                        <state key="normal">
                            <attributedString key="attributedTitle">
                                <fragment content="Already ">
                                    <attributes>
                                        <color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                        <font key="NSFont" size="15" name="Helvetica"/>
                                        <paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                    </attributes>
                                </fragment>
                                <fragment content="got">
                                    <attributes>
                                        <color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                        <font key="NSFont" size="15" name="Montserrat-Bold"/>
                                        <paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                    </attributes>
                                </fragment>
                                <fragment content=" an account? ">
                                    <attributes>
                                        <color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                        <font key="NSFont" size="15" name="Helvetica"/>
                                        <paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                    </attributes>
                                </fragment>
                                <fragment content="SIGN IN!">
                                    <attributes>
                                        <color key="NSColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
                                        <font key="NSFont" size="15" name="Helvetica-Bold"/>
                                        <font key="NSOriginalFont" size="15" name="Helvetica-Bold"/>
                                        <paragraphStyle key="NSParagraphStyle" alignment="center" lineBreakMode="wordWrapping" baseWritingDirection="natural"/>
                                    </attributes>
                                </fragment>
                            </attributedString>
                        </state>

But I can see that iOS replaced my usage of "Montserrat-Bold" with "HelveticaNeueInterface-Regular" in the word "got". Here is another excerpt from the debugger:

(lldb) po [self signInButton].titleLabel.attributedText

Already {
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb41430> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 15.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n    28L,\n    56L,\n    84L,\n    112L,\n    140L,\n    168L,\n    196L,\n    224L,\n    252L,\n    280L,\n    308L,\n    336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}got{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb3ffe0> font-family: \".HelveticaNeueInterface-Regular\"; font-weight: normal; font-style: normal; font-size: 14.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n    28L,\n    56L,\n    84L,\n    112L,\n    140L,\n    168L,\n    196L,\n    224L,\n    252L,\n    280L,\n    308L,\n    336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
} an account? {
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb41430> font-family: \"Helvetica\"; font-weight: normal; font-style: normal; font-size: 15.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n    28L,\n    56L,\n    84L,\n    112L,\n    140L,\n    168L,\n    196L,\n    224L,\n    252L,\n    280L,\n    308L,\n    336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";
}SIGN IN!{
NSColor = "UIDeviceRGBColorSpace 0 0 0 1";
NSFont = "<UICTFont: 0x7bb3f6a0> font-family: \"Helvetica\"; font-weight: bold; font-style: normal; font-size: 15.00pt";
NSParagraphStyle = "Alignment 1, LineSpacing 0, ParagraphSpacing 0, ParagraphSpacingBefore 0, HeadIndent 0, TailIndent 0, FirstLineHeadIndent 0, LineHeight 0/0, LineHeightMultiple 0, LineBreakMode 0, Tabs (\n    28L,\n    56L,\n    84L,\n    112L,\n    140L,\n    168L,\n    196L,\n    224L,\n    252L,\n    280L,\n    308L,\n    336L\n), DefaultTabInterval 0, Blocks (null), Lists (null), BaseWritingDirection -1, HyphenationFactor 0, TighteningFactor 0, HeaderLevel 0";

}

The same problem seems to happen on UILabels, simulator or device, iOS 7 or 8. But I can use Montserrat just fine on a non attributed title. I'm really stumped at this point. Anybody ever run into this problem?

Thanks, Omri

1

1 Answers

1
votes

I think this is a bug

Came across this radar http://openradar.appspot.com/18716979