简体   繁体   English

如何从Mac osx 10.5中的字体文件获取字体名称?

[英]How to get the Font name from a font file in Mac osx 10.5?

I want to get the font name of a font file in Mac osx 10.5. 我想在Mac osx 10.5中获取字体文件的字体名称。 I have done this for Mac osx 10.6 using CTFontManagerCreateFontDescriptorsFromURL like this. 我已经使用CTFontManagerCreateFontDescriptorsFromURL这样在Mac osx 10.6上完成了此操作。

        CFArrayRef fontDescription=CTFontManagerCreateFontDescriptorsFromURL(cfUrl);
        NSDictionary *dict=[(NSArray *)fontDescription objectAtIndex:0];

        fontName=[dict objectForKey:@"NSFontNameAttribute"];

Core Text is only available in Snow Leopard. 核心文字仅在Snow Leopard中可用。 You need to use the legacy Apple Type Services (ATS) for Leopard and below. 您需要为Leopard和更低版本使用旧版Apple Type服务(ATS)

Also see the ATS programming guide . 另请参阅ATS编程指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM