Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: How to position the text on (0, 0)?  (Read 1994 times)

0 Members and 1 Guest are viewing this topic.

nefx

  • Newbie
  • *
  • Posts: 4
    • View Profile
How to position the text on (0, 0)?
« on: June 19, 2011, 04:41:46 pm »
I use sfml 2 and I try to center the text in my button. However it seems text has a vertical margin so even if position is (0, 0) it starts at (0,10) or something like that and it doesn't look right.

Here is the example. Any help?
Code: [Select]

#include <iostream>
#include <SFML/Graphics.hpp>

int main()
{
   sf::RenderWindow  window(sf::VideoMode( 800, 600 ), "Test" );
 
   sf::Text     text( "Test!" );  

   window.Clear();

   window.Draw(text );
   
   window.Display();

   system("pause");

   return 0;
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
How to position the text on (0, 0)?
« Reply #1 on: June 19, 2011, 06:09:23 pm »
That's because text is vertically aligned on the baseline. If you put the tallest possible character in your string, its top will be 0.
Laurent Gomila - SFML developer