[PIL] quake like multicoloured text

D

Durand

I'm wondering how I could render text with PIL in which different
parts of the text are different characters. This is for a game stats
script where names are written like:
^1Red ^2Green ^3Yellow, etc.
The problem is that I currently use text in the ImageDraw module but
the only way I can think of rendering text is by rendering each bit of
text in a separate colour.

Example:

draw.text((0,0),"Red", fill="red")
draw.text((30,0),"Green", fill="green")
draw.text((60,0),"Yellow", fill="green")

except that I'm not sure how much spacing there is between each
coloured bit of text(30px is assumed in the example)...Would there be
an alternate method of doing this?

Thanks =)
 
D

Durand

Oops, I meant, "I'm wondering how I could render text with PIL in
which different
parts of the text are different *colours*."
 
G

Gabriel Genellina

I'm wondering how I could render text with PIL in which different
parts of the text are different characters. This is for a game stats
script where names are written like:
^1Red ^2Green ^3Yellow, etc.
The problem is that I currently use text in the ImageDraw module but
the only way I can think of rendering text is by rendering each bit of
text in a separate colour.

Example:

draw.text((0,0),"Red", fill="red")
draw.text((30,0),"Green", fill="green")
draw.text((60,0),"Yellow", fill="green")

except that I'm not sure how much spacing there is between each
coloured bit of text(30px is assumed in the example)...Would there be
an alternate method of doing this?

You could use the draw.textsize method to measure how much space will take
each part...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,780
Messages
2,569,611
Members
45,266
Latest member
DavidaAlla

Latest Threads

Top