[PIL] quake like multicoloured text

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Durand

    [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)...Woul d there be
    an alternate method of doing this?

    Thanks =)
  • Durand

    #2
    Re: quake like multicoloured text

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

    Comment

    • Gabriel Genellina

      #3
      Re: [PIL] quake like multicoloured text

      En Fri, 05 Sep 2008 16:24:08 -0300, Durand <durand1@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)...Woul d 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

      Comment

      • Durand

        #4
        Re: quake like multicoloured text

        On Sep 5, 10:32 pm, "Gabriel Genellina" <gagsl-...@yahoo.com.a r>
        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)...Woul d 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...

        Comment

        Working...