swift – 字体’SF Mono’的NSFont名称是什么?

前端之家收集整理的这篇文章主要介绍了swift – 字体’SF Mono’的NSFont名称是什么?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
Xcode 8引入了一种名为’SF Mono’的新字体.

这是我个人觉得非常易读的字体,我想在NSTextView中使用它.但是,要为NSTextView设置字体,需要使用NSFont对象.问题是我似乎无法通过NSFontManager.shared().availableFonts在可用字体列表中找到SF Mono字体.

有没有人知道SF Mono的编程名称是什么用于初始化NSFont(NSFont(名称:字符串,大小:CGFloat))的字体?

“SF Mono”不是系统字体.您无法在终端,控制台和Xcode之外选择SF Mono,因为它未安装到系统中.

终端中的“SF Mono”是/Applications/Utilities/Terminal.app/Contents/Resources/Fonts/中的custom font.

同样,Console中的“SF Mono”是/Applications/Utilities/Console.app/Contents/Resources/Fonts中的另一个自定义字体.

同样,Xcode中的“SF Mono”也是/Applications/Xcode.app/Contents/SharedFrameworks/DVTKit.framework/Resources/中的自定义字体.

当然,如果不违反Apple的版权许可,您不能将SF Mono与您的程序捆绑在一起:

This SF Mono Font (the “Apple Font”) is licensed to you by Apple Inc. (“Apple”) in consideration of your agreement to the following terms. If you do not agree with these terms,do not use the Apple Font.

You may use the Apple Font solely in conjunction with Apple-branded applications,including,but not limited to,Xcode,Terminal.app and Console.app. You may not embed or use the Apple Font in or with any other software applications or programs or other products and you may not use the Apple Font to create,develop,display or otherwise distribute any content,documentation,artwork or any other work product.

You may use the Apple Font only for the purposes described in this License or as otherwise expressly permitted by Apple in writing.

如果用户手动安装了字体,则可以使用系列名称SF Mono或字体名称SFMono-Regular(与其他权重类似)找到该字体.

let f = NSFont(name: "SFMono-Regular",size: 12)
原文链接:https://www.f2er.com/swift/319189.html

猜你在找的Swift相关文章