title: Extracting text attributes using Tesseract hOCR
body: <p>I am using Tesseract (on windows) to extract text from scientific diagrams, e.g. plots, where there are many isolated words or numbers but no sentences or paragraphs. I then turn the HTML into SVG. This works well except that I cannot get </p>
  
  <ul>
  <li>font-size</li>
  <li>font-family</li>
  <li>xy-coordinate of text anchor</li>
  <li>text orientation (e.g. rotated Math.PI/2 for labelling graph axes)</li>
  </ul>
  
  <p>I can get a rough font size from the bounding box but this depends on whether characters have ascenders or descenders. Thus all the lines below (in hOCR output) have the same font-family and size:</p>
  
  <pre><code>&lt;span class='ocrx_word' id='word_6' title="bbox 1177 491 1637 549"&gt;Herpetotherinae&lt;/span&gt; 
  &lt;span class='ocrx_word' id='word_13' title="bbox 1183 1179 1514 1228"&gt;Cathartidae&lt;/span&gt;
  &lt;span class='ocrx_word' id='word_35' title="bbox 1847 1742 1907 2077"&gt;Accipitridae&lt;/span&gt; 
  </code></pre>
  
  <p>span_1 has a descender (in "p") and a bbox y-height of 58, while span_2 has bbox height 49 (no descenders) and span_3 has bbox x-width of 60, showing the text is rotated. However the bbox by itself is not enough to position the text accurately or determine text orientation.</p>
  
  <p>I would like to use Tess4J and use any API that would lead to getting these attributes.</p>
  
  <p>If anyone has already written an SVG output from Tess4J I'd be grateful. (any code from me is F/OSS).</p>