cem
cem

Reputation: 3321

Fonts on iOS device

I've read the available font families by [UIFont familyNames], but I've got various lists on different devices (but with the same iOS version). Can somebody tell me, if the fonts listed with the method above, are including custom fonts provided by other installed applications or if those are only the fonts shipped with iOS?

Upvotes: 40

Views: 29364

Answers (6)

kakilangit
kakilangit

Reputation: 1350

Yes, it shows all the fonts within your app, including the custom fonts you've added. Here's the shorter code to list all the fonts:

Objective-C

for (NSString *familyName in [UIFont familyNames]){
    NSLog(@"Family name: %@", familyName);
    for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
        NSLog(@"--Font name: %@", fontName);
    }
}

Swift 2

for familyName:AnyObject in UIFont.familyNames() {
    print("Family Name: \(familyName)")
    for fontName:AnyObject in UIFont.fontNamesForFamilyName(familyName as! String) {
        print("--Font Name: \(fontName)")
    }
}

Swift 3

 for familyName:String in UIFont.familyNames {
     print("Family Name: \(familyName)")
     for fontName:String in UIFont.fontNames(forFamilyName: familyName) {
         print("--Font Name: \(fontName)")
     }
 }

Upvotes: 106

chrisallick
chrisallick

Reputation: 1358

Here is the correct snippet for listing out all the fonts:

    // 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]);
    }
}

Upvotes: 14

Hemant Dixit
Hemant Dixit

Reputation: 1145

Please try this code :https://github.com/zynga/FontLabel/

for checking Available iOS Fonts:

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]; 

Upvotes: 2

barfoon
barfoon

Reputation: 28157

Gruber posted a link to the fonts included a little while ago: iOS Fonts

Edit: The site he links to is iosfonts.com

Upvotes: 5

CutMaster
CutMaster

Reputation: 109

You'll find a list of all embedded fonts in iOS that don't need any extra class to build with, here : List Of Available iOS Fonts

Upvotes: 11

Srikar Appalaraju
Srikar Appalaraju

Reputation: 73588

I believe those are only the fonts shipped with iOS. Any Custom fonts you need to find the respective .otf or .ttf files & include that file in your project resource.

Am saying this because, I wanted to use HelveticaNeue-UltraLight font. Its listed in iOS & you see this font option in Xcode. But upon selecting nothing happens. For this to work I had to do the above & put in HelveticaNeue-UltraLight font file.

Upvotes: 2

Related Questions