title: Text wrapping in LibHaru
body: <p>I am working for some project development related to PDF generation using LibHaru. I plan to fit some text in a particular region. I used <code>TextRect()</code> for that but I have some trouble with the text wrapping. </p>
  
  <ol>
  <li>If the width of the text is more than that of the width of the rectangle, the rectangle goes blank. How do I get rid of that?</li>
  <li>I tried to write my own text wrapping or split string function which adds space after a particular number of characters but even that seems to fail after a particular limit. Any help regarding the text wrapping function.</li>
  <li>How go I calculate the width of the text which will fit inside a particular width of the rectangle?</li>
  </ol>
  
  <p>Here is the code snippet for the split string function:</p>
  
  <pre><code>void SplitString(int iLength, string strInput, string&amp; strOutput)
  {
  
      int iSubstringsCnt;
      int iAddedCnt;
  
  
      iSubstringsCnt = strInput.length() / iLength;
      iAddedCnt = iSubstringsCnt / iLength;
      cout&lt;&lt;iSubstringsCnt&lt;&lt;endl;
      cout&lt;&lt;iAddedCnt&lt;&lt;endl;
  
      cout&lt;&lt;strInput.length()&lt;&lt;endl;
      for (int iCnt = 0; iCnt &lt;= iSubstringsCnt+ iAddedCnt; iCnt++)
      {
              if (0 == iCnt)
                      continue;
                  strInput.insert((iCnt * iLength)+(iCnt-1) , " ");
      }
  
      strOutput= strInput;
  
  }
  </code></pre>
  
  <ul>
  <li><code>iLength</code>: The length after which I want to split.</li>
  <li><code>iAddedCnt</code>: The count of the string after I added space after a few characters.</li>
  </ul>