Contextual Kerning and Interpolation

The following code works for variable fonts, but not for standard OpenType fonts (.otf). Only the default value is used here. Have I perhaps overlooked something?

pos [f]' 50 (wght:14 wdth:0) 100 (wght:285 wdth:0) 30 space [T Tbar Tcaron Tcedilla Tcommaaccent Tdieresis Tdieresisbelow Tdotbelow Tmacronbelow ];
1 Like

Variable feature code is currently only ever used for variable fonts. That’s why it is recommended to put it in #ifdef VARIABLE … #endif block: Conditional Feature Code — Glyphs Handbook

For static instances, you can define a number value in the masters and put in the values you need in each master. You can give the number value a descriptive name, I used kern1:

pos [f]' ${kern1} space [T Tbar Tcaron Tcedilla Tcommaaccent Tdieresis Tdieresisbelow Tdotbelow Tmacronbelow ];

We are working on improving this.

1 Like

Ok, I had somehow understood it differently in the “learn” article.
Anyway, thanks for the clarification.

# Automatic Code
pos f' 50 (wdth:150) 95 space [T V W Y];

The above piece of code means that, in the origin master, f will get an extra 50 units of space if it appears before space followed by any of the glyphs in [T V W Y]. In an extended style, or in other words, at designspace coordinate (wdth:150), that same extra space is 95 instead of 50. And the best thing: along the width axis, this value will interpolate for every instance, and even variable fonts. Pretty cool…

Faced the same problem and spotted this article. In variable it works perfectly – kerning affects in weights where needed. But unlucky for static can’t get same result. At the moment for static going to use an alternate glyph with changed sidebearing. Wishing you luck on improving that! :slight_smile:

For static you can add a kern feature in custom parameters. The default is

pos f' 50 space [T V W Y];

And in instances with higher width, you can change that to:

pos f' 95 space [T V W Y];

I been trying next
pos Idieresis’ 0 (wght:175) 0 (wght:230) 80 space Idieresis;

Feature above working only for varialbe.
I been built up and simplify feature several times and been trying different set up.
The result – for static every time i been add more than 1 value of kerning it stops working. With one value it’s working, but obviously, same for all masters. I wanted activate positive kerning when weight is too big and dieresises overlap each other even between space inserted.

“And in instances with higher width”. Maybe I missing something. How would I add instance if it’s (wght:175) not the way?

This will not work in static exports. So what you can do is to go to File > Font Info > Exports, select the weights beyond 230, and add a custom parameter called Add Feature, and add this line to its content:

pos Idieresis' 80 space Idieresis;

Then confirm the dialog:

This will add this kern feature, but only the static export of the instances you selected.

1 Like

Thank you for making it clear! Works well. Since then, I preferred to add custom parameter in Export > Variable instance, as well as for static. Because when I had kern feature in the tab of all Features and plus Custom Parameter for static instances they conflicted with each other in a way that after export statics kerning didn’t apply, so I needed to turn off the kern feature in the Features tab. Even been trying to limit feature to only variable with
#ifdef VARIABLE
…
#endif
but no luck
However if I add a kern custom parameter to a variable instance in the Export tab both satic and var exports fine.