I have added an external font in /assets directory, and manually doing setFacetype(font). Isn't there a general way to set the whole application to use a specific font if you have added it external? Or do you have to use Android's selected fonts in order to achieve this?
Asked
Active
Viewed 1,074 times
3 Answers
3
You cannot use your custom fonts through to whole application in a general way.
You cannot set your custom fonts through xml files.
You have to use the Typeface
functions in your code to use your custom fonts within your application.

C.d.
- 9,932
- 6
- 41
- 51
-
you CAN set your custom fonts in xml, you just need to override the TextView, full code and examples here: http://helpmeco.de/2012/2/custom-fonts-in-android-widgets – browep Mar 07 '12 at 19:27
-
That code is actually setting the font via TypeFace functions so still you cannot set a custom font for default views from xml. – C.d. Mar 07 '12 at 21:41
-
It's setting via the TypeFace functions in the overridden TextView widget which pulls it from xml. You could just default the typeface if nothing was specified in the XML. – browep Mar 11 '12 at 21:43
2
tv=(TextView)findViewById(res);
Typeface font = Typeface.createFromAsset(this.getAssets(), "MYFONT.TTF");
tv.setTypeface(font);
This also how to use it in a textview.
For whole application go to Using a custom typeface in Android.
and go to Manish Singla answer
2
Typeface mTypeface = Typeface.createFromAsset(getAssets(), "YOUR FONT NAME");
textview.setTypeface(mTypeface, Typeface.NORMAL);

Bhavesh Vadalia
- 369
- 2
- 7