安卓:如何用泰米尔语字体 [英] Android : how to use Tamil font

查看:149
本文介绍了安卓:如何用泰米尔语字体的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的泰米尔HTML UNI code字符串

This is my tamil html unicode string

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

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

我用这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("முதல் பக்க செய்திகள்");

在Android的,这可能吗?

In Android, is this possible?

推荐答案

首先,你必须明白,没有泰米尔语支持Android操作系统(除了少数三星和放大器; SE手机),直到ICS(4.0)。即使如此,它有缺陷,并全力支持带有果冻豆(4.2)。

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).

如果您使用的Uni code泰米尔语字体在你的应用程序,你将只能看到盒子。原因是没有泰米尔语字体在系统中。

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

有一个工作围绕这个解决方案。所有你需要做的是,下载Bamini字体,并把它放在你的资产的文件夹。而创建字体的字体Bamini并将其设置为TextView的。

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);

现在使用转换器转换成统一code字型进Bamini 编码。而不是统一code文本提供转换Bamini EN codeD脚本到的setText 方法。

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

正如我所说的上面行,如果你喜欢同时运行的应用程序动态地更改编码然后考虑使用我写的Andr​​oid库。该库将帮助你统一code字符串转换为Bamini,TSCII,TAB,TAM和Anjal。

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.

设置非常简单。所有你需要做的就是简单地导入库到你的Andr​​oid项目,并调用库如下图所示。

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);

有一个示例应用可随着库。检查出库如何被用来在UNI code字符串转换为Bamini,TAB,TAM,TSCII和Anjal应用程序。

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.

请务必阅读如何应对泰米尔我的COM prehensive答案在这个答案 Android原生的应用程序和WebViews这里。

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

这篇关于安卓:如何用泰米尔语字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆