Skip to content
No description, website, or topics provided.
Branch: master
Clone or download
Latest commit 38344a9 Feb 16, 2018
Type Name Latest commit message Commit time
Failed to load latest commit information.
.google Auto-update Oct 11, 2017
gradle/wrapper Auto-update Feb 16, 2018
kotlinApp Auto-update Feb 16, 2018
screenshots Auto-update May 17, 2017 Auto-update May 17, 2017
LICENSE Auto-update Feb 16, 2018
NOTICE Auto-update Feb 16, 2018 Auto-update Feb 16, 2018
build.gradle Auto-update Feb 16, 2018
gradlew Auto-update May 17, 2017
gradlew.bat Auto-update May 17, 2017
settings.gradle Auto-update May 17, 2017

Android DownloadableFonts Sample

This sample demonstrates how to use the Downloadable Fonts feature introduced in Android O. Downloadable Fonts is a feature that allows apps to request a certain font from a provider instead of bundling it or downloading it themselves. This means, there is no need to bundle the font as an asset.


There are two ways of requesting a font to download. To request a font to download from Java code, you need to create a FontRequest class first like this:

FontRequest request = new FontRequest(
    "", // ProviderAuthority
    "",  // ProviderPackage
    query,  // Query
    R.array.com_google_android_gms_fonts_certs); // Certificates

The parameters ProviderAuthority, ProviderPackage are given by a font provider, in the case above uses Google Play Services as a font provider. The third parameter is a query string about the requested font. The syntax of the query is defined by the font provider.

Then pass the request instance to the requestFont method in the FontsContractCompat.

FontsContractCompat.requestFont(context, request, callback, handler);

The downloaded font or an error code if the request failed will be passed to the callback. The example above assumes you are using the classes from the support library. There are corresponding classes in the framework, but the feature is available back to API level 14 if you use the support library.

You can declare a downloaded font in an XML file and let the system download it for you and use it in layouts.

<font-family xmlns:app=""
        app:fontProviderQuery="Lobster Two"

By defining the requested font in an XML file and putting the preloaded_fonts array and the meta-data tag in the AndroidManifest, you can avoid the delay until the font is downloaded by the first attempt.

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


  • Android SDK 27
  • Android Build Tools v27.0.2
  • Android Support Repository



Getting Started

This sample uses the Gradle build system. To build this project, use the "gradlew build" command or use "Import Project" in Android Studio.


If you've found an error in this sample, please file an issue:

Patches are encouraged, and may be submitted by forking this project and submitting a pull request through GitHub. Please see for more details.


Copyright 2017 The Android Open Source Project, Inc.

Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

You can’t perform that action at this time.