Search guides and the APICtrl K
  1. API reference
  2. Native GUI

gfx/bidi.h

The Unicode Bidirectional Algorithm (UAX #9, Unicode 15): which way each character of a paragraph runs, and the order a line of it is shown in.

#include <sonore/gfx/bidi.h>
On this page

Design notes

Why a plugin needs it

A preset named in Hebrew or Arabic, a sample folder, a user's own label: right-to-left text, often with numbers and Latin words inside it. Drawn in the order it is stored, every word of it reads backwards. The algorithm is what every operating system and browser applies, rule for rule, and a partial one is wrong in exactly the strings people notice -- a phone number inside Arabic, a bracket round a Latin word -- so this is all of it: explicit embeddings, overrides and isolates, the weak and neutral rules, bracket pairs, and the line rules. It is checked against the Unicode Consortium's own conformance file, every line of it.

It knows nothing of fonts: it says which characters run which way and in what order the runs are shown. Shaping each run is gfx/text_shaper.h's job.

Types 1

One paragraph's bidirectional levels, and the visual order of its lines.

BidiParagraph p(codepoints, n, BidiDirection::Auto);
std::vector<int> order = p.visualOrder(0, n); // one line: all of it

Even levels run left to right and odd ones right to left. A paragraph is text up to a paragraph separator; a caller with several splits them first.

Enums 1

↑↓ to move↵ to openEvery public name in the headers, and every guide