SFML community forums
Help => Graphics => Topic started by: rojan_neo on December 20, 2011, 01:22:33 pm
-
How would I display multiple lines of text using one sf::String variable in SFML 1.6?? For example if I use SetText Function for a very long text then it just goes out of bound and the text that falls beyond the size of the window is not displayed!!
How would make something like whenever the text goes out of bound it automatically shifts the text to the next line??
-
You can insert a '\n' character after each character of the string that is located beyond the container's width.
-
You can insert a '\n' character after each character of the string that is located beyond the container's width.
Do you mean like:
sf::String testString;
testString.SetText("one line \n next line");
-
Yes.
-
This works fine when I do this directly within the code.. but since the text that i want tor set is in a text file I read the contents of the file and store the text in std::string variable and do :
testString.SetText(stringvariable);
Now when I supply \n character as the content of the file it does not change the line of the sf::String as it used to in previous example!
Any Idea how I'll get through this??
-
You don't have to write "\n" in your text file, '\n' is the character that represents a new line in a C++ literal string. Just having lines in your text file is enough to have lines in your sf::String :)
Maybe the end of lines are dropped when you read the contents of the file. Can you show how you read it?