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