How to add custom fonts in AOSP

114 views
Skip to first unread message

Shreyash Mohta

unread,
Sep 28, 2020, 12:32:34 PM9/28/20
to android-platform
Hello Folks,

I wanted to add new custom fonts (vendor fonts) while building AOSP code.

First thing,  I do not want to modify system's fonts.xml files. I tried this and its working fine.

What I wanted is to add custom fonts without adding it in the system's font file, for this I followed


and able to generate the build with the newly created/added fonts under the product folder (check out the link).


Please check the link first: 

For example :

If I add the following code in font-customization.xml

<fonts-modification version="1">
        <family customizationType="new-named-family" name="lobster">
                <font weight="400" style="normal">Lobster-Regular.ttf</font>
        </family>
</fonts-modification>

After building the image, the font-customization file is created under /product/etc/ and Lobster-Regular.ttf is created under /product/fonts. 

 
But when I am creating a sample application and trying to use the new font, as below

In the style.xml in

<item name="android:fontFamily">lobster</item>

Its not working

Do anyone have idea related to this.

Regards,
Shreyash Mohta
Reply all
Reply to author
Forward
0 new messages