SFML community forums

Help => Graphics => Topic started by: Mina66 on October 22, 2014, 11:24:02 am

Title: Text height
Post by: Mina66 on October 22, 2014, 11:24:02 am
How to measure the height of a pin

(http://s017.radikal.ru/i407/1410/42/c33165525453.jpg)
Title: Re: Text height
Post by: Raincode on October 22, 2014, 03:08:39 pm
Is this supposed to be a question, a tutorial, ... ?
Can you be more specific?

EDIT: My suggested solution doesn't work. The above still applies though imho.

If you want the height of an sf::Text Object simply call sf::Text::getLocalBounds().height.
Title: Re: Text height
Post by: Mina66 on October 22, 2014, 04:07:35 pm
If you want the height of an sf::Text Object simply call sf::Text::getLocalBounds().height.

No. It will be up to the base line.

(http://s019.radikal.ru/i621/1410/66/02d706853259.jpg)
Title: Re: Text height
Post by: wintertime on October 22, 2014, 05:01:48 pm
If you want the maximum height independent of the actual text string it should be same as getCharacterSize/setCharacterSize.
Title: Re: Text height
Post by: Mina66 on October 23, 2014, 02:43:10 am
If you want the maximum height independent of the actual text string it should be same as getCharacterSize/setCharacterSize.

If you want the height of an sf::Text Object simply call sf::Text::getLocalBounds().height.

No. It will be up to the base line.

(http://s019.radikal.ru/i621/1410/66/02d706853259.jpg)
Title: Re: Text height
Post by: Mina66 on October 23, 2014, 03:07:07 am
Maybe it will be clearer
I need to define a yellow question (??)

(http://s017.radikal.ru/i442/1410/28/cd42a478009e.jpg)
Title: Re: Text height
Post by: Gambit on October 23, 2014, 09:00:32 am
You could use getGlobalBounds().height.
Title: Re: Text height
Post by: wintertime on October 24, 2014, 12:39:56 pm
getLocalBounds can be different depending on the text string. If you actually had a "p" in the string it should reach further down to include the bar-part reaching below the o-part. getGlobalBounds is the same, just transformed into a global coordinate system.
getCharactersize should be the maximum allowed height that cant be drawn outside of when using any character, including "ÂÖgq|".