Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

When exactly are "preloaded fonts" loaded on Android?

When I use the Downloadable Fonts feature on Android, I can add a preloading strategy by adding this code to AndroidManifest.xml:

<meta-data android:name="preloaded_fonts" 
           android:resource="@array/preloaded_fonts" />

When exactly is this loaded? On app startup? On installation? If it's on app startup, and I am using the font on the very first screen, is there any performance difference at all?

like image 570
Florian Walther Avatar asked Nov 06 '22 14:11

Florian Walther


1 Answers

https://developer.android.com/guide/topics/ui/look-and-feel/downloadable-fonts#predeclaring-fonts

Layout inflation and resource retrieval are synchronous tasks. By default, the first attempt to retrieve fonts triggers a request to the font provider, and therefore increases the first layout time. To avoid the delay, you can pre-declare fonts that need retrieving in your manifest. After the system retrieves the font from the provider, it is available immediately. If the font retrieval takes longer than expected, the system aborts the fetching process and uses the default font.

like image 147
norbDEV Avatar answered Nov 15 '22 06:11

norbDEV