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

Author Topic: Problem with getLocalBounds() for sf::Text  (Read 2475 times)

0 Members and 1 Guest are viewing this topic.

ison

  • Newbie
  • *
  • Posts: 13
    • View Profile
Problem with getLocalBounds() for sf::Text
« on: August 28, 2012, 12:32:48 pm »
Hello,
I think there's a bug with getLocalBounds() method for sf::Text when there are spaces on the beginning or end of the string. I don't know, maybe it's a feature, but I need to get actual text size no matter if there are any spaces at the end, is it possible?
sf::Text text;
text.setCharacterSize(11);
text.setString("             ");
printf("%d\n", (int)text.getLocalBounds().width);
 
output is 0

I found a solution for this but it's not really nice way of getting actual text size I think ;)
Just add any letter on start and end of the string, get local bounds and then subtract length of these 2 letters.
« Last Edit: August 28, 2012, 12:36:03 pm by ison »

Nexus

  • SFML Team
  • Hero Member
  • *****
  • Posts: 6287
  • Thor Developer
    • View Profile
    • Bromeon
Zloxx II: action platformer
Thor Library: particle systems, animations, dot products, ...
SFML Game Development:

 

anything