UIFont.withSize doesn't return the same typeface sometimes

Originator:an00na
Number:rdar://31220167 Date Originated:23-Mar-2017 10:48 AM
Status:Open Resolved:
Product:iOS + SDK Product Version:10.3
Classification:Other Bug Reproducible:Always
 
Area:
UIKit

Summary:
Doc of UIFont.withSize(_ fontSize: CGFloat) -> UIFont says:
Returns a font object that is the *same* as the receiver but which has the specified size instead.

So the only thing that may change is font size, which is the very expected behavior.

However, it is not true sometimes. For example:
let font = UIFont.systemFont(ofSize: 32, weight: UIFontWeightHeavy) // It's .SFUIDisplay-Heavy
font.withSize(font.pointSize) // It's now .SFUIDisplay-Semibold

Steps to Reproduce:
Run the sample playground and read the logs.

Expected Results:
Nothing except font size should change. Or, the document should be corrected to point out these special cases.

Code: https://cloudup.com/c0GB33_YU1T

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!