DrawOpenTypeText
Text, fonts, OpenType shaping
Description
Shapes and draws Unicode text from the in-memory font program associated with an existing font handle
Syntax
Delphi
Function TPDFlib.DrawOpenTypeText(XPos, YPos: Double; FontID: Integer; Size: Double; Const Text: WideString; Options: Integer): Integer;Parameters
| XPos, YPos | The text origin in page units |
|---|---|
| FontID | A TrueType or OpenType font handle whose source font program is available |
| Size | The text size in points |
| Text | The Unicode text to shape and draw |
| Options | Bit 0 selects right-to-left direction; bit 1 forces the bounded Pascal fallback instead of the native OpenType engine |
Return values
Returns 1 when the shaped text is accepted and 0 for an invalid font, empty text, non-positive size, missing font program or shaping failure
Remarks
The portable native engine applies OpenType script shaping, GSUB substitutions, GPOS positioning and visual glyph ordering directly from the font bytes without requiring an installed system face
The bounded Pascal fallback supports cmap mapping, Arabic joining, default GSUB substitutions and common GPOS single, pair, cursive and mark attachment lookups when the native module is unavailable
The output uses a reusable Identity-H companion font, subsets the embedded program by glyph closure, retains required variable and colour-font tables, and writes source clusters to ToUnicode for extraction
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
Deploy PDFlibOpenType32.dll or PDFlibOpenType64.dll beside the executable or DLL/OCX module on Windows; use libPDFlibOpenType.so on Linux or libPDFlibOpenType.dylib on macOS
The library searches for the native OpenType module in the following order: the explicit PDFLIB_OPENTYPE_ENGINE environment variable path, the active library/module directory, the executable directory, and upward Lib/thirdparty/OpenType development folders