Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 783
cem Avatar asked Nov 11 '11 07:11

cem


People also ask

Can I change the font style on my iPhone?

Press the Settings button in the upper-right corner of the screen. Tap on Fonts. Under the Select Font list, choose your desired font style. Tap Done.


2 Answers

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)")      }  } 
like image 166
kakilangit Avatar answered Sep 27 '22 21:09

kakilangit


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]);     } } 
like image 20
chrisallick Avatar answered Sep 27 '22 20:09

chrisallick