A solution to add a new language to Android _android

Source: Internet
Author: User
Although Android has supported more than 50 languages since 2.3, there are fonts in every language that can be displayed. Meet a new demand, have customer request to Hindi language support. So the internet to find some information, found that most of the online introduction is how to replace the default font, is replaced./frameworks/base/data/fonts/droidsansfallback.ttf, but after the replacement, Chinese can not be displayed correctly.
in fact, as long as there are several steps, you can implement a new language display support:
1. Need to have the font that can display Hindi language, I downloaded one on the net: Droidhindi.ttf
2. The areas that need to be modified are mainly
1 Copy the downloaded font file to:./frameworks/base/data/fonts/
2) Modify./frameworks/base/data/fonts/android.mk, add Droidhindi.ttf to Copy_from:
Copy Code code as follows:

Copy_from: = \
DROIDSANS.TTF \
DROIDSANS-BOLD.TTF \
DROIDSANSARABIC.TTF \
DROIDSANSHEBREW.TTF \
DROIDSANSTHAI.TTF \
DROIDHINDI.TTF \
DROIDSERIF-REGULAR.TTF \
DROIDSERIF-BOLD.TTF \
DROIDSERIF-ITALIC.TTF \
DROIDSERIF-BOLDITALIC.TTF \
DROIDSANSMONO.TTF \
Clockopia.ttf

3 Hindi's language code is hi_in, modified./device/qcom/common/common.mk, add Hindi language code to your settings-> language and keyboard-> Select the language in which you can see the Hindi language:
Copy Code code as follows:

Product_locales: = en_US en_gb es_es es_us fr_fr zh_cn zh_tw hi_in it_it pt_pt ru_ru

4) Modify the/external/skia/src/ports/skfonthost_android.cpp and add the Droidhindi.ttf. Many of the methods introduced on the internet did not mention this step, if not this step, the added language is not effective, the display is garbled, because Android can not find the Hindi language to display the font, or will choose the default font to display. The modified places are:
Copy Code code as follows:

/* Fonts must is grouped by family, with the "the" in a family has the
List of names (even if that list is empty), and the following
Null for the list. The names list must be null-terminated
*/
static const FONTINITREC gsystemfonts[] = {
{"Droidsans.ttf", Gsansnames},
{"Droidsans-bold.ttf", NULL},
{"Droidserif-regular.ttf", Gserifnames},
{"Droidserif-bold.ttf", NULL},
{"Droidserif-italic.ttf", NULL},
{"Droidserif-bolditalic.ttf", NULL},
{"Droidsansmono.ttf", Gmononames},
/* These are optional, and can is ignored if not found in the file system.
These are appended to gfallbackfonts[] as they are seen, so we list
them in the "order" we want them to is accessed by Nextlogicalfont ().
*/
{"Droidsansarabic.ttf", Gfbnames},
{"Droidsanshebrew.ttf", Gfbnames},
{"Droidsansthai.ttf", Gfbnames},
{"Droidhindi.ttf", gfbnames},//newly added language
{"Mtlmr3m.ttf", gfbnames},//Motoya Japanese Font
{"Mtlc3m.ttf", gfbnames},//Motoya Japanese Font
{"Droidsansjapanese.ttf", Gfbnames},
{"Droidsansfallback.ttf", Gfbnames}
};

5) go./build/target/product/full.mk See which language list the system chooses, My is:
$ (call inherit-product, build/target/product/languages_small.mk)
So I'm going to revise./build/target/product/languages_small.mk, if the languages_full.mk is shown here, modify it./build/target/product/languages _FULL.MK file, modified as follows:
Product_locales: = en_US en_gb fr_fr hi_in it_it de_de es_es

3. The rest is to recompile, and then flash to the phone or simulator on it.
To set the page:

To open a Hindi Web page, the Hindi language can be displayed normally:

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.