kneedragger101 wrote:
So I have seen this code over at Stack Overflow to add a custom font to my application. I'm not concerned with using this for distribution I just want to know how to do it...
I wouldn't use the code you posted: it uses a private API. So even if you did work out licensing issues with the fonts, you'd still be prevented from releasing it via the App store, since private APIs aren't allowed. If you're really dead set on this, look at this application that's linked from the same page:
http://github.com/zynga/FontLabel
It's by a game company that has at least one game on the App Store, so I suspect it doesn't use private APIs. That way you'd at least be learning something useful. But be aware that it's also a lot more complex.
Honestly, for what you're doing, which is just a clock, I'd skip the whole bit about loading a custom font and just make 11 bitmaps (0-9 and ":") in whatever font I wanted to use, at the size I wanted, and draw them into a UIView. That's a whole lot simpler than what you're trying to do.
And if the goal is to eventually use a custom font for much more of the interface, I'd suggest looking at the application I linked to in this post, since you'd at least be learning something useful that you could release.
And give some thought to what K T posted when he suggested that scale back a bit and work on something a little less ambitious for the time being. Then, once you get a better handle on where to put your code, how to debug, things like that, you can move on to something more complex.
For example, the code you just posted looks like it will list all the fonts on the iPhone in the console output:
NSLog(@"Available Font Families: %@", [UIFont familyNames]);
So try that and then see what happens if you change your font to one of the fonts listed there.
charlie