About the Android font description

Source: Internet
Author: User

First, font analysis

1.1. Location of fonts in file system:
/system/fonts/The TTF files are font files for the source/frameworks/data/fonts/

Droidsans-bold.ttf sans serif fonts (Latin alphabet, etc.)

Droidsans.ttf regular sans serif fonts (Latin alphabet, etc.)

Droidsansfallback.ttf regular sans serif font (Chinese characters, etc., the general change font is to replace this file)

Droidsansmono.ttf-wide sans serif font (Latin alphabet, etc.)

Droidserif-bold.ttf font in bold (Latin alphabet, etc.)

Droidserif-bolditalic.ttf bold + Italic serif font (Latin alphabet, etc.)

Droidserif-italic.ttf Italic serif Font (Latin alphabet, etc.)

Droidserif-regular.ttf Regular serif fonts (Latin alphabet, etc.)

Clockopia.ttf (the font used when displaying the digital clock, not required)

Under frameworks/fonts/There are three XML files, respectively, Fallback_fonts.xml, System_fonts.xml, Vendor_fonts.xml, and finally the first two are programmed into the system.

There are only two ways to change the font, one is to force the replacement of the system's default font, that is, you want to replace the font renamed to Droidsansfallback.ttf, replace the/system/fonts/under the original, the other way is through the fixed vendor Fonts XML method to set, for us, the first method is too violent, and there is no room for choice. So the second method is more feasible. The brute force substitution method is not said, now talk about the manufacturer font method:

1.2.vendor Fonts Method:
Suppose you want to add a font file in XXXXX.TTF format:
Create a fallback_fonts.xml in the/vendor/etc/directory, as described in the comments in the Android use case Vendor_fonts.xml file, for example:

1 <Familyset>2     <FamilyOrder= "9">3         <Fileset>4             <file>Xxxxx.ttf</file>5         </Fileset>6     </Family>7 </Familyset>

Where family order represents the location of the required replacement for the inserted vendor font described, that is,/system/etc/fallback_ The 10th family described in Fonts.xml (starting from 0), which is Droidsansfallback.ttf, is also required to copy "Xxxxx.ttf" to/system/fonts before using this method.

Second, the font summary

Most of the fonts are copyrighted, so use someone else's font before you have to be careful, this is why Android no longer settings added fonts in the selection bar, if you use someone else's font is not paid protection fees and products bought a lot of money, the lawyer letter estimated on the way to arrive.

Modify Android Font sequel: The most significant change since the HTTP://WWW.DOUBAN.COM/NOTE/222712555/
4.x for 4.0 (ICS) is the new Roboto family, with regular/bold/ Italic/bolditalic four variants, two more italic than the original Droidsans. The original Droidsans family is still in, but has been pointed to the Roboto family, and then modify the original file is invalid.
Since the Chinese font has not yet appeared independent italic and independent bold italic, so I would like to suggest that everyone in English separate, so as to ensure that English has italic and bold italic, while the English and Chinese have more kinds of independent collocation.  
in order to replace the English font, we need to prepare four fonts (very many fonts have a separate italic, it is easy to find) to replace the following four files:
Roboto-regular.ttf
Roboto-italic.ttf
The pre-preparation and Operation Essentials of Roboto-bold.ttf
Roboto-bolditalic.ttf
Replacement are shown in the log cited at the beginning of the article.
for Chinese, 4.x or a DROIDSANSFALLBACK.TTF is complete. Some of the firmware may be Droidsansfallbackfull.ttf a class name, in short, the largest size of the one we need to replace. The individual is the font requirements are relatively high, but also like to use independent bold for CJK text, so I have to explore the independent bold, harvest see below.
Use Rootexplorer to enter the/SYSTEM/ETC directory to find fallback_fonts.xml this file. This is the 4.x after the new language of the configuration file, you can open with Notepad to modify. Friends who are familiar with Linux have a good knowledge of this file structure, and define the font family and different variants. We can find that here, Japan and South Korea are still a line of the following code:

 1  <  family  >  2   >  3  <  file  >  Droidsansfallback.ttf</ >  4  </ fileset  >  5  </ family  >  

This means that the system is not ready for us to be bold. Don't be discouraged, we find that the file begins with a statement that defines bold:

1 <Family>2     <Fileset>3         <file>Droidsanshebrew-regular.ttf</file>4         <file>Droidsanshebrew-bold.ttf</file>5     </Fileset>6 </Family>

This is Hebrew, and Google has created an independent bold for it. We followed the above statement and added a line after <file>DroidSansFallback.ttf</file>:
<file>DroidSansFallback-Bold.ttf</file>
Save, the file with Rootexplorer overwrite the original directory with the same name file, set permissions.
And then we need the Chinese general body and bold, respectively named Droidsansfallback.ttf and Droidsansfallback-bold.ttf, overwrite the original font, and will overwrite the font and new added to the Droidsansfallback-bold.ttf Permissions are modified as I did in the previous tutorial.
This can be restarted after the completion of the work to see the effect, so that the English replacement of the same time the Chinese new bold, for the font control is pleasing. Of course, the above fallback_fonts.xml can theoretically increase the font family infinitely. For example, I have just replaced the font in Chinese and Japanese (quite a lot of fonts do not have Korean), I define new families in the back like Droidsanskorean.ttf and Droidsanskorean-bold.ttf (whatever you name) and then add a new font that can theoretically continue fallback, fallback order is Fallback_ Fonts.xml in the upper and lower order.
Confined to my mobile phone space is too small to try to verify the above hypothesis, interested users can try their own.
  
Actual operation:

After modifying the font-related files, you need to restart the machine, or restart Android, that is, enter Stop;start in the ADB shell.

1. According to the online information, the matrix can be added to the Droidsansfallback.ttf, in theory in the Flash,air (based on the air development of the APK), the web and other places to display. In fact, non-self-created characters are not shown. Later in the/system/etc/fallback_fonts.xml see the following comments:

<!-- Note:complex scripts (i.e. those requiring shaping in harfbuzz) has       a cumulative limit of 64k glyphs. Thus, if they is placed after       the large fonts such as droidsansfallback, they is likely to render       incorrectly. P Lease use caution when putting fonts toward the end of the       list.    -

It probably means that the total number of fonts in a font file cannot exceed 64K, and the font file behind the large-size file (such as Droidsansfallback.ttf) may not be displayed properly. We have tried to add the self-created mold to the Droidsansfallback.ttf, which led to the file increased to 8M, the original only 4 m more, the result of a lot of text display does not come out. This is the same as when you delete Droidsansfallback.ttf directly.

2. Based on the above reasons, the use of small template files, only the self-made mold, test with the self-character mold file about 1M.

Add file/vendor/etc/fallback_fonts.xml, format reference/system/etc/fallback_fonts.xml, specific content as follows:

1 <?XML version= "1.0" encoding= "Utf-8"?>    2 <Familyset>  3     <FamilyOrder= "+">  4         <Fileset>  5             <file>Diy.ttf</file>  6         </Fileset>  7     </Family>  8 </Familyset>  

The font file Diy.ttf push to/system/fonts/below, order= "14" is the reference/system/etc/fallback_fonts.xml, ensure the order in front of Droidsansfallback.ttf. But the test results still do not, the Web page, Flash,air in the self-character model are not displayed, do not know where the wrong, or the system does not support.

3. The above method does not work, intends to directly modify the/system/etc/fallback_fonts.xml, in front of the Droidsansfallback.ttf added:

1 <Family>  2    <Fileset>  3        <file>Diy.ttf</file>  4    </Fileset>  5 </Family>  6 <Family>  7    <Fileset>  8        <file>Droidsansfallback.ttf</file>  9    </Fileset>  Ten </Family>  

Also need to push Diy.ttf to/system/fonts/below. At this point, the Web page, flash in the self-character can be displayed normally, but the air in the self-word display.
4. Add the self-casting to the Roboto-regular.ttf:

Add the self-made mold to the/system/fonts/roboto-regular.ttf, restart the machine, air, flash in the self-made look normal display. But the self-character in the Web page does not show.

5. According to the experimental results, two methods need to be used simultaneously:

A. Add font file/system/fonts/diy.ttf, and modify/system/etc/fallback_fonts.xml accordingly;

B. Add the self-made mold to the/system/fonts/roboto-regular.ttf.

This makes the Web, flash, and air appear normal.

Other knowledge:

The system fonts must be placed below the/system/fonts/, and the fonts to be used should be configured in/system/etc/system_fonts.xml and/system/etc/fallback_fonts.xml. The system takes precedence from the fonts listed in System_fonts.xml to find the matrix, followed by Fallback_fonts.xml.

If the bold italic is required to display self-word, the following file will be added to the font.
Roboto-italic.ttf
Roboto-light.ttf
Roboto-lightitalic.ttf
Roboto-regular.ttf
Roboto-thin.ttf
Roboto-thinitalic.ttf

This time it was operated on a android4.2 machine, and the list of system fonts is as follows:

1 Androidclock.ttf2 Androidclock_highlight.ttf3 Androidclock_solid.ttf4 Androidemoji.ttf5anjalinewlipi-Light.ttf6 Clockopia.ttf7droidnaskh-Regular.ttf8droidnaskh-regular-Systemui.ttf9 Droidsansarmenian.ttfTendroidsansdevanagari-Regular.ttf Onedroidsansethiopic-Regular.ttf A Droidsansfallback.ttf - Droidsansgeorgian.ttf -droidsanshebrew-Bold.ttf thedroidsanshebrew-Regular.ttf - Droidsansmono.ttf -droidsanstamil-Bold.ttf -droidsanstamil-Regular.ttf + Droidsansthai.ttf -droidserif-Bold.ttf +droidserif-Bolditalic.ttf Adroidserif-Italic.ttf atdroidserif-Regular.ttf -lohit-Bengali.ttf -lohit-Kannada.ttf -lohit-Telugu.ttf - Mtlmr3m.ttf - Nanumgothic.ttf inroboto-Bold.ttf -roboto-Bolditalic.ttf torobotocondensed-Bold.ttf +robotocondensed-Bolditalic.ttf -robotocondensed-Italic.ttf therobotocondensed-Regular.ttf *roboto-Italic.ttf $roboto-Light.ttfPanax Notoginsengroboto-Lightitalic.ttf -roboto-Regular.ttf theroboto-Thin.ttf +Roboto-thinitalic.ttf

End of analysis.

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.