Skip to main content

Module font_scale

Module font_scale 

Source
Expand description

The system font-size setting, as the curve it is and not the multiplier it looks like.

A size in Sp used to be sp * font_scale dp, and on Android 13 and below that is exactly what the platform does. Android 14 replaced it: above a threshold setting the platform runs the sp value through a piecewise-linear table, so small text grows by the full setting and large text grows by less. TypedValue.applyDimension(COMPLEX_UNIT_SP, ..) answers from that table, and Jetpack Compose carries its own copy so its Density answers the same.

Measured on a Wear OS 5 emulator at density 2.0 with the setting at 1.24 (TypedValue.applyDimension and androidx.compose.ui.unit.Density(context) agree to the last bit on every sample):

spmultipliedplatform
1229.76 px29.76 px
1332.24 px32.72 px
1434.72 px35.68 px
1639.68 px38.72 px
1947.12 px43.76 px

So multiplying is wrong in both directions at once, and by enough to change where a line wraps. A FontScaleCurve carries the platform’s answer instead: the host samples the real conversion when the configuration says it changed, and everything that resolves an Sp goes through FontScaleCurve::sp_to_dp.

Off Android, and on an Android below the version that has a table, the curve holds no knots and sp_to_dp is the multiplication again — which is what those platforms actually do.

Structs§

FontScaleCurve
The sp → dp conversion the platform performs, sampled from the platform.

Constants§

MAX_FONT_SCALE_KNOTS
How many knots a curve keeps.