Fix UnbouldLocalError and let {h,v}hea be no-op when no {v,h}mtx is present

Fixes https://github.com/fonttools/fonttools/issues/3289
This commit is contained in:
Cosimo Lupo 2023-10-06 10:28:58 +01:00
parent 4e2f80cc08
commit 442576fb1f
2 changed files with 10 additions and 6 deletions

View File

@ -67,9 +67,11 @@ class table__h_h_e_a(DefaultTable.DefaultTable):
return sstruct.pack(hheaFormat, self)
def recalc(self, ttFont):
if "hmtx" in ttFont:
hmtxTable = ttFont["hmtx"]
self.advanceWidthMax = max(adv for adv, _ in hmtxTable.metrics.values())
if "hmtx" not in ttFont:
return
hmtxTable = ttFont["hmtx"]
self.advanceWidthMax = max(adv for adv, _ in hmtxTable.metrics.values())
boundsWidthDict = {}
if "glyf" in ttFont:

View File

@ -50,9 +50,11 @@ class table__v_h_e_a(DefaultTable.DefaultTable):
return sstruct.pack(vheaFormat, self)
def recalc(self, ttFont):
if "vmtx" in ttFont:
vmtxTable = ttFont["vmtx"]
self.advanceHeightMax = max(adv for adv, _ in vmtxTable.metrics.values())
if "vmtx" not in ttFont:
return
vmtxTable = ttFont["vmtx"]
self.advanceHeightMax = max(adv for adv, _ in vmtxTable.metrics.values())
boundsHeightDict = {}
if "glyf" in ttFont: