title: Centering text in Gosu
body: <p>I've been having trouble centering text in the Gosu library to the absolute middle of the screen.</p>
  
  <pre><code>require 'gosu'
  
  class GameWindow &lt; Gosu::Window
    def initialize (width=800, height=600, fullscreen=false)
      super
      self.caption = 'Hello'
      @message = Gosu::Image.from_text(
          self, 'HELLO WORLD', Gosu.default_font_name, 45)
    end
  
    def draw
      @message.draw(377.5,277.5,0)
    end
  end
  
  window = GameWindow.new
  window.show 
  </code></pre>
  
  <p><br>
  My first approach was to take the <code>height</code> of the screen, subtract it by the height of the text <code>45</code>, and then divide by 2. Now that seemed to work when aligning vertically. </p>
  
  <p><a href="https://i.stack.imgur.com/QVwYK.png" rel="noreferrer"><img src="https://i.stack.imgur.com/QVwYK.png" alt="enter image description here"></a></p>
  
  <p>However, horizontally is a different story...It seems to 
  be taking the top left corner of the text and centering it which I expected it to do, instead of the middle of the text.</p>
  
  <p><a href="https://i.stack.imgur.com/X6AuA.png" rel="noreferrer"><img src="https://i.stack.imgur.com/X6AuA.png" alt="enter image description here"></a></p>
  
  <p>Anyone got a formula for this ? I tried a whole bunch of things, and only came close.</p>