自TTF字体显示不正确的TextView的在Android 4.4奇巧奇巧、不正确、字体、TTF

2023-09-05 00:20:27 作者:痛也不说出口

我有有一些加粗部分一些文字。直到奇巧这种策略(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.

 
精彩推荐
图片推荐