I’m having some issues with RoboFab scripting, so I’m trying to use Glyphs objects instead. More specifically, I can’t cycle through components or anchors through RoboFab (for one script I want to output all the components for each glyph to double-check that I used the right components where there are variations, say with accents where I have regular, UC, narrow and UC narrow versions; the other one would look at each glyph’s anchors and add TOP or BOTTOM anchors if they are missing). The scripts run perfectly on RoboFont, so I figured it’s a Glyphs-RoboFab issue and decided to bite the bullet and learn to use the Glyphs model.
My question is whether there are “current” objects. Instead of having to specify a layer number (or font or master, etc), could I just say CurrentLayer? Or is there a “selection” object that would go through the glyphs in the selection (I can do it with RoboFab, but can’t seem to understand it with Glyphs).
Also, not 100% sure what’s the difference between layers and masters. And while I’m at it, how can I access the background layer through scripting?
Sorry for the double-dipping. I thought it was a RoboFab issue and posted on the other forum and when I realized it wasn’t I posted here��"and you had already replied when I went to delete the other post.
Downloaded the latest objectsGS and the anchors are now working, but the components still are not. These are the three scripts in question:
Why do you want a script to output component names? This is already built into the app. Go to the font tab, switch to list view, and make sure the components column is on.
And if you still want a script to do that, must it be with RoboFab? It’s easy with plain vanilla Glyphs objects.
Yeah, in my original question I mentioned I solved it with Glyphs objects and my question was specifically about Glyphs objects (how to use the “current” elements). But Georg asked me to send the scripts and he fixed objectsGS for the anchors object, so I posted the RoboFab version. I appreciate that Glyphs has so many built-in tools, but my point in learning all this is to be able to build new tools.
At this point I’ve realized I’d be better served by learning the Glyphs object but RoboFab support was definitely a big selling point.
The list view is very helpful. Good to see it can be printed too.
Better to use a list comprehension than to just hang plusses at the end of each glyph name. The current font is Glyphs.font, the currently active layers of selected glyphs are Glyphs.font.selectedLayers, etc. I suppose you know this site already: http://docu.glyphsapp.com
That’s awesome! Still learning, so this is kinda advanced to me, but cool to know. Wrapping my head around the last print statement, but I just used the way you did the listOfComponents to save some lines in another script.
Quite familiar with docu.glyphsapp.com. As much as I love the handbook, I’m still learning to navigate this resource.
Thanks for your help. Can you recommend any resources for learning more advanced Python? I took a couple of basic workshops, but would love to learn more.
Hey Mekka, been reading the book (thanks for the suggestion) and now that I understand your script I’m wondering what’s the advantage of using %s over writing it like this? or is it just a coding style choice?
It is more modular and thus much easier to change, re-use or fix at a later time. Imagine you want to change the structure of the sentence, or add more string variables. Besides, I do believe it creates easier-to-read code.