Search code examples
androidfonts

Chrisjenx's Calligraphy library doesn't work


I don't think I really understood the ReadMe well, because I have this in my code:

@Override
public void onCreate() {
    super.onCreate();
    CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
            .setDefaultFontPath("fonts/trado.ttf")
            .setFontAttrId(R.attr.fontPath)
            .build());
}

@Override
protected void attachBaseContext(Context newBase) {
    super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}

And I have trado.ttf in my assets folder. This is in my Application class. This is all I've done, did I miss something?


Solution

    • Override attachBaseContext(...) in your Activity classes.
    • Do initDefault(...) stuff inside Application onCreate().
    • Put trado.ttf inside assets/fonts folder.