How to use external fonts in Android

In this tutorial we will show how you can use external fonts in your Android applications instead of regular available fonts.

The first step is that you need to download a free font (.ttf file) from internet which you want to use. It's easy. Go to and search for free fonts and download the one which you want to use. Here in this tutorial we will be using two fonts - RockFont font and FeastOfFlesh font as shown below.


RockFont for Android

RockFont for Android

Feast of Flesh Font for Android


Create a new Android Project. This project will have the following properties -

  • Project Name - ExternalFont
  • Application Name - How to use custom fonts in Android
  • Package Name - com.botskool.ExternalFont
  • Activity Name - ExternalFont

Now inside the assets folder of your project create a new folder and name it as fonts. Copy the font(.ttf) files in this folder. In our case the font files are RockFont.ttf and FEASFBRG.TTF.

If you are using Eclipse refresh your project directory tree once. Now copy the following code in the main.xml.

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android=""


We are using XML layout for our application's UI and we are creating two textviews with ids text1 and text2.

Now copy the following code in

package com.botskool.ExternalFont;

import android.os.Bundle;
import android.widget.TextView;

public class ExternalFont extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        Typeface font1 = Typeface.createFromAsset(getAssets(), "fonts/RockFont.ttf");
        Typeface font2 = Typeface.createFromAsset(getAssets(), "fonts/FEASFBRG.TTF");
        TextView customText1 = (TextView)findViewById(;
        TextView customText2 = (TextView)findViewById(;

        customText1.setText("Hello! This is a custom font...");
        customText2.setText("Developed by");


The Typeface class specifies the typeface and intrinsic style of a font. We have created two objects of this class - font1 and font2 and assigned them the path of two font files by using creatFromAsset() method.

After this we declare two objects of TextView class and assign them the ids of our XML layout. We then define what type of font to use by using setTypeface() function. We can alter the default textsize by using setTextSize() method. And finally we define the text to be displayed via setText() method.

Run your Android Application.

How to use custom fonts in Android



Do post your doubts, queries or suggestions in our forum.

Download ExternalFont.apk.