title: Draw string to image in Java
body: <p>I need to draw a string to a BufferedImage in Java. The way this is done doesn't matter, however the image should take up only the space it needs, like in the example below.
  I need a new BufferedImage created containing only the string. Extra space above the string and on the right side of the string could be tolerated, but I can't have extra space below and left of the drawn string.</p>
  
  <p><img src="https://i.stack.imgur.com/1CPQ8.png" alt="Image"></p>
  
  <p>Is something like this possible? I have tried to do it myself, but I always end up having extra space which is not what I want. Any help would be appreciated.</p>