Up until iOS 13 I was able to create a CTFont object (it's a weird low level use case that doesn't permit UIFont) with:
CTFontCreateWithName((UIFont.systemFont(ofSize: 17.0).fontName as CFString), 16, nil)
The fontName in there is just .SFUI-Regular
. Starting on iOS 13 it got angry:
CoreText performance note: Client called CTFontCreateWithName() using name ".SFUI-Regular" and got font with PostScript name "TimesNewRomanPSMT". For best performance, only use PostScript names when calling this API.
Okay, PostScript name. Not 100% sure what that is, but okay. I tried looking it up in the macOS Font Book. For San Francisco it says PostScript name: "SFProText-Regular". I plug that in:
CTFontCreateWithName(("SFProText-Regular" as CFString), 16, nil)
It returns… Helvetica:
<UICTFont: 0x108f220a0> font-family: "Helvetica"; font-weight: normal; font-style: normal; font-size: 16.00pt
Okay, maybe the macOS Font Book is wrong. Let's get it manually:
CGFont((UIFont.systemFont(ofSize: 16.0).fontName as NSString))!.postScriptName
Which outputs ".SFUI-Regular". Yeah the one from the beginning that makes it angry and turns into Times New Roman. We've came full circle.
What am I doing wrong?
Swift or Objective-C, doesn't matter.
EDIT: Heck how do you even create a UIFont
from a string in iOS 13? I can't even get that working. https://i.imgur.com/zqW1stf.png
Subreddit
Post Details
- Posted
- 5 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/iOSProgramm...