mirror of
https://github.com/rsms/inter.git
synced 2024-11-23 11:43:47 +03:00
tooling: include anchors in final font files. This does not seem to have real-world practial effects beyond increasing the file size, but more testing is needed. Sharing the work first. Easy to revert.
This commit is contained in:
parent
053cb053e7
commit
206f684bfa
@ -193,42 +193,46 @@ class Main(object):
|
||||
elif fext != ".otf":
|
||||
raise Exception('invalid file format %r (expected ".otf" or ".ttf")' % fext)
|
||||
|
||||
# temp file to write to
|
||||
tmpfilename = pjoin(self.tmpdir, basename(outfilename))
|
||||
mkdirs(self.tmpdir)
|
||||
|
||||
# build OTF or TTF file from UFO
|
||||
FontBuilder().buildStatic(args.srcfile, tmpfilename, cff)
|
||||
FontBuilder().buildStatic(args.srcfile, outfilename, cff)
|
||||
|
||||
# Run ots-sanitize on produced OTF/TTF file and write sanitized version to outfilename
|
||||
self._ots_sanitize(tmpfilename, outfilename)
|
||||
# code to pipe font through ots-sanitize:
|
||||
# # temp file to write to
|
||||
# tmpfilename = pjoin(self.tmpdir, basename(outfilename))
|
||||
# mkdirs(self.tmpdir)
|
||||
#
|
||||
# # build OTF or TTF file from UFO
|
||||
# FontBuilder().buildStatic(args.srcfile, tmpfilename, cff)
|
||||
#
|
||||
# # Run ots-sanitize on produced OTF/TTF file and write sanitized version to outfilename
|
||||
# self._ots_sanitize(tmpfilename, outfilename)
|
||||
|
||||
|
||||
def _ots_sanitize(self, tmpfilename, outfilename):
|
||||
# run through ots-sanitize
|
||||
# for filename in args.output:
|
||||
tmpfile = pjoin(self.tmpdir, tmpfilename)
|
||||
mkdirs(dirname(outfilename))
|
||||
success = True
|
||||
try:
|
||||
self.log("write %s" % outfilename)
|
||||
otssan_res = subprocess.check_output(
|
||||
['ots-sanitize', tmpfile, outfilename],
|
||||
# ['cp', tmpfile, outfilename],
|
||||
shell=False
|
||||
).strip()
|
||||
# Note: ots-sanitize does not exit with an error in many cases where
|
||||
# it fails to sanitize the font.
|
||||
success = str(otssan_res).find('Failed') == -1
|
||||
except:
|
||||
success = False
|
||||
if len(otssan_res) == 0:
|
||||
otssan_res = 'error'
|
||||
|
||||
if success:
|
||||
os.unlink(tmpfile)
|
||||
else:
|
||||
fatal('ots-sanitize failed for %s: %s' % (tmpfile, otssan_res))
|
||||
#def _ots_sanitize(self, tmpfilename, outfilename):
|
||||
# # run through ots-sanitize
|
||||
# # for filename in args.output:
|
||||
# tmpfile = pjoin(self.tmpdir, tmpfilename)
|
||||
# mkdirs(dirname(outfilename))
|
||||
# success = True
|
||||
# try:
|
||||
# self.log("write %s" % outfilename)
|
||||
# otssan_res = subprocess.check_output(
|
||||
# ['ots-sanitize', tmpfile, outfilename],
|
||||
# # ['cp', tmpfile, outfilename],
|
||||
# shell=False
|
||||
# ).strip()
|
||||
# # Note: ots-sanitize does not exit with an error in many cases where
|
||||
# # it fails to sanitize the font.
|
||||
# success = str(otssan_res).find('Failed') == -1
|
||||
# except:
|
||||
# success = False
|
||||
# if len(otssan_res) == 0:
|
||||
# otssan_res = 'error'
|
||||
#
|
||||
# if success:
|
||||
# os.unlink(tmpfile)
|
||||
# else:
|
||||
# fatal('ots-sanitize failed for %s: %s' % (tmpfile, otssan_res))
|
||||
|
||||
|
||||
|
||||
@ -264,7 +268,7 @@ class Main(object):
|
||||
if g.name in glyphOrder:
|
||||
del(glyphOrder[g.name])
|
||||
g.unicodes = []
|
||||
g.clearAnchors()
|
||||
# g.clearAnchors()
|
||||
if 'com.schriftgestaltung.Glyphs.lastChange' in g.lib:
|
||||
del(g.lib['com.schriftgestaltung.Glyphs.lastChange'])
|
||||
|
||||
@ -376,14 +380,9 @@ class Main(object):
|
||||
# generate designspace from glyphs project
|
||||
designspace = glyphsLib.to_designspace(
|
||||
font,
|
||||
propagate_anchors=False,
|
||||
# propagate_anchors=False,
|
||||
instance_dir=relpath(instance_dir, master_dir),
|
||||
|
||||
store_editor_state=False,
|
||||
# do not store glyphs editor UI state in UFOs
|
||||
|
||||
minimize_glyphs_diffs=True,
|
||||
# do not store glyphs metadata in UFOs
|
||||
store_editor_state=False, # do not store glyphs editor UI state in UFOs
|
||||
)
|
||||
|
||||
# strip lib data
|
||||
@ -528,9 +527,9 @@ class Main(object):
|
||||
del(font.lib[italicAngleKey])
|
||||
font.info.italicAngle = italicAngle
|
||||
|
||||
# clear anchors
|
||||
for g in font:
|
||||
g.clearAnchors()
|
||||
# # clear anchors
|
||||
# for g in font:
|
||||
# g.clearAnchors()
|
||||
|
||||
# update font info
|
||||
weight = instance_weight[basename(font.path)]
|
||||
|
Loading…
Reference in New Issue
Block a user