|
THotPDF.AssignSyntheticCodepointForGID / GetSyntheticCodepointForGID THotPDF PUA 合成碼點配置器 (v2.119.68)
|
GSUB Engine Auto Shaping Pipeline Arabic Shaping |
|
為沒有自然 Unicode codepoint 可透過字型 cmap 抵達的 OpenType GSUB substitute GIDs,設定並查詢 Private Use Area(U+E000 - U+F8FF)synthetic codepoints。這補上 v2.119.43-66 GSUB query 與 refinement APIs 留下的 producer-side GID-level emission gap
Delphi 語法: function AssignSyntheticCodepointForGID(GID: Word; out SyntheticCP: Word): Boolean; function GetSyntheticCodepointForGID(GID: Word): Word;
Why the API exists v2.119.32-67 producer-side automatic shaping pipeline(Arabic / Latin / Devanagari)要求 GSUB engine 回傳的 substitute GIDs 可透過 Unicode codepoint 抵達;既有 hex-encoded text pipeline 輸出的是 codepoints 而非 GIDs,閱讀端會透過內嵌的
但落在 font-internal GIDs 上的 font-specific substitutes,例如多數 Devanagari cluster shapes、字型設計者只以 numbered GIDs 提供的 stylistic alternates、CJK ideographic variation sequences(IVS)、沒有對應 Presentation Form 的 discretionary ligatures,在字型 cmap 中完全沒有 codepoint。v2.119.68 之前,這些 GIDs 無法透過 producer-side hex pipeline 抵達;v2.119.68 允許呼叫端為任意 GID 在 Private Use Area 設定 synthetic codepoint,以補上此缺口
AssignSyntheticCodepointForGID semantics 為提供的 GID 設定下一個可用 PUA codepoint(從 U+E000 開始),並將設定鏡射到既有 producer-side hex pipeline + consumer-reader resolution chain 所依賴的每個 cache:
1. 2. 3.
成功時傳回
GetSyntheticCodepointForGID semantics 對既有分配做純函式查詢。若先前呼叫過
Allocator state lifecycle
Typical workflow (Devanagari cluster shape)
PDF.RegisterUnicodeTTF('NotoDeva', 'NotoSansDevanagari-Regular.ttf'); PDF.ShapingFeatures := [sfIndicShaping]; PDF.SetGSUBScript('deva');
// Get a font-internal cluster GID through the GSUB engine ClusterGID := PDF.GetSingleSubstituteGlyph(BaseGID, 'nukt'); if ClusterGID <> BaseGID then begin // Check if cmap reaches the substitute - usually no for Indic // clusters, since cluster GIDs are font-internal // Allocate a synthetic codepoint that the producer-side // hex pipeline can emit if PDF.AssignSyntheticCodepointForGID(ClusterGID, SyntheticCP) then begin // SyntheticCP is now in the U+E000-F8FF range; emit it // through UnicodeTextOut just like a normal codepoint PDF.CurrentPage.UnicodeTextOut(X, Y, 0, UnicodeChar(SyntheticCP)); PDF.MarkUnicodeGlyphUsed(ClusterGID); end; end;
冪等性範例
PDF.AssignSyntheticCodepointForGID(150, CP1); // CP1 = $E000 PDF.AssignSyntheticCodepointForGID(151, CP2); // CP2 = $E001 PDF.AssignSyntheticCodepointForGID(150, CP3); // CP3 = $E000 (idempotent) CP4 := PDF.GetSyntheticCodepointForGID(150); // CP4 = $E000 CP5 := PDF.GetSyntheticCodepointForGID(999); // CP5 = 0 (no assignment)
Consumer-reader behavior 閱讀端會在 text-showing operator 中看到 PUA codepoint,並透過內嵌於文件的
複製 / 貼上行為:當 ToUnicode CMap 把 PUA codepoint 宣告為 identity mapping 時,PUA codepoint 會以自身原樣往返。若呼叫端希望改為還原來源的 Unicode 字元(也就是產生 substitute 的輸入 run),可以用
Phase 8 roadmap closure v2.119.68 / Phase 8c.6 收束了 Phase 8 GSUB engine 的roadmap:LookupType 1-8 的查詢 API(Phase 1-6)、Script / LangSys 選擇 API(Phase 7)、TTF subsetter closure 進入點(Phase 9)、靜態 post-pass 連字摺疊(v2.119.32 / 58 / 60 / 62)、需自行啟用的自動 pipeline(v2.119.59)、阿拉伯文
請參閱: OpenType GSUB Substitution Engine, Automatic Shaping Pipeline (Phase 8), Arabic / Persian / Urdu Shaping Support, Syriac / Mongolian / Devanagari Shaping, THotPDF.BeginTaggedContent |