def _parse_char_metrics(fh):
 ascii_d = {}
 name_d = {}
 for line in fh:
  line = line.rstrip().decode(u'ascii')
  if line.startswith(u'EndCharMetrics'):
   return (ascii_d, name_d)
  vals = dict((s.strip().split(u' ', 1) for s in line.split(u';') if s))
  if (not {u'C', u'WX', u'N', u'B'}.issubset(vals)):
   raise RuntimeError((u'Bad char metrics line: %s' % line))
  num = _to_int(vals[u'C'])
  wx = _to_float(vals[u'WX'])
  name = vals[u'N']
  bbox = _to_list_of_floats(vals[u'B'])
  bbox = list(map(int, bbox))
  if (name == u'Euro'):
   num = 128
  if (num != (-1)):
   ascii_d[num] = (wx, name, bbox)
  name_d[name] = (wx, bbox)
 raise RuntimeError(u'Bad parse')

def _parse_char_metrics ( fh ) : ascii_d = { } name_d = { } for line in fh : line = line . rstrip ( ) . decode ( u'ascii' ) if line . startswith ( u'EndCharMetrics' ) : return ( ascii_d , name_d ) vals = dict ( ( s . strip ( ) . split ( u' ' , 1 ) for s in line . split ( u';' ) if s ) ) if ( not { u'C' , u'WX' , u'N' , u'B' } . issubset ( vals ) ) : raise RuntimeError ( ( u'Bad char metrics line: %s' % line ) ) num = _to_int ( vals [ u'C' ] ) wx = _to_float ( vals [ u'WX' ] ) name = vals [ u'N' ] bbox = _to_list_of_floats ( vals [ u'B' ] ) bbox = list ( map ( int , bbox ) ) if ( name == u'Euro' ) : num = 128 if ( num != ( - 1 ) ) : ascii_d [ num ] = ( wx , name , bbox ) name_d [ name ] = ( wx , bbox ) raise RuntimeError ( u'Bad parse' )
return a character metric dictionary .