function AddShapedText(const Text, Font: WString; FontSize: Single; X, Y: Double; out Shaped: TPdfShapedText; Direction: TPdfTextDirection = ptdAuto; Color: TColor = clBlack; Alpha: Byte = $FF): Boolean;
Shapes Unicode text through the native Windows script engine, loads the selected system font once, and writes explicitly positioned glyphs through PDFium's CID Type 2 font API
ptdAuto resolves the paragraph base direction from the first strong character, whilst explicit left-to-right and right-to-left modes are available for application-controlled layout
Each glyph receives a bounded CID mapping and a generated ToUnicode entry, including cluster-aware mappings for ligatures and contextual forms
The text object carries the original logical string in ActualText, so conforming consumers can recover logical reading order even when positioned glyph geometry is visual-order bidi content
TPdf.Text follows PDFium's physical bidi extraction order and may therefore differ from the original logical input order
TPdfShapedText returns font bytes, total width, glyph and logical-character counts, and visual runs containing bidi levels, glyph IDs, advances, offsets, and source clusters
Use ShapePdfText for shaping without modifying a document, or instantiate TPdfUniscribeTextShaper with TPdfTextShapingOptions when explicit character, glyph, and run budgets are required
Input, glyph, and run limits fail closed before unbounded allocation
Runs sharing one baseline are emitted as one text object and glyph positions are generated in linear time
The method requires the PDFium CID Type 2 font, character-code, position, marked-content, and content-regeneration exports