SFML community forums
Bindings - other languages => DotNet => Topic started by: Wibbs on March 16, 2010, 07:36:53 pm
-
Hi all,
Just wanted to ask a quick question. I'm currently implementing the GUI for my game, and am working out how to deal with multiple lines of text. Given that the height of a String2D varies depending on the characters in the string, is there an easy way of determining the vertical spacing required to ensure that lines of text are evenly spaced for a given font and font size?
The way I'm thinking of doing it at the moment, is to use a test string containing the highest and lowest characters for a particular font to establish the largest height a String2D could have, but this seems a tad cumbersome. Is there an easier way?
Thanks,
Wibbs
-
In SFML 1, the line spacing is simply the character size of the String2D.
In SFML 2, the line spacing is given by the Font.GetLineSpacing function.
In both cases it is a constant, it never depends on the characters in the string.
-
Hi again,
I'm using 1.5 coz I don't want to have to deal with the regular updates to the version 2 code base at the moment.
I'm working out the String2D height by calling .GetRect() and taking the height from the resulting FloatRect. When I do this for different strings, it gives different heights. Am I doing this wrong then, because this is the only way I can see of getting a height measurement for the String2D?
Thanks,
Wibbs
-
This is not wrong, when you call GetRect().Height you get the actual height of the string. When you use the the character size, you have a constant number which is the maximum height that a character can have. Use the one that you need ;)
-
Ah, ok I think I've got what you mean. So, the size I specify when I create the String2D object gives the maximum height of any text entered?
-
Yes.