kotlin-toolkit icon indicating copy to clipboard operation
kotlin-toolkit copied to clipboard

Consider using Android downloadable fonts APIs

Open JayPanoz opened this issue 7 years ago • 3 comments

The fonts we offer in the typeface picker (user settings) are currently retrieved using the Google Fonts’ <script> method. It would be a lot better to use the new APIs to request fonts from Google Fonts, see Downloadable Fonts.

Since multiple APKs can share the same font through a provider, it means that if another app has already cached some fonts, it will also be available to us – and they doesn’t need to be downloaded.

Compat: The feature is available on devices running Android API versions 14 and higher through the Support Library 26. That should be compatible back to Android 4.0?

For reference, here are the libre/open fonts recommended in ReadiumCSS, most of which being available on Google Fonts.

Extra complexity may arise when dealing with i18n, as we’ll need to download extra CJK or Indic fonts for instance.

JayPanoz avatar Apr 27 '18 08:04 JayPanoz

Also, as a clarification we’ll do need to download:

  • Regular, Bold, Italic, and Bold Italic for Latin fonts;
  • Regular and Bold for Indic, CJK, Hebrew and Arabic.

Or else we’re breaking authors’ expectations

JayPanoz avatar Apr 27 '18 08:04 JayPanoz

Note that GDPR compliance is kinda obscure right now: https://github.com/google/fonts/issues/1495 (also impacts the Android APIs).

JayPanoz avatar May 26 '18 09:05 JayPanoz

After some work on it, it appears that the new Downloadable Fonts API works well, but this returns a Typeface object, which should be used to set the fontfamily of objects such as TextViews, etc.

The way we use now for google fonts seems to be the almost only one solution, the other being to download the fonts as ttf files, like the others classic fonts

clementbmn avatar Jun 18 '18 12:06 clementbmn