SFML community forums

Help => Window => Topic started by: nefx on June 19, 2011, 04:41:46 pm

Title: How to position the text on (0, 0)?
Post by: nefx 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;
}
Title: How to position the text on (0, 0)?
Post by: Laurent 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.