SFML community forums

Help => Graphics => Topic started by: DevBug on December 20, 2010, 11:58:17 pm

Title: sf::Text positioning is off?
Post by: DevBug on December 20, 2010, 11:58:17 pm
I'm having problems with SFML 2.0's sf::Text class.  It seems that the text position is off. It seems to be a problem with the sf::Text class because the rectangle (where the text should be) draws fine.  The positioning error only shows up when my position (x, y) are not a 1:1 ratio.

(http://anyhub.net/file/1dbV-fail.png)

Code: [Select]

// Inside my gui component
GetRenderer()->DrawText(GetCaption(), Gum::Base::Point(GetGlobalPos().x, GetGlobalPos().y));

// My renderer
void SFMLRenderer::DrawText(std::string& text, Point& position) {
    Gum::Base::Size size = MeasureText(text);
    sf::Text sfText = sf::Text(text, m_Font, 10);
    sfText.SetPosition(sf::Vector2f((int)position.x, (int)position.y));

    DrawRectangle(Gum::Base::Rect(position.x, position.y, size.w, size.h));
    m_pTarget->Draw(sfText);
}
Title: sf::Text positioning is off?
Post by: Laurent on December 21, 2010, 07:36:34 am
Could you please give a minimal and complete code that reproduces this bug? If it's just a positionning problem it should hard to do ;)
Title: sf::Text positioning is off?
Post by: Laurent on December 21, 2010, 10:34:57 am
Topic locked, information about this bug are gathered in this other similar topic:
http://www.sfml-dev.org/forum/viewtopic.php?t=3798