Skip to content

Instantly share code, notes, and snippets.

@nealsanche
Created November 20, 2013 05:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nealsanche/7558253 to your computer and use it in GitHub Desktop.
Save nealsanche/7558253 to your computer and use it in GitHub Desktop.
A text view that loads a particular font at runtime.
package com.robotsandpencils.wclclottery.controls;
import android.content.Context;
import android.graphics.Typeface;
import android.util.AttributeSet;
import android.widget.TextView;
/**
* A textview that will show using Helvetica Neu
* Created by neal on 11/18/2013.
*/
public class NeuTextView extends TextView {
public NeuTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
init();
}
public NeuTextView(Context context, AttributeSet attrs) {
super(context, attrs);
init();
}
public NeuTextView(Context context) {
super(context);
init();
}
private void init() {
if (isInEditMode()) return;
Typeface tf = Typeface.createFromAsset(getContext().getAssets(),
"fonts/HelveticaNeueLTStd-BlkCnO.otf");
setTypeface(tf);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment