I'm having a little trouble with text alignment. So I did a little experiment and saw some confusing results.
I decided to draw a rectangle using the position of the text and the bounding rect of the text and then drawing the text on top of it. I was surprised to see that although the rectangle appeared to be the same size as the text they did not align correctly. The text appeared about 2 pixels to the right and 8 pixels down from rectangle. So I checked the origin of the text and it is set at 0,0 which I assume is the upper left corner. Here's a snippet of my code if that helps:
text.setPosition(x, y);
sf::RectangleShape rec2;
rec2.setFillColor(sf::Color::White);
sf::FloatRect textsize = text.getLocalBounds();
rec2.setSize(sf::Vector2f(textsize.width, textsize.height));
rec2.setPosition(x,y);
rw.draw(rec2);
rw.draw(text);
I expected the text to be exactly bounded by the rectangle. Is there something obvious I'm missing? I can adjust by setting the text origin to -2,-8 but that seems kind of strange. Its almost as if they are using different coordinate systems but I'm not sure.