load Typeface - Android Graphics

Android examples for Graphics:Font

Description

load Typeface

Demo Code


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

import java.util.HashMap;
import java.util.Map;

public class Main {
    private static final Map<String, Typeface> sTypefaceCache = new HashMap<String, Typeface>();

    private static Typeface loadTypeface(Context c, String filepath) {
        Typeface tf = sTypefaceCache.get(filepath);
        if (tf == null) {
            tf = Typeface.createFromAsset(c.getAssets(), filepath);
            sTypefaceCache.put(filepath, tf);
        }/*from   w  ww. j ava  2 s. c o m*/
        return tf;
    }
}

Related Tutorials