Python script to shift mask layer

scruggsdesign's picture

I'm in the very early stages of trying to learn python. Of course, I’m most interested in using Python to script FontLab. However, I find the documentation on how Python works with the Fontlab methods to be extremely sparse. I’m familiar with this http://www.e-font.de/flpydoc/ but that doesn't make much sense to me right now. I've also worked with Robofab a little. I’m sure it will click as I learn more about Python but right now I’m not much further than learning about strings, lists, and loops.

Anyway… I keep hitting a dead end on something that I’m sure is pretty simple…
I frequently save my progress as I’m designing by copying my outlines to the mask layer and shifting the entire mask layer to the left (-1200 units at 2048 UPM). I have an Action Set saved for this that works by shifting outline & mask -1200 then shifting just the outline back 1200. I would like to do this with just a keyboard shortcut so I explored ways of making it happen with a Python script but I could never find a way to act on the mask layer in either the built-in FontLab methods or Robofab.

Any help on this would be greatly appreciated.

Thanks!
Josh

eigi's picture

Hello,


glyph = fl.glyph.mask
glyph.Shift(Point(-1000,0))
fl.glyph.mask = glyph
fl.UpdateGlyph(fl.iglyph)

Best
Eigi

scruggsdesign's picture

Thank you! Thank you! Thank you!

That works perfectly!
How did you become so well versed in scripting FontLab with Python?

I'm going to keep studying and someday, hopefully, I’ll be skilled enough to solve my own problems…
Thanks again!

Syndicate content Syndicate content