DrawShapedText

Text

Description

This page describes DrawShapedText in PDFlibPas 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 (for example 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 paragraph direction; set it for Arabic or Hebrew text.

Return Values

Returns 1 on success; 0 when the shaping engine is unavailable, the font face is not installed, or Text is empty.

Remarks

The text is shaped with the system shaping engine before drawing, so Arabic letters take their correct word-initial, medial, final or isolated forms, mandatory ligatures such as lam-alef are applied, and right-to-left runs come out in the correct visual order. The shaped glyphs are written by glyph index through a companion Type0 (Identity-H) font, which lets forms that have no character code of their own render correctly. One companion font is created per face and reused by later calls in the same document. When the document is saved, the embedded font program is subsetted to just the glyphs the document shows, with real per-glyph widths and a ToUnicode map that translates each shaped glyph back to its source characters — so text copied or extracted from the output returns the original string, ligatures included. Positioning is exact: each glyph advance from the shaping engine is written into the content stream, so the printed layout matches the shaped measurement from GetShapedTextWidth.