有时常规的成对定位并不够用。它能修复两个字母之间的间距,但若是某个特定的三字符组合(如 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 年上半年成为官方标准。