7
votes

How to add additional font in android environment? I need to make a font like LCD with pale background numbers like this:

http://www.androidfreeware.net/img2/gps_speedometer_android_1.png

3
You may want to consider that commercial fonts probably require a license before embedding them in your own app. - sstn

3 Answers

35
votes

We at bangalore android developers group had done this for one of our project AutoMeter You can have a look at the code there in detail.

The code would look something like this

Typeface myTypeface = Typeface.createFromAsset(this.getAssets(),"DS-DIGIB.TTF");
waitingTimeView = (TextView) findViewById(R.id.WaitingTime);
waitingTimeView.setTypeface(myTypeface);

DS-DIGIB.TTF is the font put in the assets folder

12
votes
public void setFontTextView(Context c, TextView name) {
Typeface font = Typeface.createFromAsset(c.getAssets(),"fonts/Arial.ttf");
name.setTypeface(font);
}

Download Arial font in ttf file formate and put in asset folder. Thats enough.

6
votes

You want to use the android.graphics.Typeface class, which can create new Typefaces from assets or files.