Table of Contents

Struct LineBreak

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

A place where a line may or must end.

public readonly record struct LineBreak : IEquatable<LineBreak>
Implements
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
}

Constructors

LineBreak(int, bool, bool)

A place where a line may or must end.

public LineBreak(int Index, bool IsMandatory, bool IsSoftHyphen)

Parameters

Index int

The UTF-16 index the next line would start at.

IsMandatory bool

Whether the line must end here: after a hard line break (LF, CR, CR LF, NEL, VT, FF, U+2028 or U+2029) or at the end of text after one.

IsSoftHyphen bool

Whether the break follows a soft hyphen (U+00AD), which shows a hyphen when the line ends there.

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

Index

The UTF-16 index the next line would start at.

public int Index { get; init; }

Property Value

int

IsMandatory

Whether the line must end here: after a hard line break (LF, CR, CR LF, NEL, VT, FF, U+2028 or U+2029) or at the end of text after one.

public bool IsMandatory { get; init; }

Property Value

bool

IsSoftHyphen

Whether the break follows a soft hyphen (U+00AD), which shows a hyphen when the line ends there.

public bool IsSoftHyphen { get; init; }

Property Value

bool