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
TTF files are stored in the \WINDOWS\SYSTEM or \WINDOWS\FONTS folders. For example, the following files make up the Arial typeface.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With