Created
November 4, 2016 16:55
-
-
Save raviyadav4875/503b40024882539b2da74faf73c24bef to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TypeFaceProvider { | |
public static final String TYPEFACE_FOLDER = "fonts"; | |
public static final String TYPEFACE_EXTENSION = ".ttf"; | |
private static Hashtable<String, Typeface> sTypeFaces = new Hashtable<String, Typeface>( | |
2); | |
public static Typeface getTypeFace(Context context, String fileName) { | |
Typeface tempTypeface = sTypeFaces.get(fileName); | |
if (tempTypeface == null) { | |
String fontPath = new StringBuilder(TYPEFACE_FOLDER).append('/').append(fileName).append(TYPEFACE_EXTENSION).toString(); | |
tempTypeface = Typeface.createFromAsset(context.getAssets(), fontPath); | |
sTypeFaces.put(fileName, tempTypeface); | |
} | |
return tempTypeface; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment