Cocoa in reporter plugins

I am trying to write a Reporter plugin that draws shapes on top of glyphs.
Now what I noticed is that you can’t write Cocoa code in since it is not conforming with the Python syntax. Or am I missing out on something here?

also, when I execute

print Glyphs.reporters

in Makro Window, my plugin does not show up, despite being installed in Application Support folder. What do?

What do you mean? You can definitely use the PyObjC bridge. The complete API makes use of it. Can you give me an example of what you want to do?

1 Like

typedef struct _NSRect
NSPoint origin;
NSSize size;
} NSRect;

That is Objective C, right?
How do I declare my own NSRect correctly?

If you just want to draw a rectangle, see other people’s code, for example, Mekkablue’s: Masters > Fill up empty masters.

r = NSRect()
r.origin = NSPoint( 20, 30 )
r.size = NSSize( 100, 90 )
print r
1 Like

Thank you! :heart_eyes:

You can write cocoa code. You probably meant ObjectivC code. And you can even use it when you translate it for the pyObjC bridge.

Then there is the plain c code. Like the NSRect functions. Most of them are also covered by the bridge.
the most convenient method to make a NSRect is probably NSMakeRect(10, 10, 20, 20).

1 Like

I’m sorry I didn’t read it carefully. You’re not adding a rectangle to a layer.

1 Like

I’m quite confused about what is Quartz/ Cocoa/ ObjectiveC.

Now I took the Reporter template and just replaced the code in def foreground(self, layer) with:

NSMakeRect(10, 10, 20, 20)

and did some renaming and installed the Plugin by double clicking.
It does not Showup in the menue nor with

print Glyphs.reporters

Did you restart the app?

1 Like

Yes, many times.
I’m using Version 2.4.1 (964).

I closed Glyphs,
Manually deleted plugin,
re-installed by double-clicking
reopened Glyphs
still doesnt show in under “View”

please check the console app. It should give you some error message when the loading of the plugin fails.

And you don’t need to install the plugin every time. Just edit it in the plugin folder directly or put an alias in the plugin folder.

Console does not complain and I can see it in the Preferences -> Plugins pane.
print Glyphs.reporters
does not list it and it does not appear in the “View” menu.

Is your project on GitHub? Can you post a link, we will have a look.

1 Like

I had a look and created a pull request.

There was nothing wrong with your plugin (hence no error), just that Info.plist pointed to a class called ____PluginClassName____ that did not exist inside Do not forget to fill in all the blanks.

There were a few other things I assume you intended differently. You will find them in the pull request I sent you on GitHub. Go through the changes and you’ll see.

Thank you, I was really getting frustrated. :fried_shrimp:

I’ll add an better error message, then.