DrawShapedText

Text

Description

This page describes DrawShapedText in PDF Library for Delphi under the "Text" topic. API names, parameters, class names, filenames, and literals are kept exactly as they appear in the Delphi library and DLL entry points.

Review the syntax, parameters, and return values before calling the function.

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

Use DrawOpenTypeText when the exact font handle is already available or the operation must not depend on resolving an installed face name