Table of Contents

Class Bidi

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

The Unicode Bidirectional Algorithm (UAX #9): embedding levels for mixed left-to-right and right-to-left text, and the visual order of a line.

public static class Bidi
Inheritance
Bidi
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")}");
}

Methods

Resolve(ReadOnlySpan<char>, TextDirection)

Resolves the embedding level of every UTF-16 unit of a text.

public static BidiResult Resolve(ReadOnlySpan<char> text, TextDirection direction = TextDirection.Auto)

Parameters

text ReadOnlySpan<char>

The text. Each paragraph separator (U+2029, CR, LF and the other Bidi_Class B characters) ends a paragraph, and each paragraph is resolved on its own (rule P1).

direction TextDirection

The paragraph direction; Auto takes it from the first strong character of each paragraph; TopToBottom resolves as left to right.

Returns

BidiResult

The levels and runs; dispose it to return its arrays to the pool.

Exceptions

ArgumentOutOfRangeException

direction is not a TextDirection.