Here is my code and screenshot I'm trying to set custom font typeface but Runtime exception occurs font asset not found while font file is in asset folder. Am I missing something ?
Typeface font = Typeface.createFromAsset(getAssets(), "font/terminal.ttf");
((TextView) findViewById(R.id.weatherHeadingTV)).setTypeface(font);
Use this method :
final Typeface typeface = ResourcesCompat.getFont(context, R.font.X);
ResourcesCompat
class is a compatible way to retrieve your resources.
the folder name has to be 'fonts' not 'font'
Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/" + font);
Your font asset folder is named incorrectly. You should name the folder as fonts
not as font
. Also change your code:
Typeface font = Typeface.createFromAsset(getAssets(), "fonts/terminal.ttf");
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