Table of Contents

Class ShapedText

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

Text shaped by Shape(string, Font, ShapingOptions?): one ShapedLine per line between hard breaks, each with its runs in visual order. Nothing wraps.

public sealed class ShapedText
Inheritance
ShapedText
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;
}

Remarks

Immutable once returned; safe to share between threads.

Properties

Advance

Gets the widest line's advance.

public float Advance { get; }

Property Value

float

Lines

Gets the lines, split at \n, \r\n, \r, U+0085, U+2028 and U+2029.

public IReadOnlyList<ShapedLine> Lines { get; }

Property Value

IReadOnlyList<ShapedLine>

ParagraphLevel

Gets the paragraph level of the first line: 0 for left to right, 1 for right to left.

public int ParagraphLevel { get; }

Property Value

int

Text

Gets the text that was shaped.

public string Text { get; }

Property Value

string