[SDL] How to draw text in some determined area, doing auto wrap

Gustavo Sverzut Barbieri gsbarbieri at yahoo.com.br
Thu Sep 5 23:27:01 PDT 2002


 --- Charles Wardlaw <kattkieru at yahoo.com> escreveu: > >    PS: We use
python+SDL and pygame. So solutions using them are
> > preferable :)
> 
> Well, the only real way to do this is manually by calculating how
> many
> characters can fit into a rectangle.  I'll tell you now: skip the TTF
> font stuff and use monospace bitmap fonts.  Non-monospace fonts
> require
> a bit more calculation.
> 
> Basically, you step through the string character by character and
> print
> away, then add the width of the font to your current X coordinate. 
> If
> you're out of bounds, drop back to the beginning of the line and then
> drop down by adding to the y coordinate.  It's a pretty simple thing
> to
> do with a monospace font.  A variable-width font requires you to
> check
> the sizes of individual characters.
> 
> Does this help?
> - Charles
> 
Kind of... We must do this work with all type of fonts. It's an
eye-candy program.
But that was the idea we had before.

Thanks,

Gustavo


_______________________________________________________________________
Yahoo! PageBuilder
O super editor para criação de sites: é grátis, fácil e rápido.
http://br.geocities.yahoo.com/v/pb.html




More information about the SDL mailing list