Skip to content

Instantly share code, notes, and snippets.

@abbas-oveissi
Created March 19, 2016 18:32
Show Gist options
  • Save abbas-oveissi/2c8193cc562292d4fb84 to your computer and use it in GitHub Desktop.
Save abbas-oveissi/2c8193cc562292d4fb84 to your computer and use it in GitHub Desktop.
public class FontHelper {
private static final Map<String, Typeface> TYPEFACES = new HashMap<>();
public static Typeface get(Context context,String fontFileName){
Typeface typeface = TYPEFACES.get(fontFileName);
if(typeface == null){
typeface = Typeface.createFromAsset(context.getResources().getAssets(), fontFileName);
TYPEFACES.put(fontFileName, typeface);
}
return typeface;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment