Java tutorial
//package com.java2s; import android.content.Context; import android.graphics.Typeface; public class Main { private static Typeface appTypefaceZh; private static Typeface appTypefaceEn; private static Typeface appTypeface33; private static Typeface appTypeface35; private static Typeface appTypeface53; public static Typeface getTypeface(Context context, String type) { if (type == null) { return getDefaultTypeface(context); } else if (type.equals("zh")) { return getTypefaceZh(context); } else if (type.equals("en")) { return getTypefaceEn(context); } else if (type.equals("en53")) { return getTypeface53(context); } else if (type.equals("en35")) { return getTypeface35(context); } else if (type.equals("en33")) { return getTypeface33(context); } else { return getDefaultTypeface(context); } } public static Typeface getDefaultTypeface(Context context) { //String lcal = Util.getLocalLanguage(context); // if("en".equals(lcal)){ // return getTypefaceEn(context); // }else{ // return getTypefaceZh(context); // } return getTypefaceZh(context); } public static Typeface getTypefaceZh(Context context) { if (appTypefaceZh == null) { appTypefaceZh = Typeface.createFromAsset(context.getAssets(), "fonts/en53.otf"); ;//Typeface.createFromAsset (context.getAssets() , "fonts/zh.otf"); } return appTypefaceZh; } public static Typeface getTypefaceEn(Context context) { if (appTypefaceEn == null) { appTypefaceEn = Typeface.createFromAsset(context.getAssets(), "fonts/en_arial.ttf"); } return appTypefaceEn; } public static Typeface getTypeface53(Context context) { if (appTypeface53 == null) { appTypeface53 = Typeface.createFromAsset(context.getAssets(), "fonts/en53.otf"); } return appTypeface53; } public static Typeface getTypeface35(Context context) { if (appTypeface35 == null) { appTypeface35 = Typeface.createFromAsset(context.getAssets(), "fonts/en35.otf"); } return appTypeface35; } public static Typeface getTypeface33(Context context) { if (appTypeface33 == null) { appTypeface33 = Typeface.createFromAsset(context.getAssets(), "fonts/en33.otf"); } return appTypeface33; } }