How do differentiate between SF Pro Display and Text on iOS 13?

I am familiar with the new Apple guidelines that the system fonts should no longer be accessed by the names and only the system API should be used. Beyond this new requirement, it seems like the two SF fonts have been merged into one font. The app I work on has user content where the users in the past have freely used SF Display or SF Text at any size. This appears to no longer be possible. Some code:


UIFont *fontDisplay = [UIFont systemFontOfSize:10];
UIFont *fontText = [UIFont systemFontOfSize:20];
NSLog(@"display font %@ and %@", fontDisplay.fontName, fontDisplay.familyName);
NSLog(@"text font %@ and %@", fontText.fontName, fontText.familyName);


On ios12, we get two distinct fonts:


display font .SFUIText and .SF UI Text
text font .SFUIDisplay and .SF UI Display


On ios13, we get one font:


display font .SFUI-Regular and .AppleSystemUIFont
text font .SFUI-Regular and .AppleSystemUIFont


On ios12, we used to be able to use "UIFont fontWithSize" with either fontDisplay and fontText to get a small point version of Display or a large point version of Text to support what the authors have created. On ios 13, this is no longer possible.


Are they any workarounds for this new behavior?


A secondary question is related to the new SF Symbol glyphs. We have attempted to use them with a NSAttributedString and CTTypesetterCreateWithAttributedString and been unsuccessful.

Replies

The document says use it will return SF Pro for

UIFontDescriptorSystemDesignDefault . But did not work for me. It always returned SFUI-Regular or SFUI-Light based on the weight.


https://developer.apple.com/documentation/uikit/uifontdescriptorsystemdesign?language=objc


So have to download the fonts for SF Pro. and use the .otf files https://developer.apple.com/fonts/


    func sfProFont(style: UIFont.TextStyle, weight: UIFont.Weight = .regular, design: UIFontDescriptor.SystemDesign = .default , size: CGFloat) -> UIFont? {
       
        guard let descriptor = UIFontDescriptor.preferredFontDescriptor(withTextStyle: style)
            .addingAttributes([UIFontDescriptor.AttributeName.traits: [UIFontDescriptor.TraitKey.weight: weight]])
            .withDesign(design) else {
                return nil
        }
       
        return UIFont(descriptor: descriptor, size: size
SF was re-engineered for iOS 13 to provide the same appearance without requiring distinct Text and Display fonts. You shouldn’t be bundling your own copy of the font.