Skip to content

Instantly share code, notes, and snippets.

@simonbromberg
Last active September 6, 2023 03:35
Show Gist options
  • Star 16 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save simonbromberg/24a48fb5e94b2bde82df1e5c97e733da to your computer and use it in GitHub Desktop.
Save simonbromberg/24a48fb5e94b2bde82df1e5c97e733da to your computer and use it in GitHub Desktop.
List all fonts available on iOS device in console
// List all fonts on iPhone
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
for (NSString *family in familyNames) {
NSLog(@"Family name: %@", family);
fontNames = [UIFont fontNamesForFamilyName: family];
for (NSString *font in fontNames) {
NSLog(@" Font name: %@", font);
}
}
let familyNames = UIFont.familyNames
for family in familyNames {
print("Family name " + family)
let fontNames = UIFont.fontNames(forFamilyName: family)
for font in fontNames {
print(" Font name: " + font)
}
}
@kasperkronborg
Copy link

You are missing a type declaration for fontNames in ListFonts.m

NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
  
for (NSString *family in familyNames) {
  NSLog(@"Family name: %@", family);

  NSArray *fontNames = [UIFont fontNamesForFamilyName: family];
  for (NSString *font in fontNames) {
    NSLog(@"    Font name: %@", font);
  }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment