Reputation: 6011
I have set the default font of my application class in the onCreate()
method as detailed in the doc of Calligraphy:
CalligraphyConfig.initDefault(new CalligraphyConfig.
.setDefaultFontPath("fonts/MetaOT-Medi.otf")
.setFontAttrId(R.attr.fontPath)
.addCustomViewWithSetTypeface(CustomViewWithTypefaceSupport.class)
.addCustomStyle(TextField.class, R.attr.textFieldStyle)
.build()
);
I have got a TextView and would like it to fallback using default system font (e.g. Roboto). May I know how to do it?
Now I circumvent this by copying a set of Roboto font to my assets/fonts folder and then for those TextView I would like to fallback, override the fonts to use it in the xml like fontPath="fonts/Roboto-Regular.ttf"
. Or is there a better solution beside this?
Upvotes: 2
Views: 351
Reputation: 6855
Yes it is possible, which font do you wan to set to which TextView
you can set it in XML or pragmatically.
fontPath="fonts/Roboto-Regular.ttf"
XML Sample Code
<TextView
android:id="@+id/tv_name"
fontPath="fonts/Roboto-Regular.ttf"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
/>
pragmatically Sample code
Typeface tf = Typeface.createFromAsset(context.getAssets(), "fonts/Roboto-Regular.ttf");
setTypeFace(view, tf);
Upvotes: 1