HPDFResolveHeadlessTextLineOrder Function
Resolve embedding levels for one complete logical paragraph and reorder a selected physical line while retaining directional embeddings, overrides, isolates and paired-bracket context that began on earlier lines
function HPDFResolveHeadlessTextLineOrder(const Paragraph: UnicodeString;
FirstUnit, UnitCount, MaximumUnits: Integer;
CancellationToken: THPDFCancellationToken;
ParagraphDirection: THPDFHeadlessTextDirection = htdAuto): THPDFHeadlessTextOrder;
FirstUnit is a zero-based UTF-16 offset and UnitCount is the physical line length, excluding line or paragraph separators; both boundaries must contain complete Unicode scalars
The returned arrays describe only that physical line, while BaseRightToLeft describes the complete paragraph; supplementary scalars share a visual rank, level and script across both UTF-16 units
The function applies paragraph embedding resolution followed by physical-line whitespace reset and visual reordering through the configured native FriBidi library; it preserves logical text and does not shape or mirror glyphs itself
MaximumUnits must be positive and at most 131070; the complete paragraph must fit this budget, contain valid Unicode and have no line separators
For many lines from the same paragraph, resolve HPDFResolveHeadlessTextOrder once and use HPDFReorderHeadlessTextLine to avoid repeatedly processing the paragraph
Pass each physical line and its returned order to HPDFShapeHeadlessTextOrderedSpan for native contextual OpenType shaping