Android examples for Graphics:Font
get Font from ttf file
//package com.java2s; import android.content.Context; import android.graphics.Typeface; public class Main { public static final String NanumGothic = "NanumGothic.ttf"; public static final String NanumGothicBold = "NanumGothicBold.ttf"; public static final String NanumGothicExtraBold = "NanumGothicExtraBold.ttf"; private static Typeface nanumGothic = null; private static Typeface nanumGothicBold = null; private static Typeface nanumGothicExtraBold = null; public static Typeface getFont(Context context, final String font) { if (font.equals(NanumGothic)) { if (nanumGothic == null) nanumGothic = Typeface.createFromAsset(context.getAssets(), NanumGothic);/*from w ww . j av a 2 s . co m*/ return nanumGothic; } else if (font.equals(NanumGothicBold)) { if (nanumGothicBold == null) nanumGothicBold = Typeface.createFromAsset( context.getAssets(), NanumGothicBold); return nanumGothicBold; } else if (font.equals(NanumGothicExtraBold)) { if (nanumGothicExtraBold == null) nanumGothicBold = Typeface.createFromAsset( context.getAssets(), NanumGothicExtraBold); return nanumGothicExtraBold; } else return null; } }