swift 5.0打印字体和设置字体的一些问题

前言

项目中可能用不同的字体,如果又支持国际化,不同语言设置不同字体。

获取字体名字:

    func showAllFonts(){
        let familyNames = UIFont.familyNames
        
        var index:Int = 0
        
        for familyName in familyNames {
            
            let fontNames = UIFont.fontNames(forFamilyName: familyName as String)
            for fontName in fontNames
            {
                index += 1
                
                print("第 \(index) 个字体,字体font名称:\(fontName)")
            }
        }
    }

在项目中在iOS13.0以前这样用是没问题的:

"AKbalthomNagaFont" = "AKbalthom Naga";
"AKbalthomNagaFontBold" = "AKbalthom Naga Bold";

但是iOS13.0以后就会获取不到字体而出现闪退

正确用法:

"AKbalthomNagaFont" = "AKbalthomNaga";
"AKbalthomNagaFontBold" = "AKbalthomNaga-Bold";

END.

上一篇:行列式的几何直观


下一篇:字体系统之字体粗细(CSS、HTML)