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)

相关文章

软件简介:蓝湖辅助工具,减少移动端开发中控件属性的复制和粘...
现实生活中,我们听到的声音都是时间连续的,我们称为这种信...
前言最近在B站上看到一个漂亮的仙女姐姐跳舞视频,循环看了亿...
【Android App】实战项目之仿抖音的短视频分享App(附源码和...
前言这一篇博客应该是我花时间最多的一次了,从2022年1月底至...
因为我既对接过session、cookie,也对接过JWT,今年因为工作...