Thursday, December 22, 2011

How to add Indian Languages to Android ICS (4.0.3)

Google is officially supporting the Indian languages rendering from 4.0.3 onwards.
The AOSP code supports rendering of three Indian languages in Web-kit. (Devanagari, Tamil, and Bengali).
I just added support for the other Indian languages as well. Tested it on my Nexus-S device

Prerequisites :

Follow these instructions:

1) Download the "Binary" file of the Indian language from this link.
         Ex: lohit-kananda-ttf-2.5.0.tar.gz

2) Untar the downloaded file and Copy the extracted folder into  
    external/lohit-fonts directory
        Ex: lohit-kannada-ttf-2.5.0

3) Rename the folder name to lohit-kannada-ttf

4) Modify the file which is present in external\lohit-fonts directory

       ifneq ($(SMALLER_FONT_FOOTPRINT),true)
            extra_lohit_fonts := Lohit-Bengali.ttf Lohit-Tamil.ttf Lohit-Kannada.ttf

       include $(CLEAR_VARS)
        LOCAL_MODULE := Lohit-Kannada.ttf
        LOCAL_SRC_FILES := lohit-kannada-ttf/$(LOCAL_MODULE)
        LOCAL_MODULE_TAGS := optional
        LOCAL_MODULE_PATH := $(TARGET_OUT)/fonts
        include $(BUILD_PREBUILT)

5) Modify the FontAndroid.cpp file (external/webkit/source/webcore/platform/graphics/android)

    a) Add an language entry to CustomScript enum
             enum CustomScript {


    b) Add the ttf file path to the TextRunWalker Paths

           const char* TextRunWalker::paths[] = {


    c) Now setup the Font for Script Run
            case HB_Script_Kannada:
              complexPlatformData = setupComplexFont(Kannada, platformData);

6) Add the *.ttf file in Fallback_fonts.xml (frameworks\base\data\fonts)

Note : Assamese language is not enabled as Harfbuzz is not supporting this language.