# FontScaling

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

  ```
  interface FontScaling
  ```
Known direct subclasses [Density](https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Density` | A density of the screen. |

Known indirect subclasses [ApproachIntrinsicMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachIntrinsicMeasureScope), [ApproachMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachMeasureScope), [AwaitPointerEventScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/AwaitPointerEventScope), [BlurScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/BlurScope), [CacheDrawScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/CacheDrawScope), [CanvasDrawScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/CanvasDrawScope), [CommonStyleScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyleScope), [ContentDrawScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/ContentDrawScope), [CustomStyleScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CustomStyleScope), [DragAndDropSourceScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/draganddrop/DragAndDropSourceScope), [DrawScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope), [DropShadowScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/DropShadowScope), [FlexBoxConfigScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/FlexBoxConfigScope), [FlexConfigScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/FlexConfigScope), [GraphicsLayerScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope), [GridConfigurationScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/GridConfigurationScope), [IndirectPointerInjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/IndirectPointerInjectionScope), [InjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope), [InnerShadowScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/InnerShadowScope), [IntrinsicMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/IntrinsicMeasureScope), [KeyInjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/KeyInjectionScope), [LazyLayoutMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutMeasureScope), [MeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope), [MouseInjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope), [MultiModalInjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MultiModalInjectionScope), [Placeable.PlacementScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Placeable.PlacementScope), [PointerInputScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputScope), [PolygonShapeScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope), [PolygonShapeTransformScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeTransformScope), [PressGestureScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/PressGestureScope), [RotaryInjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope), [RulerScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RulerScope), [ShadowScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/ShadowScope), [StyleResolverScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolverScope), [StyleScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleScope), [SubcomposeMeasureScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope), [SubspaceMeasureScope](https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceMeasureScope), [TextAutoSizeLayoutScope](https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/modifiers/TextAutoSizeLayoutScope), [TouchInjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/TouchInjectionScope), [TrackpadInjectionScope](https://developer.android.com/reference/kotlin/androidx/compose/ui/test/TrackpadInjectionScope)

|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachIntrinsicMeasureScope` | The receiver scope of a layout's intrinsic approach measurements lambdas. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachMeasureScope` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachMeasureScope` provides access to lookahead results to allow `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/ApproachLayoutModifierNode` to leverage lookahead results to define how measurements and placements approach their destination. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/AwaitPointerEventScope` | Receiver scope for awaiting pointer events in a call to `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputScope#awaitPointerEventScope(kotlin.coroutines.SuspendFunction1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/BlurScope` | Configures progressive `https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/blur.modifier#(androidx.compose.ui.Modifier).blur(androidx.compose.ui.unit.Dp,androidx.compose.ui.unit.Dp,androidx.compose.ui.draw.BlurredEdgeTreatment)` layer properties. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/CacheDrawScope` | Handle to a drawing environment that enables caching of content based on the resolved size. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/CanvasDrawScope` | Implementation of `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope` that issues drawing commands into the specified canvas and bounds via `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/CanvasDrawScope#draw(androidx.compose.ui.unit.Density,androidx.compose.ui.unit.LayoutDirection,androidx.compose.ui.graphics.Canvas,androidx.compose.ui.geometry.Size,kotlin.Function1)` |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyleScope` | A `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyleScope` is the scope used by a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CommonStyle`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/ContentDrawScope` | Receiver scope for drawing content into a layout, where the content can be drawn between other canvas operations. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/CustomStyleScope` | An interface that is the base interface for all styles scopes. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/draganddrop/DragAndDropSourceScope` | **This interface is deprecated.** Replaced by a callback for obtain a transfer data,start detection is performed by Compose itself |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/drawscope/DrawScope` | Creates a scoped drawing environment with the provided `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/Canvas`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/DropShadowScope` | Scope that provides the capability to configure the properties of a drop shadow in order to support efficient transformations without recomposition |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/FlexBoxConfigScope` | Receiver scope for configuring `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/FlexBox.composable#FlexBox(androidx.compose.ui.Modifier,androidx.compose.foundation.layout.FlexBoxConfig,kotlin.Function1)` container properties. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/FlexConfigScope` | Scope for configuring flex item properties within a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/FlexBox.composable#FlexBox(androidx.compose.ui.Modifier,androidx.compose.foundation.layout.FlexBoxConfig,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope` | A scope which can be used to define the effects to apply for the content, such as scaling (`https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#scaleX()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#scaleY()`), rotation (`https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#rotationX()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#rotationY()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#rotationZ()`), opacity (`https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#alpha()`), shadow (`https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#shadowElevation()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#shape()`), and clipping (`https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#clip()`, `https://developer.android.com/reference/kotlin/androidx/compose/ui/graphics/GraphicsLayerScope#shape()`). |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/GridConfigurationScope` | Scope for configuring the structure of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/layout/Grid.composable#Grid(kotlin.Function1,androidx.compose.ui.Modifier,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/IndirectPointerInjectionScope` | The receiver scope of the indirect pointer input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performIndirectPointerInput(androidx.compose.ui.input.indirect.IndirectPointerEventPrimaryDirectionalMotionAxis,androidx.compose.ui.unit.IntSize,kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/InjectionScope` | The receiver scope for input injection lambdas that are tied to a specific node, such as `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performTouchInput(kotlin.Function1)` and `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMouseInput(kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/InnerShadowScope` | Scope that provides the capability to configure the properties of an inner shadow in order to support efficient transformations without recomposition |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/IntrinsicMeasureScope` | The receiver scope of a layout's intrinsic measurements lambdas. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/KeyInjectionScope` | The receiver scope of the key input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performKeyInput(kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayoutMeasureScope` | The receiver scope of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/lazy/layout/LazyLayout.composable#LazyLayout(kotlin.Function0,androidx.compose.ui.Modifier,androidx.compose.foundation.lazy.layout.LazyLayoutPrefetchState,androidx.compose.foundation.lazy.layout.LazyLayoutMeasurePolicy)`'s measure lambda. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope` | The receiver scope of a layout's measure lambda. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MouseInjectionScope` | The receiver scope of the mouse input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMouseInput(kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/MultiModalInjectionScope` | The receiver scope of the multi-modal input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performMultiModalInput(kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Placeable.PlacementScope` | Receiver scope that permits explicit placement of a `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Placeable`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputScope` | Receiver scope for `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/pointerInput.modifier#(androidx.compose.ui.Modifier).pointerInput(kotlin.coroutines.SuspendFunction1)` that permits `https://developer.android.com/reference/kotlin/androidx/compose/ui/input/pointer/PointerInputScope#awaitPointerEventScope(kotlin.coroutines.SuspendFunction1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeScope` | Builds `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeGeometry` for a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape` at layout resolution. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShapeTransformScope` | Transforms a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape`'s geometry inside `https://developer.android.com/reference/kotlin/androidx/compose/foundation/shape/PolygonShape#transform(kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/PressGestureScope` | Receiver scope for `https://developer.android.com/reference/kotlin/androidx/compose/foundation/gestures/package-summary#(androidx.compose.ui.input.pointer.PointerInputScope).detectTapGestures(kotlin.Function1,kotlin.Function1,kotlin.coroutines.SuspendFunction2,kotlin.Function1)`'s `onPress` lambda. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/RotaryInjectionScope` | The receiver scope of rotary input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performRotaryScrollInput(kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/RulerScope` | A scope used in `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope#layout(kotlin.Int,kotlin.Int,kotlin.collections.Map,kotlin.Function1)` for the `rulers` parameter to allow a layout to define `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/Ruler` values for children. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/draw/ShadowScope` | Scope that can be used to define properties to render either a drop shadow or inner shadow. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolverScope` | The type of the scope of `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleResolver#resolve(kotlin.Function1)` that allows the `block` to read the fully resolved values from a style. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleScope` | A `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/StyleScope` is the receiver scope of a `https://developer.android.com/reference/kotlin/androidx/compose/foundation/style/Style` lambda. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeMeasureScope` | The receiver scope of a `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/SubcomposeLayout.composable#SubcomposeLayout(androidx.compose.ui.Modifier,kotlin.Function2)`'s measure lambda which adds ability to dynamically subcompose a content during the measuring on top of the features provided by `https://developer.android.com/reference/kotlin/androidx/compose/ui/layout/MeasureScope`. |
| `https://developer.android.com/reference/kotlin/androidx/xr/compose/subspace/layout/SubspaceMeasureScope` | The receiver scope of a layout's measure lambda. |
| `https://developer.android.com/reference/kotlin/androidx/compose/foundation/text/modifiers/TextAutoSizeLayoutScope` | An entity that allows performing text layout for auto sizing text. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/TouchInjectionScope` | The receiver scope of the touch input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performTouchInput(kotlin.Function1)`. |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/TrackpadInjectionScope` | The receiver scope of the trackpad input injection lambda from `https://developer.android.com/reference/kotlin/androidx/compose/ui/test/package-summary#(androidx.compose.ui.test.SemanticsNodeInteraction).performTrackpadInput(kotlin.Function1)`. |

*** ** * ** ***

Converts `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` and vice-versa.

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

## Summary

| ### Public functions |
|---|---|---|
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.TextUnit).toDp()()` Convert Sp to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`. | Cmn android |
| `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/TextUnit` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp.https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#(androidx.compose.ui.unit.Dp).toSp()()` Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to Sp. | Cmn android |

| ### Public properties |
|---|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-float/index.html` | `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/FontScaling#fontScale()` Current user preference for the scaling factor for fonts. | Cmn android |

## Public functions

### TextUnit.toDp

Cmn android Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/FontScaling.+function:toDp) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

Convert Sp to `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp`.

| Throws |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-illegal-state-exception/index.html` | if TextUnit other than SP unit is specified. |

### Dp.toSp

Cmn android Artifact: [androidx.compose.ui:ui-unit](https://developer.android.com/jetpack/androidx/releases/compose-ui) [View Source](https://cs.android.com/search?q=file:androidx/compose/ui/unit/FontScaling.+function:toSp) Added in [1.10.0](https://developer.android.com/jetpack/androidx/releases/compose-ui#1.10.0)

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

Convert `https://developer.android.com/reference/kotlin/androidx/compose/ui/unit/Dp` to Sp. Sp is used for font size, etc.

## Public properties

### fontScale

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

```
val fontScale: Float
```

Current user preference for the scaling factor for fonts.