Table of Contents

Class LayoutRun

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

A piece of a line: glyphs of one font and bidi level, or a placeholder, tab or break.

public sealed class LayoutRun
Inheritance
LayoutRun
Inherited Members

Examples

ParagraphStyle style = new() { DefaultStyle = new TextStyle { FontFamilies = [family], Size = 16 } };
Paragraph paragraph = Paragraph.Create("A paragraph is shaped once and laid out at any width.", style);

// Each width gives an immutable layout: lines of glyph runs, positioned from the box's top-left corner.
TextLayout narrow = paragraph.Layout(120);
TextLayout wide = paragraph.Layout(400);
foreach (TextLine line in narrow.Lines)
{
    string text = paragraph.Text[line.Start..line.End];   // the line's text, its trailing space included
    float baseline = line.Baseline;                        // y of the baseline
    foreach (LayoutRun run in line.Runs)
    {
        GlyphRun? glyphs = run.Glyphs;                     // glyphs at their layout positions
    }
}

// No wrapping: the box is as wide as the longest line.
TextLayout unbounded = paragraph.Layout(float.PositiveInfinity);

Properties

Advance

Gets the run's width.

public float Advance { get; }

Property Value

float

BidiLevel

Gets the run's bidi level after the line rules; odd levels run right to left.

public int BidiLevel { get; }

Property Value

int

Glyphs

Gets the glyphs, positioned in layout coordinates with their clusters, for Text runs; otherwise null.

public GlyphRun? Glyphs { get; }

Property Value

GlyphRun

Kind

Gets what the run holds.

public LayoutRunKind Kind { get; }

Property Value

LayoutRunKind

Length

Gets the number of UTF-16 units in the run.

public int Length { get; }

Property Value

int

Placeholder

Gets the index of the rich text's placeholder, for Placeholder runs; otherwise -1.

public int Placeholder { get; }

Property Value

int

Start

Gets the UTF-16 index of the run's first character.

public int Start { get; }

Property Value

int

StyleIndex

Gets the style of the run's first character: 0 for the paragraph's default style, else 1 plus the index of the rich text's span.

public int StyleIndex { get; }

Property Value

int

X

Gets the x of the run's left edge.

public float X { get; }

Property Value

float