Ali Bdeir
Ali Bdeir

Reputation: 4375

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?

Upvotes: 0

Views: 588

Answers (2)

MEGHA RAMOLIYA
MEGHA RAMOLIYA

Reputation: 1927

 1. Add below code
   ViewPump.init(ViewPump.builder()
                .addInterceptor(new CalligraphyInterceptor(
                        new CalligraphyConfig.Builder()
                                .setDefaultFontPath("fonts/OpenSans-Regular.ttf")
                                .setFontAttrId(androidx.core.R.attr.font)
                                .build()))
                .build());
 2. instead of 

   ViewPump.init(ViewPump.builder()
                .addInterceptor(new CalligraphyInterceptor(
                        new CalligraphyConfig.Builder()
                                .setDefaultFontPath("fonts/OpenSans-Regular.ttf")
                                .setFontAttrId(R.attr.font)

Upvotes: 1

Ugurcan Yildirim
Ugurcan Yildirim

Reputation: 6142

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

Upvotes: 4

Related Questions