LSB Scripting using the API


#1

2018 goal is to get into Python and I wanted some help/an example to study.

How would one write a basic script to select all glyphs in a font and reset the LSB/RSB of each to 0? Completely academic as I know you can do this in the app quite easily.


#2
currentFont = Glyphs.font
for thisGlyph in currentFont.glyphs:
	for thisLayer in thisGlyph.layers:
		thisLayer.LSB = 0
		thisLayer.RSB = 0

Start here: We have some tutorials for learning Python with Glyphs.


#3

Thank you much appreciated!


#4

I just wanted to follow up regarding the thisLayer, thisGlyph classes - are these documented anywhere? I could not see them in the Glyphs API docs. I mean it is obvious in readable text what they do but how many of these are there?


#5

thisLayer and thisGlyph are variable names for GSLayer and GSGlyph objects. They are documented on docu.glyphsapp.com.


#6

If you do ‘print thisLayer’ it will tell you the class name that you can look up in the docu.


#7

Thanks guys, apologies for the utter beginner questions!

Wrote my first very simple proofing script to take a width and then return a list of glyph names that are not at that width.