DrawShapedText
Text
Description
Shapes complex-script text such as Arabic and Hebrew with the named installed font and draws the resulting glyphs at the given position. It returns 1 on success and 0 when the face cannot be resolved, the text is empty or shaping fails.
Syntax
Delphi
Function TPDFlib.DrawShapedText(XPos, YPos: Double; Const FontName: WideString; Size: Double; Const Text: WideString; Options: Integer): Integer;
Parameters
XPos/YPos position the text in page units; FontName names an installed font face such as Arial; Size is the text size in points; Text is the string to shape and draw; Options bit 0 selects a right-to-left base direction
Return Values
Returns 1 on success and 0 when the face cannot be resolved, Text is empty or shaping fails
Remarks
The library reads the resolved font program and prefers its portable native OpenType engine for GSUB substitutions, GPOS positioning, script shaping and visual glyph order; the Windows system shaper remains a compatibility fallback and a bounded Pascal layout path is available when the native module cannot load
The shaped glyphs are written by glyph index through a reusable Type0 Identity-H companion font, subsetted by glyph closure with real per-glyph widths and a ToUnicode map that restores source clusters during extraction
Each glyph advance and offset is written into the content stream, so the printed layout matches GetShapedTextWidth
A CFF-based OpenType face is embedded as an OpenType font file, a stream type introduced in PDF 1.6, so the writer automatically raises a document below PDF 1.6 to that version; when LockSaveVersion pins a lower version, saving fails with LastErrorCode 602 instead
Use DrawOpenTypeText when the exact font handle is already available or the operation must not depend on resolving an installed face name