SetTextShaping

Text

Description

Turns automatic complex-script shaping on or off, which routes Arabic, Hebrew, Indic and other complex-script text in DrawText and GetTextWidth through the shaping engine so contextual forms, mandatory ligatures and right-to-left ordering come out correctly; shaping is on by default. Returns the previous state: 1 when shaping was enabled before the call, 0 when it was disabled.

Syntax

Delphi

Function TPDFlib.SetTextShaping(Enable: Integer): Integer;

Parameters

Enable 1 turns automatic complex-script shaping on (the default), 0 turns it off

Return Values

Returns the previous state: 1 when shaping was enabled before the call, 0 when it was disabled

Remarks

When enabled, DrawText and GetTextWidth detect Arabic, Hebrew, Indic and other complex-script characters and route them through the shaping engine automatically, so contextual forms, mandatory ligatures and right-to-left ordering come out correctly without calling DrawShapedText yourself. Latin, Cyrillic, Greek and CJK text is never rerouted, so existing output is unchanged. Disable the routing to reproduce the exact pre-shaping behaviour or when the unshaped byte-for-byte content stream matters more than correct complex-script rendering

The same routing applies to text laid out by DrawHTMLText, DrawMarkdownText, DrawSVG and the text box functions, one run of text at a time. Text that is centred, right-aligned, underlined or highlighted is drawn unshaped. The layout measures text before it is shaped, so a run can come out slightly wider or narrower than the space it was given

Where the platform shaping engine is not available, the text is shaped with the program of the selected font, so that font must be an embedded TrueType or OpenType font. Text that mixes directions is first split into runs by the Unicode bidirectional algorithm: numbers keep their left-to-right order inside right-to-left text, spaces and punctuation take the direction of the text around them, and each run is shaped in its own direction and set in visual order