code: def textdim(s, fontname="Consolas", fontsize=11):
      fig, ax = plt.subplots(1, 1)
      t = ax.text(
          0,
          0,
          s,
          bbox={"lw": 0, "pad": 0},
          fontname=fontname,
          fontsize=fontsize,
      )
      # plt.savefig(tempfile.mktemp(".pdf"))
      plt.savefig("/tmp/font.pdf", pad_inches=0, dpi=200)
      print(t)
      plt.close()
      bb = t.get_bbox_patch()
      print(bb)
      w, h = bb.get_width(), bb.get_height()
      return w, h
  
imports: import matplotlib
  import matplotlib.patches
  from matplotlib import pyplot
label_desc: Use image node_id 1 for calling a global function with example usage: textdim(s, fontname, fontsize) and returns: w,  h