Android 中的默认字体系列是什么?
What is the default font family in Android?
从 API16 开始,引入了 Jellybean Roboto 作为可用字体系列。查看 Android 中的 "new" 16 here.
在 TextView
上指定 android:fontFamily="sans-serif"
(API 16+ 中的机器人)TextView
的默认值 fontFamily
?
是
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
相当于
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif" />
?
来自 Material design typography website:
"Roboto and Noto are the standard typefaces on Android and Chrome."
来自 Wiki、
"Roboto is a sans-serif typeface family developed by Google as the
system font for its mobile operating system Android."
我没有在文档中看到 Android 的默认 fontFamily
是什么。见参考资料:
- https://developer.android.com/reference/android/R.attr.html#fontFamily
- Valid values for android:fontFamily and what they map to?
- https://developer.android.com/about/versions/android-4.1.html#Fonts
- http://alvinalexander.com/photos/android-roboto-fonts-examples
没有关于 d.android.com 字体系列名称的文档。但是,如果您查看 AOSP,默认字体会加载到 android.graphics.*
中。 FontListParser loads the default fonts from /system/etc/fonts.xml
(Android 5.0+) or /system/etc/system_fonts.xml
(Android 4.1). The default fonts are loaded in Typeface#init.
两个 XML 文件有一些文档。第一种字体是默认字体。您可以从您的设备中提取 /system/etc/fonts.xml。设备制造商或自定义 ROM 可能会更改默认系统字体。
fonts.xml (API 21+)
NOTE: this is the newer (L) version of the system font configuration,
supporting richer weight selection. Some apps will expect the older
version, so please keep system_fonts.xml and fallback_fonts.xml in sync
with any changes, even though framework will only read this file.
All fonts withohut names are added to the default list. Fonts are chosen
based on a match: full BCP-47 language tag including script, then just
language, and finally order (the first font containing the glyph).
Order of appearance is also the tiebreaker for weight matching. This is
the reason why the 900 weights of Roboto precede the 700 weights - we
prefer the former when an 800 weight is requested. Since bold spans
effectively add 300 to the weight, this ensures that 900 is the bold
paired with the 500 weight, ensuring adequate contrast.
system_fonts.xml (API 16-20)
System Fonts
This file lists the font families that will be used by default for all supported glyphs.
Each entry consists of a family, various names that are supported by that family, and
up to four font files. The font files are listed in the order of the styles which they
support: regular, bold, italic and bold-italic. If less than four styles are listed, then
the styles with no associated font file will be supported by the other font files listed.
The first family is also the default font, which handles font request that have not specified
specific font names.
Any glyph that is not handled by the system fonts will cause a search of the fallback fonts.
The default fallback fonts are specified in the file /system/etc/fallback_fonts.xml, and there
is an optional file which may be supplied by vendors to specify other fallback fonts to use
in /vendor/etc/fallback_fonts.xml.
如果你解析 fonts.xml 文件,你可以找到哪个字体系列使用哪个字体(参见 here):
╔════╦════════════════════════════╦═════════════════════════════╗
║ ║ FONT FAMILY ║ TTF FILE ║
╠════╬════════════════════════════╬═════════════════════════════╣
║ 1 ║ casual ║ ComingSoon.ttf ║
║ 2 ║ cursive ║ DancingScript-Regular.ttf ║
║ 3 ║ monospace ║ DroidSansMono.ttf ║
║ 4 ║ sans-serif ║ Roboto-Regular.ttf ║
║ 5 ║ sans-serif-black ║ Roboto-Black.ttf ║
║ 6 ║ sans-serif-condensed ║ RobotoCondensed-Regular.ttf ║
║ 7 ║ sans-serif-condensed-light ║ RobotoCondensed-Light.ttf ║
║ 8 ║ sans-serif-light ║ Roboto-Light.ttf ║
║ 9 ║ sans-serif-medium ║ Roboto-Medium.ttf ║
║ 10 ║ sans-serif-smallcaps ║ CarroisGothicSC-Regular.ttf ║
║ 11 ║ sans-serif-thin ║ Roboto-Thin.ttf ║
║ 12 ║ serif ║ NotoSerif-Regular.ttf ║
║ 13 ║ serif-monospace ║ CutiveMono.ttf ║
╚════╩════════════════════════════╩═════════════════════════════╝
从 API16 开始,引入了 Jellybean Roboto 作为可用字体系列。查看 Android 中的 "new" 16 here.
在 TextView
上指定 android:fontFamily="sans-serif"
(API 16+ 中的机器人)TextView
的默认值 fontFamily
?
是
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
相当于
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif" />
?
来自 Material design typography website:
"Roboto and Noto are the standard typefaces on Android and Chrome."
来自 Wiki、
"Roboto is a sans-serif typeface family developed by Google as the system font for its mobile operating system Android."
我没有在文档中看到 Android 的默认 fontFamily
是什么。见参考资料:
- https://developer.android.com/reference/android/R.attr.html#fontFamily
- Valid values for android:fontFamily and what they map to?
- https://developer.android.com/about/versions/android-4.1.html#Fonts
- http://alvinalexander.com/photos/android-roboto-fonts-examples
没有关于 d.android.com 字体系列名称的文档。但是,如果您查看 AOSP,默认字体会加载到 android.graphics.*
中。 FontListParser loads the default fonts from /system/etc/fonts.xml
(Android 5.0+) or /system/etc/system_fonts.xml
(Android 4.1). The default fonts are loaded in Typeface#init.
两个 XML 文件有一些文档。第一种字体是默认字体。您可以从您的设备中提取 /system/etc/fonts.xml。设备制造商或自定义 ROM 可能会更改默认系统字体。
fonts.xml (API 21+)
NOTE: this is the newer (L) version of the system font configuration, supporting richer weight selection. Some apps will expect the older version, so please keep system_fonts.xml and fallback_fonts.xml in sync with any changes, even though framework will only read this file.
All fonts withohut names are added to the default list. Fonts are chosen based on a match: full BCP-47 language tag including script, then just language, and finally order (the first font containing the glyph).
Order of appearance is also the tiebreaker for weight matching. This is the reason why the 900 weights of Roboto precede the 700 weights - we prefer the former when an 800 weight is requested. Since bold spans effectively add 300 to the weight, this ensures that 900 is the bold paired with the 500 weight, ensuring adequate contrast.
system_fonts.xml (API 16-20)
System Fonts
This file lists the font families that will be used by default for all supported glyphs. Each entry consists of a family, various names that are supported by that family, and up to four font files. The font files are listed in the order of the styles which they support: regular, bold, italic and bold-italic. If less than four styles are listed, then the styles with no associated font file will be supported by the other font files listed.
The first family is also the default font, which handles font request that have not specified specific font names.
Any glyph that is not handled by the system fonts will cause a search of the fallback fonts. The default fallback fonts are specified in the file /system/etc/fallback_fonts.xml, and there is an optional file which may be supplied by vendors to specify other fallback fonts to use in /vendor/etc/fallback_fonts.xml.
如果你解析 fonts.xml 文件,你可以找到哪个字体系列使用哪个字体(参见 here):
╔════╦════════════════════════════╦═════════════════════════════╗
║ ║ FONT FAMILY ║ TTF FILE ║
╠════╬════════════════════════════╬═════════════════════════════╣
║ 1 ║ casual ║ ComingSoon.ttf ║
║ 2 ║ cursive ║ DancingScript-Regular.ttf ║
║ 3 ║ monospace ║ DroidSansMono.ttf ║
║ 4 ║ sans-serif ║ Roboto-Regular.ttf ║
║ 5 ║ sans-serif-black ║ Roboto-Black.ttf ║
║ 6 ║ sans-serif-condensed ║ RobotoCondensed-Regular.ttf ║
║ 7 ║ sans-serif-condensed-light ║ RobotoCondensed-Light.ttf ║
║ 8 ║ sans-serif-light ║ Roboto-Light.ttf ║
║ 9 ║ sans-serif-medium ║ Roboto-Medium.ttf ║
║ 10 ║ sans-serif-smallcaps ║ CarroisGothicSC-Regular.ttf ║
║ 11 ║ sans-serif-thin ║ Roboto-Thin.ttf ║
║ 12 ║ serif ║ NotoSerif-Regular.ttf ║
║ 13 ║ serif-monospace ║ CutiveMono.ttf ║
╚════╩════════════════════════════╩═════════════════════════════╝