title: Measuring string width in Python
body: <p>I have some font (Times New Roman, 14) and I need to measure string width. I found matplotlib and example from API:</p>
  
  <pre><code>from matplotlib import rcParams
  import os.path
  afm_filename = os.path.join(rcParams['datapath'], 'fonts', 'afm', 
                 'ptmr8a.afm')
  from matplotlib.afm import AFM
  afm = AFM(open(afm_filename))
  afm.string_width_height('What the heck?')
  </code></pre>
  
  <p>But I can't understand what I should paste instead of "datapaths", "fonts", "afm". 
  Is it the way to get sting width in Python? Maybe another way?  </p>