Skip to content

Latest commit

 

History

History
34 lines (20 loc) · 1.06 KB

Fonts.md

File metadata and controls

34 lines (20 loc) · 1.06 KB

macOS App 如何配置自定义字体。具体参考 https://stackoverflow.com/a/57412354

  1. Create a folder named Fonts.

enter image description here

  1. Add fonts to the Fonts folder. Uncheck Add to targets and check Copy items if needed.

enter image description here

  1. Add Application fonts resource path to Info.plist and enter Fonts.

enter image description here

  1. Go to Build Phases and create a New Copy Files Phase.

enter image description here

  1. Set the Destinations to Resources and Subpath to Fonts. Then add your font files to the list.

enter image description here

  1. 获取字体名称

    for family: String in NSFontManager.shared.availableFontFamilies {
        print("\(family)")
        for name in NSFontManager.shared.availableMembers(ofFontFamily: family)! {
            print("== \(name[0])")
        }
    }