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

Re: [pygame] Font.render() and multi-line text?



Right, it doesn't work.

This is what works.

This is what you have:

text = font.render("<Insert text here>", 1, (10, 10, 10))
textpos = text.get_rect()
textpos.centerx = background.get_rect().centerx
background.blit(text, textpos)

Well. To get something below that. You have to do this:

text2 = font.render("<Insert othert text here>", 1, (10, 10, 10))
background.blit(text2, (1,20))

Note the second argument in background.blit replaces textpos for the
original. If you wish it to be centered, you must find the center of your
rectangle and put the coordinates of x and y in the place of the second
argument. I have x defaulted to 1 here and y to 20.

----- Original Message ----- 
From: "Stuart" <stuartw@kcbbs.gen.nz>
To: <pygame-users@seul.org>
Sent: Tuesday, May 20, 2003 2:49 AM
Subject: [pygame] Font.render() and multi-line text?


>
> Hello People,
>
> I'm sure this is a simple question, but I was wondering if font.render can
> handle multi-line tetx (ie: embedded \n characters) properly, or if I need
to
> split and manually re-position for each line.
>
> At present it does not seem to be managing it (\n shows up as a 'box' -
ie:
> bad character), but maybe I'm just missing something?
>
> PS: I just *LOVE* the fact that unicode is handled correctly, more font
> libraries out there need to gain this level of competence!
>
> Regards,
> Stuart.
>