import android.content.Context; import android.graphics.Typeface; import android.widget.TextView; /** * @author yuyh. * @date 2016/11/10. */ public class MDFontsUtils { public static Typeface OCTICONS; /** * Get octicons typeface * * @param context * @return octicons typeface */ public static Typeface getOcticons(final Context context) { if (OCTICONS == null) OCTICONS = getTypeface(context, "fonts/icomoon.ttf"); return OCTICONS; } /** * Set octicons typeface on given text view(s) * * @param textViews */ public static void setOcticons(final TextView... textViews) { if (textViews == null || textViews.length == 0) return; Typeface typeface = getOcticons(textViews[0].getContext()); for (TextView textView : textViews) textView.setTypeface(typeface); } /** * Get typeface with name * * @param context * @param name * @return typeface */ public static Typeface getTypeface(final Context context, final String name) { return Typeface.createFromAsset(context.getAssets(), name); } }
-
1
-
2
-
3
-
4
-
5
-
6
-
7
-
8
-
9
-
10
-
11
-
12
-
13
-
14
-
15
-
16
-
17
-
18
-
19