How to use custom Truetype font in Android UI or playing with TypeFaces

Published by Igor Khrupin on

Here is the sample of usage:

Below you can download source code of this sample Android project

To use custom Truetype font in your Android UI you need.
1. Download *.TTF file with font.
2. put this file in assets project’s dir.
3. You need read this font from assets dir:

Typeface typeFace = Typeface.createFromAsset(context.getAssets(), "YOUR_FONT.ttf");

4. set TypeFace for your UI element. In my case it is TextView.


Also it works for Button, EditText, etc.
Full source code of activity:

package com.hrupin.sample.customfont;

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

public class CustomFontInAndroidActivity extends Activity {
    private static Typeface typeFace = null;
    private TextView textView;

    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {
        textView = (TextView) findViewById(;
        textView.setText("Hello, my name is Igor Khrupin.\n\n I can help you in Android development.\n\n Contact me:\n");

    public static void initTypeFace(Context context) {
        if (typeFace == null) {
            try {
                typeFace = Typeface.createFromAsset(context.getAssets(), "AeroviasBrasilNF.ttf");
            } catch (Exception e) {

Here you can download source code of this sample Android project.

Download it from github


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.