Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: add custom fonts to system

Tags:

android

fonts

I know how to use custom font in an app, but what I want to do is adding custom fonts system-wide, just like adding a new font on Windows. If there's no official way, which module of android source code should I read? I have to change android source code and build it to support custom fonts.

like image 917
Dagang Avatar asked Mar 09 '12 01:03

Dagang


1 Answers

Here are steps to add custom font into Android build-in system:

  • Copy custom font .ttf into frameworks/base/data/fonts

  • Modify frameworks/base/data/fonts/Android.mk
    Add your custom font into list of 'font_src_files'

    font_src_files :=
    Roboto-Regular.ttf
    .... AndroidClock_Solid.ttf
    <custom_font>.ttf \

  • Modify frameworks/base/data/fonts/fonts.mk
    Add your custom font into list of PRODUCT_PACKAGES

    PRODUCT_PACKAGES :=
    DroidSansFallback.ttf
    ... AndroidClock_Solid.ttf
    <custom_font>.ttf \

  • Rebuild
    NOTE: Check if your custom font exists in out/target/product/generic/system/fonts or not. If yes, your custom font have already included in system. If no, recheck your modification.

like image 62
Nguyen Avatar answered Sep 18 '22 22:09

Nguyen