I am using Multiple custom fonts in my app.i know how to Add custom font but the Terrible parts of all this process is when we are going to use the custom font because mostly the custom font name is different from the file that we are using in app.here i would like to explain the recent example that i did,First of all i have added two custom font file in my app
For getting the above custom font names i tried this way
NSArray *familyNames = [[NSArray alloc] initWithArray:[UIFont familyNames]];
NSArray *fontNames;
NSInteger indFamily, indFont;
FontnameArray=[[NSMutableArray alloc] init];
for (indFamily=0; indFamily<[familyNames count]; ++indFamily)
{
fontNames = [[NSArray alloc] initWithArray:
[UIFont fontNamesForFamilyName:
[familyNames objectAtIndex:indFamily]]];
for (indFont=0; indFont<[fontNames count]; ++indFont)
{
NSString *fullName = [NSString stringWithFormat:@"%@",[fontNames objectAtIndex:indFont]];
[FontnameArray addObject:fullName];
}
}
[FontnameArray sortUsingSelector:@selector(localizedCaseInsensitiveCompare:)];
NSLog(@" Font name: %@", FontnameArray);
The above Code display 199 font names for me ,so it was to difficult for me to pick the custom font name among 199 fonts, To make my doubt clear then i have simply drag the font file to font book Then i got the orignal names of custom Font.
[UIFont fontWithName:@"Ethiopia Primary" size:20]];
[UIFont fontWithName:@"Ethiopia jiret" size:20]];
So the Question is how can i get all Custom font names in Array like Above instead of draging the each font file to Fontbook for getting orignal names.
Just compare with all fonts exist in iOS
*Create new project like this code and write array of all font names to a plist file
Open your simulator dir and copy this plist to your App bundle. Then read this plist to an array and compare with all of your fonts by this code
I've done all in my test project, you just copy and paste it.