Example usage for android.graphics Typeface createFromAsset

List of usage examples for android.graphics Typeface createFromAsset

Introduction

In this page you can find the example usage for android.graphics Typeface createFromAsset.

Prototype

public static Typeface createFromAsset(AssetManager mgr, String path) 

Source Link

Document

Create a new typeface from the specified font data.

Usage

From source file:Main.java

public static Typeface getTypeface(Context context) {
    if (tfTextView == null) {
        tfTextView = Typeface.createFromAsset(context.getAssets(), "fonts/times.ttf");
    }/*w  w  w. j  a  v a  2  s.  com*/
    return tfTextView;
}

From source file:Main.java

public static Typeface getRobotoRegular(Context context) {
    if (mRobotoReg == null) {
        mRobotoReg = Typeface.createFromAsset(context.getAssets(), "Roboto-Regular.ttf");
    }//from w ww. j  ava  2  s.c  o  m
    return mRobotoReg;
}

From source file:Main.java

public static void setFontOnView(AssetManager assets, TextView textView, String fontPath) {
    Typeface quicksandBold = Typeface.createFromAsset(assets, fontPath);
    textView.setTypeface(quicksandBold);
}

From source file:Main.java

public static void generateTypeface(Context context) {
    arabicTypeFace = Typeface.createFromAsset(context.getAssets(), "fonts/app_font.ttf");
}

From source file:Main.java

public static Typeface getTypeface53(Context context) {

    if (appTypeface53 == null) {
        appTypeface53 = Typeface.createFromAsset(context.getAssets(), "fonts/en53.otf");
    }// w  ww . j  a v a 2s .  c o  m
    return appTypeface53;
}

From source file:Main.java

public static Typeface getTypeface35(Context context) {

    if (appTypeface35 == null) {
        appTypeface35 = Typeface.createFromAsset(context.getAssets(), "fonts/en35.otf");
    }/*from  w  w  w. ja v a 2  s. co  m*/
    return appTypeface35;
}

From source file:Main.java

public static void setDefaultFont(Context context, String path, String fontName) {
    try {//from   w  ww .  j a  v a  2  s.  co m
        defaultTypeFace = Typeface.createFromAsset(context.getAssets(), path + "/" + fontName + ".ttf");
    } catch (RuntimeException e) {
        if (e.getMessage().equals("native typeface cannot be made")) {
            try {
                throw new Exception("the fontName that you use does not exist in the file path!!");
            } catch (Exception e1) {
                e1.printStackTrace();
            }
        }
    }
}

From source file:Main.java

public final static Typeface getOogie(Context ctx) {
    if (oogie == null)
        oogie = Typeface.createFromAsset(ctx.getAssets(), "fonts/OogieBoogie.ttf");
    return oogie;
}

From source file:Main.java

public static Typeface getTypface(@Nullable String font_name, Context mContext) {
    if (font_name == null)
        return Typeface.DEFAULT;
    return Typeface.createFromAsset(mContext.getAssets(), "fonts/" + font_name);
}

From source file:Main.java

public static void setFont(Context context, View view) {
    ((TextView) view).setTypeface(Typeface.createFromAsset(context.getAssets(), "font/"));
}