---
title: "FontSynthesis"
description: "Possible options for font synthesis.

`FontSynthesis` is used to specify whether the system should fake bold or slanted glyphs when the
[FontFamily] used does not contain bold or oblique [Font]s.

If the font family does not include a requested [FontWeight] or [FontStyle], the system fakes
bold or slanted glyphs when the [Weight] or [Style], respectively, or both when [All] is set. If
this is not desired, use [None] to disable font synthesis.

It is possible to fake an increase of [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."
type: "class"
---

<div class='type'>Class</div>


<a id='references'></a>

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


```kotlin
value class FontSynthesis internal constructor(val value: Int)
```


Possible options for font synthesis.

`FontSynthesis` is used to specify whether the system should fake bold or slanted glyphs when the
`FontFamily` used does not contain bold or oblique `Font`s.

If the font family does not include a requested `FontWeight` or `FontStyle`, the system fakes
bold or slanted glyphs when the `Weight` or `Style`, respectively, or both when `All` is set. If
this is not desired, use `None` to disable font synthesis.

It is possible to fake an increase of `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.


## Companion Object

#### Properties

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


```kotlin
val None = FontSynthesis(0)
```


Turns off font synthesis. Neither bold nor slanted faces are synthesized if they don't
exist in the `FontFamily`



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


```kotlin
val Weight = FontSynthesis(WeightFlag)
```


Only a bold font is synthesized, if it is not available in the `FontFamily`. Slanted
fonts will not be synthesized.



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


```kotlin
val Style = FontSynthesis(StyleFlag)
```


Only an slanted font is synthesized, if it is not available in the `FontFamily`. Bold
fonts will not be synthesized.



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


```kotlin
val All = FontSynthesis(AllFlags)
```


The system synthesizes both bold and slanted fonts if either of them are not available in
the `FontFamily`



#### Methods

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


```kotlin
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 | The integer representation of the FontSynthesis. |






## Code Examples

### FontFamilySynthesisSample
```kotlin
@Composable
fun FontFamilySynthesisSample() {
    // 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,
            ),
    )
}
```

