Adding Custom Fonts

You can now use Runtime Resource Overlays (RROs) to change fonts. By adding custom fonts to make a font package, you can use fonts in themes and use RROs to apply the customizations.

Complete these tasks:

A sample file structure and sample files are provided in Download and then extract this file locally for your own use.

Make a font package

To make a font package:

  1. Add all the font ttf files to the font package in the vendor partition. For example:


  2. Create the file for the font package. For example:


  3. Make sure the module will be installed in the product partition in the etc folder. To do so, confirm the module has the following flags:

    The sample code provided above illustrates a complete definition of a font package module.

  4. Create a file named for the font package and then add the font ttf files to PRODUCT_PACKAGES. For example:


    For example:

    [font name].ttf \

Create a device overlay package

  1. Make a module called fonts_customization.xml to be added to the build. This module points to the fonts_customization.xml file that contains the font families and calls the make files of all the font packages. For example:


  2. Create the font families:


    The root level of the file must be a fonts-modification tag. Add font families for each of the font packages under this element. In addition, add customizationType="new-named-family" to every font family, and make sure each has a name attribute. This name is used later to access the font family. This file must be added to the fonts_customizations.xml module defined previously in

    The sample provided above contains a valid fonts_customization.xml file.

  3. Create For example:


  4. Add fonts_customization.xml under the PRODUCT_PACKAGES flag.
  5. Call into each of the previously created font packages.

    $(call inherit-product-if-exists, vendor/[oem]/fonts/[oem]-[fontname]/

  6. Add the font module to the build under PRODUCT_PACKAGES and then rebuild. The fonts will be installed on the system.
  7. Verify that the ttf fonts files are in the /product/fonts folder on the device.
  8. Verify that fonts_customization.xml is in /product/etc/ on the device.

Use the new system fonts family

To use the new system fonts family:

<style name="customstyle">
    <item name="android:fontFamily">customfontfamily</item>