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.

I cannot get this to work, when I export the parameter is seemingly ignored, why might this be? Also, If I just set a parameter on a black master will the kerning interpolate for the rest of the weights if the origin master is the ExtraLight?

The parameter needs to be on the instances, not the masters.

Can you explain what you are trying to do? When you like to have some contextual kerning, you might write the feature normally and use number value tokens: Tokens — Glyphs Handbook

Thanks for the reply Georg. Essentially, I have done some contextual kerning for the ExtraLight which causes the same combination in the black to clash. Currently I have opted for an ideal kern for the regular which isn’t perfect for the extreme weights. Ideally I could set each static weight individually which I believe adding a custom parameter directly to the instances would achieve? Currently though I have tried adding a kern feature to a single instance (black), and also calculating the interpolated kern value and writing a separate piece of kern feature code for each instance in custom parameters, neither of which made any difference. As I understand it the process is:

– in the exports window I select an instance
– I add a custom parameter “Add Feature”
– I set the title to kern and set the code to something along the lines of pos L’ 50 quoteright [B, C, D];
– I repeat this for the other instances changing the value of the kern accordingly

If this is correct, it’s not working for me. I thought the interaction with the feature code may be causing the issue but I deleted that and still faced the same issue.

It seems like the number tokens will work, I’ll give this a go now!

UPDATE
The method with the number tokens works Georg, thanks very much.