简体   繁体   English

使用Facebook API为所有印度语言定制字体

[英]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. 我假设默认的Android字体(自ICS以来为Roboto )不包含印地语,马拉雅拉姆语和泰米尔语。 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). 这篇文章来看,Jellybean附带支持Malayalam(可能还​​有其他)的字体。 Still, you need to explicitly specify the use of this font if you wish the text to render properly in a textview or similar. 不过,如果希望文本在textview或类似视图中正确呈现,则需要明确指定此字体的使用。 To set a specific TypeFace you can use TextView.setTypeface() . 要设置特定的TypeFace,可以使用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. 您可能需要研究缓存TypeFace,以防止旧版本Android上的内存泄漏 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 . 另外,对于高级用途,您可以按照此答案中的说明通过XML设置TextViews,Button等的样式。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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