How to add your own fonts in iOS madness

Source: Internet
Author: User

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 Testfont.ttf.

So, 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:@ "testfont" 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 objectAt  Index:indfamily]];
  
For (indfont=0; Indfont<[fontnames count]; ++indfont)
             
    {  
NSLog (@ "Font name:%@", [FontNames Objectatindex:indfont]);
             
       }  
         
[FontNames release];
}  
     
[Familynames release];

Check the 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, to find out for yourself
Example:
Testfont.ttf, join Fonts provided by Application
executing the above program will list

2012-10-20 21:56:21.321 myanimationtest[5397:c07] Family name:hakuyoguifanzi3500
2012-10-20 21:56:21.321 myanimationtest[5397:c07] Font name:hakuyoguifanzi3500
2012-10-20 21:56:21.322 myanimationtest[5397:c07] Family Name:didot
2012-10-20 21:56:21.322 myanimationtest[5397:c07] Font name:didot-italic
2012-10-20 21:56:21.322 myanimationtest[5397:c07] Font Name:didot
2012-10-20 21:56:21.323 myanimationtest[5397:c07] Font name:didot-bold
2012-10-20 21:56:21.323 myanimationtest[5397:c07] Family name:bodoni
2012-10-20 21:56:21.323 myanimationtest[5397:c07] Font Name:bodonisvtytwoscitctt-book

to use the font's family name instead of the font's file name, you will not see the effect if you make a mistake.

Note It is also important to add the font file Xxx.ttf that you just added in "Copy boundle Resources" as follows:



It's OK to use it directly.


Effect:


you can be inHttp://www.webpagepublicity.com/free-fonts.htmldownload more TTF fonts.

How to add your own fonts in iOS madness

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.