GetOpenTypeGlyphRun

Text, fonts, diagnostics, OpenType shaping

Description

Shapes Unicode text from an existing font handle and returns the resulting glyph run as JSON

Syntax

Delphi

Function TPDFlib.GetOpenTypeGlyphRun(FontID: Integer; Const Text: WideString; Options: Integer; Out GlyphRunJSON: WideString): Integer;

Parameters

FontIDA TrueType or OpenType font handle whose source font program is available
TextThe Unicode text to shape
OptionsBit 0 selects right-to-left direction; bit 1 forces the bounded Pascal fallback
GlyphRunJSONReceives the direction, total advance and visual glyph array

Return values

Returns the glyph count on success and 0 for invalid input or a shaping failure

JSON schema

{"rtl":true,"advance":1470,"glyphs":[{"id":993,"cluster":3,"advance":338,"offsetX":0,"offsetY":0}]}

Remarks

id is the font glyph ID; cluster is a zero-based UTF-16 source index; advances and offsets are expressed in thousandths of an em

Glyphs are returned in visual order and use the same positions consumed by DrawOpenTypeText

Use option bit 1 to compare the native result with the resource-bounded Pascal GSUB and GPOS fallback during diagnostics

See also

DrawOpenTypeText, GetOpenTypeTextWidth