Showing posts with label Fetch Family Name and Font. Show all posts
Showing posts with label Fetch Family Name and Font. Show all posts

Tuesday, December 1, 2015

Fetch all Font family and Fonts in ios


Get all available font family and fonts from iOS


  • Below code is useful to fetch all available Family and Font Name in iOS Development 

-(void)printAllFontFamilyAndFonts
{

    NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
    NSArray *fontNames;
    NSInteger indFamily, indFont;
    NSInteger fontsCount = [familyNames count];
    
    for (indFamily = 0; indFamily < fontsCount; ++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]);
        }
        
    }
}