I want to get the font traits - specifically Bold/Italic - from a ttf or otf file.
I currently have the following code
No matter what file I send (fontFileWithFullPath) the fontTraits is always null.
I don't want to install the font, as I'm just examining a folder of fonts (could be hundreds) and displaying the info, but just can't seem to get the bold/italic font traits.
Any ideas?
I currently have the following code
Code:
NSURL *fontURL = [NSURL fileURLWithPath: fontFileWithFullPath];
CFArrayRef fontDescription = CTFontManagerCreateFontDescriptorsFromURL ( (CFURLRef) fontURL );
NSDictionary *fontDesc= [(__bridge NSArray *)fontDescription objectAtIndex:0];
NSString* fontName = [fontDesc objectForKey:@"NSFontNameAttribute"];
NSString* familyName = [fontDesc objectForKey:@"NSFontFamilyAttribute"];
id fontTraits = [fontDesc objectForKey:@"NSFontTraitsAttribute"];
NSLog(@"%@ -> %@ -> %@", fontName, familyName, fontTraits);
No matter what file I send (fontFileWithFullPath) the fontTraits is always null.
I don't want to install the font, as I'm just examining a folder of fonts (could be hundreds) and displaying the info, but just can't seem to get the bold/italic font traits.
Any ideas?