Font descriptor with family overrides symbolic traits

Originator:fcanas
Number:rdar://35111688 Date Originated:21-Oct-2017 03:34 PM
Status:Duplicate of 18035399 Resolved:
Product:iOS + SDK Product Version:11.0
Classification:Other Bug Reproducible:Always
 
Summary:
When creating a derived font descriptor with a font family, existing traits such as italic or bold are overwritten or ignored. This can be very confusing. If the behavior is somehow deemed to be correct, then the documentation for [UIFontDescriptor fontDescriptorWithFamily] should be updated to describe this behavior.

Steps to Reproduce:
var wrongFontDescriptor = UIFontDescriptor()
wrongFontDescriptor = wrongFontDescriptor.withSymbolicTraits([.traitItalic])!
wrongFontDescriptor = wrongFontDescriptor.withFamily("Avenir")
var wrongFont = UIFont(descriptor: wrongFontDescriptor, size: 12)

Expected Results:
I Expect the resulting font to be “Avenir-BookOblique”

Actual Results:
Instead, the resulting font is "Avenir-Book"

Version:
11.0

Notes:
The correct font can be achieved by changing the order of calls building up the font descriptor:

var rightFontDescriptor = UIFontDescriptor()
rightFontDescriptor = rightFontDescriptor.withFamily("Avenir")
rightFontDescriptor = rightFontDescriptor.withSymbolicTraits([.traitItalic])!
var rightFont = UIFont(descriptor: rightFontDescriptor, size: 12)
rightFont.fontName

Comments


Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!