0

I'm trying to change the font from a specific EditText in the MainActivity, but I'm getting the following error :

java.lang.RuntimeException: Font asset not found font/af.ttf

the code :

val texto: EditText = findViewById(R.id.texto)
        var face = Typeface.createFromAsset(assets, "font/af.ttf")
        texto.typeface = face

How do I solve this?

* the font is in a folder called font in the res folder. *

ArthurOgg
  • 23
  • 4
  • 2
    That's not an asset, it's a resource. An asset is in your assets folder. Does this answer your question? [create typeface from font resource id](https://stackoverflow.com/questions/48688026/create-typeface-from-font-resource-id) – Nicolas May 27 '20 at 22:55

1 Answers1

2

You should move your fonts to the assets directory

From the docs

   /**
     * @param mgr  The application's asset manager
     * @param path The file name of the font data in the assets directory
     * @return The new typeface.
     */
    public static Typeface createFromAsset(AssetManager mgr, String path)

enter image description here

Beyazid
  • 1,795
  • 1
  • 15
  • 28