From a93ced044f6f8dc81f7be4a60acf52e82778be71 Mon Sep 17 00:00:00 2001 From: Behdad Esfahbod Date: Sun, 28 Feb 2021 18:19:24 -0700 Subject: [PATCH] [varLib.mutator] Simplify maxp handling --- Lib/fontTools/varLib/mutator.py | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/Lib/fontTools/varLib/mutator.py b/Lib/fontTools/varLib/mutator.py index d48707091..04e3f9a1a 100644 --- a/Lib/fontTools/varLib/mutator.py +++ b/Lib/fontTools/varLib/mutator.py @@ -345,14 +345,8 @@ def instantiateVariableFont(varfont, location, inplace=False, overlap=True): # Change maxp attributes as IDEF is added if 'maxp' in varfont: maxp = varfont['maxp'] - if hasattr(maxp, "maxInstructionDefs"): - maxp.maxInstructionDefs += 1 - else: - setattr(maxp, "maxInstructionDefs", 1) - if hasattr(maxp, "maxStackElements"): - maxp.maxStackElements = max(len(loc), maxp.maxStackElements) - else: - setattr(maxp, "maxStackElements", len(loc)) + setattr(maxp, "maxInstructionDefs", 1 + getattr(maxp, "maxInstructionDefs", 0)) + setattr(maxp, "maxStackElements", max(len(loc), getattr(maxp, "maxStackElements", 0))) if 'name' in varfont: log.info("Pruning name table")