Skip to content

Instantly share code, notes, and snippets.

@h6y3
Created October 24, 2012 18:59
Show Gist options
  • Save h6y3/3948104 to your computer and use it in GitHub Desktop.
Save h6y3/3948104 to your computer and use it in GitHub Desktop.
print ios font names and families rubymotion style
for (NSString *familyName in [UIFont familyNames] )
{
NSLog(@"Family name: %@", familyName);
for (NSString *fontName in [UIFont fontNamesForFamilyName:
familyName])
{
NSLog(@" Font name: %@", fontName);
}
}
def printFontNames
UIFont.familyNames.each do |familyName|
puts "Family name #{familyName}"
UIFont.fontNamesForFamilyName(familyName).each do |fontName|
puts "Font name #{fontName}"
end
end
end
@iljaiwas
Copy link

Note you would write that code in Objective-C like you did:

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

@h6y3
Copy link
Author

h6y3 commented Oct 24, 2012

Updated per Ilja's comment - clearly got caught. Don't need all those unnecessary array allocs (in addition to the better iteration syntax in Objective-C).

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