I Have a Custom View which draws text onto the Canvas.
I want to change the font to a font stored in the assets folder.
I
In order to reuse typefaces in my projects I create a class full of typeface methods, this way I dont have to create a new typeface every time.
I call the class FontClass and in the class there is a method for each typeface I need to use e.g:
public static Typeface getOpenSansRegular(Context c){
return Typeface.createFromAsset(c.getAssets(), "OpenSans-Light.ttf");
}
Then I can use them like so:
TextView text = (TextView) findViewById(R.id.textview);
text.setTypeface(FontClass.getOpenSansRegular(getApplicationContext());