ddn.cti.text.bidi
ddn.cti.text.bidi — the bidi role.
A paragraph of text to one embedding level per code point: the UAX #9 "resolves the levels" step (FriBidi's and SheenBidi's job, ICU's ubidi), not the reordering. The engine derives visual order from the levels (and reorders properly, rather than reversing every odd run).
An implementor is a struct mirroring this surface, proven by one static assert(isBidi!MyBidi);.
Semantics the checker cannot enforce (doc/DDN-CTI.md section 9.2):
levelsfillsoutBufwith one UAX #9 level byte per codepoint of
paragraphand returns{required, written}with the shared capacity protocol: on a capacity miss (required > outBuf.length) nothing is written; on completionwritten == required. The resolved base direction travels in the payload whatever the capacity outcome.- A requested
BidiBase.AUTOresolves per UAX #9 P2/P3 (firststrong character);
LTR/RTLforce the paragraph level. The result'sbaseis the resolved direction. INVALID_INPUTfor a malformed request, backend failures aserrors — never as a zero count. Thread safety: one thread at a time per resolver; a resolver may be stateless and copyable.
Inspiration: FriBidi fribidi_get_par_embedding_levels_ex: levels per code point with an explicit base. SheenBidi SBParagraph: the same shape in a small C API. ICU ubidi_setPara / ubidi_getLevels: levels and resolved paragraph direction. DirectWrite IDWriteTextAnalyzer::AnalyzeBidi: levels through a sink, which is why the level array is a caller buffer here.
Types 3
The requested base direction of a paragraph. AUTO follows UAX #9 P2/P3 (first strong character); the resolved direction comes back in LevelsResult.
The capacity protocol of levels plus the resolved base direction (doc/DDN-CTI.md section 9.3).
size_t requiredLevel bytes the paragraph needs; `> outBuf.length` on a capacity miss, where nothing is written.size_t writtenLevel bytes written; equals `required` on completion, 0 on a capacity miss.Direction baseThe resolved base direction.Reference signatures of a bidi resolver. Bodiless on purpose: never instantiated, only compared against with implements (through isBidi).
string nameImplementor name for logs and conformance tables, e.g. `"fribidi"`; empty in the reference.Result!(LevelsResult, TextError) levels(const(dchar)[] paragraph, BidiBase base,
scope ubyte[] outBuf) @safe nothrow @nogcResolves one paragraph into UAX #9 embedding levels.