微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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.jb51.cc/swift/319189.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐