Skip to content

Instantly share code, notes, and snippets.

@chrissimpkins
Last active February 14, 2019 04:06
Show Gist options
  • Save chrissimpkins/43083cac7bb9c36fc81f24e7e7e190f1 to your computer and use it in GitHub Desktop.
Save chrissimpkins/43083cac7bb9c36fc81f24e7e7e190f1 to your computer and use it in GitHub Desktop.
mutator-fix.py
# snip: https://github.com/fonttools/fonttools/blob/51a49de3eda4c10df29ceba85a90e7d7378137e8/Lib/fontTools/varLib/mutator.py#L303-L310
if glyf:
for glyph in glyf.glyphs.values():
if hasattr(glyph, "program"):
instructions = glyph.program.getAssembly()
# If GETVARIATION opcode is used in bytecode of any glyph add IDEF
addidef = any(op.startswith("GETVARIATION") for op in instructions)
if addidef:
break
# need to add a parameter in the
# instantiateVariableFont call
# e.g.
# def instantiateVariableFont(varfont, location, inplace=False, set_macos_overlap_flag=False)
# and create an argparse command line argument that is used in the mutator executable
# function call. Then use the flag to determine execution of the following source:
if set_macos_overlap_flag:
for glyph in glyf.keys():
glyph = glyf[glyph_name]
# Only needs to be set for glyphs with contours
if glyph.numberOfContours > 0:
glyph.flags[0] |= 1 << 6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment