Zeeshan
Zeeshan

Reputation: 751

Font Typeface doesn't work

TextView tv=(TextView)findViewById(R.id.textView1); 
Typeface face=Typeface.createFromAsset(getAssets(), "font.ttf"); 
tv.setTypeface(face);

I am unable to see the textview typeface changed. I have "font.ttf" file in assets folder. Basically, I am intended to show "Urdu" word in that textview (requirement) and therefore added urdu font in assets. Yet it is showing me "WORD" in English.

Thanks for help.

Upvotes: 4

Views: 1541

Answers (2)

Muhammad Usman Ghani
Muhammad Usman Ghani

Reputation: 1279

Typeface tf = Typeface.createFromAsset(getAssets(),
            "fonts/burnstown_dam.otf");
    TextView tv = (TextView) findViewById(R.id.CustomFontText);
    tv.setTypeface(tf);


    Typeface tf1 = Typeface.createFromAsset(this.getAssets(), "fonts/Jameel Noori Nastaleeq Kasheeda.ttf");
    TextView textView = (TextView)findViewById(R.id.CustomFontText);
    textView.setTypeface(tf1);
    textView.setText("Your Font Language Here");

Upvotes: 0

Raghav Sood
Raghav Sood

Reputation: 82543

Android doesn't support the full range of ttf fonts. Here is a font that I have used personally in my app. Try using this instead. If this one works, and your urdu one doesn't then your code it correct, and Android does not support your font. If neither work, then something is wrong with your code.

Upvotes: 4

Related Questions