Hello,
sorry for being so late.
The samples from the posts above can be made more readable by importing
fl_cmd. Then you can write something like this:
import fl_cmd
fl.CallCommand(fl_cmd.MaskClear)
fl.CallCommand(fl_cmd.MaskCopy)
You can print a list of available command constants like this:
import fl_cmd
for name in dir(fl_cmd):
print name
It is also possible to access the mask of a glyph directly. The following little function replaces the glyph mask with a copy of the glyph itself.
def replaceMaskWithGlyphCopy(glyph):
glyph.mask = Glyph(glyph)
Modification of the mask is a bit more complicated because 'in place' modification of the mask is not possible. You have to do it in three steps:
- create a reference to the glyph in the mask layer
- modify this mask glyph
- assign the modified glyph back to the mask
A function to
add a copy of the glyph itself to the mask may look like this:
def addGlyphCopyToMask(glyph):
if glyph.mask is None:
maskGlyph = Glyph()
else:
maskGlyph = glyph.mask
maskGlyph.Add(Glyph(glyph))
glyph.mask = maskGlyph
A function to shift the mask follows the same pattern:
def shiftMask(glyph, dx=0, dy=0):
if glyph.mask is not None:
maskGlyph = glyph.mask
maskGlyph.Shift(Point(dx, dy))
glyph.mask = maskGlyph
It is not possible to clear the mask by using the mask attribute of a glyph object. For a glyph without mask the mask attribute is None. If you try to assign None to the glyph attribute an exception is raised. The only thing you can do is to assign an empty glyph to the mask, but this is not the same.
That's all I can contribute as doc for the glyph mask.
Best
Eigi