Thursday, November 28, 2013

Importing a new font in Windows 7 and/or Android

For Android programming, see below the ***** line...
But as I was on this, I decided to check how to do it for Windows 7 :). These are the steps:
  1. Download the font file (extension ttf). There are several free sites. Check in case they are not completely free (donation, or shareware, or...). This is a site I used.
  2. For the next step, folks say to make sure that all your office programs (Outlook, Word, etc...) are closed.
  3. If the file is zip, unzip it (duh!), and then right click on the file and select Open with - Windows Font Viewer. You will see the fonts and on top, the Install button.
  4. Done! You should now be able to see them in your Font menus, in Office.
**********************************
For Android programming:
  1. Download the font file (extension ttf). There are several free sites. Check in case they are not completely free (donation, or shareware, or...). This is a site I used.
  2. If the file is zip, unzip it (duh!), and then place it in the assests directory of your project.
  3. Then use something like the following (basically extracted from this post in StackOverflow):
 protected void onCreate(Bundle savedInstanceState) {  
           super.onCreate(savedInstanceState);  
           setContentView(R.layout.activity_main);       
           mdisplay = (TextView) findViewById(R.id.textView1);  
           try{  
                Typeface myTypeface = Typeface.createFromAsset(this.getAssets(),"wwDigital.ttf");  
                mdisplay.setTypeface(myTypeface);  
           }  
           catch (IllegalStateException e){  
                System.out.println("This didn't work very well");  
                return;  
           }  
           mdisplay.setTextSize(50);  
           mdisplay.setTextColor(Color.RED);  
      }  

Good luck!

PS.: Please, click here to see an index of other posts on Android. 

No comments:

Post a Comment