Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where should I put the "ttf" files in an Android project?

I'm trying to use fonts in my project using Typeface. I copied the "font.ttf" into a folder named "fonts" inside "assets" folder. But eclipse do not allow to compile it. It shows an error on fonts folder. What should I do?

The error I get is:

invalid resource directory name     fonts   /NoRats/assets  line 1  Android AAPT Problem 
like image 645
dinesh707 Avatar asked Jun 28 '11 12:06

dinesh707


People also ask

Where is the TTF file located?

TTF files are stored in the \WINDOWS\SYSTEM or \WINDOWS\FONTS folders. For example, the following files make up the Arial typeface.

Does TTF work on Android?

Not all TTF files will work with Android, but the vast majority should. A file browser — We used Solid Explorer for this tutorial, but any file browser should get the job done without much hassle.

What do I do with a TTF file?

You can open a TTF file in Microsoft Windows Font Viewer (Windows), Apple Font Book (Mac), or iFont (iOS, Android). Before opening a TTF file in Windows Font Viewer, you must place the file in the C:/​Windows/​Fonts directory. Otherwise, Windows will not recognize the file as a valid font file.


1 Answers

Please check this link, it may be helpful to you.


OR


use below code.

Typeface tf = Typeface.createFromAsset(this.getAssets(),"fonts/LATINWD.TTF"); txt1.setTypeface(tf); 

.ttf file is in --> assets/fonts/LATINWD.TTF

Please first clean your project then check again.

Happy Coding.

like image 69
Nikhil Avatar answered Oct 02 '22 08:10

Nikhil