iOS development: Importing font libraries

Source: Internet
Author: User

Using custom Fonts

Way one: Local fonts imported to the Engineering directory use first, to find a font package download down, I use the founder of the Orchid Pavilion Special Black Simplified (Figure 1), 2.5M size


Drag to the engineering directory to ensure that this package is visible in copy Bundle resources (Figure 2)


Configure plist: Add a field to Info.plist fonts provided by application adds an item to the name of the font package (Figure 3)


Someone on the blog said next to open the font pack Note name (Figure 4) can be used as a font name


I can't do this, I printed the list of the current fonts in the system
Nsarray * Fontsarray = [Nsarray alloc] Initwitharray: [Uifont Familynames]]
For (NSString *font in Fontsarray) {
NSLog (@ "Font Name =%@\n", font);
}

Find imported fonts (Figure 6)


and then you can use the
[Uifont fontwithname:@ FZLANTINGHEI-H-GBK size:17] Two: Using fonts downloaded from the server
download fonts to Local

New Uifont class extension Uifont+customfont

Implementation
+ (uifont*) Customfontwithpath: (nsstring*) path size: ( CGFloat) size
{
Nsurl *fonturl = [Nsurl Fileurlwithpath:path];
Cgdataproviderref fontdataprovider =cgdataprovidercreatewithurl ((__bridge cfurlref) fontUrl);
Cgfontref fontref = Cgfontcreatewithdataprovider (Fontdataprovider);
Cgdataproviderrelease (Fontdataprovider);
Ctfontmanagerregistergraphicsfont (Fontref, NULL);
NSString *fontname = Cfbridgingrelease (Cgfontcopypostscriptname (fontref));
Uifont *font = [Uifont fontwithname:fontname size:size];
Cgfontrelease (FONTREF);
return font;
}

You know
[Uifont Customfontwithpath:fontfilepath size:20];

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.