Android:向系统添加自定义字体 [英] Android: add custom fonts to system
问题描述
我知道如何在应用程序中使用自定义字体,但是我想做的是在系统范围内添加自定义字体,就像在Windows上添加新字体一样.如果没有官方方法,我应该阅读哪个模块的Android源代码?我必须更改android源代码并构建它以支持自定义字体.
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.
推荐答案
以下是将自定义字体添加到Android内置系统中的步骤:
+将自定义字体.ttf复制到frameworks/base/data/fonts
+修改framworks/base/data/fonts/Android.mk
将您的自定义字体添加到"font_src_files"列表中
Here are steps to add custom font into Android build-in system:
+ Copy custom font .ttf into frameworks/base/data/fonts
+ Modify framworks/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 \
+修改frameworks/base/data/fonts/fonts.mk
将自定义字体添加到PRODUCT_PACKAGES列表中
+ 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 \
+重建
注意::检查您的自定义字体是否存在于out/target/product/generic/system/fonts中.如果是,则您的自定义字体已包含在系统中.如果否,请重新检查您的修改.
+ 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.
这篇关于Android:向系统添加自定义字体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!