What is the rectangle relative to? The Character Size?
No, that's what makes sf::Text::GetRect() complicated to use in a generic way
The rectangle depends on the single character's heights (the sf::Glyph class contains those values). So, a text with a "y" is higher than with a "m".
I wrote a function to compute the rect size of a sf::Text independent of its characters. It is probably bugged, I haven't used it for a long time (in fact I have hardly ever used it
), but maybe you can adapt it:
sf::Vector2f GetSize(const sf::Text& text)
{
const sf::String& str = text.GetString();
unsigned int lines = std::count(str.Begin(), str.End(), '\n') + 1;
float height = lines * text.GetScale().y * (text.GetFont().GetLineSpacing(text.GetCharacterSize()) + 2);
return sf::Vector2f(text.GetRect().Width, height);
}