Hmm, I am having a bit of trouble figuring out how I can layout my text in a neat box for display. Say I have a box to display the text in, and it is 50 pixels high by 200 wide, or something simular. If I input a string and it is too long to fit in box, I want it to continue on a new line. Wordwrapping I guess I mean.
So far I have:
void TALK(std::string MyWords)
{
std::string MyWords1, MyWords2, MyWords3;
if(MyWords.size > 80)
{
int SIZE = MyWords.size;
MyWords1.assign(MyWords, 80, 80);
MyWords.erase(80, 80);
Line1 = TTF_RenderText_Solid(FONT, MyWords1.c_str(), WhiteColor);
if(SIZE > 160)
{
MyWords2.assign(MyWords, 80, 80);
MyWords.erase(80, 80);
Line2 = TTF_RenderText_Solid(FONT, MyWords2.c_str(), WhiteColor);
if(SIZE > 240)
{
MyWords3.assign(MyWords, 80, 80);
MyWords.erase(80, 80);
Line3 = TTF_RenderText_Solid(FONT, MyWords3.c_str(), WhiteColor);
}
}
}
I will take the 'Line
X's and combine them into a single texture 500 * 200 pixels, but my current problem is how would I break off my strings at an ideal spot so as to not cut words in half? If at the 78th letter of my string is the word 'Servant', I would get:
......................Se
rvant...................
Which I don't want. I would rather the whole word drop to the next line, and so no string is bigger than 80 charactors. Can someone point me in the right direction?