Tutorial - How to make Downloadable Fonts with Android Support Library

in #utopian-io7 years ago

Downloadable Fonts

In last Google I/0 2017 Google announced API which allow programers create app that allows request fonts from the application, instead attaching them inside APK. It is possible from Android 4.0 and higher. We have more than 850 different fonts available in google fonts which we can use.

Advantages:

  • fonts are shared across multiple applications so it improves the overall health of the system.
  • reduce size of APK

Lets do it!

First of all we have add API support Library 26 or newer one.

implementation 'com.android.support:appcompat-v7:26.1.0'

Example layout:

image.png

Downloadable fonts via XML

Layout Editor -> TextView -> Properties -> fontFamily -> more Fonts

image.png

image.png

After that we shoud have 3 more files:

  • res/values/font_certs.xml

    image.png

  • res/values/preloaded_fonts.xml

    image.png

  • res/font/selected_font_name.xml
    image.png

Setting our font in XML

image.png

image.png

Downloadable fonts in entive application

image.png

We need to make sure that our AppTheme style is set to application inside

image.png

GitHub link: https://github.com/babelek/downloadableFont



Posted on Utopian.io - Rewarding Open Source Contributors

Sort:  

Your contribution cannot be approved because it does not refer to or relate to an open-source repository. See here for a definition of "open-source."

You can contact us on Discord.
[utopian-moderator]

Coin Marketplace

STEEM 0.19
TRX 0.13
JST 0.030
BTC 63595.77
ETH 3415.98
USDT 1.00
SBD 2.49