upload webpage to other dir.
[mftrace.git] / afm.py
blobdb3a612f2f87c2ec6febaca9078a34ac96ffbc1d
1 # this file is part of mftrace - a tool to generate scalable fonts from bitmaps
2 # This program is free software; you can redistribute it and/or modify
3 # it under the terms of the GNU General Public License version 2
4 # as published by the Free Software Foundation
6 # This program is distributed in the hope that it will be useful,
7 # but WITHOUT ANY WARRANTY; without even the implied warranty of
8 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9 # GNU Library General Public License for more details.
11 # You should have received a copy of the GNU General Public License
12 # along with this program; if not, write to the Free Software
13 # Foundation, Inc.,
15 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17 # Copyright (c) 2001--2006 by
18 # Han-Wen Nienhuys, Jan Nieuwenhuizen
22 import re
23 import sys
25 # Read some global vars
26 class Afm_reader:
27 def __init__ (self, lines):
28 self.lines = lines
30 def get_afm (self):
31 afm = Afm_font_metric ()
32 for i in self.lines[:20]:
33 m = re.match ('([^ \t\n]*)[ \t]*(.*[^ \t\n])', i)
34 if m and m.group (1):
35 key = m.group (1)
36 value = m.group (2)
37 if key != 'Comment':
38 afm.__dict__[key] = value
39 return afm
41 class Afm_font_metric:
42 def __init__ (self):
43 pass
45 def read_afm_file (filename):
46 reader = Afm_reader (open (filename).readlines ())
47 return reader.get_afm ()
49 if __name__ == '__main__':
50 i = read_afm_file (sys.argv[1])
51 print i, i.FullName, i.FontName