- # try to mask rounding errors
- if (dimstr == '-0.00'):
- dimstr = '0.00'
- self.write( dimstr +' ');
-
- def def_symbol (self, code, lily_id, tex_id, xdim, ydim):
- xdim = map (string.atof, xdim)
- ydim = map (string.atof, ydim)
+class Char_metric:
+ def __init__ (self):
+ pass
+
+
+def tfm_checksum (fn):
+ sys.stderr.write ("Reading checksum from `%s'\n" % fn)
+ s = open (fn).read ()
+ s = s[ 12 * 2 : ]
+ cs_bytes = s[:4]
+
+ shift = 24
+ cs = 0
+ for b in cs_bytes:
+ cs = cs + (long (ord (b)) << shift)
+ shift = shift - 8
+
+ return cs
+
+## ugh. What's font_family supposed to be? It's not an afm thing.
+font_family = 'feta'
+def parse_logfile (fn):
+ (autolines, deps) = read_log_file (fn)
+ charmetrics = []
+ global_info = {}
+ group = ''
+
+ for l in autolines:
+ tags = string.split(l, '@:')
+ if tags[0] == 'group':
+ group = tags[1]
+ elif tags[0] == 'char':
+ m = {
+ 'description': tags[1],
+ 'name': group + '-' + tags[9],
+ 'tex': tags[10],
+ 'code': string.atoi (tags[2]),
+ 'breapth':string.atof (tags[3]),
+ 'width': string.atof (tags[4]),
+ 'depth':string.atof (tags[5]),
+ 'height':string.atof (tags[6]),
+ 'wx': string.atof (tags[7]),
+ 'wy':string.atof (tags[8]),
+ }
+ charmetrics.append (m)
+ elif tags[0] == 'font':
+ global font_family
+ font_family = (tags[3])
+ # To omit 'GNU' (foundry) from font name proper:
+ # name = tags[2:]
+ #urg
+ if 0: #testing
+ tags.append ('Regular')
+
+
+ encoding = re.sub (' ','-', tags[5])
+ tags = tags[:-1]
+ name = tags[1:]
+ global_info['DesignSize'] = string.atof (tags[4])
+ global_info['FontName'] = string.join (name,'-')
+ global_info['FullName'] = string.join (name,' ')
+ global_info['FamilyName'] = string.join (name[1:-1],
+ '-')
+ if 1:
+ global_info['Weight'] = tags[4]
+ else: #testing
+ global_info['Weight'] = tags[-1]
+
+ global_info['FontBBox'] = '0 0 1000 1000'
+ global_info['Ascender'] = '0'
+ global_info['Descender'] = '0'
+ global_info['EncodingScheme'] = encoding