开发者

Objective C - Get the name of a CTFont?

开发者 https://www.devze.com 2023-03-19 07:50 出处:网络
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

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

精彩评论

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