docstr: Writes out an AFM font to the given path.
docstr_tok: ["Writes","out","an","AFM","font","to","the","given","path","."]
code: def write(self, path, sep="\r"):
      """Writes out an AFM font to the given path."""
      import time
  
      lines = [
          "StartFontMetrics 2.0",
          "Comment Generated by afmLib; at %s"
          % (
              time.strftime(
                  "%m/%d/%Y %H:%M:%S", time.localtime(time.time())
              )
          ),
      ]
  
      # write comments, assuming (possibly wrongly!) they should
      # all appear at the top
      for comment in self._comments:
          lines.append("Comment " + comment)
  
      # write attributes, first the ones we know about, in
      # a preferred order
      attrs = self._attrs
      for attr in preferredAttributeOrder:
          if attr in attrs:
              value = attrs[attr]
              if attr == "FontBBox":
                  value = "%s %s %s %s" % value
              lines.append(attr + " " + str(value))
      # then write the attributes we don't know about,
      # in alphabetical order
      items = sorted(attrs.items())
      for attr, value in items:
          if attr in preferredAttributeOrder:
              continue
          lines.append(attr + " " + str(value))
  
      # write char metrics
      lines.append("StartCharMetrics " + repr(len(self._chars)))
      items = [
          (charnum, (charname, width, box))
          for charname, (charnum, width, box) in self._chars.items()
      ]
  
      def myKey(a):
          """Custom key function to make sure unencoded chars (-1)
          end up at the end of the list after sorting."""
          if a[0] == -1:
              a = (0xFFFF,) + a[
                  1:
              ]  # 0xffff is an arbitrary large number
          return a
  
      items.sort(key=myKey)
  
      for charnum, (charname, width, (l, b, r, t)) in items:
          lines.append(
              "C %d ; WX %d ; N %s ; B %d %d %d %d ;"
              % (charnum, width, charname, l, b, r, t)
          )
      lines.append("EndCharMetrics")
  
      # write kerning info
      lines.append("StartKernData")
      lines.append("StartKernPairs " + repr(len(self._kerning)))
      items = sorted(self._kerning.items())
      for (leftchar, rightchar), value in items:
          lines.append("KPX %s %s %d" % (leftchar, rightchar, value))
      lines.append("EndKernPairs")
      lines.append("EndKernData")
  
      if self._composites:
          composites = sorted(self._composites.items())
          lines.append("StartComposites %s" % len(self._composites))
          for charname, components in composites:
              line = "CC %s %s ;" % (charname, len(components))
              for basechar, xoffset, yoffset in components:
                  line = line + " PCC %s %s %s ;" % (
                      basechar,
                      xoffset,
                      yoffset,
                  )
              lines.append(line)
          lines.append("EndComposites")
  
      lines.append("EndFontMetrics")
  
      writelines(path, lines, sep)
  
imports: import re
label_desc: Use image node_id 7 for calling the AFM obj's underlying member method code with example usage: obj.write(path, sep) and returns: a