iOS how to add your own fonts------lable set a custom font

Source: Internet
Author: User

Today made a custom font of the lable program, the design said the system is not in line with the artistic atmosphere, so designed a custom font, added to the project.

1. The first step is to find the TTF format for 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", then add the key for Item0,value as you just joined Aragones.ttf.

Yes, you can add multiple, use the time to write the corresponding font name on the line


3. You can use it directly in your project. Xx.font = [Uifont fontwithname:@ "aragones" size:20.0];

Attention:

In the program, first add this code, run,

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 console, The above program will list all the fonts, of course, also contains "Fonts provided by Application" the added font, but please note that the name may be very large, you have to find the

Aragones.TTF  , join fonts provided by Application
       execute 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, smallcaps2012-10-20 21:56:21.323 MYANIMATIONTEST[5397:C07]     Font Name:bodonisvtytwoscitctt-book

to use the family name of the font instead of the file name of the font, you will not see the effect if you make a mistake. If you are using a font style alone, you can also use the font name to see personal preferences.

Effect:


you can download more TTF fonts in http://www.webpagepublicity.com/free-fonts.html.

iOS how to add your own fonts------lable set a custom font

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.