Declarative downloadable fonts
Implement support for downloadable font requests in xml. Given the xml fonts feature in O, this adds support to not only declare local font files as font resources, but also Downloadable fonts from a fonts provider. A provider returns a font family (of one or more files) given a query, so the new attributes are added to the font-family tag. Additionally, add support to pre-declare downloadable font resources in the Android Manifest. These will then be fetched at app startup time so they are available to use from the Typeface cache asap. When retrieving downloadable fonts via resources, the cache is checked to see if the font is already there and is used, otherwise a request is sent to the provider and the default font is returned as we need a result synchronously. To do this, the developer declares an additional fonts xml resource file with the list of fonts to preload and links it in the manifest with a meta-data tag. E.g.: res/font/mydownloadedfont.xml <font-family xmlns:android="http://schemas.android.com/apk/res/android" android:fontProviderAuthority="com.example.test.fontprovider" android:fontProviderQuery="myrequestedfont"> </font-family> res/font/preloaded_fonts.xml <?xml version="1.0" encoding="utf-8"?> <font-family xmlns:android="http://schemas.android.com/apk/res/android"> <font android:font="@font/mydownloadedfont" /> </font-family> and in the AndroidManifest.xml <meta-data android:name="preloaded_fonts" android:resource="@font/preloaded_fonts" /> Bug: 34660500, 34658116 Test: WIP, need to add more Change-Id: I1d92555e115e241bf23b59e6f5c6cca6c7361de7
Loading
Please register or sign in to comment