Adding Custom Fonts in Android Apps

1 minute read

This is the most important thing in Android development for making UI really beautiful and understandable for user expecially for Persian or arabic language users.

To add a custom font easily, (which I prefer using Calligraphy library). First, paste your font in Assets folder and then, add these dependencies in app Build.gradle:

dependencies {
    implementation 'io.github.inflationx:calligraphy3:3.1.1'
    implementation 'io.github.inflationx:viewpump:1.0.0'

After that, you’ll need to hit sync now from above. After syncing the gradle, create a class called CustomFont with following codes. You might consider adding fonts folder inside /Assets. So -> /Assets/fonts.

Kotlin class:

class CustomFont : Application() {

    override fun onCreate() {

Here I pasted my font (called myFont.ttf) inside /Assets/fonts folder and link it inside setDefaultFontPath double quotation. So, we did the whole thing but, the class is unusable and for preventing that, go to AndroidManifest.xml and inside application tag, link your class in android:name attribute like this:


And that’s it. So for using in each class or Activity you want, the only thing you should do is adding following codes after class - Activity definition:

class MainActivity : AppCompatActivity() {

   override fun attachBaseContext(newBase: Context) {

That’s all of it.