List of Fonts Available on the iPhone

The system font on the iPhone is a good choice for many purposes. You can easily select it in a regular, bold or italic style using built-in font class methods. For example

  UIFont *mainTitleFont = [UIFont boldSystemFontOfSize:14.0];
  UIFont *subTitleFont = [UIFont SystemFontOfSize:14.0];
  UIFont *textFont = [UIFont italicSystemFontOfSize:12.0];

 
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.

  // List all fonts on iPhone
  NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
  NSArray *fontNames;
  NSInteger indFamily, indFont;
  for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
  {
      NSLog(@"Family name: %@", [familyNames objectAtIndex:indFamily]);
      fontNames = [[NSArray alloc] initWithArray:
          [UIFont fontNamesForFamilyName:
          [familyNames objectAtIndex:indFamily]]];
      for (indFont=0; indFont<[fontNames count]; ++indFont)
      {
          NSLog(@"    Font name: %@", [fontNames objectAtIndex:indFont]);
      }
      [fontNames release];
  }
  [familyNames release];

 
Using the iPhone SDK v2.1, the resulting output was as follows.

Family name: Hiragino Kaku Gothic ProN W3
    Font name: HiraKakuProN-W3
Family name: Courier
    Font name: Courier
    Font name: Courier-BoldOblique
    Font name: Courier-Oblique
    Font name: Courier-Bold
Family name: Arial
    Font name: ArialMT
    Font name: Arial-BoldMT
    Font name: Arial-BoldItalicMT
    Font name: Arial-ItalicMT
Family name: STHeiti TC
    Font name: STHeitiTC-Light
    Font name: STHeitiTC-Medium
Family name: AppleGothic
    Font name: AppleGothic
Family name: Courier New
    Font name: CourierNewPS-BoldMT
    Font name: CourierNewPS-ItalicMT
    Font name: CourierNewPS-BoldItalicMT
    Font name: CourierNewPSMT
Family name: Zapfino
    Font name: Zapfino
Family name: Hiragino Kaku Gothic ProN W6
    Font name: HiraKakuProN-W6
Family name: Arial Unicode MS
    Font name: ArialUnicodeMS
Family name: STHeiti SC
    Font name: STHeitiSC-Medium
    Font name: STHeitiSC-Light
Family name: American Typewriter
    Font name: AmericanTypewriter
    Font name: AmericanTypewriter-Bold
Family name: Helvetica
    Font name: Helvetica-Oblique
    Font name: Helvetica-BoldOblique
    Font name: Helvetica
    Font name: Helvetica-Bold
Family name: Marker Felt
    Font name: MarkerFelt-Thin
Family name: Helvetica Neue
    Font name: HelveticaNeue
    Font name: HelveticaNeue-Bold
Family name: DB LCD Temp
    Font name: DBLCDTempBlack
Family name: Verdana
    Font name: Verdana-Bold
    Font name: Verdana-BoldItalic
    Font name: Verdana
    Font name: Verdana-Italic
Family name: Times New Roman
    Font name: TimesNewRomanPSMT
    Font name: TimesNewRomanPS-BoldMT
    Font name: TimesNewRomanPS-BoldItalicMT
    Font name: TimesNewRomanPS-ItalicMT
Family name: Georgia
    Font name: Georgia-Bold
    Font name: Georgia
    Font name: Georgia-BoldItalic
    Font name: Georgia-Italic
Family name: STHeiti J
    Font name: STHeitiJ-Medium
    Font name: STHeitiJ-Light
Family name: Arial Rounded MT Bold
    Font name: ArialRoundedMTBold
Family name: Trebuchet MS
    Font name: TrebuchetMS-Italic
    Font name: TrebuchetMS
    Font name: Trebuchet-BoldItalic
    Font name: TrebuchetMS-Bold
Family name: STHeiti K
    Font name: STHeitiK-Medium
    Font name: STHeitiK-Light

 
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.

Late Addition: For samples of each font’s appearance, see my more recent post.

Oz Weather for iPhone – Beta

Woot! I’m no longer a recluse! After about a month’s hard slog at Objective-C, Cocoa and XCode’s weird bugs in in its own debugger, I now have a beta version of Oz Weather native iPhone app ready for testing. I’m pleased to say that it beats the Oz Weather web app hands down.

I’m inviting a handful of iPhone aficionados to put it through its paces – using the ad-hoc app distribution system. This requires me to collect the unique device ID of each tester’s iPhone and add them to my distribution profile. So how do you find your unique device ID (UDID)?

You can find out your device’s UDID using iTunes 7.7. or later. To do this, connect your device to your Mac and launch iTunes. In iTunes, select your device in the ‘Devices’ section and navigate to the Summary tab. Click on the Serial Number label to reveal the Identifier field and the 40 character UDID. Press Command+C to copy the UDID to your clipboard.

I’m not going to reveal all the details on my app right here and now, because there are some ingenious but evil competitors out there. (Well no doubt they are actually nice people who I would probably get on with like a house on fire, but it makes for a better blog post if I add some provocative language).

Just for tasters, here is a single screen shot anyway.