首先您必须了解,在 ICS(4.0) 之前,Android 操作系统(少数三星和 SE 手机除外)不支持泰米尔语。即便如此,它也有错误,并且 Jelly Bean (4.2) 提供了全面支持。
只有在您的应用中使用 Unicode Tamil 字体时,您才会看到框。原因是系统中没有泰米尔语字体。
1。手动操作方式
这个解决方案有一个变通方法。您所要做的就是download the Bamini font 并将其放在您的资产文件夹中。并使用 Bamini 字体创建 TypeFace 并将其设置为 TextView。
Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/Bamini.ttf");
customText1.setTypeface(font1);
现在使用converter to convert Unicode font into Bamini 编码。而不是 Unicode 文本,而是将转换后的 Bamini 编码脚本提供到 setText 方法中。
2。使用库
如果您讨厌所有这些手动编码转换,请查看library
正如我在上面所说的,如果您想在运行应用程序时动态更改编码,那么 consider using the library 我是为 Android 编写的。该库将帮助您将 Unicode 字符串转换为 Bamini、TSCII、TAB、TAM 和 Anjal。
设置非常简单。您只需将该库导入您的 Android 项目并调用该库,如下所示。
// 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);
库中有一个sample app。查看该应用程序,了解如何利用该库将 Unicode 字符串转换为 Bamini、TAB、TAM、TSCII 和 Anjal。
当你使用这个库时,你会得到类似的东西。
您需要使用 Android 中可用的 TypeFace 类。您可以使用 Bamini 或 TSCII 编码(Mylai 是 TSCII 字体)。
免责声明:我编写了这个库。
3。对于 Web 视图
如果您使用封装在 WebView 中的 html 和 CSS 进行开发,请查看 this application's source。您将不得不使用 CSS3 的fontface 功能。
首先,您需要将样式声明为 this
@font-face {
font-family: MyCustomFont;
src: url("Bamini.ttf") /* TTF file for CSS3 browsers */
}
那么你必须在你的标签中使用MyCustomFont。例如,如果您想将其设置为整个身体(在这种情况下更容易)
body {
font-family: MyCustomFont, Verdana, Arial, sans-serif;
font-size: medium;
color: black
}
希望这会让您得到应有的提醒。希望在 Play 商店中看到更多泰米尔语应用。