Table of Contents

Struct LineBreakEnumerator

Namespace
Egami.Fonts.Layout
Assembly
Egami.Fonts.dll

Enumerates line break opportunities; get one from Enumerate(ReadOnlySpan<char>, LineBreakOptions).

public ref struct LineBreakEnumerator
Inherited Members

Examples

// Where lines may end: after spaces and hyphens, and always at the end; a line must end after a newline.
List<int> breaks = [];
foreach (LineBreak b in LineBreaks.Enumerate("A well-known fact.\nNext"))
{
    breaks.Add(b.Index);                       // 2, 7, 13, 19 (mandatory), 23
}

// CSS switches: break-all lets letters break like ideographs.
LineBreakOptions breakAll = new(WordBreak: WordBreak.BreakAll);
int count = 0;
foreach (LineBreak b in LineBreaks.Enumerate("word", breakAll))
{
    count++;                                   // 4: after every letter
}

Properties

Current

Gets the current break.

public readonly LineBreak Current { get; }

Property Value

LineBreak

Methods

GetEnumerator()

Returns this enumerator, for foreach.

public readonly LineBreakEnumerator GetEnumerator()

Returns

LineBreakEnumerator

This enumerator.

MoveNext()

Moves to the next break opportunity.

public bool MoveNext()

Returns

bool

false after the break at the end of the text.