編集:いくつかの実験で、特にユーザーがフォントを変更できるGalaxy S3で、これは私が発見したものです:
- を使用
Typeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)
すると、システムのデフォルトのsans-serifフォント(つまりRoboto)ではなく、そのカスタム書体が返されます。
- 代わりに
Typeface.create("sans-serif", Typeface.NORMAL)
(またはBOLD)を使用すると、ユーザーのフォントのカスタマイズに関係なく、Robotoが返されます。以下のリストから、実際には、上記の「sans-serif」の代わりに「helvetica」、「tahoma」、「verdana」、または「arial」を使用して同じ結果を得ることができます。
以下のSDKディレクトリでsystem_fonts.xml
Robotoが参照に使用されることを確認しているように見えるというドキュメントを見つけました。Typeface.SANS_SERIF
プラットフォーム>android-14>データ>フォント
<!--
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.
-->
<familyset>
<family>
<nameset>
<name>sans-serif</name>
<name>arial</name>
<name>helvetica</name>
<name>tahoma</name>
<name>verdana</name>
</nameset>
<fileset>
<file>Roboto-Regular.ttf</file>
<file>Roboto-Bold.ttf</file>
<file>Roboto-Italic.ttf</file>
<file>Roboto-BoldItalic.ttf</file>
</fileset>
</family>
ベンダーフォントを配置する必要がfallback_fonts.xml
あり、システムフォントが常に優先されるため、リストされている最初のファミリは、sans-serif、aria、helvetica、tahoma、またはverdanaのエイリアスの下にあるRobotoです。 Robotoがへの呼び出しに対して返されるフォントであると想定しTypeface.create(Typeface.SANS_SERIF, Typeface.NORMAL)
ます。
OEMがsystem_fonts.xmlを変更できるかどうかわからないため、決定的な答えを期待して、今のところこれを開いたままにしておきます。もしそうなら、これはまったく役に立ちません。