package com.bzh.mysimplefresco;
import android.content.Context;
import android.graphics.Typeface;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;
/**
* ========================================================== <br>
* <b>版权</b>: 别志华 版权所有(c) 2015 <br>
* <b>作者</b>: 别志华 biezhihua@163.com<br>
* <b>创建日期</b>: 15-9-26 <br>
* <b>描述</b>: <br>
* <b>版本</b>: V1.0 <br>
* <b>修订历史</b>: <br>
* ========================================================== <br>
*/
public class FontManager {
public static final String ROOT = "fonts/";
public static final String FONTAWESOME = ROOT + "fontawesome-webfont.ttf";
public static Typeface getTypeface(Context context, String font) {
return Typeface.createFromAsset(context.getAssets(), font);
}
public static void markAsIconContainer(View v, Typeface typeface) {
if (v instanceof ViewGroup) {
ViewGroup vg = (ViewGroup) v;
for (int i = 0; i < vg.getChildCount(); i++) {
View child = vg.getChildAt(i);
markAsIconContainer(child, typeface);
}
} else if (v instanceof TextView) {
((TextView) v).setTypeface(typeface);
}
}
}