How do I get the font name from an otf or ttf file?

前端 未结 15 1659
-上瘾入骨i
-上瘾入骨i 2020-11-28 03:44

I have used a custom font in my previous app.

The file name was \"ProximaNova-Regular.otf\" and to load the font I just used...

[UIFont fontWithName:         


        
15条回答
  •  情深已故
    2020-11-28 04:06

    Swift 4.0+ solution

        for fontFamilyName in UIFont.familyNames {
            print("family: \(fontFamilyName)\n")
    
            for fontName in UIFont.fontNames(forFamilyName: fontFamilyName) {
                print("font: \(fontName)")
            }
        }
    

    Will output:

    family: Apple SD Gothic Neo

    font: AppleSDGothicNeo-Thin

    font: AppleSDGothicNeo-Light

提交回复
热议问题