title: detecting font of text in image
body: <p>i want to detect the font of text in an image so that i can do better OCR on it. searching for a solution i found <a href="https://stackoverflow.com/questions/42552271/detect-font-in-a-image">this</a> post. although it may seem that it is the same as my question, it does not exactly address my problem.</p>
  
  <hr>
  
  <p><strong>background</strong></p>
  
  <p>for OCR i am using tesseract, which uses trained data for recognizing text. training tesseract with lots of fonts reduces the accuracy which is natural and understandable. one solution is to build multiple trained data - one per few similar fonts - and then automatically use the appropriate data for each image. for this to work we need to be able to detect the font in image.</p>
  
  <hr>
  
  <p>number 3 in <a href="https://stackoverflow.com/a/43599355/8585270">this answer</a> uses OCR to isolate image of characters along with their recognized character and then generates the same character's image with each font and compare them with the isolated image. in my case the user should provide a bounding box and the character associated with it. but because i want to OCR Arabic script(which is cursive and character shapes may vary depending on what other characters are adjacent to it) and <strong><em>because the bounding box may not be actually the minimal bounding box</em></strong>, i am not sure how i can do the comparing.</p>
  
  <p>i believe <a href="https://en.wikipedia.org/wiki/Hausdorff_distance" rel="nofollow noreferrer">Hausdorff distance</a> is not applicable here. am i right?</p>
  
  <p><a href="https://en.wikipedia.org/wiki/Shape_context" rel="nofollow noreferrer">shape context</a> may be good(?) and there is a shapeContextDistanceExtractor class in opencv but i am not sure how i can use it in opencv-python</p>
  
  <p>thank you
  sorry for bad English</p>