HPDFReorderHeadlessTextLine Function

Reorder a physical line using previously resolved paragraph levels and scripts, retaining explicit directional state across wrapping without resolving the entire paragraph again

function HPDFReorderHeadlessTextLine(const Text: UnicodeString;
  const ParagraphOrder: THPDFHeadlessTextOrder; FirstUnit, MaximumUnits: Integer;
  CancellationToken: THPDFCancellationToken): THPDFHeadlessTextOrder;

Resolve HPDFResolveHeadlessTextOrder once for the complete paragraph; pass the exact selected line as Text and its zero-based UTF-16 paragraph offset as FirstUnit

The caller must supply the matching paragraph order and unchanged logical line text; the function validates array lengths, bounds, embedding levels, scalar boundaries and cancellation but cannot reconstruct text omitted from the cached record

Line reordering copies only the selected scalar levels, applies the trailing-whitespace reset and visual reordering through native FriBidi, and returns line-local UTF-16 arrays; it does not modify the shared paragraph record

MaximumUnits must be positive and at most 131070; the complete cached paragraph must fit within this budget and Text must contain valid Unicode without separators

Rich field appearances use this cache for each logical paragraph, then shape each style item against its complete physical line through HPDFShapeHeadlessTextOrderedSpan