Jack K Fouani Jack K Fouani - 1 year ago 159
Android Question

How to get default Typeface of Android device?

I have an API class inside my application; inside API class there is a custom font that has been setup as static, for example

public static Typeface font_short;

public Api(Context c , Display d)
this.context = c ;

//I want to change this if user wants to keep using System font style or my custom style
if ( keep_curren == true )
font_title = //What to add here to get Default fonts Typeface
//use my costume font
font_title = Typeface.createFromAsset(context.getAssets(),"fonts/custome.ttf");

display = d;

w = display.getWidth(); // deprecated
h = display.getHeight(); // deprecated

I want to get default and current Typeface of device if user doesn't want to use my custom font!

in Activity Class

TextView blaaa = (TextView) findViewById(R.id.blaaa);
//change to custome font style or keep current font style

Any ideas?

Answer Source

You can get the default Typeface using:

if (keep_curren) {
    font_title = Typeface.DEFAULT;

You can also get the default Typeface based on specified style: Typeface.defaultFromStyle(int style).

More on this: Here.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download