Friday, 1 July 2011

Listing font names on iOS

A single line of code is all that's needed to display the fonts available to your code base,
NSLog(@"%@", [UIFont familyNames]);

Add this anywhere, in your application delegate's initial call back for example,
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    
    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    // testing font names
    NSLog(@"%@", [UIFont familyNames]);
    
    return YES;
}

This lists all available fonts, for example the iOS simulator 4.2 shows
[Session started at 2011-07-01 16:54:50 +0400.]
2011-07-01 16:55:11.370 PRDigitalClock[2754:207] (
    Zapfino,
    "Arial Hebrew",
    "Oriya Sangam MN",
    Cochin,
    Baskerville,
    Palatino,
    "Chalkboard SE",
    "Gurmukhi MN",
    Verdana,
    "Tamil Sangam MN",
    "Marker Felt",
    "Courier New",
    Courier,
    "Trebuchet MS",
    "DB LCD Temp",
    "Apple Color Emoji",
    "Arial Rounded MT Bold",
    "Bangla Sangam MN",
    "Telugu Sangam MN",
    "American Typewriter",
    Arial,
    Kailasa,
    AppleGothic,
    "Hiragino Kaku Gothic ProN",
    "Heiti SC",
    "Malayalam Sangam MN",
    Thonburi,
    Helvetica,
    "Gujarati Sangam MN",
    "Heiti K",
    Futura,
    "Devanagari Sangam MN",
    "Heiti TC",
    "Sinhala Sangam MN",
    "Kannada Sangam MN",
    Georgia,
    "Heiti J",
    "Times New Roman",
    "Snell Roundhand",
    "Geeza Pro",
    "Helvetica Neue"
)

No comments:

Post a Comment