472,127 Members | 1,563 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,127 software developers and data experts.

[PIL] quake like multicoloured text

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 =)
Sep 5 '08 #1
3 1086
Oops, I meant, "I'm wondering how I could render text with PIL in
which different
parts of the text are different *colours*."
Sep 5 '08 #2
En Fri, 05 Sep 2008 16:24:08 -0300, Durand <du*****@gmail.comescribió:
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...

--
Gabriel Genellina

Sep 5 '08 #3
On Sep 5, 10:32*pm, "Gabriel Genellina" <gagsl-...@yahoo.com.ar>
wrote:
En Fri, 05 Sep 2008 16:24:08 -0300, Durand <dura...@gmail.comescribió:


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...

--
Gabriel Genellina
Thanks, I guess I should have done more research...
Sep 6 '08 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Marek | last post: by
reply views Thread by jean-Baptiste Cazier | last post: by
4 posts views Thread by Doug R | last post: by
3 posts views Thread by Steve Holden | last post: by
1 post views Thread by Greg Lindstrom | last post: by
1 post views Thread by Daewon YOON | last post: by
6 posts views Thread by Rancid Buttchutney | last post: by
1 post views Thread by Neil Toronto | last post: by
reply views Thread by Huuuze | last post: by
reply views Thread by leo001 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.