From d75dc81c0d9e10175322a8ef59e8f25a40ef8276 Mon Sep 17 00:00:00 2001 From: Andrew Dolgov Date: Sat, 25 Jan 2014 21:34:50 +0400 Subject: add option for condensed fonts --- src/org/fox/ttrss/util/TypefaceCache.java | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 src/org/fox/ttrss/util/TypefaceCache.java (limited to 'src/org/fox/ttrss/util') 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 cache = new Hashtable(); + + 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 -- cgit v1.2.3-54-g00ecf