[varLib.mutator] Simplify maxp handling

This commit is contained in:
Behdad Esfahbod 2021-02-28 18:19:24 -07:00
parent 23e5d4eb0b
commit a93ced044f

View File

@ -345,14 +345,8 @@ def instantiateVariableFont(varfont, location, inplace=False, overlap=True):
# Change maxp attributes as IDEF is added # Change maxp attributes as IDEF is added
if 'maxp' in varfont: if 'maxp' in varfont:
maxp = varfont['maxp'] maxp = varfont['maxp']
if hasattr(maxp, "maxInstructionDefs"): setattr(maxp, "maxInstructionDefs", 1 + getattr(maxp, "maxInstructionDefs", 0))
maxp.maxInstructionDefs += 1 setattr(maxp, "maxStackElements", max(len(loc), getattr(maxp, "maxStackElements", 0)))
else:
setattr(maxp, "maxInstructionDefs", 1)
if hasattr(maxp, "maxStackElements"):
maxp.maxStackElements = max(len(loc), maxp.maxStackElements)
else:
setattr(maxp, "maxStackElements", len(loc))
if 'name' in varfont: if 'name' in varfont:
log.info("Pruning name table") log.info("Pruning name table")