[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Rendering Text By Line



On Tue, Jul 10, 2007 at 10:34:45PM -0000, kschnee@xxxxxxxxxx wrote:
> > It's pretty simple to split your string on carriage returns (and/or line
> > feeds), create surfaces for each line of text, and blit those surfaces to
> > the destination surface.
> 
> I'm doing something like that. I haven't yet gotten word-wrapping to work,
> but the following out-of-context code does wrapping by line.

PySpaceWar has word-wrapping for the help screen:
http://mg.pov.lt/pyspacewar/pyspacewar-help-screen.png

(For some reason the pygame window is translucent by default, so you can
see a terminal underneath.  Yes, I'm playing with Compiz Fusion.).

The code is here:
http://mg.pov.lt/pyspacewar/trac/browser/trunk/src/pyspacewar/ui.py#L466
(class HUDFormatted Text).

(It's under the GNU GPL, in case you're considering copying it.)

Cheers from EuroPython,
Marius Gedminas
-- 
I need a word processor on my laptop like I need a Selectric typewriter in my
laptop bag.
        -- Don Marti

Attachment: signature.asc
Description: Digital signature