Table of Contents

Class BidiResult

Namespace
Egami.Fonts.Unicode
Assembly
Egami.Fonts.dll

The result of Resolve(ReadOnlySpan<char>, TextDirection): a level per UTF-16 unit, the runs in logical order, and the visual order of any line. Dispose it to return its arrays to the pool.

public sealed class BidiResult : IDisposable
Inheritance
BidiResult
Implements
Inherited Members

Examples

// A Hebrew word inside English text: three runs, the middle one drawn right to left.
string text = "abc \u05D0\u05D1\u05D2 def";
using BidiResult result = Bidi.Resolve(text, TextDirection.Auto);
int paragraph = result.ParagraphLevel;           // 0: the first strong character is Latin
foreach (BidiRun run in result.Reorder(0, result.Length))
{
    Console.WriteLine($"{run.Start}+{run.Length} {(run.IsRightToLeft ? "right to left" : "left to right")}");
}

Properties

Length

Gets the number of UTF-16 units resolved.

public int Length { get; }

Property Value

int

Levels

Gets the level of every UTF-16 unit, with each paragraph laid out as one line (rule L1 applied: separators and trailing whitespace take the paragraph level). Units that UAX #9 removes (embedding controls and boundary neutrals) take the level of the unit before them.

public ReadOnlySpan<byte> Levels { get; }

Property Value

ReadOnlySpan<byte>

Exceptions

ObjectDisposedException

The result was disposed.

ParagraphLevel

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

public int ParagraphLevel { get; }

Property Value

int

Runs

Gets the runs of equal Levels, in logical order.

public ReadOnlySpan<BidiRun> Runs { get; }

Property Value

ReadOnlySpan<BidiRun>

Exceptions

ObjectDisposedException

The result was disposed.

Methods

Dispose()

Returns the arrays to the pool.

public void Dispose()

Reorder(int, int)

Orders one line for display (rules L1 and L2): splits it into runs of equal level, with the line's trailing whitespace at the paragraph level, and returns the runs from left to right. The units of a right-to-left run are drawn last to first.

public BidiRun[] Reorder(int start, int length)

Parameters

start int

The index of the line's first UTF-16 unit.

length int

The number of UTF-16 units in the line.

Returns

BidiRun[]

The runs in visual order.

Exceptions

ArgumentOutOfRangeException

The line is not inside the text.

ObjectDisposedException

The result was disposed.