HPDFShapeHeadlessTextStyledSpan

function HPDFShapeHeadlessTextStyledSpan(const Context: UnicodeString;
  FirstUnit, UnitCount: Integer; const Order: THPDFHeadlessTextOrder;
  const FontBytes: SysUtils.TBytes; MaximumGlyphs: Integer;
  CancellationToken: THPDFCancellationToken;
  CharacterAdvance, WordAdvance: Double;
  CSSLetterSpacing, CSSWordSpacing: Boolean): THPDFHeadlessShapedGlyphs;

Declared in HPDFHeadlessShaping, this function shapes a UTF-16 span using its complete surrounding context and previously resolved visual order, with the supplied HarfBuzz and FriBidi runtime and font bytes

FirstUnit is a zero-based UTF-16 offset and UnitCount selects the requested span; callers must supply compatible order data and a positive MaximumGlyphs budget

CharacterAdvance and WordAdvance use normalized 1000-font-unit advances, rather than PDF points; convert point spacing with points * 1000 / fontSize before calling

Raw advances must be finite and have absolute values at most 1000000000000000, allowing the native point budget at the minimum supported positive font size; appearance builders enforce their separate authored and computed point limits

CSSLetterSpacing enables typographic-unit tracking and optional-ligature handling; CSSWordSpacing enables half spacing around SPACE and NBSP clusters, including separator marks, following the bounded spacing profile

Returned glyph advances and offsets include the requested spacing; SpacingAdvance records its contribution, while TypographicUnit, CursiveUnit and WordSeparator provide boundary metadata for the rich physical-line composer

Cancellation is checked during classification and shaping, and glyph-budget or malformed-input failures use the existing shaping exception contract; this function neither publishes a PDF nor owns the caller's font bytes or token

Existing shaping entry points preserve their previous semantics; rebuild Pascal and C++Builder consumers using the matching public glyph record and generated headers