How to change fonts on Android

Asked 2 years ago, Updated 2 years ago, 20 views

I'm developing an Android app. I already have a font file, but I want to change the font to this font file. What should I do?

android

2022-09-21 16:21

1 Answers

Changing fonts on Android takes a lot of work. Therefore, I would like to recommend related open source.

https://github.com/tsengvn/Typekit It's an open source called Typekit.

In Build.gradle, Please add compile 'com.tsengvn:Typekit:1.0.0' only.

In the application class,

Typekit.getInstance()
        .addNormal(Typekit.createFromAsset(this, "fonts/NanumBarunGothic-Regular.otf"))
        .addBold(Typekit.createFromAsset(this, "fonts/NanumBarunGothic-Bold.otf"));

write like this. Please put the second parameter to the font you want.

And for each activity,

@Override
protected void attachBaseContext(Context newBase) {

super.attachBaseContext(TypekitContextWrapper.wrap(newBase));

}

You can override this method.


2022-09-21 16:21

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.