Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/macos/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何在MacOS中找到东亚字符的默认字体_Macos_Textedit_Nsfont - Fatal编程技术网

如何在MacOS中找到东亚字符的默认字体

如何在MacOS中找到东亚字符的默认字体,macos,textedit,nsfont,Macos,Textedit,Nsfont,使用文本编辑应用程序时,当选定字体不包含特殊字形(例如“这由“级联列表”处理)时,会选择字体(例如“Menlo”)来显示字形。如果需要默认列表,可以通过ctfontcypydefaultcascadelistforlanguages按字体提供: import CoreText let font = CTFontCreateWithName("Helvetica" as CFString, 12, nil) let descriptors = CTFontCopyDefaultCascadeLis

使用文本编辑应用程序时,当选定字体不包含特殊字形(例如“这由“级联列表”处理)时,会选择字体(例如“Menlo”)来显示字形。如果需要默认列表,可以通过
ctfontcypydefaultcascadelistforlanguages
按字体提供:

import CoreText
let font = CTFontCreateWithName("Helvetica" as CFString, 12, nil)
let descriptors = CTFontCopyDefaultCascadeListForLanguages(font, nil)! as! [CTFontDescriptor]
如果您想查看列表,可以这样做(核心文本与Swift之间没有很好的桥接):

==>

PingFangSC Regular是列表中的第一个东亚字体,因此它将被选为取代Helvetica的字体。它也是Lucida Grande和Helvetica Neue的cascade列表中的第一个东亚字体。它有点直截了当,甚至很无聊。但是如果你使用的是更不寻常的字体,比如美国打字机?嗯,这将被松蒂取代,松蒂稍微轻一点。Marker Felt取代了Kaiti,它在斯托克宽度上有更多的变化(虽然在我看来,用Kaiti黑色取代比普通的要好得多)。我不知道有任何内置的亚洲字体是“有趣”的作为可用的拉丁字体,但如果您有,您可以自定义级联列表以选择它(在Mac上使用NSFontDescriptor,或在iOS上使用UIFontDescriptor)


如果您想了解有关级联列表的更多详细信息,请参阅WWDC 2018视频,

完美答案!
for descriptor in descriptors {
    let attributes = CTFontDescriptorCopyAttributes(descriptor) as! [String: Any]
    print(attributes[kCTFontNameAttribute as String]!)
}
LucidaGrande
.AppleSymbolsFB
GeezaPro
NotoNastaliqUrdu
Thonburi
Kailasa
PingFangSC-Regular
PingFangTC-Regular
AppleSDGothicNeo-Regular
PingFangTC-Regular
PingFangSC-Regular
PingFangHK-Regular
PingFangSC-Regular
HiraginoSans-W3
HiraginoSansGB-W3
KohinoorBangla-Regular
KohinoorDevanagari-Regular
KohinoorGujarati-Regular
MuktaMahee-Regular
NotoSansKannada-Regular
KhmerSangamMN
LaoSangamMN
MalayalamSangamMN
NotoSansMyanmar-Regular
NotoSansZawgyi-Regular
NotoSansOriya
SinhalaSangamMN
TamilSangamMN
KohinoorTelugu-Regular
NotoSansArmenian-Regular
EuphemiaUCAS
Menlo-Regular
STIXGeneral-Regular
Galvji
Kefa-Regular
.NotoSansUniversal
AppleColorEmoji