Added Custom Auto for iOS [uifont fontwithname: Size:]

Source: Internet
Author: User

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]

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.