But what if you want a font using both bold and italic at the same time, or a different typeface altogether? In that case, you can use the “fontWithName” method as follows.

UIFont *altFont = [UIFont fontWithName:@"Courier-Bold" size:14.0];

This is all well and good, but how did you know what font names and variants are available? If you just guess and get the name wrong, your code will throw an exception – there is no graceful mapping to nearest available font here!

I couldn’t find the list of available font names anywhere in the iPhone documentation, or for that matter even with a web search (at least within the first few pages of returned results). So instead I wrote a small snippet of code to list them for me.

So when choosing a non-system font, you just have to make sure that you choose a font name from this list. Whether or not the list of font will change in future iPhone OS updates remains to be seen. It may be worth re-running this code snippet to see.

30 Responses

Thanks Keith. Yep! I’ll do it as soon as I find time to create a view to display them. Hmmm… I think it was meant to be about 5 days per view wasn’t it? Maybe I’d better sell it in the app store once its done!

[…] Let’s pick a new font. You need to set the font property of the cell to a UIFont. You’ll need a font name (a string) and a size. Here, we’re using Georgia. You can find a full list of font names here. […]

at the top of the page, with the single line examples. But the SystemFontOfSize method should be systemFontOfSize (no capital s). I’m not sure if it works properly or not with the capital letter, but I didn’t catch that and my compiler gave me a warning. I never actual ran that iteration of the program to where it would have actually tried calling SystemFontOfSize.