Sunday, February 3, 2013

10. How to display local Language Text with custom font in Android

For displaying the Languages which are not supported by Android, we have to pack the font for the language along with our application package.

First Download the required font for your language (To find one just Google it) I have used Malayalam font here (https://sites.google.com/site/fontpacksite/malayalam-fonts).Then we have to copy a suitable font for your language in to the "asset" folder. For example I have used the font named "AnjaliOldLipi" for  "Malayalam" .


Now If you want to display it in to a TextView the format is as shown below, since I have saved the font inside a new folder named "fonts" I have to give "fonts/.......,ttf"

TextView tv = (TextView)findViewById(R.id.textView1);
                    Typeface typeFace = Typeface.createFromAsset(getAssets(),"fonts/AnjaliOldLipi.ttf");
                    tv.setTypeface(typeFace);
                    tv.setText("മലയാളം");   


Now it will show the corresponding text in to the TextView in your language. When you run the program or export an APK file, this font will be packed along with the APK file, so the font will work in any Android device, which do not have this font installed.

6 comments:

  1. Hello Arise,

    I have been trying to resolve Malyalam font issue by doing same as the above, even I tried many types of fonts like Meera, Dyuthi, Rachana, RaghuMalayalamSans, AnjaliOldLipi. But There is still issue of some characters if I am going for AnjaliOldLipi.

    ReplyDelete
    Replies
    1. Anjali old lipi is the best one and it works perfectly for me

      Delete
  2. Hello sir,
    I am a bigginer. Your help will be valuable for me. I succeeded to develop an android application for my malayalam blog which using Anjali Old Lipi. However the blog is not showing the letters when the blog open in the "webview" since the lack of necessary coding.. Its my dream to make a facility to make available my blog for mobile viewers who may not have malayalam facility. My mobile does not support malayalam but it can read Malayalam manorama app clearly. If manorama can make such an app why don't I? I also want to make such a facility. Pls help me. I tried all the things available in stack flow.

    ReplyDelete
  3. This information you provided in the blog that was really unique I love it!!, Thanks for sharing such a great blog..Keep posting..

    Andriod Training in Chennai

    ReplyDelete
  4. Wonderful blog.. Thanks for sharing informative blog.. its very useful to me..
    mobile apps development companies melbourne | web development Melbourne

    ReplyDelete

  5. TextView tv = (TextView)findViewById(R.id.textView1);
                        Typeface typeFace = Typeface.createFromAsset(getAssets(),"fonts/AnjaliOldLipi.ttf");
                        tv.setTypeface(typeFace);
                        tv.setText("മലയാളം");   
    tv.setText("how to type malayalam this place i dont know")

    ReplyDelete

Please give your valuable comments so as to know whether this blog is useful to you.You can also write helpful Android Development Syntax or Shortcuts or Tips.