Created
October 24, 2012 18:59
-
-
Save h6y3/3948104 to your computer and use it in GitHub Desktop.
print ios font names and families rubymotion style
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
for (NSString *familyName in [UIFont familyNames] ) | |
{ | |
NSLog(@"Family name: %@", familyName); | |
for (NSString *fontName in [UIFont fontNamesForFamilyName: | |
familyName]) | |
{ | |
NSLog(@" Font name: %@", fontName); | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def printFontNames | |
UIFont.familyNames.each do |familyName| | |
puts "Family name #{familyName}" | |
UIFont.fontNamesForFamilyName(familyName).each do |fontName| | |
puts "Font name #{fontName}" | |
end | |
end | |
end |
Post included for real this time: http://stackoverflow.com/questions/9432373/custom-fonts-xcode-4-3
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);
}
}
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
Gist is a port of this post - notice how clean the Ruby version is compared to the original Objective-C variant.