---
title: "FontScaling"
description: "Converts [TextUnit] to [Dp] and vice-versa.

If you are implementing this interface yourself on Android, please check the docs for important
optimization tips about caching."
type: "interface"
---

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


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

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



```kotlin
@JvmDefaultWithCompatibility
expect interface FontScaling
```


Converts `TextUnit` to `Dp` and vice-versa.

If you are implementing this interface yourself on Android, please check the docs for important
optimization tips about caching.


## Properties

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


```kotlin
val fontScale: Float
```


Current user preference for the scaling factor for fonts.



## Functions

```kotlin
open fun Dp.toSp(): TextUnit
```


Convert `Dp` to Sp. Sp is used for font size, etc.


```kotlin
open fun TextUnit.toDp(): Dp
```


Convert Sp to `Dp`.



<div class='sourceset sourceset-android'>Android</div>



```kotlin
@JvmDefaultWithCompatibility
actual interface FontScaling
```


Converts `TextUnit` to `Dp` and vice-versa.

Note that the converter can't be cached in the interface itself. FontScaleConverterFactory
already caches the tables, but it still does a a map lookup for each conversion. If you are
implementing this interface, you should cache your own converter for additional speed.


## Properties

<div class='sourceset sourceset-android'>Android</div>


```kotlin
actual val fontScale: Float
```


Current user preference for the scaling factor for fonts.



## Functions

```kotlin
actual fun Dp.toSp(): TextUnit
```


Convert `Dp` to Sp. Sp is used for font size, etc.


```kotlin
actual fun TextUnit.toDp(): Dp
```


Convert Sp to `Dp`.



