1. Add the corresponding font (. ttf or. odf) to the resurce of the project, such as UnidreamLED. ttf (led font)
2. In info. plist, add a Fonts provided by application (the value corresponding to item0 is UnidreamLED. ttf, and add multiple Fonts in sequence)
3. Find UnidreamLED. the font name corresponding to ttf. You can use the following code to print all available font names of the system. Then you need to look for the corresponding font name carefully, here there is a stupid way to compare, that is to say, print out the familyname of all fonts in the system before adding this font, then add this font and print all familynames again, then, you can find the added familyname.
NSArray * familyNames = [[NSArray alloc] initWithArray: [UIFont familyNames];
NSArray * fontNames;
NSInteger indFamily, indFont;
For (indFamily = 0; indFamily <[familyNames count]; ++ 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]);
}
[FontNames release];
}
[FamilyNames release];
3. The next step is to use it. For example, the name of the font corresponding to the font I added is @ "UniDream_LED". When using label. font = [UIFont fontWithName: @ "UniDream_LED" size: 13];