7

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

user345602
  • 578
  • 1
  • 12
  • 26
  • 3
    You may want to consider that commercial fonts probably require a license before embedding them in your own app. – sstn May 26 '11 at 12:40

3 Answers3

35

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

the100rabh
  • 4,077
  • 4
  • 32
  • 40
12
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.

ios developer
  • 923
  • 2
  • 12
  • 19
6

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

Yann Ramin
  • 32,895
  • 3
  • 59
  • 82