I have a custom built font that I've added to the Xcode project. I've followed all the instructed steps in adding the font and when I set a UILabel or UITextField as the custom font in IB it works great, however when I set the custom font at runtime it appears as the iOS default font instead. I've checked the UIAppFonts list and have them print out with NSLog where it shows the full name so I know that when I call [UIFont fontWithName:@"font name" size:s] it's the correct name. What could be the issue?
The font name finding method below (This method provided the incorrect names to use in custom UIFont instantiation):
NSDictionary* infoDict = [[NSBundle mainBundle] infoDictionary];
NSArray* fontFiles = [infoDict objectForKey:@"UIAppFonts"];
for (NSString *fontFile in fontFiles) {
NSURL *url = [[NSBundle mainBundle] URLForResource:fontFile withExtension:NULL];
NSData *fontData = [NSData dataWithContentsOfURL:url];
CGDataProviderRef fontDataProvider = CGDataProviderCreateWithCFData((__bridge CFDataRef)fontData);
CGFontRef loadedFont = CGFontCreateWithDataProvider(fontDataProvider);
NSString *fullName = CFBridgingRelease(CGFontCopyFullName(loadedFont));
CGFontRelease(loadedFont);
CGDataProviderRelease(fontDataProvider);
NSLog(@"FULL NAME:%@",fullName);
}