Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import android.content.Context;

import android.graphics.Typeface;

public class Main {
    private static Typeface defaultTypeFace;

    public static void setDefaultFont(Context context, String path, String fontName) {
        try {
            defaultTypeFace = Typeface.createFromAsset(context.getAssets(), path + "/" + fontName + ".ttf");
        } catch (RuntimeException e) {
            if (e.getMessage().equals("native typeface cannot be made")) {
                try {
                    throw new Exception("the fontName that you use does not exist in the file path!!");
                } catch (Exception e1) {
                    e1.printStackTrace();
                }
            }
        }
    }
}