Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p><code>[UIFont familyName]</code> is supported back to iPhone OS 2.0 (before 2.0, third-party apps were not allowed on iPhone or iPod touch) , so I would use that to check to see if a font family exists on the current device, and if it doesn't exist, use a suitable fall-back font for that version of iOS. Here's John Gruber's list of iPhone fonts from the original iPhone in 2007 (contrasted with the fonts in Mac OS X of the day). I haven't checked them all, but the iOS fonts I did check are still in iOS 5:</p> <ul> <li><a href="http://daringfireball.net/misc/2007/07/iphone-osx-fonts" rel="noreferrer">http://daringfireball.net/misc/2007/07/iphone-osx-fonts</a></li> </ul> <p>Here's an example of using <code>[UIFont familyName]</code>:</p> <pre><code>NSLog (@"Font families: %@", [UIFont familyNames]); </code></pre> <p>This will produce a list like this:</p> <blockquote> <p>Font families: ( Thonburi, "Snell Roundhand", "Academy Engraved LET", ... et cetera.</p> </blockquote> <p>Once you know the family name, you can use the <code>UIFont</code> class method <code>fontNamesForFamilyName</code> to get an NSArray of the names of all the fonts in the family. For example:</p> <pre><code>NSLog (@"Courier New family fonts: %@", [UIFont fontNamesForFamilyName:@"Courier New"]); </code></pre> <p>That will produce a list like this:</p> <blockquote> <p>Courier New family fonts: ( CourierNewPSMT, "CourierNewPS-BoldMT", "CourierNewPS-BoldItalicMT", "CourierNewPS-ItalicMT" )</p> </blockquote> <p>The following example code prints a list of each font in every family on the current device:</p> <pre><code>NSArray *fontFamilies = [UIFont familyNames]; for (int i = 0; i &lt; [fontFamilies count]; i++) { NSString *fontFamily = [fontFamilies objectAtIndex:i]; NSArray *fontNames = [UIFont fontNamesForFamilyName:[fontFamilies objectAtIndex:i]]; NSLog (@"%@: %@", fontFamily, fontNames); } </code></pre> <p>For more information, check out the iOS Developer Reference document for the <code>UIFont</code> class methods <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIFont_Class/Reference/Reference.html#//apple_ref/occ/clm/UIFont/familyNames" rel="noreferrer" title="familyNames">familyNames</a> and <a href="http://developer.apple.com/library/ios/documentation/uikit/reference/UIFont_Class/Reference/Reference.html#//apple_ref/occ/clm/UIFont/fontNamesForFamilyName:" rel="noreferrer" title="fontNamesForFamilyName">fontNamesForFamilyName:</a>.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload