Add script with UI as a custom parameter (filter)

Hi,

I’m at the beginning of a project that’s going to need a some python to generate instances. The idea is to use a typeface already designed and deform it using the transform matrix to deform it in different ways in different instances.

So here comes the question: since I would like to write a script with UI (like Roughenizer) and copy its different parameters to different instances, how would you add this “new” filter? I read this article to understand the logic of custom parameters and there’s this line of text:

You can also enter the property name with the keyboard. The property will remain grey until Glyphs recognizes it as a registered parameter name.

Should I access the customInstanceParameters.plist and add it there? In that case, how does each filter which value is linked to which one from the UI?

Thanks!

Please NEVER edit the customInstanceParameters.plist. It will break the app. And it will not change the behaviour of Glyphs.

So you like to add a “Filter” with a script?
That can be done like this:

parameter = GSCustomParameter("Filter", "Transform something")
Font.instances[0].customParameters.append(parameter)
1 Like

Thanks for the advise, Georg.

I don’t actually want to add a Filter with a script. I would like to creat a new filter I could add like a custom parameter/filter just like round corners or Roughenizer do. I was thinking about designing a UI like these filters but with different parameters that I could paste as a filter in the instances.

Thanks.

Then you need to build a plugin that contains the filter: https://github.com/schriftgestalt/GlyphsSDK/tree/master/Python%20Templates

1 Like

Oh, great. I didn’t remember there’s the option for this kind of filters in the SDK.

Thanks, Georg!

I did it the way you said and it did. It’s great.