Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use external fonts in android

I want to use external fonts in my app. I have tried adding new fonts using AssetManager but it did not work. Below is my code:

Typeface face;  face = Typeface.createFromAsset(getAssets(), "font.otf");  textview.setTypeface(face); 

but its not showing the text...

Please help me with this.

like image 319
mudit Avatar asked Sep 15 '09 09:09

mudit


People also ask

How do I create a TTF file on Android?

Once you download the fonts of your choice, unzip the folder and copy the font file. By creating a new Android resource directory: Step 1: In the project's resource folder, create a new Android Resource Directory of Resource type: font and paste this 'ttf' file here.

How do I use OTF files on Android?

To change font styles in GO Launcher, copy the TTF or OTF font files on your phone. Long press on the home screen and select GO Settings > Font > Select Font. Pick the font you want or tap Scan to add files stored on your device. This won't be a system-wide change but will include the menus and app icons.


1 Answers

AFAIK, Android does not support OpenType. Use a TrueType font instead.


UPDATE: Apparently OpenType is now supported, at least somewhat. It was not supported originally, so you will want to test your font thoroughly on whatever versions of Android your app will support.

like image 161
CommonsWare Avatar answered Sep 29 '22 23:09

CommonsWare