Android知识

QC8916 修改系统默认字体(Android 5.0)

2016-11-01  本文已影响884人  水月心刀

涉及文件

frameworks\base\data\fonts\
1. fonts.xml
2. fallback_fonts.xm

3. fonts.mk
4. Android.mk
5. ttf字体文件

修改方法

<familyset version="22">
    <!-- first font is default -->
    <!-- add start -->
    <family name="hp">
        <font weight="400" style="normal">Hpsimplifiedhans-light.ttf</font>
        <font weight="700" style="normal">Hpsimplifiedhans-regular.ttf</font>
    </family>
    <!-- 不加下面这句会导致桌面英文数字字体不发生改变 -->
    <alias name="sans-serif" to="hp" />
    <!-- add end -->
    <family name="sans-serif">
 ...
 <!-- modify start -->
    <family lang="zh-Hans">
        <font weight="400" style="normal">Hpsimplifiedhans-light.ttf</font>
        <font weight="700" style="normal">Hpsimplifiedhans-regular.ttf</font>
    </family>
    <family lang="zh-Hant">
        <font weight="400" style="normal">Hpsimplifiedhans-light.ttf</font>
        <font weight="700" style="normal">Hpsimplifiedhans-regular.ttf</font>
    </family>
 <!-- modify end -->
 ...
</familyset>
<familyset>
 <!-- add start -->
 <family>
 <fileset>
 <file>Hpsimplifiedhans-light.ttf</file>
 <file>Hpsimplifiedhans-regular.ttf</file>
 </fileset>
 </family>
 <!-- add end -->
 ... 
</familyset>
# modify start
PRODUCT_COPY_FILES := \
 frameworks/base/data/fonts/system_fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/system_fonts.xml \
 frameworks/base/data/fonts/fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/fonts.xml \
 frameworks/base/data/fonts/fallback_fonts.xml:$(TARGET_COPY_OUT_SYSTEM)/etc/fallback_fonts.xml
# modify end
ifneq ($(MULTI_LANG_ENGINE),REVERIE)
...
# modify
PRODUCT_PACKAGES := \
 Hpsimplifiedhans-light.ttf \
 Hpsimplifiedhans-regular.ttf \
 ...
ifeq ($(MINIMAL_FONT_FOOTPRINT),true)
...
else # !MINIMAL_FONT
font_src_files += \
   Hpsimplifiedhans-light.ttf \
   Hpsimplifiedhans-regular.ttf \
 ...
frameworks\base\data\fonts\
上一篇 下一篇

猜你喜欢

热点阅读