# FontSynthesis

Artifact: [androidx.compose.ui:ui-text](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/text/font/FontSynthesis.kt+class:androidx.compose.ui.text.font.FontSynthesis) Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0) Common/AllAndroid/JVM
- Cmn

  ```
  value class FontSynthesis
  ```

*** ** * ** ***

Possible options for font synthesis.

`FontSynthesis` is used to specify whether the system should fake bold or slanted glyphs when the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` used does not contain bold or oblique `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/Font`s.

If the font family does not include a requested `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontStyle`, the system fakes bold or slanted glyphs when the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#Weight()` or `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#Style()`, respectively, or both when `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#All()` is set. If this is not desired, use `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#None()` to disable font synthesis.

It is possible to fake an increase of `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontWeight` but not a decrease. It is possible to fake a regular font slanted, but not vice versa.

`FontSynthesis` works the same way as the [CSS font-synthesis](https://www.w3.org/TR/css-fonts-4/#font-synthesis) property.

```kotlin
import androidx.compose.material3.Text
import androidx.compose.ui.text.TextStyle
import androidx.compose.ui.text.font.Font
import androidx.compose.ui.text.font.FontFamily
import androidx.compose.ui.text.font.FontSynthesis
import androidx.compose.ui.text.font.FontWeight

// The font family contains a single font, with normal weight
val fontFamily = FontFamily(Font(resId = R.font.myfont, weight = FontWeight.Normal))
// Configuring the Text composable to be bold
// Using FontSynthesis.Weight to have the system render the font bold my making the glyphs
// thicker
Text(
    text = "Demo Text",
    style =
        TextStyle(
            fontFamily = fontFamily,
            fontWeight = FontWeight.Bold,
            fontSynthesis = FontSynthesis.Weight,
        ),
)
```

## Summary

| ### Public companion functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#valueOf(kotlin.Int)(value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html)` Creates a FontSynthesis from the given integer value. | Cmn |

| ### Public companion properties |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#All()` The system synthesizes both bold and slanted fonts if either of them are not available in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily` | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#None()` Turns off font synthesis. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#Style()` Only an slanted font is synthesized, if it is not available in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`. | Cmn |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#Weight()` Only a bold font is synthesized, if it is not available in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`. | Cmn |

| ### Public functions |
|---|---|---|
| `open https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#toString()()` | Cmn |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#value()` The integer representation of the FontSynthesis. | Cmn |

## Public companion functions

### valueOf

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
fun valueOf(value: Int): FontSynthesis
```

Creates a FontSynthesis from the given integer value. This can be useful if you need to serialize/deserialize FontSynthesis values.

| Parameters |
|---|---|
| `value: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | The integer representation of the FontSynthesis. |

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-argument-exception/index.html` | if the given `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis.Companion#valueOf(kotlin.Int)` is not recognized. |

| See also |
|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontSynthesis#value()` |   |

## Public companion properties

### All

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val All: FontSynthesis
```

The system synthesizes both bold and slanted fonts if either of them are not available in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`

### None

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val None: FontSynthesis
```

Turns off font synthesis. Neither bold nor slanted faces are synthesized if they don't exist in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`

### Style

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Style: FontSynthesis
```

Only an slanted font is synthesized, if it is not available in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`. Bold fonts will not be synthesized.

### Weight

Cmn Added in [1.0.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.0.0)

```
val Weight: FontSynthesis
```

Only a bold font is synthesized, if it is not available in the `https://developer.android.com/reference/kotlin/androidx/compose/ui/text/font/FontFamily`. Slanted fonts will not be synthesized.

## Public functions

### toString

Cmn

```
open fun toString(): String
```

## Public properties

### value

Cmn Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

```
val value: Int
```

The integer representation of the FontSynthesis.