Interface

FontScaling

Converts TextUnit to Dp and vice-versa.

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

Source set: Android
@Stable public val fontScale: Float

Current user preference for the scaling factor for fonts.

Functions

toSp

Source set: Android
public fun Dp.toSp(): TextUnit

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

toDp

Source set: Android
public fun TextUnit.toDp(): Dp

Convert Sp to Dp.

Throws: IllegalStateException

if TextUnit other than SP unit is specified.

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

Source set: Common
@Stable public val fontScale: Float

Current user preference for the scaling factor for fonts.

Functions

toSp

Source set: Common
@Stable public open fun Dp.toSp(): TextUnit

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

toDp

Source set: Common
@Stable public open fun TextUnit.toDp(): Dp

Convert Sp to Dp.

Throws: IllegalStateException

if TextUnit other than SP unit is specified.

Jetpack Compose beyond MaterialFree components, screens and templates for apps that don’t look like Google’s. Copy them into your app, or let your coding agent add them.Browse for free

Content updated: