HPDFShapeHeadlessTextOrderedSpan Function
Shape a selected style span against a complete physical line using paragraph-derived embedding levels, scripts and visual positions
function HPDFShapeHeadlessTextOrderedSpan(const Context: UnicodeString;
FirstUnit, UnitCount: Integer; const Order: THPDFHeadlessTextOrder;
const FontBytes: SysUtils.TBytes; MaximumGlyphs: Integer;
CancellationToken: THPDFCancellationToken;
CharacterAdvance: Double = 0; WordAdvance: Double = 0): THPDFHeadlessShapedGlyphs;
Order must cover every UTF-16 unit of the complete physical-line Context; obtain it from HPDFResolveHeadlessTextLineOrder or HPDFReorderHeadlessTextLine
FirstUnit and UnitCount select complete scalars within the physical line; the real HarfBuzz buffer receives the surrounding line text whilst direction and script come from the resolved paragraph order
Returned glyph source offsets are relative to the selected style span; glyph IDs, advances and offsets use the real embedded font and a scale of 1000 units per em
The function validates matching arrays, unique scalar visual ranks, embedding levels, surrogate consistency, finite spacing, glyph limits and cancellation; malformed order does not silently fall back to isolated direction detection
Character spacing is applied once per shaped cluster apart from a cluster containing only Unicode directional controls; word spacing applies to a space cluster, and callers retain their original logical value and style text separately from the visual glyph order