有時常規的成對定位並不夠用。它能修復兩個字母之間的間距,但若是某個特定的三字元組合(如 L'Amour)出問題呢?這時上下文字偶距就派上用場了!
我相信您遇到過這種情況,所有側邊距和字距對看起來都很棒,但在進一步檢視長文字列表以驗證所有字距看起來都很棒時,您會發現一些更多的問題。
這次調整單個字距對是不夠的,因為問題涉及多個字元。它只是與特定的周圍字元(L'Amour)看起來不正確。有幾種解決方案可以克服字元範圍之間的碰撞或不正確的間距。其中之一是上下文字距。常規字距保留,因此我們在此基礎上新增額外的間距。
我們使用 OpenType 設計器新增對調整(PairAdjTriplet)和鏈式上下文定位(TripletAdj)查詢。
由於上下文字距新增到常規字距,我們將其新增到現有的字距功能中,以便人們可以決定是否啟用整套字距。
這是完整的功能程式碼,包含原始字距以及新新增的上下文字距:
locationDef wght=16d @ThinItalic;
locationDef wght=72d @Italic; # Default
locationDef wght=170d @BoldItalic;
languagesystem latn dflt; # Latin default
lookup PairAdjTriplet { # GPOS lookup type PairAdjustment
pos quoteright A (<120 0 100 0> @ThinItalic:<250 0 200 0> @BoldItalic:<120 0 100 0>);
} PairAdjTriplet;
feature kern { # Kerning
lookup PairAdj { # GPOS lookup type PairAdjustment
pos L quoteright (-260 @ThinItalic:-220);
pos quoteright A (-90 @ThinItalic:-130 @BoldItalic:-40);
} PairAdj;
lookup TripletAdj { # GPOS lookup type ChainedContextPositioning
pos L quoteright' lookup PairAdjTriplet A';
} TripletAdj;
} kern;
這是最終結果:
致謝:本教程中使用的字型是 Kantumruy Pro Italic – Tep Sovichet 設計的可變字型 – https://github.com/sovichet/kantumruy-pro
注意:使用的可變功能程式碼目前(2024 年 10 月)正在審查中,應於 2025 年上半年成為官方標準。