Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: sf::Text positioning is off?  (Read 1255 times)

0 Members and 1 Guest are viewing this topic.

DevBug

  • Newbie
  • *
  • Posts: 12
    • View Profile
sf::Text positioning is off?
« 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.



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);
}

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Text positioning is off?
« Reply #1 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 ;)
Laurent Gomila - SFML developer

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
sf::Text positioning is off?
« Reply #2 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
Laurent Gomila - SFML developer

 

anything