5

This is my tamil html unicode string

முதல் பக்க செய்திகள்

I am using this code:

    TextView text=(TextView)findViewById(R.id.text); // initialize to your textview
    Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/tamil.ttf");
    text.setTypeface(tf);
    text.setText("முதல் பக்க செய்திகள்");

In Android, is this possible?

Jonathan Leffler
  • 730,956
  • 141
  • 904
  • 1,278
Jeeva
  • 1,166
  • 4
  • 18
  • 39

4 Answers4

13

First of all you have to understand that there is no Tamil Language support in Android OS (except few Samsung & SE mobiles) till ICS(4.0). Even then it had bugs and full support is provided with Jelly Bean (4.2).

You will only see boxes if you use Unicode Tamil font in your app. Reason is there are no Tamil fonts in the system.

There is a work around for this solution. All you have to do is, download the Bamini font and place it in your assets folder. And create TypeFace with the font Bamini and set it to the TextView.

Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/Bamini.ttf");
customText1.setTypeface(font1);

Now use a converter to convert Unicode font into Bamini encoding. instead of the Unicode text provide the converted Bamini encoded script into the setText method.

If you hate all these manual encoding conversion then check out this library

As I said in above line, if you like to change the encoding dynamically while running the application then consider using the library I wrote for Android. This library will help you to convert Unicode String to Bamini, TSCII, TAB, TAM and Anjal.

Set up is very simple. All you have to do is simply import the library into your Android project and call the library as below.

// Initialise the Typeface (assumes TSCII, Bamini, Anjal, TAB or TAM font located inside assets/fonts folder)
Typeface tf = Typeface.createFromAsset(getAssets(),"fonts/mylai.ttf");
// Initialises the TextView
TextView tv = (TextView)findViewById(R.id.textView1);
//Setting the Typeface
tv.setTypeface(tf);
//Magic happens here ;) encoding conversion
String TSCIIString = TamilUtil.convertToTamil(TamilUtil.TSCII, "வணக்கம் அன்ரொயிட்");
//Setting the new string to TextView
tv.setText(TSCIIString);

There is a sample app available along with the library. Check out the app on how the library is utilised to convert the Unicode String to Bamini, TAB, TAM, TSCII and Anjal.

Please make sure to read my comprehensive answer on how to tackle Tamil on Android Native apps and WebViews here in this Answer.

Community
  • 1
  • 1
Jay Mayu
  • 17,023
  • 32
  • 114
  • 148
  • sorry, I forgot to mention something. please see the updated answer. – Jay Mayu Aug 22 '11 at 06:43
  • You can't directly use the unicode script. That is because no Tamil rendring support and font available in Android OS. What you can do is convert the unicode string into Bamini encording with the site I gave above. and use the string u get from the converter in the SetText method of your TextView. Hope that'll help you. – Jay Mayu Aug 22 '11 at 06:49
  • make sure you have folder named "fonts" and place Bamini.ttf inside. As you can see in the code, bamaini.ttf is retreived from font folder. Make sure the font Name and the name you give in the code is same. (capital small -case sensitive) – Jay Mayu Aug 22 '11 at 06:50
  • i want coding for convert Unicode font into Bamini encoding.please help me.. for this tamil news feed http://feeds.feedburner.com/dinamalar/Front_page_news?format=xml – Jeeva Aug 22 '11 at 07:02
  • I'm not sure how u can do it real time. use google search to figure it out. – Jay Mayu Aug 22 '11 at 09:06
2

Thanks Mayu.. Nice info...

Jeeva,.. Just view the source of this page http://www.islamkalvi.com/web/unicode_to_bamini.htm.. you will get one JavaScript function you can use that for convert Unicode font into Bamini encoding.

VeerKrish
  • 21
  • 1
1

To convert unicode to TSCII please refer to ThamiZha's TamilVisai. They have released an InputMethod for Tamil and it's opensource. Here is the link for their application source code. There is a class called UnicodeUtil which converts Unicode to TSCII on the fly.

Sergey Glotov
  • 20,200
  • 11
  • 84
  • 98
javamak
  • 41
  • 3
0

I have used the Bamini.ttf for tamil font. you will need to convert the tamil font to unicode by using bamini converter. To get the source code for doing application in tamil. Please visit the below website,

http://www.tamilvizhi.com/sample-android-application-in-tamil-book-applicationandroid-application-development-source-code/