HPDFResolveHeadlessTextOrder

function HPDFResolveHeadlessTextOrder(const Text: UnicodeString;
  MaximumUnits: Integer; CancellationToken: THPDFCancellationToken;
  ParagraphDirection: THPDFHeadlessTextDirection = htdAuto): THPDFHeadlessTextOrder;

Resolves the logical-to-visual scalar mapping, embedding levels and script items of one actual Unicode paragraph through the native FriBidi and HarfBuzz libraries

MaximumUnits is a positive UTF-16 budget no greater than 131070; malformed surrogates and CR, LF, NEL, LS or PS paragraph separators fail, and an empty paragraph returns empty arrays

Each array has Length(Text) entries; both UTF-16 units of a supplementary scalar share its visual scalar position, embedding level and script tag

VisualPositions contains zero-based visual scalar positions, Levels contains FriBidi embedding levels and Scripts contains HarfBuzz script tags represented as Cardinal values

BaseRightToLeft records the resolved paragraph direction; common and inherited script values acquire adjacent paragraph script context for style item splitting

Cancellation is observed during Unicode decoding, script classification and item mapping; call this function with an explicit ParagraphDirection when retaining the original direction across wrapped lines

See THPDFHeadlessTextOrder, THPDFHeadlessTextDirection and HPDFShapeHeadlessTextSpan