系统版本:Android 4.2.2_r1
本文主要是在Android中添加思源字体的过程记录。思源字体是Google和Adobe在2014.07.18发布的中文字体。
1.获取思源字体(Google:Noto Sans CJK; Adobe:Source Han Sans)。
2.解压后如下几个才是思源字体。
- NotoSansHans-Regular.otf 常规
- NotoSansHans-Black.otf 黑体
- NotoSansHans-DemiLight.otf
- NotoSansHans-Medium.otf
- NotoSansHans-Thin.otf
- NotoSansHans-Bold.otf 加粗
- NotoSansHans-Light.otf
注:这里说下otf,意为opentype和ttf(truetype)是兼容的。
3.安装体验
由于Android中只使用到常规和加粗体,这里也只以这两个做实验(同时也有容量的考虑),在高PPI(分辨率)的屏幕上或许只是感觉到字形变了,在低分辨率的屏幕上变的更加清晰了,前后对比:
之前:
之后:
(上传到这里就不清晰了,真是怪,点击链接看原图更为清晰)
1) 将NotoSansHans-Regular.otf NotoSansHans-Bold.otf放到/system/fonts/目录下。
2) 将如下fallback_fonts.xml放到/vendor/etc/下。
<?xml version="1.0" encoding="utf-8"?>
<!--
Vendor-provided fallback fonts
This file can be edited to add references to fonts that are not installed or referenced in the
default system. The file should then be placed in /vendor/etc/fallback_fonts.xml. Note
that in your makefile, this directory should be referenced as $(TARGET_COPY_OUT_VENDOR)/etc/:
PRODUCT_COPY_FILES += \
frameworks/base/data/fonts/vendor_fonts.xml:$(TARGET_COPY_OUT_VENDOR)/etc/fallback_fonts.xml
For example, vendors might want to build configurations for locales that are
better served by fonts which either handle glyphs not supported in the default fonts or which
handle these glyphs differently than the default fallback fonts.
Each entry in this list is a "fa