Back to project page sms-smap-gateway.
The source code is released under:
GNU General Public License
If you think the Android project sms-smap-gateway 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.android.smap.utils; // w ww . j a v a2 s .co m import java.util.HashMap; import android.content.Context; import android.graphics.Typeface; public class MWAssetsUtils { private static final HashMap<String, Typeface> mCachedFonts = new HashMap<String, Typeface>(); /** * Returns typeface font from assets. If cached returns the cached value, otherwise loads from * assets and caches it. * * @param context * @param fontName * @return */ public static final Typeface getCachedFont(Context context, String fontName) { Typeface tf = null; Context appContext = context.getApplicationContext(); try { // check if the font is cached if (mCachedFonts.containsKey(fontName) && mCachedFonts.get(fontName) != null) { tf = mCachedFonts.get(fontName); } else { // get the font from assets tf = Typeface.createFromAsset(appContext.getAssets(), "fonts/" + fontName); // cache the font mCachedFonts.put(fontName, tf); } } catch (Exception e) { } return tf; } }