How to add new fonts in Android _android

Source: Internet
Author: User
Tags new set

The Android font file is placed in: alps\frameworks\base\data\fonts
Which Droidsans.ttf is the default English font, DROIDSANS-BOLD.TTF is the default English bold font; DROIDSANSFALLBACK.TTF is the default Chinese font.

To add a set of third party Chinese font () for example.

Because Google provides the default Chinese font Droidsansfallback.ttf is not very comprehensive, so customers often need to increase the three-party Chinese font to support the display of characters, and the new set of fonts as the system's default Chinese font.

In two different situations:

First, do not need to retain the Google default Chinese font:

Rename the three-party font to DROIDSANSFALLBACK.TTF and copy it to the Alps\frameworks\base\data\fonts, replacing the original default Chinese font for the system. New project and download bin to cell phone.

second, there is a need to retain Google's default Chinese font, and on this basis to increase their need for the new font
different from code version:

-Prior to the ICS 4.0 version:
1 copy newfontfile.ttf file to Alps\frameworks\base\data\fonts
2 The font file into the compilation options:
To modify the Frameworks/base/data/fonts/android.mk file:

Copy Code code as follows:

Copy_from: = \
DROIDSANSMONO.TTF \
NEWFONTFILE.TTF \
......

3) Modify External/skia/src/ports/skfonthost_android.cpp file:
Copy Code code as follows:

Add the corresponding font family
static const char *gnewfontfilenames[] = {
"..." the NULL//omitted part is determined by the current system-supported font engine.
};

Add the following statement
{"Newfontfile.ttf", Gnewfontfilenames},

So even if the addition is complete.

-ICS 4.0 version:
1 copy the corresponding font file to the Frameworks/base/data/fonts
2) Add the font family of the new font file under Fallback_fonts.xml (frameworks/base/data/fonts):
Copy Code code as follows:

<family>
<fileset>
<file>NewFontFile.ttf</file>
</fileset>
</family>

3) Modify Font makefile:fonts.mk (frameworks/base/data/fonts)
Copy Code code as follows:

Product_copy_files: = \
......
FRAMEWORKS/BASE/DATA/FONTS/NEWFONTFILE.TTF:SYSTEM/FONTS/NEWFONTFILE.TTF \

Related Article

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.