LineBreak

Class

Common
expect value class LineBreak private constructor(internal val mask: Int)

When soft wrap is enabled and the width of the text exceeds the width of its container, line breaks are inserted in the text to split it over multiple lines.

There are a number of parameters that affect how the line breaks are inserted. For example, the breaking algorithm can be changed to one with improved readability at the cost of speed. Another example is the strictness, which in some languages determines which symbols can appear at the start of a line.

LineBreak represents a configuration for line breaking, offering several presets for different use cases: Simple, Heading, Paragraph.

For further customization, each platform has its own parameters. An example on Android:

Companion Object

Properties

Common
val Simple: LineBreak

Basic, fast line breaking. Ideal for text input fields, as it will cause minimal text reflow when editing.

Common
val Heading: LineBreak

Looser breaking rules, suitable for short text such as titles or narrow newspaper columns. For longer lines of text, use Paragraph for improved readability.

Common
val Paragraph: LineBreak

Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.

Common
val Unspecified: LineBreak

This represents an unset value, a usual replacement for "null" when a primitive value is desired.

Android
actual value class LineBreak internal constructor(internal val mask: Int)

When soft wrap is enabled and the width of the text exceeds the width of its container, line breaks are inserted in the text to split it over multiple lines.

There are a number of parameters that affect how the line breaks are inserted. For example, the breaking algorithm can be changed to one with improved readability at the cost of speed. Another example is the strictness, which in some languages determines which symbols can appear at the start of a line.

This represents a configuration for line breaking on Android, describing Strategy, Strictness, and WordBreak.

Secondary Constructors

constructor(
    strategy: Strategy,
    strictness: Strictness,
    wordBreak: WordBreak,
) : this(packBytes(strategy.value, strictness.value, wordBreak.value))

This represents a configuration for line breaking on Android, describing Strategy, Strictness, and WordBreak.

Parameters

strategydefines the algorithm that inserts line breaks
strictnessdefines the line breaking rules
wordBreakdefines how words are broken

Properties

Android
val strategy: Strategy
Android
val strictness: Strictness
Android
val wordBreak: WordBreak

Functions

fun copy(
        strategy: Strategy = this.strategy,
        strictness: Strictness = this.strictness,
        wordBreak: WordBreak = this.wordBreak,
    ): LineBreak

Companion Object

Properties

Android
actual val Simple: LineBreak

The greedy, fast line breaking algorithm. Ideal for text that updates often, such as a text editor, as the text will reflow minimally.

+---------+
 This is |
 an      |
 example |
 text.   |
 今日は自  |
 由が丘で  |
 焼き鳥を  |
 食べま   |
 す。     |
+---------+
Android
actual val Heading: LineBreak

Balanced line lengths, hyphenation, and phrase-based breaking. Suitable for short text such as titles or narrow newspaper columns.

+---------+
 This    |
 is an   |
 example |
 text.   |
 今日は   |
 自由が丘  |
 で焼き鳥  |
 を食べ   |
 ます。   |
+---------+
Android
actual val Paragraph: LineBreak

Slower, higher quality line breaking for improved readability. Suitable for larger amounts of text.

+---------+
 This    |
 is an   |
 example |
 text.   |
 今日は自  |
 由が丘で  |
 焼き鳥を  |
 食べま   |
 す。     |
+---------+
Android
actual val Unspecified: LineBreak

This represents an unset value, a usual replacement for "null" when a primitive value is desired.