-
Notifications
You must be signed in to change notification settings - Fork 4
Font (typeface) management
ViewBinder has an integrated FontManager that enables you to use custom typefaces in your views. Here's a quick guide:
-
Put your font files into the
assetsfolder. -
When instantiating
ViewBinder, register the default font:mViewBinder.getFontManager().setDefaultFont(Typeface.createFromAsset(getAssets(), "Roboto-Regular.ttf")); -
Also when instantiating
ViewBinder, register all the other fonts that you want to use, with their keywords:mViewBinder.getFontManager().registerFont("light", Typeface.createFromAsset(getAssets(), "Roboto-Light.ttf")); -
in the layout XML file, use the
ToFontconverter to bind the font to the Typeface property:{ Typeface @- ToFont(this, 'bold') }or, for the default font{ Typeface @- ToFont(this) }. If you mistype the font keyword, it will use the default font. If there's noTypefaceproperty binding, it will behave as a regular widget and use the system font.
Also, take a look at the example code.