Zeeshan Chaudhry
Zeeshan Chaudhry

Reputation: 862

Android Arabic/Farsi Fonts

I am developing an Android aap that uses Arabic Fonts. I have successfully display Arabic text by using "tahoma.ttf" But problem is that these Arabic Fonts Didn't give a cool look. So i wanted to change that Font Style. Is there any way of doing this ?

Upvotes: 1

Views: 1884

Answers (1)

hasanghaforian
hasanghaforian

Reputation: 14042

If you want to use external font do :

  1. First step is to pick a font that you want to use.
  2. Create a fonts folder in your assets directory and copy your font there.
  3. To access your custom font,use the Typeface class in the Android SDK to create a typeface that Android can use, then set any display elements that need to use your custom font appropriately.

Unfortunately, you can no longer use layout XML for this, since the XML does not know about any fonts you may have tucked away as an application asset.You can do like this in your code:

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

Note: Android does not seem to like all TrueType fonts.So, if you try to use a different font and it does not seem to be working, it may be that the font is incompatible with Android, for whatever reason.

You can see more details in these pages:
Fun with Fonts
Musings of the Bare Bones Coder/using custom fonts

Upvotes: 1

Related Questions