开发者

Objective C - Get the name of a CTFont?

I开发者_如何学Go have a CTFontRef, how can i get the font name as a string?


read this http://developer.apple.com/library/mac/#documentation/Carbon/Reference/CTFontRef/Reference/reference.html

There are methods defined for example.

Getting Font Names
CTFontCopyPostScriptName
CTFontCopyFamilyName
CTFontCopyFullName
CTFontCopyDisplayName
CTFontCopyName
CTFontCopyLocalizedName


You'll need to be a bit more specific about what you mean by "font name". The PostScript name? Display name? Family name?

In any case, this is how you'd go about it:

NSString *postScriptName = 
             [(NSString *)CTFontCopyPostScriptName(fontRef) autorelease];
NSLog(@"postScriptName == %@", postScriptName);

CFStringRef and NSString are toll-free bridged (see Toll-Free Bridged Types).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜