Can I embed a custom font in an Android application?

Yes you can, you jsut can’t define it into xml layouts. You need to use it dynamically each time. Check this tutorial for instance.

In case link is dead, here is a sum up of the stuff :

  • Get a font file like times.otf
  • Drop it in your asset folder, inside a “fonts” folder
  • Get a reference of TextView with something like that:

    TextView tv = (TextView) findViewById(R.id.myCustomTVFont);
    
  • Grab you font from the asset folder:

    Typeface tf = Typeface.createFromAsset(getAssets(), "fonts/times.otf");
    
  • Make your TextView look great:

    tv.setTypeface(tf);
    

Leave a Comment