title: Compute column widths in a HTML-like manner (based on cell contents)
body: <p>I have a grid of data that I want to export to RTF, PDF etc. using various (and not perfect) PHP converters/generators.</p>
  
  <p>What I am missing most is the HTML table automatic adjustment of column widths based on the lengths of strings in the cells (strings contain line breaks which complicate things a bit, as they should be preserved).</p>
  
  <p>I need an algorithm that, given the contents of the cells (plain text), a total width of the table and an average width of a character, would return a width for each column. I wouldn't want to reinvent the wheel if something is already available.</p>
  
  <p>Of course it can't be perfect if the font is variable width, but an approximation would do just fine. Or maybe it could have a configurable table with widths for each character.</p>
  
  <p>Any hint would be appreciated. </p>