2 # -*- coding: utf-8 -*-
5 # Author: mshio <mshio@users.sourceforge.jp>
12 from fontparser import FontDiffParser
13 from listprinter import SimpleListPrinter
16 def print_new_glyph(archive, newfile, printer=None):
17 def fontfilepath_in_archive(archive_path, weight, ext='ttf'):
18 filenm = archive_path.split('/')[-1]
23 return '%s-%s/%s-%s-%s.%s' % (family_name, type_name,
24 family_name, type_name, weight, ext)
26 def expand_archive(archive_path, fontfile_path):
27 f = tarfile.open(archive_path, 'r:gz')
28 f.extract(fontfile_path)
30 def clean_up(fontfile_path):
31 os.remove(fontfile_path)
32 os.rmdir(fontfile_path.split('/')[0])
34 def main(archive, newfile, printer):
35 font_path = fontfilepath_in_archive(archive, 'medium')
36 expand_archive(archive, font_path)
38 parser = FontDiffParser(font_path, newfile)
39 diff = parser.get_diff()
43 if p == None: p = SimpleListPrinter(delimiter=0x3001)
46 print >>p.out, "%d char(s)" % len(diff)
48 main(archive, newfile, printer)
50 if __name__ == '__main__':
51 if len(sys.argv) != 3:
52 print 'usage: %s tar.gz-file font-file' % sys.argv[0]
58 print_new_glyph(archive, newfile)