In my current project I noticed that some of my buttons had their text at different heights. It took awhile to figure out what the problem was. I had used sf::Text getLocalBounds().height
The height returned was
its current bounds for that particular text. So I made my self a little helper function. It may not be the best solution but it at least it works (I think).
int Button::GetXHeight()
{
// Info about x-height: https://en.wikipedia.org/wiki/X-height
text.setString("a");
int xheight = (int)this->text.getLocalBounds().height;
text.setString(buttonText);
return xheight;
}
Note: must used before using text dimensions.
By setting the text to temporally to "a" then query the getLocalBounds().height for its x-height. Then set the text back.
I am wondering if this could be a feature to be added. Lets say: getXHeight() perhaps?
That said, I am not an expert so I might have overlooked something essential.