title: Draw multi-line BitmapFont vertically centered
body: <p>I wish to center some long wrapped text that spans several lines on a rectangle (or anything else) like in the image below (I don't need to hide excess text but it'd be a big plus I'd be so grateful):</p>
  <p><a href="https://i.stack.imgur.com/BxiMS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BxiMS.png" alt="enter image description here" /></a></p>
  <p>I've been able to achieve vertical centering with a single-line text like below:</p>
  <pre class="lang-java prettyprint-override"><code>BitmapFont font = new BitmapFont();
  String text = &quot;Hello&quot;;
  Rectangle bounds = new Rectangle(0, 0, 100, 100);
  
  void render(SpriteBatch spriteBatch) {
      font.draw(
          spriteBatch,
          text,
          bounds.x,
          bounds.y + bounds.height / 2f + font.getLineHeight());
  }
  </code></pre>
  <p>I know there's a <code>BitmapFont.draw()</code> method variant that lets you specify horizontal alignment, the target width of your text and a wrapping flag but I can't seem to find a way to <strong>vertically</strong> align multi-line text.</p>
  <p>In the past this was possible with <code>BitmapFont.getBounds()</code> and some math but there's no such method in LibGDX 1.9.9.</p>