docstr: All tables must have been written to disk. Now write the
  directory.
code: def close(self):
      """All tables must have been written to disk. Now write the
      directory.
      """
      tables = sorted(self.tables.items())
      if len(tables) != self.numTables:
          raise TTLibError(
              "wrong number of tables; expected %d, found %d"
              % (self.numTables, len(tables))
          )
  
      if self.flavor == "woff":
          self.signature = b"wOFF"
          self.reserved = 0
  
          self.totalSfntSize = 12
          self.totalSfntSize += 16 * len(tables)
          for tag, entry in tables:
              self.totalSfntSize += (entry.origLength + 3) & ~3
  
          data = (
              self.flavorData if self.flavorData else WOFFFlavorData()
          )
          if (
              data.majorVersion is not None
              and data.minorVersion is not None
          ):
              self.majorVersion = data.majorVersion
              self.minorVersion = data.minorVersion
          else:
              if hasattr(self, "headTable"):
                  self.majorVersion, self.minorVersion = struct.unpack(
                      ">HH", self.headTable[4:8]
                  )
              else:
                  self.majorVersion = self.minorVersion = 0
          if data.metaData:
              self.metaOrigLength = len(data.metaData)
              self.file.seek(0, 2)
              self.metaOffset = self.file.tell()
              compressedMetaData = compress(data.metaData)
              self.metaLength = len(compressedMetaData)
              self.file.write(compressedMetaData)
          else:
              self.metaOffset = (
                  self.metaLength
              ) = self.metaOrigLength = 0
          if data.privData:
              self.file.seek(0, 2)
              off = self.file.tell()
              paddedOff = (off + 3) & ~3
              self.file.write(b"\0" * (paddedOff - off))
              self.privOffset = self.file.tell()
              self.privLength = len(data.privData)
              self.file.write(data.privData)
          else:
              self.privOffset = self.privLength = 0
  
          self.file.seek(0, 2)
          self.length = self.file.tell()
  
      else:
          assert not self.flavor, "Unknown flavor '%s'" % self.flavor
          pass
  
      directory = sstruct.pack(self.directoryFormat, self)
  
      self.file.seek(self.directoryOffset + self.directorySize)
      seenHead = 0
      for tag, entry in tables:
          if tag == "head":
              seenHead = 1
          directory = directory + entry.toString()
      if seenHead:
          self.writeMasterChecksum(directory)
      self.file.seek(self.directoryOffset)
      self.file.write(directory)
  
imports: from io import BytesIO
  from types import SimpleNamespace
  from fontTools.misc.textTools import Tag
  from fontTools.misc import sstruct
  from fontTools.ttLib import TTLibError, TTLibFileIsCollectionError
  import struct
  from collections import OrderedDict
  import logging
label_desc: Use image node_id 6 for calling the SFNTWriter obj's underlying member method code with example usage: obj.close() without return types