Access Masters in a Filter Plugin when run as Custom Parameter

Is it possible somehow to still access the master layers, when adding a certain Filter Plugin as a CP on an Export-Instance?

My filter plugin can do that when run in the UI, it does some path operations using the drawings of 2 masters. However when it’s run as a CP, I only have access to the one default layer “Regular” of each glyph. At least per default. Is there a way to inject the desired master layers somehow beforehad, so that the filter can work with those?

That is currently not possible for a filter.

Thanks, that’s good to know at least :slight_smile:

It might be possible with this:

	@objc.python_method
	def settings(self):
		self.menuName = Glyphs.localize({
			'en': 'Prepare Layer',
		})
		GSCallbackHandler.addCallback_forOperation_(self, "GSPrepareLayerCallback")

	@objc.typedSelector(b'c32@:@@o^@')
	def processGlyph_instance_error_(self, glyph, instance, error):
		print("__", glyph, instance)
		return True

This can be added to any plugin, just make sure that you don’t add that callback more than once.

Thank you, I’ll experiment with that.
Should I also remove that callback at some point? The Filter Plugin doesn’t have some sort of dealloc method, or?

Filters are only instantiated once and are not released until the app is closed. Some with “glyphsPluging”. All the other plugins are instantiated and deallocated a lot.

1 Like