code: def _parse_char_metrics(fh):
      """
      Return a character metric dictionary.  Keys are the ASCII num of
      the character, values are a (*wx*, *name*, *bbox*) tuple, where
      *wx* is the character width, *name* is the postscript language
      name, and *bbox* is a (*llx*, *lly*, *urx*, *ury*) tuple.
  
      This function is incomplete per the standard, but thus far parses
      all the sample afm files tried.
      """
  
      ascii_d = {}
      name_d = {}
      for line in fh:
          # We are defensively letting values be utf8. The spec requires
          # ascii, but there are non-compliant fonts in circulation
          line = _to_str(line.rstrip())  # Convert from byte-literal
          if line.startswith("EndCharMetrics"):
              return ascii_d, name_d
          # Split the metric line into a dictionary, keyed by metric identifiers
          vals = dict(
              s.strip().split(" ", 1) for s in line.split(";") if s
          )
          # There may be other metrics present, but only these are needed
          if not {"C", "WX", "N", "B"}.issubset(vals):
              raise RuntimeError("Bad char metrics line: %s" % line)
          num = _to_int(vals["C"])
          wx = _to_float(vals["WX"])
          name = vals["N"]
          bbox = _to_list_of_floats(vals["B"])
          bbox = list(map(int, bbox))
          # Workaround: If the character name is 'Euro', give it the
          # corresponding character code, according to WinAnsiEncoding (see PDF
          # Reference).
          if name == "Euro":
              num = 128
          if num != -1:
              ascii_d[num] = (wx, name, bbox)
          name_d[name] = (wx, bbox)
      raise RuntimeError("Bad parse")
  
imports: from __future__ import absolute_import, division, print_function, unicode_literals
  import six
  from six.moves import map
  import sys
  import re
  from ._mathtext_data import uni2type1
label_desc: Use image node_id 8 for calling a global function with example usage: _parse_char_metrics(fh) and returns: ascii_d,  name_d