Hi Laurent,
I am experiencing some unexpected behavior with sf::Text. The easiest way to explain is with an example:
#include <SFML/Graphics.hpp>
#include <iostream>
int main()
{
sf::RenderWindow window( sf::VideoMode( 800, 600 ), "SFML" );
window.setVerticalSyncEnabled( true );
sf::Font font;
font.loadFromFile( "arial.ttf" );
sf::Text text( "M", font );
std::cout << "text width: " << text.getLocalBounds().width << std::endl;
text.setString( sf::String( "" ) );
std::cout << "text width: " << text.getLocalBounds().width << std::endl;
while( window.isOpen() )
{
sf::Event event;
while( window.pollEvent( event ) )
if( event.type == sf::Event::Closed )
window.close();
window.clear();
window.display();
}
}
Here is what the program outputs in my case:
text width: 23
text width: 23
This is the output I was expecting:
text width: 23
text width: 0
It seems that the bounding box data isn't always updated when the string is changed.
I hope this is clear enough!