title: How to get width of a truetype font character in 1200ths of an inch with Python?
body: <p>I can get the height and width of a character in pixels with PIL (see below), but (unless I'm mistaken) pixel size depends on the screen's DPI, which can vary. Instead what I'd like to do is calculate the width of a character in absolute units like inches, or 1200ths of an inch ("wordperfect units").</p>
  
  <pre><code>&gt;&gt;&gt; # Getting pixels width with PIL
  &gt;&gt;&gt; font = ImageFont.truetype('/blah/Fonts/times.ttf' , 12)
  &gt;&gt;&gt; font.getsize('a')
  (5, 14)
  </code></pre>
  
  <p>My reason for wanting to do this is to create a word-wrapping function for writing binary Word Perfect documents. Word Perfect requires soft linebreak codes to be inserted at valid points throughout the text, or the file will be corrupt and unopenable. The question is where to add them for variable width fonts.</p>
  
  <p>I realize that I don't fully understand the relationship between pixels and screen resolution and font sizes. Am I going about this all wrong?</p>