2

Possible Duplicate:
Android - Using Custom Font

i am creating an application in arabic and have a custom font that i want to use can someone tell me the code i should use in my java class i tried this

TextView txt = (TextView) findViewById(R.id.custom_font);  
Typeface font = Typeface.createFromAsset(getAssets(), "trado.ttf");  
txt.setTypeface(font); 

but the ending line that says font theres an error that says Syntax error on token "font", VariableDeclaratorId expected after this token Can someone help!

Community
  • 1
  • 1
user1223679
  • 101
  • 1
  • 2
  • 9

2 Answers2

5

try this, as in adding this lol

TextView txt = (TextView) findViewById(R.id.custom_font);  
Typeface font = Typeface.createFromAsset(this.getAssets(), "trado.ttf");  
txt.setTypeface(font); 
Bill Gary
  • 2,987
  • 2
  • 15
  • 19
2

Save your custom font file in a folder fonts inside the assets folder.

for example:

assets/fonts/trado.ttf

enter image description here

and make sure your font extension (i.e ttf in your case) is in lower case.

waqaslam
  • 67,549
  • 16
  • 165
  • 178