How to add your own fonts for iOS ------ lable sets custom Fonts

Source: Internet
Author: User

How to add your own fonts for iOS ------ lable sets custom Fonts

Today I made a lable program for custom fonts. The design said that the system does not conform to the artistic atmosphere, so I designed a Custom font and added it to the project.

1. The first step is to find the ttf format of the font you want to use. Add to the resouce directory of your project.

 

2. In the plist of the project, AddRow, "Fonts provided by application", and then add the key as item0, and the value is the Aragones. TTF you just added.

Yes. You can add multiple names. You can write the corresponding font name when using it.

 

3. You can use it directly in your project. Xx. font = [UIFont fontWithName: @ Aragones size: 20.0];

 

 

Note:

Add this code in the program and run it,

 NSArray *familyNames =[[NSArray alloc]initWithArray:[UIFont familyNames]];    NSArray *fontNames;    NSInteger indFamily, indFont;    NSLog(@[familyNames count]===%d,[familyNames count]);    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];

View the console. The above programs will list all Fonts, including the Fonts added by "Fonts provided by application", but note that the names may differ greatly and you need to find them by yourself.
Example:
Aragones. TTF, Add Fonts provided by application
Running the above program will list
2012-10-20 21:56:21.321 MyAnimationTest[5397:c07]  Family name: HAKUYOGuiFanZi35002012-10-20 21:56:21.321 MyAnimationTest[5397:c07]     Font name: HAKUYOGuiFanZi35002012-10-20 21:56:21.322 MyAnimationTest[5397:c07] Family name: Didot2012-10-20 21:56:21.322 MyAnimationTest[5397:c07]     Font name: Didot-Italic2012-10-20 21:56:21.322 MyAnimationTest[5397:c07]     Font name: Didot2012-10-20 21:56:21.323 MyAnimationTest[5397:c07]     Font name: Didot-Bold2012-10-20 21:56:21.323 MyAnimationTest[5397:c07] Family name: Bodoni 72 Smallcaps2012-10-20 21:56:21.323 MyAnimationTest[5397:c07]     Font name: BodoniSvtyTwoSCITCTT-Book

If the Family name of the font is used instead of the file name of the font, you will not be able to see the effect if you make a mistake. If you use a font alone, you can also use the font name, depending on your preferences.

Effect:

 

 

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.