Updated 14 December 2016
Why Android ? Why, No support to custom font till date !
Android do not provide us support to change font family of the complete application. We are more or less become dependent on custom view as described in my earlier blog on change-font-of-the-application.
But fortunately (thanks to chrisopher jerkins) for creating a wonderfull library chrisjenx/Calligraphy.
In this blog we are going to add new font in our application.
Let’s get Started:
Add Dependency in our application gradle:
1 |
compile 'uk.co.chrisjenx:calligraphy:2.0.0' |
Set the path of custom font:
Create our own Application Class:
1 2 3 4 5 6 7 |
public class MyApp extends Application { @Override public void onCreate() { super.onCreate(); CalligraphyConfig.initDefault(new CalligraphyConfig.Builder().setDefaultFontPath("fonts/AlexBrush-Regular.ttf").build()); } } |
Override the context used by each activity where we want to apply custom font:
1 2 3 4 |
@Override protected void attachBaseContext(Context newBase) { super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase)); } |
Don’t forget to update the Android Manifest:
1 2 3 4 5 6 7 8 |
<application android:name=".MobikulApplication" ... > ... activities , services defined here ... </application> |
Here are the results:
If you have more details or questions, you can reply to the received confirmation email.
Back to Home
Be the first to comment.