Very quick SDL_TTF question

Is it possible to have multi-line surfaces with SDL_TTF?

I went through the documentation at the SDL_TTF page, and they only show a
"Hello World" example.

Here’s the gist of what I’d like to do:

SDL_Surface *textSur; //text surface
TTF_Font *text;
SDL_Color fontcolor; //color for the text

oStream << score ;
theText=“Score: " + oStream.str();
oStream.str(”");
oStream << lives ;
theText+="\nLives: " + oStream.str();

textSur=TTF_RenderText_Solid(text,theText.c_str(),fontcolor);

This doesn’t properly go down a line, however. It ends up giving me something
that looks like this:
Score: 21391?Lives: 3

Is there some way I can get it to print out multiple lines without having to
have a different surface for every line? I’d imagine there is, but I don’t know
what to do.

Nope! I don’t believe so!

In Tux Paint, I rolled by own word-wrap code. I pretty much blit the
paragraphs one word at a time.On Fri, Nov 04, 2005 at 01:40:42AM +0000, James O’Meara wrote:

Is there some way I can get it to print out multiple lines without
having to have a different surface for every line? I’d imagine there
is, but I don’t know what to do.


-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/

I did my own newline code. I grabbed a word at a time like Bill, and
compared TTF_TextWidth() (or whatever it’s called) with the current text
position. If the width of the word was greater, increase the y by
TTF_TextHeight(). Actually, you could probably skip the TextWidth() step and
get the width directly from the blitted text (as long as you have some
proper alpha stuff). Anyways, it’s not too hard to figure out.On 11/3/05, Bill Kendrick wrote:

On Fri, Nov 04, 2005 at 01:40:42AM +0000, James O’Meara wrote:

Is there some way I can get it to print out multiple lines without
having to have a different surface for every line? I’d imagine there
is, but I don’t know what to do.

Nope! I don’t believe so!

In Tux Paint, I rolled by own word-wrap code. I pretty much blit the
paragraphs one word at a time.


-bill!
bill at newbreedsoftware.com
http://www.newbreedsoftware.com/


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


Cheers,
Josh

Thanks for the responses guys. It was a big help.