自TTF字体显示不正确的TextView的在Android 4.4奇巧 [英] Custom ttf fonts are not showing properly in TextView on Android 4.4 KitKat

查看:634
本文介绍了自TTF字体显示不正确的TextView的在Android 4.4奇巧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有有一些加粗部分一些文字。直到奇巧这种策略(<一href="http://stackoverflow.com/questions/1529068/is-it-possible-to-have-multiple-styles-inside-a-textview">as在这篇文章中提到的)工作得很好

I have some text which has some bolded parts. Until KitKat this strategy (as mentioned in this post) worked perfectly well

我的字符串资源文件中:

My strings resources file:

<string name="multi_style_text">NON-BOLD TEXT \n<b>BOLD</b></string>

我的应用程序code的片段:

My application code in fragment:

txtView.setTypeface(FontUtils.getOstrichRegular(this.getActivity()));
...
public static Typeface getOstrichRegular(Context context) {
   return Typeface.createFromAsset(context.getAssets(),
                                "fonts/ostrich_regular.ttf");
}

目前(在奇巧),粗体部分未在自定义字体示出,非粗体部分显示在自定义字体。在Android中的previous版本,所有的文字被显示在自定义字体。

Currently (in KitKat), the bolded part is not shown in the custom font, the non-bolded part is shown in the custom font. In previous versions of Android, all of the text was shown in the custom font.

怎么办?

推荐答案

所以,后被受挫这个错误,我搜索了一圈,发现一个解决问题的办法。 在我目前的项目中,我们使用calibri.ttf字体。这是工作的罚款高达4.4。一旦我得到了更新,以我的承上启下4,所有与宋体字体TextViews都显示FF,而不是整个文本。

So, after being frustrated by this bug, I searched around and found a solution to the problem. In my current project we use calibri.ttf font. that was working fine up to 4.4. Once i got the update to my nexus 4, All the TextViews with Calibri font were showing "ff" instead of the entire text.

THE FIX - 获得.otf(开放式字体)版本的字体,并把项目,就像一个魅力。太糟糕了,谷歌没有告知这个开发商和有对此事非常小的文档。

THE FIX - get an .otf (open type font) version of your font, and put in the project, works like a charm. Too bad google didn't inform the developers on this and there's very little documentation on the matter.

这篇关于自TTF字体显示不正确的TextView的在Android 4.4奇巧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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