aryaxt
aryaxt

Reputation: 77596

Objective C - Get the name of a CTFont?

I have a CTFontRef, how can i get the font name as a string?

Upvotes: 3

Views: 1116

Answers (2)

NSGod
NSGod

Reputation: 22948

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).

Upvotes: 0

Rahul Vyas
Rahul Vyas

Reputation: 28720

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

Upvotes: 3

Related Questions