1. Add the corresponding auto file (. TTF or. OTF) to the project directory, such as simkai. TTF.
2. Add a fonts provided by application in the-info. plist file. The value corresponding to item0 is simkai. TTF, and add multiple Auto Parts in sequence.
3. Use [uifont fontwithname: Size:] to set the image itself. The fontwithname parameter is not necessarily simkai. You need other methods to check the font name.
The font name can be queried as follows:
for(NSString *familyName in [UIFont familyNames]) { NSLog(@"familyName = %@", familyName); for(NSString *fontName in [UIFont fontNamesForFamilyName:familyName]) { NSLog(@"\tfontName = %@", fontName); } }
Execute the above Code before and after the above step 1, and record the information printed on the console separately.
Console print information example:
2012-08-08 14:27:56.150[1821:c07] familyName = Thonburi2012-08-08 14:27:56.153[1821:c07] fontName = Thonburi-Bold2012-08-08 14:27:56.154[1821:c07] fontName = Thonburi2012-08-08 14:27:56.154[1821:c07] familyName = Snell Roundhand2012-08-08 14:27:56.154[1821:c07] fontName = SnellRoundhand-Bold2012-08-08 14:27:56.155[1821:c07] fontName = SnellRoundhand-Black2012-08-08 14:27:56.155[1821:c07] fontName = SnellRoundhand2012-08-08 14:27:56.156[1821:c07] familyName = Academy Engraved LET2012-08-08 14:27:56.156[1821:c07] fontName = AcademyEngravedLetPlain2012-08-08 14:27:56.157[1821:c07] familyName = Marker Felt2012-08-08 14:27:56.157[1821:c07] fontName = MarkerFelt-Wide2012-08-08 14:27:56.158[1821:c07] fontName = MarkerFelt-Thin2012-08-08 14:27:56.158[1821:c07] familyName = Geeza Pro2012-08-08 14:27:56.159[1821:c07] fontName = GeezaPro-Bold2012-08-08 14:27:56.159[1821:c07] fontName = GeezaPro2012-08-08 14:27:56.182[1821:c07] familyName = Arial Rounded MT Bold2012-08-08 14:27:56.183[1821:c07] fontName = ArialRoundedMTBold2012-08-08 14:27:56.183[1821:c07] familyName = Trebuchet MS2012-08-08 14:27:56.184[1821:c07] fontName = TrebuchetMS2012-08-08 14:27:56.184[1821:c07] fontName = TrebuchetMS-Bold
Use the Compare file method to find out the different content of the information printed from the console twice. The different content is the name of the newly added font.
We can see that the newly added auto name is kaiti_gb2312.
The following operations should be performed when setting the auto-body:
[UIFont fontWithName:@"KaiTi_GB2312" size:20.0]