admin管理员组文章数量:1614277
一、准备字体
当然第一步也是最重要的第一步就是需要准备一个字体,可以自己在网站搜索免费字体下载
这里提供一个免费下载字体的网站,只用于学习使用,切勿商用!!!
字体天下
二、替换字体
字体相关的文件路径:frameworks/base/data/fonts
- 将网上下载的字体复制到这个路径下,这里假设我添加的字体文件名称为:ErvinFonts.ttf
-
将字体文件添加到fonts.mk中
-
在Android.bp文件中添加ErvinFonts.ttf
-
修改fonts.xml中的内容,将下列所有的
Roboto-Regular.ttf
替换为ErvinFonts.ttf
即可 -
<familyset version="23"> <!-- first font is default --> <family name="sans-serif"> <font weight="100" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="100" /> </font> <font weight="200" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="200" /> </font> <font weight="300" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="300" /> </font> <font weight="400" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="400" /> </font> <font weight="500" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="500" /> </font> <font weight="600" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="600" /> </font> <font weight="700" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="700" /> </font> <font weight="800" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="800" /> </font> <font weight="900" style="normal">Roboto-Regular.ttf <axis tag="ital" stylevalue="0" /> <axis tag="wdth" stylevalue="100" /> <axis tag="wght" stylevalue="900" /> </font>
-
编译验证
在frameworks/base/data/fonts路径下执行mm
命令即可,会在out\target\product\XXX\system
路径下生成etc
文件夹和font
文件夹,push到对应路径下重启机器就可以验证啦~
三、最后
关于fonts.xml
文件的作用可以查看此文章,相信看完这篇文章会让你对系统字体了解更加深入 Android fonts相关知识以及fonts.xml解读
版权声明:本文标题:Android14 替换系统字体 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:https://www.elefans.com/dianzi/1728672435a1169213.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论