I have a label in a SpriteKit app
var speedLabel: SKLabelNode = SKLabelNode()
And when I try to assign it a Font like so:
speedLabel.fontName = UIFont.preferredFont(forTextStyle: .body).fontName
In iOS 11.0-12.x, that returns ".SFUIText" and gives the label the proper san-serif system font.
In iOS 13.0, it returns ".SFUI-Regular" and shows up as some serifed, maybe Times New Roman font.
I remember having issues with SpriteKit Label Nodes and fonts in the past. If you assigned it an invalid font, it would default to this serifed font.
Anyone have any ideas how to fix this?
I faced the same problem and found that it seems SKLabelNode’s attributedText correctly recognizes “.SFUI-Regular”. The code below displays the san-serif font.
label.attributedText = NSAttributedString(string: "blah-blah-blah", attributes: [.font: UIFont.preferredFont(forTextStyle: .body)])
Thank you so much for replying! I wonder why it changed in iOS 13.