CArcBidi
The Unicode Bidirectional Algorithm (UAX #9) over one paragraph of codepoints: explicit embeddings, overrides and isolates (X1-X10), weak and neutral resolution including bracket pairs (W1-W7, N0-N2), implicit levels (I1-I2), the paragraph half of L1, and line reordering (L2). HarfBuzz shapes a run in a direction it is given; this is what decides the direction and the run boundaries, which Arc used to hard-wire to LTR.
- Module
- Arc
- Header
#include "Arc/Text/CArcBidi.h"- Namespace
Arcf
Written in-tree rather than vendored: the property data is a compact range table of the classes that matter for layout (every RTL script block, the numerals, the separators and terminators, the explicit formatting characters, the marks of the scripts that sit beside RTL text), with unlisted codepoints taking their block's default. ValidateTables pins that the tables stay sorted, which the binary search depends on.
Constructors
| Signature | Name | Description |
|---|---|---|
CArcBidi() = delete | CArcBidi |
Public functions
| Returns | Name | Description |
|---|---|---|
EArcBidiClass | ClassOf | |
uint32_t | MirrorOf | |
bool | NeedsResolution | Whether the paragraph needs the algorithm at all: true when anything in it is right-to-left or an explicit right-to-left control. |
uint8_t | ParagraphLevel | |
void | ResolveLevels | One level per codepoint. |
void | ReorderLine | L2 over one line: outVisualToLogical[v] is the logical index drawn at visual position v. |
bool | ValidateTables |
Function details
CArcBidi
CArcBidi() = deleteClassOf
static EArcBidiClass ClassOf(uint32_t codepoint)MirrorOf
static uint32_t MirrorOf(uint32_t codepoint)NeedsResolution
static bool NeedsResolution(const uint32_t* codepoints, size_t count)Whether the paragraph needs the algorithm at all: true when anything in it is right-to-left or an explicit right-to-left control. A paragraph that is all left-to-right resolves to level 0 throughout and the layout skips the work.
ParagraphLevel
static uint8_t ParagraphLevel(const uint32_t* codepoints, size_t count, EArcTextDirection direction)ResolveLevels
static void ResolveLevels(const uint32_t* codepoints, size_t count, uint8_t paragraphLevel, std::vector<uint8_t>& outLevels)One level per codepoint. Characters X9 removes (embedding controls, boundary neutrals) take the level of the character before them, so a caller can reorder glyph runs without special-casing them.
ReorderLine
static void ReorderLine(const uint8_t* levels, size_t count, std::vector<uint32_t>& outVisualToLogical)L2 over one line: outVisualToLogical[v] is the logical index drawn at visual position v. Trailing whitespace is the caller's to reset to the paragraph level first (the line half of L1), since only it knows where the line ends.
ValidateTables
static bool ValidateTables()