Android examples for Graphics:Font
set EditText Font
//package com.java2s; import android.content.Context; import android.graphics.Typeface; import android.support.v4.util.SimpleArrayMap; import android.widget.EditText; public class Main { private static SimpleArrayMap<String, Typeface> fonts = new SimpleArrayMap<>(); public static void setEditTextFont(EditText view, String fontName) { Typeface typeface = getTypeface(view.getContext(), fontName); view.setTypeface(typeface);/*from ww w . j a v a 2s .co m*/ } public static Typeface getTypeface(Context context, String fontName) { synchronized (fonts) { Typeface typeface = fonts.get(fontName); if (typeface == null) { typeface = createFromAssets(context, fontName); fonts.put(fontName, typeface); } return typeface; } } private static Typeface createFromAssets(Context context, String fontName) { Typeface font = Typeface.createFromAsset(context.getAssets(), fontName); return font; } }