def test_ttcompile_timestamp_calcs(inpath, outpath1, outpath2, tmpdir): inttx = os.path.join("Tests", "ttx", "data", inpath) outttf1 = tmpdir.join(outpath1) outttf2 = tmpdir.join(outpath2) options = ttx.Options([], 1) # build with default options = do not recalculate timestamp ttx.ttCompile(inttx, str(outttf1), options) # confirm that font was built assert outttf1.check(file=True) # confirm that timestamp is same as modified time on ttx file mtime = os.path.getmtime(inttx) epochtime = timestampSinceEpoch(mtime) ttf = TTFont(str(outttf1)) assert ttf["head"].modified == epochtime # reset options to recalculate the timestamp and compile new font options.recalcTimestamp = True ttx.ttCompile(inttx, str(outttf2), options) # confirm that font was built assert outttf2.check(file=True) # confirm that timestamp is more recent than modified time on ttx file mtime = os.path.getmtime(inttx) epochtime = timestampSinceEpoch(mtime) ttf = TTFont(str(outttf2)) assert ttf["head"].modified > epochtime
def ttCompile(input, output, options): log.info('Compiling "%s" to "%s"...' % (input, output)) if options.useZopfli: from fontTools.ttLib import sfnt sfnt.USE_ZOPFLI = True ttf = TTFont(options.mergeFile, flavor=options.flavor, recalcBBoxes=options.recalcBBoxes, recalcTimestamp=options.recalcTimestamp) ttf.importXML(input) if options.recalcTimestamp is None and 'head' in ttf: # use TTX file modification time for head "modified" timestamp mtime = os.path.getmtime(input) ttf['head'].modified = timestampSinceEpoch(mtime) ttf.save(output)
def ttCompile(input, output, options): log.info('Compiling "%s" to "%s"...' % (input, output)) if options.useZopfli: from fontTools.ttLib import sfnt sfnt.USE_ZOPFLI = True ttf = TTFont(options.mergeFile, flavor=options.flavor, recalcBBoxes=options.recalcBBoxes, recalcTimestamp=options.recalcTimestamp, allowVID=options.allowVID) ttf.importXML(input) if not options.recalcTimestamp: # use TTX file modification time for head "modified" timestamp mtime = os.path.getmtime(input) ttf['head'].modified = timestampSinceEpoch(mtime) ttf.save(output)
def ttCompile(input, output, options): if not options.quiet: print('Compiling "%s" to "%s"...' % (input, output)) ttf = TTFont(options.mergeFile, recalcBBoxes=options.recalcBBoxes, recalcTimestamp=options.recalcTimestamp, verbose=options.verbose, allowVID=options.allowVID) ttf.importXML(input, quiet=options.quiet) if not options.recalcTimestamp: # use TTX file modification time for head "modified" timestamp mtime = os.path.getmtime(input) ttf['head'].modified = timestampSinceEpoch(mtime) ttf.save(output) if options.verbose: import time print("finished at", time.strftime("%H:%M:%S", time.localtime(time.time())))
def _ufo_date_to_opentime(d): return timestampSinceEpoch( datetime.strptime(d, "%Y/%m/%d %H:%M:%S").timestamp())