From 206f684bfae76f693e4809d4a98832d826bb32e3 Mon Sep 17 00:00:00 2001 From: Rasmus Andersson Date: Wed, 19 Aug 2020 11:54:07 -0700 Subject: 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. --- misc/fontbuild | 91 +++++++++++++++++++++++++++++----------------------------- 1 file changed, 45 insertions(+), 46 deletions(-) (limited to 'misc/fontbuild') diff --git a/misc/fontbuild b/misc/fontbuild index 761513d7a..2913c5495 100755 --- a/misc/fontbuild +++ b/misc/fontbuild @@ -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) - - # 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)) + FontBuilder().buildStatic(args.srcfile, outfilename, cff) + + # 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)) @@ -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)] -- cgit v1.2.3