Shadow script or similar

Hi all!

Someone has knowledge of the existence or development of any script that produces shadows, similar to that action effect in FontLab, to generate a shadow and do an overlap to eliminate the main shape:

f = fl.font
if f == None:
exit

def process(f, g, index):
global randomize
if g == None:
return
g1 = Glyph(g)
g2 = Glyph(g)
s = Point(40, -40)
fl.SetUndo(index)
g.Shift(s)
g1.Distance(10, 10, 2)
g.RemoveOverlap()
g.Bsubtract(g1)
g.Badd(g2)
fl.UpdateGlyph(index)
del g1
del g2

font = fl.font
glyphs = font.glyphs
for index in range(len(glyphs)):
if fl.Selected(index) and index != fl.iglyph :
process(font, glyphs[index], index)
fl.UpdateGlyph(index)

process(font, glyphs[fl.iglyph], fl.iglyph)
fl.UpdateGlyph()

Thanks in advance!

For Boolean operations, you need to set up a GSPathOperator instance:

pathOp = GSPathOperator.alloc().init()

Then you need define lists of paths, e.g., like this:

thisLayer = Font.selectedLayers[0]
p1 = thisLayer.paths[0]
p2 = thisLayer.paths[1]
p3 = thisLayer.paths[2]
thePaths = [p1,p2]
otherPaths = [p3]

Then you do any of these boolean operations:

pathOp.removeOverlapPaths_error_( thePaths, None)
pathOp.subtractPaths_from_error_( otherPaths, thePaths, None )
pathOp.intersectPaths_from_error_( otherPaths, thePaths, None )

The result will be stored in thePaths. You can iterate through it, and add paths to a layer with myLayer.addPath_( myPath ).

1 Like

Many thanks mekkablue, I’ll try to do the script to make it available to the Glyphs community.
:+1:

2 Likes