Table of Contents

Class ShapedRun

Namespace
Egami.Fonts.Shaping
Assembly
Egami.Fonts.dll

A run of a ShapedLine: one font, one bidi level, one script, one language, and its glyphs.

public sealed class ShapedRun
Inheritance
ShapedRun
Inherited Members

Examples

// Whole text: lines at hard breaks, bidi levels, script runs, fallback fonts, runs in display order.
var font = new Font(face, 24);
var options = new ShapingOptions { Fallback = new FontFallback(fonts.Families) };
ShapedText shaped = TextShaper.Shape("Shalom: \u05E9\u05DC\u05D5\u05DD!", font, options);

float x = 0;
foreach (ShapedRun run in shaped.Lines[0].Runs)
{
    GlyphRun glyphs = run.ToGlyphRun(new System.Numerics.Vector2(x, 0), shaped.Text); // what a canvas draws
    x += run.Advance;
}

Properties

Advance

Gets the run's advance along the line: the glyph advances summed (downward for a vertical run).

public float Advance { get; }

Property Value

float

BidiLevel

Gets the run's bidi embedding level; odd levels run right to left.

public int BidiLevel { get; }

Property Value

int

Font

Gets the font the run is shaped in: the text's, a span's or a fallback font.

public Font Font { get; }

Property Value

Font

Glyphs

Gets the shaped glyphs in visual order; read it, do not change it.

public GlyphBuffer Glyphs { get; }

Property Value

GlyphBuffer

IsVertical

Gets whether the run was shaped top to bottom.

public bool IsVertical { get; }

Property Value

bool

Language

Gets the run's BCP 47 language tag, or null.

public string? Language { get; }

Property Value

string

Length

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

public int Length { get; }

Property Value

int

Script

Gets the run's script.

public Script Script { get; }

Property Value

Script

Start

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

public int Start { get; }

Property Value

int

Methods

ToGlyphRun(Vector2, string?)

Builds the glyph run that draws this run with its pen at origin.

public GlyphRun ToGlyphRun(Vector2 origin, string? text = null)

Parameters

origin Vector2

The pen position of the run's first glyph, on the baseline, y down.

text string

The text the run was shaped from, for the run's clusters, or null.

Returns

GlyphRun

The glyph run, with clusters when text is given, and the run's level, script and language.

Exceptions

ArgumentException

A cluster points outside text.