whats use of `TextUnitType.Em` and how it differs ...
# compose
v
whats use of
TextUnitType.Em
and how it differs from
Sp
?
Copy code
@kotlin.jvm.JvmInline
value class TextUnitType(internal val type: Long) {
    override fun toString(): String {
        return when (this) {
            Unspecified -> "Unspecified"
            Sp -> "Sp"
            Em -> "Em"
            else -> "Invalid"
        }
    }

    companion object {
        val Unspecified = TextUnitType(UNIT_TYPE_UNSPECIFIED)
        val Sp = TextUnitType(UNIT_TYPE_SP)
        val Em = TextUnitType(UNIT_TYPE_EM)
    }
}
s
https://developer.android.com/develop/ui/compose/text/style-paragraph#adjust-line-height This article says: "You may want to adjust
lineHeight
using the text unit “em” (relative font size) instead of “sp” (scaled pixels) for improved precision. For more information about selecting an appropriate text unit, see `TextUnit`" So it looks like it's a scale relative to a baseline. I don't know how 1em is defined though 👀 I know we use them for
letterSpacing
, and there I guess there is a "baseline" letter spacing and we can increase/decrease that relative to what that baseline is.
v
Got it. Thanks.
z
Sp obeys the accessibility font scale settings
👍 1
106 Views