Remove Small Kerning Pairs in Instances

Is there a Filter / Plugin, that deletes small Kerning within the instances when they are exported?

In Bold is a Kerning Pair that is -10
In Thin, this kerning Pair isn’t necessary, so it is 0.
→ The interpolated Regular has a Kerning Pair of -5.

How can I get that -5 removed in the Regular? “Delete Small Kerning Pairs” by @mekkablue only works for masters, not within the generated instances.

I know it is possible to create, but I am unable to write this script/filter/plugin.

You would need to write an export plugin that treats each exported instance separately. You can recreate this manually with the following steps:

  • In your Glyphs file, select “File → Generate Instances”
  • Run the “Delete Small Kerning Pairs” script
  • Export

You could otherwise create a Filter plugin that you can add as a custom parameter for each instance, but that’s not really the intended use of filters.

Why is this an issue?

Potentially dangerous, even for zero kerns. Removing an exception may make an unwanted group kern kick back in.

I never thought of that, good point. I’ll need to update my plugin that Moritz is referring to.

The idea is simply that small kerning pairs are perceived as noise (as in, having a -1 kerning pair in an exported font might well be seen as unwanted noise), so I remove all pairs absolutely smaller than 5 units in my exported instances.

Better to round them. Allows for better compression in WOFFs later.


Yes, that’s what I opted for. Thanks!

You don’t need an export plugin for this. A filter plugin will do the trick.

That’s what I pointed out :wink:

Right. If I only could read.

Why not?

From what I understand, filters rather pertain to the layers/outlines rather than the relations between layers (i.e. kerning). Of course, it works perfectly with a filter. Maybe just ignore my comment :grin:

I’m just writing the PreFilter to remove small kerning pairs, but I have a question. How can I run the filter once on export on the kerning, without it being triggered once for every layer? Currently, the filter code is run once for every layer, but I would like to run the filter only once.

Do I need to set some boolean variable once when the filter is run for the first time, and then switch it after running the filter, so that the filter is not run anymore for all the other layers? Is there a smarter way?


I used a much simpler approach: I checked whether the layer belonged to the first glyph in the font, otherwise, it was skipped.

Find the filter here: GitHub - eweracs/remove-small-kerning-pairs: A small export filter to remove small kerning pairs.

There is an even better solution. The python API is a bit oversimplified. The original API is

def processFont_withArguments_(self, font, arguments):

Implement that, instead of the def filter() and it will be called only once.
Have a look at the plugin wrapper: GlyphsSDK/ObjectWrapper/GlyphsApp/ at 514948274927708b34d70ccb74ee2cf7c372b663 · schriftgestalt/GlyphsSDK · GitHub


Thank you!