Sinhala Fonts for Your Android App


When you are going to develop a localized app in Sinhala the biggest problem you are facing is Sinhala support for android. So here you can find simple example how to use Sinhala fonts with your android app. For the coding example I am using Amal Sinhla font,

First start a new Android project( In Eclipse go to New -> Other -> Android -> Android Project ). Then place your Sinhla font TTF file (Amal.TTF) in the ./assets directory. Create it if it doesn’t exist. Following figure show you how it looks after you add it.

Now you can do coding. Change the main.xml file as follows.


<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
 android:orientation="vertical"
 android:layout_width="fill_parent"
 android:layout_height="fill_parent"
 >
<TextView
 android:id="@+id/sinhala_font"
 android:layout_width="fill_parent"
 android:layout_height="wrap_content"
 android:text="wdhqfndajka"
 android:textSize="25sp"
 />
</LinearLayout>

Add following code lines to main activity class.


TextView txt = (TextView) findViewById(R.id.sinhala_font);
 Typeface font = Typeface.createFromAsset(getAssets(), "amal.TTF");
 txt.setTypeface(font);

Every thing is done. You can run the project. It will look like as shown in the bellow figure. Now you can develop a Sinhala enable android app easily. You can add not only Sinhala fonts like this but also any customized font.

Advertisements

29 thoughts on “Sinhala Fonts for Your Android App

  1. Sira machan. kool one 🙂
    If anyone creating hybrid apps can try this too 🙂
    akurulk.github.com

  2. ගොඩක් ස්තූතියි මචං.
    කාලයක් තිස්සෙ මාත් හොය හොය හිටියෙ වැඩේ කික් උනේ නැහැ කලින්.
    තෑන්ස්!

  3. Thank you very much for your valuable comments 🙂

  4. Great way to start. but thing is if you use this font you can not set any dynamic strings with english and sinhala since the font amal.ttf got only sinhala letters with it. And also if we render something like “කෝ ” it might render as “ක ේ” (without space). So the best thing is come up with complete font set which contains both english and sinhala with all ispili and papili.

    • thanks for the valuable info machan.
      please can you mention how to prevent that error?
      thanks for your time.

      • I’m working on it machan. I still couldn’t find the correct solution. SETT is soo expensive. So I had to come up with my own solution. When I was working on it I came across very interesting stuff. Android emulator doesn’t give same renderings when you developing in windows and Linux. But ultimately the way android render in real device is same as the way it gives in Linux platform. So for testing purpose we have to use Linux.

      • thx for your kind feedback machan.
        have to research more on the subject as you said. I tht SETT was an open sourced product. 😦
        any alternatives to achieve the maximum sinhala unicode rendering without using SETT FTW? thx again!

    • Thank you for your valuable comment. Is it a problem with amal.ttf? And also it is not wise to use this method for dynamic strings. Specially I posted this, those who like design UI with different fonts.

  5. yes true….. chrishi..

  6. thanka machan karana vidiya share kalata.

  7. This is really a great article helping Sri Lankan app developers. Thanks.

  8. Thanks for you valuable comments 🙂

  9. Thank You mcn… mama thawama Test kalee na.. but wadee hariyai kiyala hithanawa.. 🙂

  10. […] via Sinhala Fonts for Your Android App. […]

  11. meka hadapu kenek innawanam mata kiyanna. http://www.facebook.com/pdappi

  12. Amal.ttf works fine but do you know any other sinhala font that will work? I tried the ones in the icta website they don’t work this way.

    http://www.icta.lk/en/programmes/pli-development/104-local-languages-initiative-/1090-sinhala-stylized-fonts.html

  13. […] I am trying to include a customized font in my android application. This is the tutorial that I followed and this seems to have worked for many people: https://tharindudassanayake.wordpress.com/2012/02/25/use-sinhala-fonts-for-your-android-app/ […]

  14. Isuru Dewasurendra

    elakiri machan…. Thanks godak…. thawa me wage watin kiyana dewal dapan.. jayen jaya….

  15. How install sihala for andorid 4.0? Please tell

  16. Thanks machan. Great job!

  17. great work,and my windows project is on http://www.roshantuwanusoof.webs.com

  18. හිහි කොල්ලා කෝඩ් කරන කාලේ කොහොමෙයි වැඩ 😀

  19. HI,
    Thanks for the blog post which is really helpful.
    In the meantime, let’s say if I am to develop an Android application in Sinhala, I am okay with user input and other front end stuff according to this post, but how can I display Sinhala texts received from, say a web service call? Should I use a unicode font or what should I do?
    Really grateful if you could pass some insights over this.
    Thanks.

  20. I tried… but an error occurs
    04-03 17:49:37.011: E/AndroidRuntime(1019): FATAL EXCEPTION: main
    04-03 17:49:37.011: E/AndroidRuntime(1019): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.sinhala./com.sinhala..MainActivity}: java.lang.RuntimeException: native typeface cannot be made

  21. කොහොමද type කරන්න ඕනේ keys හොයාගන්නේ? wdhqfndajka–> ආයුබෝවන්, වගේ keyboard එක මොකක්ද? ගොඩක් ස්තුතියි

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s