<div class='sourceset sourceset-common'>Common</div>

```kotlin
object FontVariation
```

Set font variation settings.

To learn more about the font variation settings, see the list supported by
[fonts.google.com](https://fonts.google.com/variablefonts#axis-definitions).

## Functions

<h2 id="setting-name-value">Setting</h2>

```kotlin
fun Setting(name: String, value: Float): Setting
```

Create a font variation setting for any axis supported by a font.

```
val setting = FontVariation.Setting('wght', 400f);
```

You should typically not use this in app-code directly, instead define a method for each
setting supported by your app/font.

If you had a setting `fzzt` that set a variation setting called fizzable between 1 and 11,
define a function like this:
```
fun FontVariation.fizzable(fiz: Int): FontVariation.Setting {  require(fiz in 1..11) { "'fzzt' must be in 1..11" }  return Setting("fzzt", fiz.toFloat())
```

#### Parameters

| | |
| --- | --- |
| name | axis name, must be 4 characters |
| value | value for axis, not validated and directly passed to font |

<hr class="docs-overload-divider">

<h2 id="italic-value">italic</h2>

```kotlin
fun italic(value: Float): Setting
```

Italic or upright, equivalent to [FontStyle](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontStyle)

'ital', 0.0f is upright, and 1.0f is italic.

A platform _may_ provide automatic setting of `ital` on font load. When supported, `ital` is
automatically applied based on [FontStyle](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontStyle) if platform and the loaded font support 'ital'.

Automatic mapping is done via [Settings](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontVariation.Settings)\([FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight), [FontStyle](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontStyle)\)

To override this behavior provide an explicit FontVariation.italic to a [Font](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Font) that supports
variation settings.

#### Parameters

| | |
| --- | --- |
| value | [0.0f, 1.0f] |

<hr class="docs-overload-divider">

<h2 id="opticalsizing-textsize">opticalSizing</h2>

```kotlin
fun opticalSizing(textSize: TextUnit): Setting
```

Optical size is how "big" a font appears to the eye.

It should be set by a ratio from a font size.

Adapt the style to specific text sizes. At smaller sizes, letters typically become optimized
for more legibility. At larger sizes, optimized for headlines, with more extreme weights and
widths.

A Platform _may_ choose to support automatic optical sizing. When present, this will set the
optical size based on the font size.

To override this behavior provide an explicit FontVariation.opticalSizing to a [Font](/jetpack-compose/androidx.compose.ui/ui-text/interfaces/Font) that
supports variation settings.

#### Parameters

| | |
| --- | --- |
| textSize | font-size at the expected display, must be in sp |

<hr class="docs-overload-divider">

<h2 id="slant-value">slant</h2>

```kotlin
fun slant(value: Float): Setting
```

Adjust the style from upright to slanted, also known to typographers as an 'oblique' style.

Rarely, slant can work in the other direction, called a 'backslanted' or 'reverse oblique'
style.

'slnt', values as an angle, 0f is upright.

#### Parameters

| | |
| --- | --- |
| value | -90f to 90f, represents an angle |

<hr class="docs-overload-divider">

<h2 id="width-value">width</h2>

```kotlin
fun width(value: Float): Setting
```

Width of the type.

Adjust the style from narrower to wider, by varying the proportions of counters, strokes,
spacing and kerning, and other aspects of the type. This typically changes the typographic
color in a subtle way, and so may be used in conjunction with Width and Grade axes.

'wdth', such as 10f

#### Parameters

| | |
| --- | --- |
| value | > 0.0f represents the width |

<hr class="docs-overload-divider">

<h2 id="weight-value">weight</h2>

```kotlin
fun weight(value: Int): Setting
```

Weight, equivalent to [FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight)

Setting weight always causes visual text reflow, to make text "bolder" or "thinner" without
reflow see [grade](#grade)

Adjust the style from lighter to bolder in typographic color, by varying stroke weights,
spacing and kerning, and other aspects of the type. This typically changes overall width, and
so may be used in conjunction with Width and Grade axes.

This is equivalent to [FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight), and platforms _may_ support automatically setting 'wghts'
from [FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight) during font load.

Setting this does not change [FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight). If an explicit value and [FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight) disagree,
the weight specified by `wght` will be shown if the font supports it.

Automatic mapping is done via [Settings](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontVariation.Settings)\([FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight), [FontStyle](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontStyle)\)

#### Parameters

| | |
| --- | --- |
| value | weight, in 1..1000 |

<hr class="docs-overload-divider">

<h2 id="grade-value">grade</h2>

```kotlin
fun grade(value: Int): Setting
```

Change visual weight of text without text reflow.

Finesse the style from lighter to bolder in typographic color, without any changes overall
width, line breaks or page layout. Negative grade makes the style lighter, while positive
grade makes it bolder. The units are the same as in the Weight axis.

Visual appearance of text with weight and grade set is similar to text with

```
weight = (weight + grade)
```

#### Parameters

| | |
| --- | --- |
| value | grade, in -1000..1000 |

<hr class="docs-overload-divider">

<h2 id="settings-weight-style-settings">Settings</h2>

```kotlin
fun Settings(weight: FontWeight, style: FontStyle, vararg settings: Setting): Settings
```

Variation settings to configure a font with [FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight) and [FontStyle](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontStyle)

#### Parameters

| | |
| --- | --- |
| weight | to set 'wght' with [weight](/jetpack-compose/androidx.wear.compose/compose-foundation/functions/weight)\([FontWeight.weight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight)) |
| style | to set 'ital' with [italic](#italic)\([FontStyle.value](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontStyle)) |
| settings | other settings to apply, must not contain 'wght' or 'ital' |

#### Returns

| | |
| --- | --- |
|  | settings that configure [FontWeight](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontWeight) and [FontStyle](/jetpack-compose/androidx.compose.ui/ui-text/classes/FontStyle) on a font that supports 'wght' and 'ital' |