|
Automatic Shaping Pipeline (Phase 8) Opt-in producer-side GSUB pipeline (v2.119.59 - v2.120.10)
|
Arabic Shaping Multi-Script Shaping GSUB Engine |
|
automatic shaping pipeline 會將 OpenType GSUB engine 從 capability-only query surface 提升為 producer-side feature,在文字輸出到 PDF content streams 時自動套用。呼叫端透過 typed set(ShapingFeatures: THPDFShapingFeatures)啟用特定 GSUB features,HotPDF 會負責執行正確 substitutions、將 substitute glyphs 標記進 embedded font subset,並輸出 accessibility 所需的 ToUnicode CMap reverse-mapping entries property ShapingFeatures: THPDFShapingFeatures read ... write ...;
預設值為 [](empty set),會為依賴 v2.119.32-58 static post-pass shaper 的呼叫端保留 byte-identical output。設定一個或多個 flags 會將 engine 提升為對應 features 的 automatic mode
sfArabicGSUB - native Arabic GSUB shaping (v2.185.0) 設定 sfArabicGSUB 時,HotPDF 會將 logical Arabic run 對應到 base glyph IDs,依每個字母選定的 joining positions 套用已註冊字型的 positional init、medi、fina 與 isol lookups,接著在 shaped run 上套用 rlig、calt 與 rclt。沒有 Unicode codepoint 的 substitute glyphs 會透過 synthetic-codepoint path 與 ToUnicode reverse mappings 輸出,因此 contextual Arabic glyphs 位於 cmap 外的字型仍可正確嵌入與複製
設定 sfArabicGSUB 會隱含略過 v2.85.0 Arabic static 4-position shaper;若呼叫端需要 static shaper 繼續處理字型 GSUB 未宣告的 codepoints,應保持 sfArabicGSUB 關閉
sfStandardLigatures / sfContextualLigatures - Phase 8b (v2.119.65) 設定 sfStandardLigatures 時,Latin Standard Ligatures 會使用字型的 liga feature 自動摺疊。ApplyLatinLigatureRefinement 目標為 Alphabetic Presentation Forms block(U+FB00-FB4F),通常是 FB00 ff、FB01 fi、FB02 fl、FB03 ffi、FB04 ffl、FB05 long-s + t、FB06 st。sfContextualLigatures 會為字型的 clig feature 加入第二個 pass。兩個 passes 都使用與 sfArabicGSUB 相同的 reverse-cmap mechanism,並輸出 7 個新的 ToUnicode CMap reverse-mapping entries(FB00-FB06),讓閱讀端 copy / paste 可將 ligature 解析回來源字母
sfContextualAlternates - GSUB 'rclt' (v2.119.66) 設定 sfContextualAlternates 時,會套用字型的 rclt(Required Contextual Alternates)feature。ApplyArabicGSUBContextualRefinement 使用 v2.119.47 ApplyContextualSubst entry point,並處理 variable-length N-to-M output(只有每個 replacement GID 都可透過 reverse cmap 抵達時,substitution 才會提交)。Reverse cmap range 擴充到 FB00-FDFF + FE70-FEFF,以涵蓋 Latin + Arabic + Hebrew Presentation Forms
Canonical users of
sfArabicGSUB - native Arabic GSUB shaping (v2.185.0) When
Setting
sfStandardLigatures / sfContextualLigatures - Phase 8b (v2.119.65) When
sfContextualAlternates - GSUB 'rclt' (v2.119.66) When
Canonical users of
sfIndicShaping - Phase 8e (v2.119.67) 設定 sfIndicShaping 時,v2.119.55 Devanagari capability ApplyDevanagariReorder 會從手動 method 提升為套用於三個 BuildUnicode*FieldContent helpers 內的 automatic pre-pass。Devanagari runs 會將 Repha(cluster 起始處的 Ra + Halant)移到 post-base position,並將 pre-base I-matra(U+093F)移到 cluster base consonant 前方,使閱讀端的 GSUB engine 能以正確 rendering order 取得 syllable。其他 Indic reorders(above-base / below-base matra、conjunct formation)仍留給字型的 GSUB
Advance-query support (v2.119.64 / Phase 8c.5) A companion API exposes the cached
Advance-query support (v2.119.64 / Phase 8c.5) 配套 API 會公開快取的 /W em-fraction,讓呼叫端在輸出 GSUB-substituted glyphs 時能正確計算 word-wrap:
Typical workflow (full Arabic auto-shaping)
PDF.RegisterUnicodeTTF('NotoArab', 'NotoSansArabic-Regular.ttf'); PDF.ShapingFeatures := [sfArabicGSUB, // native Arabic GSUB contextual glyphs sfCursiveAttachment]; // GPOS cursive entry / exit anchors PDF.SetGSUBScript('arab'); PDF.BeginDoc; PDF.CurrentPage.SetFont('NotoArab', [], 14); PDF.CurrentPage.RtLTextOut(100, 700, 0, UnicodeString(#$0628#$0633#$0645#$0020#$0627#$0644#$0644#$0647)); PDF.EndDoc;
Typical workflow (Latin standard ligatures + Devanagari reorder)
PDF.RegisterUnicodeTTF('NotoSans', 'NotoSans-Regular.ttf'); PDF.RegisterUnicodeTTF('NotoDeva', 'NotoSansDevanagari-Regular.ttf'); PDF.ShapingFeatures := [sfStandardLigatures, // FB00-FB06 Latin liga sfContextualLigatures, // + clig sfIndicShaping]; // Devanagari Repha + I-matra reorder
Phase 8 roadmap closure Phase 8a (v2.119.59) opt-in framework + Arabic capability; Phase 8b (v2.119.65) Latin standard ligatures; Phase 8c.1 (v2.119.60) Allah; Phase 8c.2 (v2.119.63) GID-level GSUB
Scope and limitations 此 opt-in pipeline 有意建立在 static post-pass shaper 之上;既有呼叫端除非 opt in,否則看不到行為變更。預設 [] set 是 byte-stable regression 的安全選擇。沒有要求 GSUB feature tables 的字型會產生安全 no-op output(呼叫端看到沒有 substitution 套用,也不會丟出例外)
目前 shaping API 對照 目前 pipeline 已不再只是 substitution-only:sfKerning 套用 GPOS pair kerning,sfMarkPositioning 套用 Mark-to-Base 與 Mark-to-Mark offsets,sfMarkToLigature 套用 Mark-to-Ligature placement,sfCursiveAttachment 套用 cursive entry/exit anchor alignment,sfTibetanShaping 套用 Tibetan GSUB shaping,sfMongolianShaping 套用 Mongolian positional forms,sfIndicGSUB 在 syllable reorder 後套用 Indic GSUB feature chain。請參閱 ShapingFeatures、GPOS methods 與 Indic shaping methods 近期新增項目包括用於 locl 的 sfLocalizedForms、透過 ApplyGSUBContextualFeature 支援 calt、contextual 與 vertical GPOS kerning、native Arabic GSUB contextual glyph emission,以及 N'Ko、Adlam、Thai/Lao、Hebrew 與 Javanese paths。請參閱 script shaping preprocess methods
請參閱: OpenType GSUB Substitution Engine, Arabic / Persian / Urdu Shaping Support, Syriac / Mongolian / Devanagari Shaping, THotPDF.AssignSyntheticCodepointForGID, CFF / OpenType Font Subsetting |