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

Author Topic: text.getrect() behaviour  (Read 9205 times)

0 Members and 1 Guest are viewing this topic.

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
text.getrect() behaviour
« Reply #15 on: February 05, 2010, 05:11:54 pm »
Quote from: "Laurent"
I guess it depends on how the font is made.
Yes, but in general the approach with line spacing works quite well. :)

If anyone is interested in my current implementation:
Code: [Select]
sf::FloatRect GetBoundingRect(const sf::Text& Text)
{
sf::FloatRect Rect = Text.GetRect();

float Height = (Text.GetFont().GetLineSpacing(Text.GetCharacterSize()) + 2) * Text.GetScale().y;
return sf::FloatRect(Rect.Left, Rect.Top, Rect.Right, Rect.Top + Height);
}
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything