Stay organized with collections Save and categorize content based on your preferences.

FontFamily.Builder

public static final class FontFamily.Builder
extends Object

java.lang.Object
   ↳ android.graphics.fonts.FontFamily.Builder


A builder class for creating new FontFamily.

Summary

Public constructors

Builder(Font font)

Constructs a builder.

Public methods

FontFamily.Builder addFont(Font font)

Adds different style font to the builder.

FontFamily build()

Build the font family

Inherited methods

Public constructors

Builder

Added in API level 29
public Builder (Font font)

Constructs a builder.

Parameters
font Font: a font This value cannot be null.

Public methods

addFont

Added in API level 29
public FontFamily.Builder addFont (Font font)

Adds different style font to the builder. System will select the font if the text style is closest to the font. If the same style font is already added to the builder, this method will fail with IllegalArgumentException. Note that system assumes all fonts bundled in FontFamily have the same coverage for the code points. For example, regular style font and bold style font must have the same code point coverage, otherwise some character may be shown as tofu.

Parameters
font Font: a font This value cannot be null.

Returns
FontFamily.Builder this builder This value cannot be null.

build

Added in API level 29
public FontFamily build ()

Build the font family

Returns
FontFamily a font family This value cannot be null.