Interface

FontScaling

Converts TextUnit to Dp and vice-versa.

Source set: Common
@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

fontScale

Source set: Common
val fontScale: Float

Current user preference for the scaling factor for fonts.

Functions

toSp

open fun Dp.toSp(): TextUnit

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

toDp

open fun TextUnit.toDp(): Dp

Convert Sp to Dp.

Source set: Android
@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

fontScale

Source set: Android
actual val fontScale: Float

Current user preference for the scaling factor for fonts.

Functions

toSp

actual fun Dp.toSp(): TextUnit

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

toDp

actual fun TextUnit.toDp(): Dp

Convert Sp to Dp.

Last updated: