FontScaling
Converts [TextUnit] to [Dp] and vice-versa.
FontScaling
@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
val fontScale: Float
Current user preference for the scaling factor for fonts.
Functions
open fun Dp.toSp(): TextUnit
Convert Dp to Sp. Sp is used for font size, etc.
open fun TextUnit.toDp(): Dp
Convert Sp to Dp.
@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
actual val fontScale: Float
Current user preference for the scaling factor for fonts.
Functions
actual fun Dp.toSp(): TextUnit
Convert Dp to Sp. Sp is used for font size, etc.
actual fun TextUnit.toDp(): Dp
Convert Sp to Dp.