THotPDF GSUB Lookup Methods

THotPDF API reference

 

THotPDF Methods  Auto Shaping  GSUB

Documents the capability-level GSUB lookup APIs for single, multiple, alternate, ligature, contextual, chained contextual, reverse chained, contextual-feature, and localized-form substitutions

 

Delphi syntax

function GetSingleSubstituteGlyph(InputGID: Word; const FeatureTag: AnsiString): Word;

function GetMultipleSubstituteGlyphs(InputGID: Word; const FeatureTag: AnsiString; var OutGIDs: TGSUBLookupArray): Boolean;

function GetAlternateGlyphCount(InputGID: Word; const FeatureTag: AnsiString): Integer;

function GetAlternateGlyph(InputGID: Word; const FeatureTag: AnsiString; AlternateIndex: Integer): Word;

function ApplyLigatureSubstitution(const InputGIDs: array of Word; StartIndex: Integer; const FeatureTag: AnsiString; out OutGID: Word; out ConsumedCount: Integer): Boolean;

function ApplyContextualSubst(const InputGIDs: array of Word; StartIndex: Integer; const FeatureTag: AnsiString; var OutGIDs: TGSUBLookupArray; out ConsumedLen: Integer): Boolean;

function ApplyReverseChainedContextualSubst(const InputGIDs: array of Word; StartIndex: Integer; const FeatureTag: AnsiString; out OutGID: Word): Boolean;

function ApplyGSUBContextualFeature(const Wide: UnicodeString; const AFeatureTag: AnsiString): UnicodeString;

function ApplyLocalizedForms(const Wide: UnicodeString): UnicodeString;

 

Covered APIs

APIUsage notes
GetSingleSubstituteGlyphQueries GSUB LookupType 1 single substitution and returns the input GID when no match exists
GetMultipleSubstituteGlyphsQueries GSUB LookupType 2 multiple substitution and returns the replacement glyph sequence
GetAlternateGlyphCountCounts GSUB LookupType 3 alternate glyphs for a covered input glyph
GetAlternateGlyphReturns a selected alternate glyph by zero-based alternate index
ApplyLigatureSubstitutionQueries GSUB LookupType 4 ligature substitution for a glyph run starting at a specific index
ApplyContextualSubstApplies GSUB contextual or chained contextual substitution where a rule can replace a run segment
ApplyReverseChainedContextualSubstQueries GSUB reverse chained contextual single substitution for right-to-left compatible shaping rules
ApplyGSUBContextualFeatureApplies a named GSUB contextual feature such as rclt or calt to a Unicode run and maps substitutions safely
ApplyLocalizedFormsApplies GSUB locl substitutions under the active script and language while preserving text extraction mappings
MarkUnicodeGlyphUsedAdds a returned substitute GID to the embedded font subset closure
sfContextualAlternatesApplies required contextual alternates through the rclt-capable GSUB contextual lookup path
sfLocalizedFormsApplies GSUB locl localized-form substitutions under the active script and language

 

Usage notes

These methods answer what the font's GSUB table would do. ApplyGSUBContextualFeature is the shared path for contextual features such as rclt and calt; ApplyLocalizedForms applies locl under the active GSUB script and language. If the caller emits returned substitute GIDs manually, MarkUnicodeGlyphUsed or a synthetic-codepoint mapping must keep those glyphs inside the embedded subset and ToUnicode map

 

See also: OpenType GSUB Engine GSUB script and language methods ShapingFeatures Subset and mapping methods