Android Open Source - CardView Typeface Util






From Project

Back to project page CardView.

License

The source code is released under:

Apache License

If you think the Android project CardView listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package br.com.zynger.cardview;
/*ww w .  j  av a  2  s.c  o m*/
import android.content.Context;
import android.graphics.Typeface;

public class TypefaceUtil {
  private static TypefaceUtil instance;
  private Typeface mVeraMonoBold;
  private Typeface mVeraMonoBoldItalic;
  private Typeface mLiberationSans;
  
  public TypefaceUtil(Context context) {
    mVeraMonoBold = loadTypeface(context, "VeraMoBd.ttf");
    mVeraMonoBoldItalic = loadTypeface(context, "VeraMoBI.ttf");
    mLiberationSans = loadTypeface(context, "liberation-sans.ttf");
  }
  
  private Typeface loadTypeface(Context context, String name) {
    try {
      return Typeface.createFromAsset(context.getResources().getAssets(), name);
    } catch (RuntimeException e) {
      throw new MissingTypefaceException("Typeface " + name + " not found in your assets folder. Did you forget to add it?");
    }
  }
  
  public static TypefaceUtil getInstance(Context context) {
    if (instance == null) {
      instance = new TypefaceUtil(context);
    }
    return instance;
  }
  
  public Typeface getVeraMonoBold() {
    return mVeraMonoBold;
  }
  
  public Typeface getVeraMonoBoldItalic() {
    return mVeraMonoBoldItalic;
  }
  
  public Typeface getLiberationSans() {
    return mLiberationSans;
  }
}




Java Source Code List

br.com.zynger.cardview.CardBackFaceView.java
br.com.zynger.cardview.CardFaceView.java
br.com.zynger.cardview.CardFrontFaceView.java
br.com.zynger.cardview.CardView.java
br.com.zynger.cardview.MissingTypefaceException.java
br.com.zynger.cardview.TypefaceUtil.java