Here you can find the source of getTypeface(Context context, String name)
public static Typeface getTypeface(Context context, String name)
//package com.java2s; import java.util.HashMap; import android.content.Context; import android.graphics.Typeface; import android.util.Log; public class Main { private static final String TAG = "NiftyTypefaceHelper"; private static final HashMap<String, Typeface> TYPEFACE_CACHE = new HashMap<String, Typeface>(); /** Retrieve a type-face. Does not load twice, uses lazy loading. */ public static Typeface getTypeface(Context context, String name) { // ensure the global context is used. just in case. context = context.getApplicationContext(); Log.d(TAG, "name=" + name); if (TYPEFACE_CACHE.containsKey(name)) { return TYPEFACE_CACHE.get(name); }//from ww w . j a va 2 s. c om Typeface typeface = Typeface.createFromAsset(context.getAssets(), name); if (typeface != null) { TYPEFACE_CACHE.put(name, typeface); } return typeface; } }