# FontFamily.Builder

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  
Summary:[Ctors](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#pubctors)\|[Methods](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#pubmethods)\|[Inherited Methods](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#inhmethods)  

# FontFamily.Builder

*** ** * ** ***

[Kotlin](https://developer.android.com/reference/kotlin/android/graphics/fonts/FontFamily.Builder "View this page in Kotlin")\|Java

`
public
static
final

class
FontFamily.Builder
`  
`

extends `[Object](https://developer.android.com/reference/java/lang/Object)`


``


`

|---|-------------------------------------------|
| [java.lang.Object](https://developer.android.com/reference/java/lang/Object) ||
| ↳ | android.graphics.fonts.FontFamily.Builder |

<br />

*** ** * ** ***

A builder class for creating new FontFamily.

## Summary

|                                                                                                               ### Public constructors                                                                                                                ||
|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|---|
| ` `[Builder](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#Builder(android.graphics.fonts.Font))`(`[Font](https://developer.android.com/reference/android/graphics/fonts/Font)` font) ` Constructs a builder. |

|                                                                                                                                                                                      ### Public methods                                                                                                                                                                                      ||
|------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| ` `[FontFamily.Builder](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder) | ` `[addFont](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#addFont(android.graphics.fonts.Font))`(`[Font](https://developer.android.com/reference/android/graphics/fonts/Font)` font) ` Adds different style font to the builder.            |
| ` `[FontFamily](https://developer.android.com/reference/android/graphics/fonts/FontFamily)                 | ` `[build](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#build())`() ` Build the font family                                                                                                                                                 |
| ` `[FontFamily](https://developer.android.com/reference/android/graphics/fonts/FontFamily)                 | ` `[buildVariableFamily](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#buildVariableFamily())`() ` Build a variable font family that automatically adjust the \`wght\` and \`ital\` axes value for the requested weight/italic style values. |

| ### Inherited methods |
|-----------------------|---|
| From class` `[java.lang.Object](https://developer.android.com/reference/java/lang/Object)` ` |--------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| | ` `[Object](https://developer.android.com/reference/java/lang/Object)          | ` `[clone](https://developer.android.com/reference/java/lang/Object#clone())`() ` Creates and returns a copy of this object.                                                                                                                                                      | | ` boolean`                                                                     | ` `[equals](https://developer.android.com/reference/java/lang/Object#equals(java.lang.Object))`(`[Object](https://developer.android.com/reference/java/lang/Object)` obj) ` Indicates whether some other object is "equal to" this one.                                           | | ` void`                                                                        | ` `[finalize](https://developer.android.com/reference/java/lang/Object#finalize())`() ` Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.                                                          | | ` final `[Class](https://developer.android.com/reference/java/lang/Class)`<?>` | ` `[getClass](https://developer.android.com/reference/java/lang/Object#getClass())`() ` Returns the runtime class of this`Object`.                                                                                                                                                | | ` int`                                                                         | ` `[hashCode](https://developer.android.com/reference/java/lang/Object#hashCode())`() ` Returns a hash code value for the object.                                                                                                                                                 | | ` final void`                                                                  | ` `[notify](https://developer.android.com/reference/java/lang/Object#notify())`() ` Wakes up a single thread that is waiting on this object's monitor.                                                                                                                            | | ` final void`                                                                  | ` `[notifyAll](https://developer.android.com/reference/java/lang/Object#notifyAll())`() ` Wakes up all threads that are waiting on this object's monitor.                                                                                                                         | | ` `[String](https://developer.android.com/reference/java/lang/String)          | ` `[toString](https://developer.android.com/reference/java/lang/Object#toString())`() ` Returns a string representation of the object.                                                                                                                                            | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long,%20int))`(long timeoutMillis, int nanos) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed. | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait(long))`(long timeoutMillis) ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*, or until a certain amount of real time has elapsed.                   | | ` final void`                                                                  | ` `[wait](https://developer.android.com/reference/java/lang/Object#wait())`() ` Causes the current thread to wait until it is awakened, typically by being*notified* or*interrupted*.                                                                                             | ||

## Public constructors

### Builder

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public Builder (Font font)
```

Constructs a builder.

<br />

|                        Parameters                         ||
|--------|---------------------------------------------------|
| `font` | `Font`: a font This value cannot be`null`. <br /> |

## Public methods

### addFont

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
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](https://developer.android.com/reference/java/lang/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.

<br />

|                        Parameters                         ||
|--------|---------------------------------------------------|
| `font` | `Font`: a font This value cannot be`null`. <br /> |

|                                                                         Returns                                                                          ||
|---------------------------------------------------------------------------------------------------------|-------------------------------------------------|
| [FontFamily.Builder](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder) | this builder This value cannot be`null`. <br /> |

### build

Added in[API level 29](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public FontFamily build ()
```

Build the font family

<br />

|                                                                  Returns                                                                  ||
|-----------------------------------------------------------------------------------------|--------------------------------------------------|
| [FontFamily](https://developer.android.com/reference/android/graphics/fonts/FontFamily) | a font family This value cannot be`null`. <br /> |

### buildVariableFamily

Added in[API level 35](https://developer.android.com/guide/topics/manifest/uses-sdk-element#ApiLevels)  

```
public FontFamily buildVariableFamily ()
```

Build a variable font family that automatically adjust the \`wght\` and \`ital\` axes value for the requested weight/italic style values. To build a variable font family, added fonts must meet one of following conditions. If two font files are added, both font files must support \`wght\` axis and one font must support[FontStyle.FONT_SLANT_UPRIGHT](https://developer.android.com/reference/android/graphics/fonts/FontStyle#FONT_SLANT_UPRIGHT)and another font must support[FontStyle.FONT_SLANT_ITALIC](https://developer.android.com/reference/android/graphics/fonts/FontStyle#FONT_SLANT_ITALIC). If the requested weight value is lower than minimum value of the supported \`wght\` axis, the minimum supported \`wght\` value is used. If the requested weight value is larger than maximum value of the supported \`wght\` axis, the maximum supported \`wght\` value is used. The weight values of the fonts are ignored. If one font file is added, that font must support the \`wght\` axis. If that font support \`ital\` axis, that \`ital\` value is set to 1 when the italic style is requested. If that font doesn't support \`ital\` axis, synthetic italic may be used. If the requested weight value is lower than minimum value of the supported \`wght\` axis, the minimum supported \`wght\` value is used. If the requested weight value is larger than maximum value of the supported \`wght\`axis, the maximum supported \`wght\` value is used. The weight value of the font is ignored. If none of the above conditions are met, the provided font files cannot be used for variable font family and this function returns`null`. Even if this function returns`null`, you can still use[build()](https://developer.android.com/reference/android/graphics/fonts/FontFamily.Builder#build())method for creating FontFamily instance with manually specifying variation settings by using[Font.Builder.setFontVariationSettings(String)](https://developer.android.com/reference/android/graphics/fonts/Font.Builder#setFontVariationSettings(java.lang.String)).

<br />

|                                                                                        Returns                                                                                        ||
|-----------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|
| [FontFamily](https://developer.android.com/reference/android/graphics/fonts/FontFamily) | A variable font family. null if a variable font cannot be built from the given fonts. <br /> |