I am currently using the font Yoxall in my app, and have .ttf files for "Regular", "Bold", and "Italic". I am currently using the coke [UIFont fontWithName:@"Yoxall" size:20.0f]
to set the font as the regular Yoxall, using the YOXALL__.ttf file in my supporting files. I would also like to use italic Yoxall elsewhere in my app, but I obviously cannot call the same method, as "Yoxall" refers to both these files.
What code would I use to distinguish between the regular, bold, and italic styles of this font?
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]){
NSLog(@"%@", fontName);
}
}
This function will give all fonts name.
Use +[UIFont familyNames] to list of all font family names known
to the system, you can use +[UIFont fontNamesForFamilyName:] to list
all of the font names known to the system.
Example code:
static void dumpAllFonts() {
for (NSString *familyName in [UIFont familyNames]) {
for (NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) {
NSLog(@"%@", fontName);
}
}
}
in output you can get font name. hope it's help