Yes of course, here's the code. You will see that it prints "Penguin" in red text and retrieves the local bounds of the text to then draw a green box.
The text is positioned at 0,0 yet it doesn't appear there. You can also see that the local bounds don't start at 0,0 (from the console output).
The font is attached. I've tried this with several different fonts that I've downloaded from various websites. I've also tried it with "arial.ttf" taken, unmodified, directly from my C:/Windows/Fonts directory. Same problem persists.
This all leads me to think it's some issue with the way .ttf fonts are loaded. But I don't know enough about font file formats or FreeType to work it out.
#include <SFML/Graphics.hpp>
int main()
{
sf::RenderWindow window(sf::VideoMode(1600, 900), "Pirate Game", sf::Style::Titlebar | sf::Style::Close);
sf::Font f;
f.loadFromFile("BOOTERFZ.ttf");
sf::Text t("Penguin", f, 500);
t.setPosition(0,0);
t.setColor(sf::Color(255,0,0));
sf::FloatRect ff = t.getLocalBounds();
sf::RectangleShape r(sf::Vector2f(ff.width,ff.height));
r.setPosition(ff.left,ff.top);
r.setFillColor(sf::Color(0,255,0));
std::cout << ff.left << ", " << ff.top << ", " << ff.width << ", " << ff.height << std::endl;
while(window.isOpen())
{
sf::Event event;
while(window.pollEvent(event))
{
if(event.type == sf::Event::Closed)
{
window.close();
}
}
window.clear();
window.draw(r);
window.draw(t);
window.display();
}
return 0;
}