public 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
@Stable public val fontScale: Float
Current user preference for the scaling factor for fonts.
Functions
toSp
public fun Dp.toSp(): TextUnit
Convert Dp to Sp. Sp is used for font size, etc.
toDp
public fun TextUnit.toDp(): Dp
Convert Sp to Dp.
Throws: IllegalStateException
if TextUnit other than SP unit is specified.
public 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
@Stable public val fontScale: Float
Current user preference for the scaling factor for fonts.
Functions
toSp
@Stable public open fun Dp.toSp(): TextUnit
Convert Dp to Sp. Sp is used for font size, etc.
toDp
@Stable public open fun TextUnit.toDp(): Dp
Convert Sp to Dp.
Throws: IllegalStateException
if TextUnit other than SP unit is specified.