What Is the Default Font Family in Android

What is the default font family in Android?

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 ║
╚════╩════════════════════════════╩═════════════════════════════╝

How to change fontFamily of TextView in Android

From android 4.1 / 4.2 / 5.0, the following Roboto font families are available:

android:fontFamily="sans-serif"           // roboto regular
android:fontFamily="sans-serif-light" // roboto light
android:fontFamily="sans-serif-condensed" // roboto condensed
android:fontFamily="sans-serif-black" // roboto black
android:fontFamily="sans-serif-thin" // roboto thin (android 4.2)
android:fontFamily="sans-serif-medium" // roboto medium (android 5.0)

Sample Image

in combination with

android:textStyle="normal|bold|italic"

this 16 variants are possible:

  • Roboto regular
  • Roboto italic
  • Roboto bold
  • Roboto bold italic
  • Roboto-Light
  • Roboto-Light italic
  • Roboto-Thin
  • Roboto-Thin italic
  • Roboto-Condensed
  • Roboto-Condensed italic
  • Roboto-Condensed bold
  • Roboto-Condensed bold italic
  • Roboto-Black
  • Roboto-Black italic
  • Roboto-Medium
  • Roboto-Medium italic

fonts.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="font_family_light">sans-serif-light</string>
<string name="font_family_medium">sans-serif-medium</string>
<string name="font_family_regular">sans-serif</string>
<string name="font_family_condensed">sans-serif-condensed</string>
<string name="font_family_black">sans-serif-black</string>
<string name="font_family_thin">sans-serif-thin</string>
</resources>

What is the default font used in android if developer didn`t specify any

For the devices that run stock-Android, according to Material Design Guidelines:

Roboto is the standard typeface on Android.

But in case that you use languages not covered by Roboto (check the same link to see all languages covered by it), the typeface will be switched to Noto

Noto is the standard typeface for all languages on Chrome and Android for all languages not covered by Roboto.

That being said, the actuals fonts differ depending on the place where they are used (see below some examples from the same guideline)

App bar

Title style, Medium 20sp

Buttons

English: Medium 14sp, all caps

Dense: Medium 15sp, all caps

Tall: Bold 15sp

For the pre-Lollipop devices, the same rules apply, but you might notice some changes between different versions since Google refined Roboto as the time passed.

However, all the above are true only for stock-Android, the rest of them having a predefined typeface/font based on the device or manufacturer. As Eli Sadoff stated, most of these devices let the user pick a default font which will be used across all apps (without exceptions), even if you have a custom font for your app.

PS: Make sure to read everything form the provided link because you'll find more useful information.

What was the default font in Android Studio Editor for versions 3.6?

What I've ended up is Courier New, size 12

What fonts are installed by default on Android?

There are only three system wide fonts in Android;

1 normal (Droid Sans),

2 serif (Droid Serif),

3 monospace (Droid Sans Mono).

Applications can install fonts for themselves, but not for system-wide use.

For more you can see List of fonts included with each device link

and

Since the Ice Cream Sandwich release, Roboto has been the standard typeface on Android.

Since Froyo, Noto has been the standard typeface on Android for all languages not covered by Roboto. Noto is also the standard typeface for all languages on Chrome OS.

Refer here

How to set default font family for entire Android app

The answer is yes.

Global Roboto light for TextView and Button classes:

<style name="AppTheme" parent="AppBaseTheme">
<item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
<item name="android:buttonStyle">@style/RobotoButtonStyle</item>
</style>

<style name="RobotoTextViewStyle" parent="android:Widget.TextView">
<item name="android:fontFamily">sans-serif-light</item>
</style>

<style name="RobotoButtonStyle" parent="android:Widget.Holo.Button">
<item name="android:fontFamily">sans-serif-light</item>
</style>

Just select the style you want from list themes.xml, then create your custom style based on the original one. At the end, apply the style as the theme of the application.

<application
android:theme="@style/AppTheme" >
</application>

It will work only with built-in fonts like Roboto, but that was the question. For custom fonts (loaded from assets for example) this method will not work.

EDIT 08/13/15

If you're using AppCompat themes, remember to remove android: prefix. For example:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:textViewStyle">@style/RobotoTextViewStyle</item>
<item name="buttonStyle">@style/RobotoButtonStyle</item>
</style>

Note the buttonStyle doesn't contain android: prefix, but textViewStyle must contain it.

What is the default font family of a Flutter app?

The default font of MaterialApp is roboto, a Google font.

https://fonts.google.com/specimen/Roboto

What is the default font family taken by android webview to show its fonts?

WebView has provided us with the methods to check the default fonts like -

  1. webview.getSettings().getStandardFontFamily()
  2. webview.getSettings().getFixedFontFamily()

and As WebView Safe fonts Suggested, My default fonts which are applying, I get it through StandardFontFamily(sans-serif)
font-family in my case and Arial/Verdana fonts in particular.

how to set default font family available in android to action bar title

With a Toolbar you can use:

    <com.google.android.material.appbar.MaterialToolbar
app:titleTextAppearance="@style/myTitleTextAppearance"

with:

    <style name="myTitleTextAppearance" parent="TextAppearance.MaterialComponents.Subtitle1" parent="TextAppearance.AppCompat.Subhead">
<item name="fontFamily">sans-serif-medium</item>
<item name="android:fontFamily">sans-serif-medium</item>
.....
</style>

with an ActionBar you add in your app theme the actionBarStyle attribute:

<style name="AppTheme" parent="Theme.MaterialComponents.DayNight">
<item name="actionBarStyle">@style/myActionBar</item>
</style>

with:

<style name="myActionBar" parent="Widget.MaterialComponents.ActionBar.PrimarySurface">
<item name="titleTextStyle">@style/myActionBarTextTitle</item>
</style>

<style name="myActionBarTextTitle" parent="TextAppearance.AppCompat.Widget.ActionBar.Title">
<item name="fontFamily">sans-serif-medium</item>
<item name="android:fontFamily">sans-serif-medium</item>
</style>


Related Topics



Leave a reply



Submit