I did used uk.co.chrisjenx:calligraphy
dependency to use fonts from asset folder, however default font is not applied to my application. I followed the guideline used in other stackoverflow question but they did not work and all solutions used same syntax I used below.
Here is my application and path to font is correct since it works using XML fontpath
property;
public class App extends MultiDexApplication {
private static volatile Context instance;
public static Context get() {
return instance;
}
private static App enableMultiDex;
public static Context context;
public App(){
enableMultiDex=this;
}
public static App getEnableMultiDexApp() {
return enableMultiDex;
}
@Override
public void onCreate() {
super.onCreate();
context = getApplicationContext();
instance = getApplicationContext();
Thread.setDefaultUncaughtExceptionHandler(new ExceptionHandler(this));
CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
.setDefaultFontPath("fonts/mobilefont.ttf")
.setFontAttrId(R.attr.fontPath)
.build());
}
}
Wrap the Activity Context:
@Override
protected void attachBaseContext(Context newBase) {
super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
}