I'm trying to add a custom font to my project in Xcode 4.2, but whenever I try to use it, I get a error that the object is nil.
I have done the following:
1) Added a row to my .plist 'Fonts provided by application' value: "LCDMono2 Ultra.ttf"
2) Added the font to my Supporting Files and showed it in XCode to verify it was added.
3) Verified using Get Info that the Full Name is "LCDMono2 Ultra"
4) Created the font in my project with:
UIFont *myFont = [UIFont fontWithName:@"LCDMono2 Ultra" size:16];
and I've tried this variant:
UIFont *myFont = [UIFont fontWithName:@"LCDMono2 Ultra" size:16.f];
5) Tried to use the font name (addObject:myFont.fontName)
, generating the 'nil'
error.
What could be causing the error? Could it be something like the space in the name?
[UIFont familyNames]
to see if your font is actually getting "seen" by the OS. That will at least narrow things down. I've had som kinds of font files iOS wouldn't recognize. – Basuto