Back to project page ProgressTextView.
The source code is released under:
Apache License
If you think the Android project ProgressTextView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.github.yaming.progresstextview; // ww w. j a va 2 s .co m import java.util.HashMap; import java.util.Map; import android.content.Context; import android.graphics.Typeface; import android.util.Log; public class TypefaceManager { private static final String TAG = "TypefaceManager"; public static Map<String, Typeface> typefaces = new HashMap<String, Typeface>(); public static Typeface getTypeface(Context context, String font) { if (typefaces.containsKey(font)) return typefaces.get(font); else return loadTypeface(context, font); } private static synchronized Typeface loadTypeface(Context context, String font) { if (typefaces.containsKey(font)) { return typefaces.get(font); } Typeface typeface = null; try { String path = "fonts/" + font; typeface = Typeface.createFromAsset(context.getAssets(), path); } catch (RuntimeException e) { Log.e(TAG, "Failed to load typeface."); } // Even if we failed, store the result to prevent Android trying // repeatedly typefaces.put(font, typeface); return typeface; } }