自定义字体无法正确显示某些字符 [英] Custom font not showing properly some characters
问题描述
我住在匈牙利,我们有一些特殊字符,例如:ő,ű...等
I live in Hungary, and we got some special characters like: ő, ű... etc
在我的Android应用程序中,我制作了一个自定义TextView.此自定义TextView在其构造函数中设置了一个自定义字体,并且除了一个小错误外,它均可以正常工作.
In my android app i made a custom TextView. This custom TextView sets a custom typeface in its constructor and it works properly, except a little bug.
特殊字符,如ő",不会转换新字体,其字体仍与默认字体相同.
The special characters like: "ő" , does not converts the new typeface, its remains the same default font.
,
(也许是一些字符编码的东西,或者我真的不知道...)
(Maybe some character coding thingee or i dont know really...)
(我使用的字体是Helvetica Neue Light,如果从计算机的Windows/Fonts文件夹中打开,我会看到特殊字符,因此这意味着该字体确实具有ő"字符,但是由于某些原因,android无法正确处理.)
(The font i use is Helvetica Neue Light, and if i open from Windows/Fonts folder in my computer i can see the special characters, so it means this font does have the "ő" character, but some reason android cannot handle it properly.)
如果可以,请帮助!谢谢!
Please help if you can! Thanks!
E D I T:
我的自定义textView类:
My custom textView class:
public class FlexiTextView extends TextView {
public FlexiTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
initView(context);
}
public FlexiTextView(Context context) {
super(context);
initView(context);
}
public FlexiTextView(Context context, AttributeSet attrs) {
super(context, attrs);
initView(context);
}
private void initView(Context context) {
try {
Typeface typeface = Typeface.createFromAsset(context.getAssets(), "fonts/helveticaneue.ttf");
this.setTypeface(typeface);
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
推荐答案
看起来很简单,您使用的字体不支持某些字符.像ö
,œ
或â
之类的字符不只是带有重音符号的基本字母,它们(在字体中)被设计为新的和不同的角色.因此,您必须选择一种支持您语言的特殊字符的字体.否则,可能会使用默认的系统字体.
that seems simple, the font you are using does not support some characters. Characters like ö
, œ
, or â
are more than just a basic letter with an accent, they are designed (in the font) as a new and different caracter. That's why you have to choose a font that supports your language's special characters. Otherwise, the default system font will probably be used.
这篇关于自定义字体无法正确显示某些字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!