explicitly require 'head' table in TTFont.save()

it's implicitly required anyway, e.g. by ttx's ttCompile, maxp's recalc, OS/2 compile, etc.
This commit is contained in:
Cosimo Lupo 2017-02-21 12:51:34 +00:00
parent 9de3d1a5ae
commit b39f3b613c
No known key found for this signature in database
GPG Key ID: B61AAAD0B53A6419
2 changed files with 9 additions and 3 deletions

View File

@ -203,8 +203,11 @@ class TTFont(object):
# assume "file" is a writable file object # assume "file" is a writable file object
closeStream = False closeStream = False
if self.recalcTimestamp and 'head' in self: if 'head' not in self:
self['head'] # make sure 'head' is loaded so the recalculation is actually done raise TTLibError("missing required table: head")
elif self.recalcTimestamp and not self.isLoaded('head'):
# make sure 'head' is loaded so the recalculation is actually done
self['head']
tags = list(self.keys()) tags = list(self.keys())
if "GlyphOrder" in tags: if "GlyphOrder" in tags:

View File

@ -274,7 +274,10 @@ def ttCompile(input, output, options):
if not options.recalcTimestamp: if not options.recalcTimestamp:
# use TTX file modification time for head "modified" timestamp # use TTX file modification time for head "modified" timestamp
mtime = os.path.getmtime(input) mtime = os.path.getmtime(input)
ttf['head'].modified = timestampSinceEpoch(mtime) try:
ttf['head'].modified = timestampSinceEpoch(mtime)
except KeyError:
raise TTLibError("missing required table: head")
ttf.save(output) ttf.save(output)