Android 中的泰米尔语字体 [英] Tamil fonts in Android

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

问题描述

我在 Android 版本 2.3.3 中开发了一个泰米尔语新闻应用程序.但是,泰米尔语字体仅在 android 4.0 及更高版本中得到适当开发.我想在所有版本的 android mobile 中显示它们.

我尝试用一​​些泰米尔字体解决这个问题,例如baminimylai,但它们只适用于更高的android版本.

解决方案

首先你必须明白,在 ICS(4.0) 之前,Android 操作系统(除了少数三星和 SE 手机)没有泰米尔语支持.即便如此,它仍然存在错误,并且 Jelly Bean (4.2) 提供了全面支持.

如果您在应用中使用 Unicode Tamil 字体,您只会看到框.原因是系统中没有泰米尔语字体.

1.手动方式

此解决方案有一个变通方法.您所要做的就是.你将不得不使用 CSS3 的 fontface 特性.

首先你需要将样式声明为这个

@font-face {字体系列:MyCustomFont;src: url("Bamini.ttf")/* CSS3 浏览器的 TTF 文件 */}

然后你必须在你的标签中使用 MyCustomFont.例如,如果您想将其设置为整个身体(在这种情况下更容易)

body {字体系列:MyCustomFont、Verdana、Arial、sans-serif;字体大小:中等;颜色:黑色}

希望这能让您得到应有的注意.希望在 Play 商店中看到更多泰米尔语应用.

I developed a Tamil news application in android version 2.3.3. However, Tamil fonts have only been properly developed in android versions 4.0 and beyond. I want to display them in all versions of android mobile.

I tried to solve the problem with some Tamil fonts, such as bamini and mylai, but they only worked in higher android versions.

解决方案

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.

1. Manual way of doing

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.

2. Using the Library

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.

You would get something like this when you use the library.

You need to make use of the TypeFace class available in Android. You can use either Bamini or TSCII encoding (Mylai is a TSCII font).

Disclaimer : I wrote this library.

3. For WebView

If you are developing using html and CSS wraped inside a WebView then take a look at this application's source. You gonna have to make use of fontface feature of CSS3.

First you need to have style declared as this

@font-face {
 font-family: MyCustomFont;
 src: url("Bamini.ttf") /* TTF file for CSS3 browsers */
}

Then you gotta use the MyCustomFont in your tags. For example if you wanna set it to the whole body (which is much easier in this case)

body {
 font-family: MyCustomFont, Verdana, Arial, sans-serif;
 font-size: medium;
 color: black
}

Hope this would give you the heads up you deserve. Hope to see more Tamil apps in Play Store.

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

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