THotPDF Shaping Subset and ToUnicode Mapping Methods

THotPDF API 參考

 

THotPDF Methods  Auto Shaping  GSUB

記錄讓 shaped GIDs 正確 render 與 extract 的 glyph-subset 與 ToUnicode plumbing

 

Delphi 語法

procedure EnableShapingFeatureForSubset(const FeatureTag: AnsiString); overload;

procedure EnableShapingFeatureForSubset(Feature: THPDFShapingFeature); overload;

procedure MarkUnicodeGlyphUsed(GID: Word);

procedure RegisterToUnicodeReverseMapping(SubstCodepoint: Cardinal; const SourceCodepoints: array of Cardinal);

procedure ClearToUnicodeReverseMappings;

function ToUnicodeReverseMappingCount: Integer;

function AssignSyntheticCodepointForGID(GID: Word; out SyntheticCP: Word): Boolean;

function GetSyntheticCodepointForGID(GID: Word): Word;

procedure MarkSyntheticCpRTL(Cp: Word);

function IsRTLSyntheticCp(Cp: Word): Boolean;

function IsRTLSyntheticGID(GID: Word): Boolean;

 

涵蓋的 API

API使用注意事項
EnableShapingFeatureForSubset標記必須把輸出 glyph 保留在內嵌子集中的 GSUB features
MarkUnicodeGlyphUsed把回傳的 substitute GID 加入內嵌字型子集閉包
RegisterToUnicodeReverseMapping註冊 substitute codepoint 對 source-codepoint 的對應,供文字擷取與無障礙使用
ClearToUnicodeReverseMappings清除目前文件中所有由呼叫端註冊的反向對應
ToUnicodeReverseMappingCount傳回已註冊反向對應的數量
AssignSyntheticCodepointForGID配置一個 private-use synthetic codepoint,透過 CIDToGIDMap 轉譯指定的 glyph ID
GetSyntheticCodepointForGID傳回已指派給某個 glyph ID 的 synthetic codepoint
MarkSyntheticCpRTL把 synthetic codepoint 標記為右至左,讓發出順序保持正確
IsRTLSyntheticCp回報某個 synthetic codepoint 是否已標記為右至左發出
IsRTLSyntheticGID回報某個 glyph ID 是否會解析到已標記為右至左發出的 synthetic codepoint

 

使用注意事項

當 shaping workflow 輸出的 glyph IDs 無法透過一般 Unicode cmap entry 到達時,請使用這些 APIs。Synthetic codepoints 會透過 CIDToGIDMap 路由 rendering,而 reverse mappings 則會為 text extraction 還原原始 source codepoints

 

請參閱: AssignSyntheticCodepointForGID GSUB lookup methods Indic shaping methods