foregroundInViewCoords() missing 1 required positional argument: 'layer'

Hi I’m using:

def foregroundInViewCoords(self, layer):
	font = Glyphs.font
	currentTab = font.currentTab

But I get foregroundInViewCoords() missing 1 required positional argument: ‘layer’.
Any ideas? What I’m missing here.


Where are you calling this function?

in the main class of a reporter plugin

Can you show the code that is calling the function? It appears the error is originating at the function call site.

Sure. (19.7 KB)

The Glyphs API calls foregroundInViewCoords with no arguments, so your function definition cannot have a layer parameter. You might want to use the foreground method which does get the layer passed as an argument. See the Reporter Plgun documentation:

Edit: I see there is a mention of foregroundInViewCoords with a layer parameter in the documentation. I will investigate whether the documentation or the API is incorrect about this.

In the meantime, get the active layer with self.activeLayer().

Thanks for the clarification, now it works. I was reading the docs and I copied the function from the example, there uses layer as argument. I will post an issue on the docs repo.

Already reported. Thank you for finding this issue.

1 Like

I fixed it.