public class Mode internal constructor(internal val value: Int)
Determines how line height is calculated across lines in a paragraph.
Fixed, Minimum, and Tight measure font metrics on the first line only and apply that single calculated height to every line in the paragraph. If subsequent lines are taller than the first line (such as lines with larger font sizes or taller scripts), they will still use the first line's height and may clip.
Text with mixed font sizes or mixed scripts should use PerLine, which measures each line independently.
Members
Companion
public companion object
Properties
Fixed
public val Fixed: Mode
Sets the same line height for each line, calculated from the font metrics of the first line only.
If the requested line height is smaller than the first line's font metrics, adds padding outside the first line top and last line bottom to prevent clipping at the paragraph boundaries. Middle lines are not padded and will clip if they overflow.
If later lines are taller than the first line, they do not expand and may clip.
This is the default mode in LineHeightStyle.Default.
Minimum
public val Minimum: Mode
Sets the same line height for each line, calculated from the font metrics of the first line only.
If the requested line height is smaller than the first line's font metrics, uses the first line's natural height for all lines instead of shrinking them. If the requested line height is larger, behaves the same as Fixed.
If later lines are taller than the first line, they do not expand and may clip.
Tight
public val Tight: Mode
Sets the requested line height on every line based on the first line only, without adding top or bottom padding.
If the requested line height is smaller than the font metrics of any line, that line will clip.
PerLine
public val PerLine: Mode
Calculates line height independently for each line.
Unlike Fixed, Minimum, and Tight (which only measure the first line), PerLine measures every line. If a line's natural font height exceeds the requested line height, that line expands to its natural height.
Use PerLine when text contains mixed font sizes or mixed scripts so that tall lines do not clip and short lines do not leave extra gaps:
Mode.Fixed / Mode.Minimum (Only measures Line 1; Line 2 may clip):
+----------------------------------------------+
| Line 1 (Small font, measures line height) |
+----------------------------------------------+
| Line 2 (TALL SCRIPT - clips or overlaps!) |
+----------------------------------------------+
| Line 3 (Small font) |
+----------------------------------------------+
Mode.PerLine (Measures each line independently):
+----------------------------------------------+
| Line 1 (Small font, compact line height) |
+----------------------------------------------+
| Line 2 (TALL SCRIPT - expands to fit) |
+----------------------------------------------+
| Line 3 (Small font, compact line height) |
+----------------------------------------------+