androidx.compose.ui.unit
TextUnit
Value class · from org.jetbrains.compose.ui:ui-unit:1.12.2
No hand-written docs yet.
The unit used for text related dimension value.
value class TextUnit
How to get one
Create it
TextUnit(value: Float, type: TextUnitType)
Ready-made values and functions that return it
Density:toSp()FontScaling:toSp()TextAutoSize:getFontSize()TextStyle:fontSize,letterSpacing,lineHeightspem
Used by
Parameters that take a TextUnit.
paddingFrom(before, after)paddingFromBaseline(top, bottom)Text(fontSize, letterSpacing, lineHeight)TextAutoSize.StepBased(minFontSize, maxFontSize, stepSize)TextAutoSizeLayoutScope.performLayout(fontSize)TextStyle.copy(fontSize, letterSpacing, lineHeight)TextStyle.merge(fontSize, letterSpacing, lineHeight)TextUnit.compareTo(other)
Properties
Unspecified
val Unspecified
A special TextUnit instance for representing inheriting from parent value.
type
val type: TextUnitType
A type information of this TextUnit.
isSp
val isSp
True if this is a SP unit type.
isEm
val isEm
True if this is a EM unit type.
value
val value
Returns the value of this TextUnit.
Functions
unaryMinus
fun unaryMinus(): TextUnit
This is the same as multiplying the TextUnit by -1.0.
div
fun div(other: Float): TextUnit
Divide a TextUnit by a scalar.
fun div(other: Double): TextUnit
Divide a TextUnit by a scalar.
fun div(other: Int): TextUnit
Divide a TextUnit by a scalar.
times
fun times(other: Float): TextUnit
Multiply a TextUnit by a scalar.
fun times(other: Double): TextUnit
Multiply a TextUnit by a scalar.
fun times(other: Int): TextUnit
Multiply a TextUnit by a scalar.
compareTo
fun compareTo(other: TextUnit): Int
Support comparing Dimensions with comparison operators.
Library docs
The unit used for text related dimension value.
This unit can hold either scaled pixels (SP), relative font size (EM) and special unit
Unspecified for indicating inheriting from other style or using the default value. It can be
created with sp or em. (e.g. 15.sp or 18.em) which can be applied to Int, Double, and
Float.
Note that do not store this value in your persistent storage or send to another process since the internal representation may be changed in future.