Create your own font and display it in the project

Source: Internet
Author: User

Create your own font and display it in the project

This tutorial is complex but has practical value. It can be used to extract the font downloaded from the internet and create your own font for display in the project. Sometimes the experience of loading custom texts is very large, and the 8-9 m Chinese font usually occupies a large proportion, and we only need a few Chinese characters in it. This blog post does this.

First, create a font

1. Download Tool

2. Download the font

3. Import the font to the tool and find the Chinese character based on the Chinese Character

4. Create your own font

5. Search for the three characters of travel xianming, copy and paste them, and assign values to the code points and names.

6. Export to TTF font

In this way, a Custom font is created.

 

The following section shows the font display.

Source code:

//// Rootviewcontroller. M // font // created by youxianming on 14-9-6. // copyright (c) 2014 youxianming. all rights reserved. // # import "rootviewcontroller. H "# import" fontpool. H "@ interface rootviewcontroller () @ end @ implementation rootviewcontroller-(void) viewdidload {[Super viewdidload]; self. view. backgroundcolor = [uicolor blackcolor]; [fontpool registerfont: bundlefont (@ "youxianming. TTF ") withname: @" youxianming "]; uilabel * label = [[uilabel alloc] initwithframe: cgrectmake (0, 0,320, 22)]; label. center = self. view. center; label. font = [uifont fontwithname: custom_font (@ "youxianming", 0) Size: 18]; label. textcolor = [uicolor cyancolor]; label. textalignment = nstextalignmentcenter; label. TEXT = @ "youxianming siege Lion"; [self. view addsubview: Label];} @ end

The final result is as follows:

Because my font only contains the encoding of the three Chinese characters youxianming and does not include the Chinese characters of the siege lions, it turns into a black body when the siege lions are displayed. Here, it indicates that the attack was successful :)

 

Create your own font and display it in the project

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.