diff options
| author | Andrew Dolgov <fox@fakecake.org> | 2014-01-25 21:34:50 +0400 |
|---|---|---|
| committer | Andrew Dolgov <fox@fakecake.org> | 2014-01-25 21:34:50 +0400 |
| commit | d75dc81c0d9e10175322a8ef59e8f25a40ef8276 (patch) | |
| tree | 563af0d54b05d905e9950ff6dfaad4c90fe9f205 /src/org/fox/ttrss/util | |
| parent | 86daa8ee53aa638de3643d587660ae9b7804d345 (diff) | |
add option for condensed fonts
Diffstat (limited to 'src/org/fox/ttrss/util')
| -rw-r--r-- | src/org/fox/ttrss/util/TypefaceCache.java | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/org/fox/ttrss/util/TypefaceCache.java b/src/org/fox/ttrss/util/TypefaceCache.java new file mode 100644 index 00000000..150d3d83 --- /dev/null +++ b/src/org/fox/ttrss/util/TypefaceCache.java @@ -0,0 +1,29 @@ +package org.fox.ttrss.util;
+
+import java.util.Hashtable;
+
+import android.content.Context;
+import android.graphics.Typeface;
+import android.util.Log;
+
+public class TypefaceCache {
+ private static final String TAG = "TypefaceCache";
+ private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();
+
+ public static Typeface get(Context c, String typefaceName, int style) {
+ synchronized (cache) {
+ String key = typefaceName + ":" + style;
+
+ if (!cache.containsKey(key)) {
+ try {
+ Typeface t = Typeface.create(typefaceName, style);
+ cache.put(key, t);
+ } catch (Exception e) {
+ Log.e(TAG, "Could not get typeface '" + typefaceName + "' because " + e.getMessage());
+ return null;
+ }
+ }
+ return cache.get(key);
+ }
+ }
+}
\ No newline at end of file |