0

I live in Hungary, and we got some special characters like: ő, ű... etc

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.

See my pic here,

(Maybe some character coding thingee or i dont know really...)

(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:

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();
    }

}

}
Adam Varhegyi
  • 11,307
  • 33
  • 124
  • 222

2 Answers2

1

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.

gnclmorais
  • 4,897
  • 5
  • 30
  • 41
  • But i told that if i open this font in my PC i can clearly see the special characters. – Adam Varhegyi Nov 22 '13 at 11:56
  • Sorry, I missed that part... That is strange, indeed. Have you tried to load the text from HTML, something like `myTextView.setText(Html.fromHtml("Időpont kérés")); `? – gnclmorais Nov 22 '13 at 12:02
  • hm... Can you please update your question with the code you are using in order to apply the custom font? – gnclmorais Nov 22 '13 at 14:22
  • I see no problem with you code... so I still think it's a font related issue. Just to make sure it is not, can you try to load other custom font instead of Helvetica Neue Light? Open Sans, for example? (I think it supports most of special characters.) – gnclmorais Nov 22 '13 at 18:30
  • I have the same problem, but in my case, I can't see those characters correctly on a PC but I do can in an application that I'm programming for iOS. – Juan José Melero Gómez Feb 01 '17 at 11:39
0

The problem is with your device where you are trying to set it. Just try to find other .ttf with the same font. And do not set typeface this way! Typeface.createFromAsset() is too expensive. Use caching for this. link which saves your performance