blob: e2271bd5ff56b19b239a31104b2833b27d518407 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
package com.mapbox.mapboxsdk.testapp.utils;
import android.content.Context;
import android.graphics.Typeface;
import timber.log.Timber;
import java.util.Hashtable;
public class FontCache {
private static Hashtable<String, Typeface> fontCache = new Hashtable<>();
public static Typeface get(String name, Context context) {
Typeface tf = fontCache.get(name);
if (tf == null) {
try {
tf = Typeface.createFromAsset(context.getAssets(), name);
fontCache.put(name, tf);
} catch (Exception exception) {
Timber.e("Font not found");
}
}
return tf;
}
}
|