Question

I am trying to use a custom font in my iPhone app but somehow it does not load I believe at all in the app as a start to my problem.

I dragged and dropped the "My Font.ttf" in xcode and create the key with UIAppFonts. First question: I guess the these 2 names should be strictly identical i.e. my key must display the the exact filename and so with the extension ".ttf"...? what about if upper/lower case? what about if there are spaces in the filename...?

Then I use this:

NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSLog(@"Fonts: %@", [UIFont familyNames]);
[familyNames release];

to display all the fonts and clearly see that my font is NOT there....

Then so when I use that below, nothing works (for sure):

lblSol1.font = [UIFont fontWithName:@"My Font" size:32];

(if I replace by Arial, it does work so I can only think it has to do with the loading of the font...)

I understood that the name to use with -fontWithName can be different that filename (and is actually the name of the font "fullname" when you open in the get info window). Anyway, I by now tried all combinations and can't get it to work...

(I also did deploy and build for iOS 4.o to be sure to be far from 3.2 in case of..)

Thanks for your help.

Cheers, geebee

EDIT1: the result (as asked) of showing the fonts is: Fonts: ( "Arial Hebrew", Zapfino, "Oriya Sangam MN", Cochin, Baskerville, Palatino, "Chalkboard SE", "Gurmukhi MN", Verdana, "Tamil Sangam MN", "Marker Felt", "Courier New", Courier, "Trebuchet MS", "DB LCD Temp", "Apple Color Emoji", "Arial Rounded MT Bold", "Bangla Sangam MN", "Telugu Sangam MN", "American Typewriter", Arial, Kailasa, AppleGothic, "Hiragino Kaku Gothic ProN", "Heiti SC", "Malayalam Sangam MN", Thonburi, Helvetica, Noteworthy, "Gujarati Sangam MN", "Heiti K", Futura, "Devanagari Sangam MN", "Heiti TC", "Sinhala Sangam MN", "Kannada Sangam MN", Georgia, "Heiti J", "Times New Roman", "Snell Roundhand", "Geeza Pro", "Helvetica Neue"

No correct solution

OTHER TIPS

According to the documentation here: UIAppFonts

UIAppFonts (Array - iOS) specifies any application-provided fonts that should be made available through the normal mechanisms. Each item in the array is a string containing the name of a font file (including filename extension) that is located in the application’s bundle. The system loads the specified fonts and makes them available for use by the application when that application is run.

This key is supported in iOS 3.2 and later.

So yes, you need to include the filename extension.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top