def _parse_kern_pairs(fh):
 line = fh.readline()
 if (not line.startswith('StartKernPairs')):
  raise RuntimeError(('Bad start of kern pairs data: %s' % line))
 d = {}
 while 1:
  line = fh.readline()
  if (not line):
   break
  line = line.rstrip()
  if (len(line) == 0):
   continue
  if line.startswith('EndKernPairs'):
   fh.readline()
   return d
  vals = line.split()
  if ((len(vals) != 4) or (vals[0] != 'KPX')):
   raise RuntimeError(('Bad kern pairs line: %s' % line))
  (c1, c2, val) = (vals[1], vals[2], _to_float(vals[3]))
  d[(c1, c2)] = val
 raise RuntimeError('Bad kern pairs parse')

def _parse_kern_pairs ( fh ) : line = fh . readline ( ) if ( not line . startswith ( 'StartKernPairs' ) ) : raise RuntimeError ( ( 'Bad start of kern pairs data: %s' % line ) ) d = { } while 1 : line = fh . readline ( ) if ( not line ) : break line = line . rstrip ( ) if ( len ( line ) == 0 ) : continue if line . startswith ( 'EndKernPairs' ) : fh . readline ( ) return d vals = line . split ( ) if ( ( len ( vals ) != 4 ) or ( vals [ 0 ] != 'KPX' ) ) : raise RuntimeError ( ( 'Bad kern pairs line: %s' % line ) ) ( c1 , c2 , val ) = ( vals [ 1 ] , vals [ 2 ] , _to_float ( vals [ 3 ] ) ) d [ ( c1 , c2 ) ] = val raise RuntimeError ( 'Bad kern pairs parse' )
return a kern pairs dictionary; keys are tuples and values are the kern pair value .