How to change font direction?

Frederic Rentsch anthra.norell at vtxmail.ch
Mon Sep 18 06:33:07 EDT 2006


theju wrote:
> 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[i],(<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
>
> Daniel Mark wrote:
>   
>> 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
>>     
>
>   

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




More information about the Python-list mailing list