What is the default font family in Android?

111,894

There is no documentation on d.android.com for font family names. However, if you look at AOSP, the default fonts are loaded in android.graphics.*. The 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.

The two XML files have some documentation. The first font is the default font. You can pull /system/etc/fonts.xml from your device. A device manufacturer or custom ROM may change the default system fonts.

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.

If you parse the fonts.xml file, you can find which font family uses which typeface (see 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              ║
╚════╩════════════════════════════╩═════════════════════════════╝
Share:
111,894
Jared Burrows
Author by

Jared Burrows

My Site: http://jaredsburrows.com/ My Email: [email protected] My Apps: http://burrowsapps.com/ **Android Apps** **Github** **LinkedIn** **Twitter**

Updated on September 17, 2020

Comments