I have an Api class in my application. Inside the Api class there is a custom font that has been setup as static. For example:
public static Typeface fontShort;
public Api(Context c, Display d) {
// I want to change this if user wants to keep using system font style or my custom style
if (shouldKeepCurrent == true) {
// Use system default font
fontTitle = // ???
} else {
// Use my costume font
fontTitle = Typeface.createFromAsset(context.getAssets(), "fonts/custom.ttf");
}
}
I want to get default and current Typeface of device if user doesn't want to use my custom font!
In Activity class:
TextView myView = (TextView) findViewById(R.id.myView);
// Change to custom font style or keep current font style
myView.setTypeface(Api.fontTitle);
Any ideas?
SANS_SERIF. The NORMAL style of the default sans serif typeface.
Roboto is the default font on Android and other Google services.
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)
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With