如何在 Android Lollipop 下更换字体 如何在 Android Lollipop 下更换字体

\u5982\u4f55\u5728 Android Lollipop \u4e0b\u66f4\u6362\u5b57\u4f53

\u524d\u63d0\uff1aRoot\u3002

\u7b2c\u4e00\u6b65\uff0c\u5c06\u51c6\u5907\u597d\u7684\u5b57\u4f53\u6587\u4ef6\u7528 Root Explorer \u4e4b\u7c7b\u7684\u6587\u4ef6\u7ba1\u7406\u5668\u590d\u5236\u5230 /system/fonts/ \u76ee\u5f55\uff0c\u5e76\u8bbe\u7f6e\u597d\u76f8\u5e94\u6743\u9650\u3002

\u7b2c\u4e8c\u6b65\u5c31\u662f\u4fee\u6539Android \u7cfb\u7edf\u7684\u5b57\u4f53\u914d\u7f6e\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5728 Android \u4e4b\u4e2d\u4fee\u6539\uff0c\u9274\u4e8e\u6587\u4ef6\u884c\u6570\u5f88\u591a\uff0c\u5728\u7535\u8111\u4e0a\u4fee\u6539\u597d\u518d\u8986\u76d6\u6e90\u6587\u4ef6\u4e5f\u662f\u4e0d\u9519\u7684\u9009\u62e9\u3002

\u4ee5\u524d\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539\u4e00\u4e2a fallback_fonts.xml \u6587\u4ef6\u5373\u53ef\uff0c\u800c Android 5.0 \u4e3a\u4e86\u66f4\u597d\u5730 \u5b9e\u73b0\u591a\u91cd\u5b57\u91cd\u548c\u6837\u5f0f\uff0c\u4f7f\u7528\u4e86\u65b0\u7684\u5b57\u4f53\u914d\u7f6e\u6587\u4ef6 fonts.xml\uff0c\u4e24\u4e2a\u6587\u4ef6\u90fd\u5728 /etc/ \u76ee\u5f55\u4e0b\u53ef\u4ee5\u627e\u5230\uff0c\u6211\u4eec\u9700\u8981\u540c\u65f6\u4fee\u6539\u4e24\u4e2a\u6587\u4ef6\u3002

\u65e7\u6587\u4ef6\uff1afallback_fonts.xml

\u627e\u5230\u5176\u4e2d\u7684\u8fd9\u4e00\u5904\uff1a


NotoSansHans-Regular.otf



\u8fd9\u91cc\u8bb0\u5f55\u4e86\u7cfb\u7edf\u9ed8\u8ba4\u7684\u7b80\u4f53\u4e2d\u6587\u5b57\u4f53 NotoSans Hans\uff0c\u662f\u5426\u7559\u7740\u5b83\u7531\u4f60\u51b3\u5b9a\uff0c\u4f60\u53ef\u4ee5\u7528\u4f60\u81ea\u5df1\u7684\u5b57\u4f53\u8bb0\u5f55\u5c06\u5176\u66ff\u6362\uff0c\u6216\u8005\u5199\u5728\u5b83\u524d\u9762\u3002\u5f62\u5f0f\u662f\u8fd9\u6837\u7684\uff1a


YourFont-Regular.otf
YourFont-Bold.otf
YourFont-Italic.otf
YourFont-ItalicBold.otf



\u5176\u4e2d\uff0clang \u5c5e\u6027\u662f\u53ef\u9009\u7684\uff0c\u5b57\u4f53\u6587\u4ef6\u53ef\u4ee5\u4f7f otf\uff0c\u4e5f\u53ef\u662f\u662f ttf\u3002\u4e00\u4e2a family \u4e0b\u6700\u591a\u53ef\u4ee5\u5bf9\u5e94\u56db\u4e2a\u5b57\u4f53\uff0c\u5206\u522b\u662f\u5e38\u89c4\u3001\u7c97\u4f53\u3001\u659c\u4f53\u3001\u7c97\u659c\u4f53\u3002\u5bf9\u4e8e\u4e2d\u6587\u5b57\u4f53\uff0c\u4e00\u822c\u53ea\u6709\u5e38\u89c4\u548c\u7c97\u4f53\u4e24\u4e2a\u5355\u72ec\u7684\u5b57\u4f53\u6587\u4ef6\uff0c\u6240\u4ee5\u4e00\u822c\u4e0d\u9700\u8981\u5199\u540e\u4e24\u884c\u3002

\u65b0\u6587\u4ef6\uff1afonts.xml

\u8fd9\u662f Android 5.0 \u65b0\u5f15\u5165\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u8ddf\u8001\u7684\u6587\u4ef6\u76f8\u6bd4\uff0c\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6

\u8fd9\u4e00\u6b21\uff0c\u7cfb\u7edf\u9996\u9009\u5b57\u4f53\uff08\u4e5f\u5c31\u662f Roboto \uff09\u548c\u5404\u4e2a\u8bed\u8a00\u7684 fallback \u5b57\u4f53\u90fd\u8bb0\u5f55\u5728\u4e86\u540c\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff08\u4e4b\u524d\u5206\u4e86\u4e24\u4e2a\u6587\u4ef6\uff09\uff0c\u800c\u4e14\u4f7f\u7528\u4e86\u76f8\u4f3c\u7684\u8bb0\u5f55\u683c\u5f0f\uff0c\u56e0\u6b64\uff0cfallback \u5b57\u4f53\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u591a\u91cd\u5b57\u91cd\u548c\u6837\u5f0f\uff0c\u800c\u4e0d\u662f\u4e4b\u524d\u53ea\u6709\u5e38\u89c4\u3001\u7c97\u3001\u659c\u3001\u7c97\u659c\u56db\u79cd\u3002

\u9996\u5148\u770b\u5230\u5176\u4e2d Roboto \u90e8\u5206\uff1a

Roboto-Thin.ttf
Roboto-ThinItalic.ttf
Roboto-Light.ttf
Roboto-LightItalic.ttf
Roboto-Regular.ttf
Roboto-Italic.ttf
Roboto-Medium.ttf
Roboto-MediumItalic.ttf
Roboto-Black.ttf
Roboto-BlackItalic.ttf
Roboto-Bold.ttf
Roboto-BoldItalic.ttf


\u53ef\u4ee5\u770b\u5230\uff0c \u53ea\u8981\u6211\u4eec\u613f\u610f\uff0c\u53ef\u4ee5\u4ee5\u5f88\u7ec6\u7684\u95f4\u9694\u4e3a\u6bcf\u4e2a\u5b57\u91cd\uff0c\u6bcf\u4e2a\u6837\u5f0f\u5bf9\u5e94\u76f8\u5e94\u7684\u5b57\u4f53\u6587\u4ef6\u3002\u8fd9\u4e00\u6bb5\u4ee3\u7801\u662f\u6211\u4eec\u6a21\u4eff\u7684\u5bf9\u8c61\u3002

\u7136\u540e\u540c\u6837\u627e\u5230\u540e\u9762\u63a7\u5236\u7b80\u4f53\u4e2d\u6587\u7684\u90e8\u5206\uff1a

NotoSansHans-Regular.otf


Google \u867d\u7136\u5f88\u61d2\u5730\u53ea\u5199\u4e86\u4e00\u884c\uff0c\u4f46\u662f\u6211\u4eec\u5b8c\u5168\u4eff\u7167\u524d\u9762\u7684\u4ee3\u7801\u4efb\u610f\u589e\u52a0\u5b57\u91cd\u2014\u2014\u53ea\u8981\u4f60\u6709\u76f8\u5e94\u5730\u5b57\u4f53\u6587\u4ef6\uff0c\u8fd9\u91cc\u5c31\u4e0d\u5570\u55e6\u4e86\u3002

\u5168\u90e8\u4fee\u6539\u5b8c\u6210\u4e4b\u540e\uff08\u8f6f\uff09\u91cd\u542f\u624b\u673a\u5373\u53ef\u3002

\u524d\u63d0\uff1aRoot\u3002

\u7b2c\u4e00\u6b65\uff0c\u5c06\u51c6\u5907\u597d\u7684\u5b57\u4f53\u6587\u4ef6\u7528 Root Explorer \u4e4b\u7c7b\u7684\u6587\u4ef6\u7ba1\u7406\u5668\u590d\u5236\u5230 /system/fonts/ \u76ee\u5f55\uff0c\u5e76\u8bbe\u7f6e\u597d\u76f8\u5e94\u6743\u9650\u3002

\u7b2c\u4e8c\u6b65\u5c31\u662f\u4fee\u6539Android \u7cfb\u7edf\u7684\u5b57\u4f53\u914d\u7f6e\u6587\u4ef6\uff0c\u4f60\u53ef\u4ee5\u5728 Android \u4e4b\u4e2d\u4fee\u6539\uff0c\u9274\u4e8e\u6587\u4ef6\u884c\u6570\u5f88\u591a\uff0c\u5728\u7535\u8111\u4e0a\u4fee\u6539\u597d\u518d\u8986\u76d6\u6e90\u6587\u4ef6\u4e5f\u662f\u4e0d\u9519\u7684\u9009\u62e9\u3002

\u4ee5\u524d\u6211\u4eec\u53ea\u9700\u8981\u4fee\u6539\u4e00\u4e2a fallback_fonts.xml \u6587\u4ef6\u5373\u53ef\uff0c\u800c Android 5.0 \u4e3a\u4e86\u66f4\u597d\u5730 \u5b9e\u73b0\u591a\u91cd\u5b57\u91cd\u548c\u6837\u5f0f\uff0c\u4f7f\u7528\u4e86\u65b0\u7684\u5b57\u4f53\u914d\u7f6e\u6587\u4ef6 fonts.xml\uff0c\u4e24\u4e2a\u6587\u4ef6\u90fd\u5728 /etc/ \u76ee\u5f55\u4e0b\u53ef\u4ee5\u627e\u5230\uff0c\u6211\u4eec\u9700\u8981\u540c\u65f6\u4fee\u6539\u4e24\u4e2a\u6587\u4ef6\u3002

\u65e7\u6587\u4ef6\uff1afallback_fonts.xml

\u627e\u5230\u5176\u4e2d\u7684\u8fd9\u4e00\u5904\uff1a
NotoSansHans-Regular.otf
\u8fd9\u91cc\u8bb0\u5f55\u4e86\u7cfb\u7edf\u9ed8\u8ba4\u7684\u7b80\u4f53\u4e2d\u6587\u5b57\u4f53 NotoSans Hans\uff0c\u662f\u5426\u7559\u7740\u5b83\u7531\u4f60\u51b3\u5b9a\uff0c\u4f60\u53ef\u4ee5\u7528\u4f60\u81ea\u5df1\u7684\u5b57\u4f53\u8bb0\u5f55\u5c06\u5176\u66ff\u6362\uff0c\u6216\u8005\u5199\u5728\u5b83\u524d\u9762\u3002\u5f62\u5f0f\u662f\u8fd9\u6837\u7684\uff1a
YourFont-Regular.otf YourFont-Bold.otf YourFont-Italic.otf YourFont-ItalicBold.otf
\u5176\u4e2d\uff0clang \u5c5e\u6027\u662f\u53ef\u9009\u7684\uff0c\u5b57\u4f53\u6587\u4ef6\u53ef\u4ee5\u4f7f otf\uff0c\u4e5f\u53ef\u662f\u662f ttf\u3002\u4e00\u4e2a family \u4e0b\u6700\u591a\u53ef\u4ee5\u5bf9\u5e94\u56db\u4e2a\u5b57\u4f53\uff0c\u5206\u522b\u662f\u5e38\u89c4\u3001\u7c97\u4f53\u3001\u659c\u4f53\u3001\u7c97\u659c\u4f53\u3002\u5bf9\u4e8e\u4e2d\u6587\u5b57\u4f53\uff0c\u4e00\u822c\u53ea\u6709\u5e38\u89c4\u548c\u7c97\u4f53\u4e24\u4e2a\u5355\u72ec\u7684\u5b57\u4f53\u6587\u4ef6\uff0c\u6240\u4ee5\u4e00\u822c\u4e0d\u9700\u8981\u5199\u540e\u4e24\u884c\u3002

\u65b0\u6587\u4ef6\uff1afonts.xml

\u8fd9\u662f Android 5.0 \u65b0\u5f15\u5165\u7684\u914d\u7f6e\u6587\u4ef6\uff0c\u8ddf\u8001\u7684\u6587\u4ef6\u76f8\u6bd4\uff0c\u8fd9\u4e2a\u914d\u7f6e\u6587\u4ef6

\u8fd9\u4e00\u6b21\uff0c\u7cfb\u7edf\u9996\u9009\u5b57\u4f53\uff08\u4e5f\u5c31\u662f Roboto \uff09\u548c\u5404\u4e2a\u8bed\u8a00\u7684 fallback \u5b57\u4f53\u90fd\u8bb0\u5f55\u5728\u4e86\u540c\u4e00\u4e2a\u6587\u4ef6\u4e2d\uff08\u4e4b\u524d\u5206\u4e86\u4e24\u4e2a\u6587\u4ef6\uff09\uff0c\u800c\u4e14\u4f7f\u7528\u4e86\u76f8\u4f3c\u7684\u8bb0\u5f55\u683c\u5f0f\uff0c\u56e0\u6b64\uff0cfallback \u5b57\u4f53\u4e5f\u53ef\u4ee5\u5b9e\u73b0\u591a\u91cd\u5b57\u91cd\u548c\u6837\u5f0f\uff0c\u800c\u4e0d\u662f\u4e4b\u524d\u53ea\u6709\u5e38\u89c4\u3001\u7c97\u3001\u659c\u3001\u7c97\u659c\u56db\u79cd\u3002

\u9996\u5148\u770b\u5230\u5176\u4e2d Roboto \u90e8\u5206\uff1a
Roboto-Thin.ttf Roboto-ThinItalic.ttf Roboto-Light.ttf Roboto-LightItalic.ttf Roboto-Regular.ttf Roboto-Italic.ttf Roboto-Medium.ttf Roboto-MediumItalic.ttf Roboto-Black.ttf Roboto-BlackItalic.ttf Roboto-Bold.ttf Roboto-BoldItalic.ttf
\u53ef\u4ee5\u770b\u5230\uff0c \u53ea\u8981\u6211\u4eec\u613f\u610f\uff0c\u53ef\u4ee5\u4ee5\u5f88\u7ec6\u7684\u95f4\u9694\u4e3a\u6bcf\u4e2a\u5b57\u91cd\uff0c\u6bcf\u4e2a\u6837\u5f0f\u5bf9\u5e94\u76f8\u5e94\u7684\u5b57\u4f53\u6587\u4ef6\u3002\u8fd9\u4e00\u6bb5\u4ee3\u7801\u662f\u6211\u4eec\u6a21\u4eff\u7684\u5bf9\u8c61\u3002

\u7136\u540e\u540c\u6837\u627e\u5230\u540e\u9762\u63a7\u5236\u7b80\u4f53\u4e2d\u6587\u7684\u90e8\u5206\uff1a
NotoSansHans-Regular.otf
Google \u867d\u7136\u5f88\u61d2\u5730\u53ea\u5199\u4e86\u4e00\u884c\uff0c\u4f46\u662f\u6211\u4eec\u5b8c\u5168\u4eff\u7167\u524d\u9762\u7684\u4ee3\u7801\u4efb\u610f\u589e\u52a0\u5b57\u91cd\u2014\u2014\u53ea\u8981\u4f60\u6709\u76f8\u5e94\u5730\u5b57\u4f53\u6587\u4ef6\uff0c\u8fd9\u91cc\u5c31\u4e0d\u5570\u55e6\u4e86\u3002

\u5168\u90e8\u4fee\u6539\u5b8c\u6210\u4e4b\u540e\uff08\u8f6f\uff09\u91cd\u542f\u624b\u673a\u5373\u53ef\u3002

前提:Root。

第一步,将准备好的字体文件用 Root Explorer 之类的文件管理器复制到 /system/fonts/ 目录,并设置好相应权限。

第二步就是修改Android 系统的字体配置文件,你可以在 Android 之中修改,鉴于文件行数很多,在电脑上修改好再覆盖源文件也是不错的选择。

以前我们只需要修改一个 fallback_fonts.xml 文件即可,而 Android 5.0 为了更好地 实现多重字重和样式,使用了新的字体配置文件 fonts.xml,两个文件都在 /etc/ 目录下可以找到,我们需要同时修改两个文件。

旧文件:fallback_fonts.xml

找到其中的这一处:

<family>
<fileset>
<file lang="zh-Hans">NotoSansHans-Regular.otf</file>
</fileset>
</family>

这里记录了系统默认的简体中文字体 NotoSans Hans,是否留着它由你决定,你可以用你自己的字体记录将其替换,或者写在它前面。形式是这样的:

<family>
<fileset>
<file>YourFont-Regular.otf</file>
<file>YourFont-Bold.otf</file>
<file>YourFont-Italic.otf</file>
<file>YourFont-ItalicBold.otf</file>
</fileset>
</family>

其中,lang 属性是可选的,字体文件可以使 otf,也可是是 ttf。一个 family 下最多可以对应四个字体,分别是常规、粗体、斜体、粗斜体。对于中文字体,一般只有常规和粗体两个单独的字体文件,所以一般不需要写后两行。

新文件:fonts.xml

这是 Android 5.0 新引入的配置文件,跟老的文件相比,这个配置文件

这一次,系统首选字体(也就是 Roboto )和各个语言的 fallback 字体都记录在了同一个文件中(之前分了两个文件),而且使用了相似的记录格式,因此,fallback 字体也可以实现多重字重和样式,而不是之前只有常规、粗、斜、粗斜四种。

首先看到其中 Roboto 部分:

<family name="sans-serif">
<font weight="100" style="normal">Roboto-Thin.ttf</font>
<font weight="100" style="italic">Roboto-ThinItalic.ttf</font>
<font weight="300" style="normal">Roboto-Light.ttf</font>
<font weight="300" style="italic">Roboto-LightItalic.ttf</font>
<font weight="400" style="normal">Roboto-Regular.ttf</font>
<font weight="400" style="italic">Roboto-Italic.ttf</font>
<font weight="500" style="normal">Roboto-Medium.ttf</font>
<font weight="500" style="italic">Roboto-MediumItalic.ttf</font>
<font weight="900" style="normal">Roboto-Black.ttf</font>
<font weight="900" style="italic">Roboto-BlackItalic.ttf</font>
<font weight="700" style="normal">Roboto-Bold.ttf</font>
<font weight="700" style="italic">Roboto-BoldItalic.ttf</font>
</family>

可以看到, 只要我们愿意,可以以很细的间隔为每个字重,每个样式对应相应的字体文件。这一段代码是我们模仿的对象。

然后同样找到后面控制简体中文的部分:

<family lang="zh-Hans">
<font weight="400" style="normal">NotoSansHans-Regular.otf</font>
</family>

Google 虽然很懒地只写了一行,但是我们完全仿照前面的代码任意增加字重——只要你有相应地字体文件,这里就不啰嗦了。

全部修改完成之后(软)重启手机即可。

有更换字体的软件,你可以到软件下载平台里找一找。

下载字体管家啊!

扩展阅读:android苹果版下载 ... android官网入口 ... android下载安装app ... my android tools pro ... android系统怎么打开 ... wireless android auto ... 永久在线免费的云服务器 ... 赛风android 手机版 ... ankidroid安卓版下载官网 ...

本站交流只代表网友个人观点,与本站立场无关
欢迎反馈与建议,请联系电邮
2024© 车视网