🌈 Create new beautiful Compose Gradients with our new wesite ->
Class

LineHeightStyle.Trim

Controls trimming of extra space from the first line top and last line bottom.

Source set: Common
public class Trim internal constructor(internal val value: Int)

Controls trimming of extra space from the first line top and last line bottom.

Requires PlatformParagraphStyle.includeFontPadding to be false to take effect.

Trimming behavior depends on the selected Mode:

    taller than the font default (prevents clipping).

  • Mode.Fixed / Mode.Minimum: Trims extra space only when the configured line height is
  • default.

  • Mode.Tight: Trims space even when the configured line height is shorter than the font

Warning: Use Mode.Tight with caution to avoid cutting off tall characters or accents. Test your text layout with tall scripts (e.g., Arabic "العَرَبِيَّةُ", Tibetan "དབུ་ཅན་", or Burmese "မြန်မာဘာသာ") before using in production.

Functions

isTrimFirstLineTop

Source set: Common
public fun isTrimFirstLineTop(): Boolean

Returns true if this Trim configuration trims the space at the top of the first line.

isTrimLastLineBottom

Source set: Common
public fun isTrimLastLineBottom(): Boolean

Returns true if this Trim configuration trims the space at the bottom of the last line.

Members

Companion

Source set: Common
public companion object

Properties

FirstLineTop

Source set: Common
public val FirstLineTop: Trim

Trim the space that would be added to the top of the first line as a result of the line height. Single line text is both the first and last line. This feature is available only when PlatformParagraphStyle.includeFontPadding is false.

For example, when line height is 3.em, and Alignment is Alignment.Center, the first line has 2.em height and the height from first line baseline to second line baseline is still 3.em:

+--------+ | Line1 | | | |--------| | | | Line2 | | | +--------+

LastLineBottom

Source set: Common
public val LastLineBottom: Trim

Trim the space that would be added to the bottom of the last line as a result of the line height. Single line text is both the first and last line. This feature is available only when PlatformParagraphStyle.includeFontPadding is false.

For example, when line height is 3.em, and Alignment is Alignment.Center, the last line has 2.em height and the height from first line baseline to second line baseline is still 3.em:

+--------+ | | | Line1 | | | |--------| | | | Line2 | +--------+

Both

Source set: Common
public val Both: Trim

Trim the space that would be added to the top of the first line and bottom of the last line as a result of the line height. This feature is available only when PlatformParagraphStyle.includeFontPadding is false.

For example, when line height is 3.em, and Alignment is Alignment.Center, the first and last line has 2.em height and the height from first line baseline to second line baseline is still 3.em:

+--------+ | Line1 | | | |--------| | | | Line2 | +--------+

None

Source set: Common
public val None: Trim

Do not trim first line top or last line bottom.

For example, when line height is 3.em, and Alignment is Alignment.Center, the first line height, last line height and the height from first line baseline to second line baseline are 3.em:

+--------+ | | | Line1 | | | |--------| | | | Line2 | | | +--------+