I have formatted text delivered to the app as HTML that I am converting to a NSAttributedString and then assigning to a UILabel like this:
NSDictionary* options = @{ NSCharacterEncodingDocumentAttribute: @(NSUTF8StringEncoding), NSDefaultAttributesDocumentAttribute: @{ NSFontAttributeName: label.font, NSForegroundColorAttributeName: label.textColor, NSStrikethroughStyleAttributeName: @1, NSUnderlineStyleAttributeName: @(NSUnderlineStyleSingle) }, NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType }; attributedString = [[NSAttributedString alloc] initWithData:data options:options documentAttributes:NULL error:&error]; label.attributedText = attributedString; The UILabel has its font set to Avenir Next Medium, which the code above uses as the base font for the attributed string. The HTML is of the form: <p>Blah blah blah <em>blah blah blah</em> blah blah blah</p> What I'm seeing visually is that the normal paragraph text is fine but that the text inside the <em> tag is nearly unreadable. I added code to dump out the attribute runs and found that the starting paragraph text is what's expected: NSFont = "<UICTFont: 0x14c51680> font-family: \"AvenirNext-Medium\"; font-weight: normal; font-style: normal; font-size: 16.00pt"; but that the text inside the <em> tag uses Avenir Next UltraLight Italic: NSFont = "<UICTFont: 0x14c51ee0> font-family: \"AvenirNext-UltraLightItalic\"; font-weight: normal; font-style: italic; font-size: 16.00pt"; This seems odd to me since there's a perfectly fine Avenir Next Medium Italic available. Is this an expected font choice for italic text given the setup above and, more importantly, is there a way for me to end up with an attributed string that's using the italic version of the base font short of manually walking each of the attribute runs and "correcting" the font? Thanks, Steve _______________________________________________ Cocoa-dev mailing list (Cocoa-dev@lists.apple.com) Please do not post admin requests or moderator comments to the list. Contact the moderators at cocoa-dev-admins(at)lists.apple.com Help/Unsubscribe/Update your Subscription: https://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com This email sent to arch...@mail-archive.com