Monday, May 27, 2013

Stock font and app exclusive font.

One thing I always see is people referencing font.  I think what some don't realize is that if you don't set your font in your app a run time, it will automatically run as whatever font the user has enabled on their phone.  So, if you built the app in SANS_SERIF and had it looking spectacular, they might see it in MONOSPACE and the experience just wouldn't be the same for them.  Also, I could rarely ever find anything pointing at using the stock font on the device so I'll include it here.  There are more advanced ways to do this via xml files etc, but if you know you want custom font right from the start it is no problem.


/** Depending on the version,
there are a few possibilities for the
stock typeface. A couple being
SANS_SERIF, SERIF, and MONOSPACE. Others
are introduced in later versions **/
Typeface font=Typeface.SANS_SERIF; /**STOCK FONTS**/
//--OR--//
Typeface font = Typeface.createFromAsset(getAssets(),"fonts/customfont.ttf");
/** THIS WOULD BE CALLED FROM A FONTS FOLDER YOU CREATED IN YOUR ASSETS
AND THEN INSERTED YOUR TTF FILE IN IT.**/
// Then you can simply set the typeface in each textView, paint, or button. //
textview.setTypeface(font);
view raw fonts hosted with ❤ by GitHub

As usual thanks for reading and please check out my newest photo editing app for Android called Perspective!!!