How to add external fonts to android application

bHaRaTh picture bHaRaTh · Apr 12, 2011 · Viewed 116.1k times · Source

I was looking for some stylish fonts for my android application. but the problem is how can i make my android application supportable for external fonts.

Thank you.

Answer

Zelimir picture Zelimir · Apr 12, 2011

You need to create fonts folder under assets folder in your project and put your TTF into it. Then in your Activity onCreate()

TextView myTextView=(TextView)findViewById(R.id.textBox);
Typeface typeFace=Typeface.createFromAsset(getAssets(),"fonts/mytruetypefont.ttf");
myTextView.setTypeface(typeFace);

Please note that not all TTF will work. While I was experimenting, it worked just for a subset (on Windows the ones whose name is written in small caps).