473,406 Members | 2,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How to change font direction?

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

Sep 15 '06 #1
2 2296
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

<optionsis 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
Sep 16 '06 #2
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

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

Sep 18 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: kmunderwood | last post by:
I am having trouble changing the font size when extracting xml into an html web page. I think it can be done so many ways, that my searches bring up examples that I am not familiar with. I am a...
115
by: J | last post by:
I've run CSSCheck on my style sheets and I always get a warning similar to this: "font: bold 9pt/100% sans-serif Warning: Absolute length units should not generally be used on the Web ..." ...
2
by: Tony | last post by:
Hi all, I've been researching MSDN and news forums for the past few days trying to achieve a more user friendly UI, similar to what MS applications (and others) do with regards to using system...
4
by: Ronny Sigo | last post by:
Hello all, I am trying to programmatically change the orientation of a MS Word Document to landscape. I must be doing something wrong cause it does not work ... can anybody help me with this?...
2
by: Jim | last post by:
Working with VB.net under VS.Net 2003. Have a simple form with a Button1. I want to change the font on the button when the button is clicked. Is there a way to Dynamically change the Font for...
1
by: ken | last post by:
Hi, How do you change the font for the data labels on your bar graph report/chart? I have 24 series, and when I change the font of the data label for one series that does not change them all......
3
by: Jim in Arizona | last post by:
I have a gridview that's being populated from an access db query. The problem I'm having is that the date/time fields in access that are populating the gridview are showing both date and time, when...
3
by: Phil Stanton | last post by:
Correct me if I'm wrong, but is it impossible to change the font in a report field when in print preview (MDE database) or can it only be done in design view in the MDB database. Part of my...
14
by: Roedy Green | last post by:
Is there a shortcut way to define the default font family (and characteristics) to be applied to all styles? -- Roedy Green Canadian Mind Products The Java Glossary http://mindprod.com
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.