Running a filter on an instance

Hi, I want to write a filter that runs once on the instance. I know about the “Process font with arguments” method, but does something similar exist for the instance on which the filter is called?

Thanks!

What exactly are you trying to do?

I want to run a duplexer filter as an export filter.

Duplexer;wght:150;ital:0

That gets the metrics from the corresponding axis location and I want to apply them to all layers.

You can try to set it up as “PreInterpolationFilter”. The filter needs to have a

- (void)processGlyph:(GSGlyph *)glyph withArguments:(NSArray *)arguments;

or in python

def processGlyph_withArguments_(self, glyph: GSGlyph, arguments: list):

method. the glyph should have all the original layers. I dont’t know if you get to the actual instance. You might need to add the values you need as a argument to the filter.

Thanks. I still don’t see how that would work efficiently. From what I gather, the filter is called for every single glyph, right?

I want the filter to be called once (so that I can calculate the necessary metrics) and then I apply that dictionary to the layers.

Ideally, something like:

  • Filter is called
  • Build a proxy instance/font for the defined axis location
  • Build a dict with all layers as keys, and their sidebearings as values
  • Go through all layers and apply the sidebearings from the dict

Does this make sense?

Maybe I can harness the processFont_withArguments_ method. If called on export, does that process the actual font, or a version that is only used for exporting, and not saved?

That should always be run on a copy.

But I still don’t understand what you are trying to do. Can you send me more detail (maybe by email)?

You can set a variable like “processed” on the first run and skip if it’s True for the rest. Still gets called many times, but at least without any processing.