简体   繁体   中英

custom typeface for all Indian languages with Facebook api

我的Android应用程序使用facebook api读取了用户的最新FB状态更新。但是其中一些是用诸如印地语,马拉雅拉姆语,泰米尔语等本地语言编写的(例如:ശിഖര,‍,‍,മ,വിരാട,കോലി,如何在文本视图中显示时使所有这些文本可读?

I would assume that the default Android font ( Roboto since ICS) doesn't include Hindi, Malayalam and Tamil. At least I'm not able to find evidence that it does. Judging from this post Jellybean ships with a font with support for Malayalam (and possibly others). Still, you need to explicitly specify the use of this font if you wish the text to render properly in a textview or similar. To set a specific TypeFace you can use TextView.setTypeface() . I would suggest that you bundle the font mentioned in the link above in your assets folder and load it like this:

TypeFace tf = Typeface.createFromAsset(context.getAssets(), "AnjaliNewLipi-light.ttf")

You might want to look into caching the TypeFace to prevent memory leaks on older Android versions. Resuse this class if you wish.

Also, for advanced use, you can make your TextViews, Buttons etc styleable via XML by following the instructions in this answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM