How to change font direction?

Discussion in 'Python' started by Daniel Mark, Sep 15, 2006.

  1. Daniel Mark

    Daniel Mark Guest

    Hello all:

    I am using PIL to draw some graphics and I need to draw some texts
    in vertical direction rather than the default left-to-right horizontal
    direction.

    Is there anyway I could do that?


    Thank you
    -Daniel
     
    Daniel Mark, Sep 15, 2006
    #1
    1. Advertisements

  2. Daniel Mark

    theju Guest

    Well here are some self explanatory functions that I've written for
    displaying the text vertically and from right to left. As for rotation
    gimme some more time and i'll come back to you. Also I don't guarantee
    that this is the best method(cos I myself am a newbie), but I can
    guarantee you that it works.
    Here it goes...

    im=Image.open("imgfile.jpg")
    draw=ImageDraw.Draw(im)

    def verdraw(width,height,spacing,a="Defaulttext"):
    for i in range(0,len(a)):
    draw.text((width,height),a,(<options>))
    height+=spacing

    def right2leftdraw(width,height,spacing,a="Defaulttext"):
    for i in range(0,len(a)):
    draw.text((width,height),a[len(a)-i-1],(<options>))
    width += spacing

    <options> is a 3 field length tuple is mentioned in the PIL-Handbook.
    Hope you find it useful
    -Theju
     
    theju, Sep 16, 2006
    #2
    1. Advertisements



  3. I have done a circular 24-hour dial with the numbers arranged to read
    upright as seen from the center. I remember writing each number into a
    frame, rotating the frame and pasting it into the dial image at the
    right place. I also remember using a transparency mask, so the white
    background of the little frame didn't cover up what it happened to
    overlap (minute marks). The numbers were black on white, so the frame
    was monochrome and could be used as its own transparency mask.
    (This could well be an needlessly complicated approach. When
    confronting a problem, I tend to weigh the estimated time of hacking
    against the estimated time of shopping and reading recipes and often
    decide for hacking as the faster alternative.)

    Regards

    Frederic
     
    Frederic Rentsch, Sep 18, 2006
    #3
    1. Advertisements

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 (here). After that, you can post your question and our members will help you out.