Created
March 20, 2019 18:31
-
-
Save ahmedyehya92/6006f637045ebed53bb15e69e70b4e6b to your computer and use it in GitHub Desktop.
FontCache
This file contains hidden or 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 FontCache { | |
private static Map<String, Typeface> sCachedFonts = new HashMap<String, Typeface>(); | |
public static Typeface getTypeface(String assetPath, Context context ) { | |
if (!sCachedFonts.containsKey(assetPath)) { | |
Typeface tf = Typeface.createFromAsset(context.getAssets(), assetPath); | |
sCachedFonts.put(assetPath, tf); | |
} | |
return sCachedFonts.get(assetPath); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment