code: def _parse_kern_pairs(fh):
      """
      Return a kern pairs dictionary; keys are (*char1*, *char2*) tuples and
      values are the kern pair value.  For example, a kern pairs line like
      ``KPX A y -50``
  
      will be represented as::
  
        d[ ('A', 'y') ] = -50
  
      """
  
      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()  # EndKernData
              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")
  
imports: import sys, os, re
  from _mathtext_data import uni2type1
label_desc: Use image node_id 7 for calling a global function with example usage: _parse_kern_pairs(fh) and returns: d