473,225 Members | 1,259 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,225 software developers and data experts.

PIL cutting off letters

I'm using PIL (Python Imaging Library) to generate button images.
They consist of a left end image, a middle, repeating image and a
right side image.... anyway, that's not important

I'm using a TTF font for the text of the button (Verdana.TTF) and it
keeps cutting the bottom part of the the g's q's and y's off.

Here's the important parts of my code (options contains command-line
params):

im = Image.new("RGB",(1,1))
font = ImageFont.truetype(options.font,options.fontsize)
draw = ImageDraw.Draw(im)
textsize = draw.textsize(options.text, font=font)
im = im.resize( (totalwidth, maxheight) )
draw = ImageDraw.Draw(im)
thecolor = "rgb(0,0,0)"
x = (totalwidth - textsize[0]) / 2
y = (maxheight - textsize[1]) / 2 + options.offsetY
draw.text((x, y), options.text, font=font, fill=thecolor )
im.save(savefile, quality=100)

If I increase the font-size to larger than about 16, the tails
appear... any clue as to why this happens or what I can do to fix it?

Jun 15 '07 #1
4 2697
Matt Haggard a écrit :
I'm using PIL (Python Imaging Library) to generate button images.
They consist of a left end image, a middle, repeating image and a
right side image.... anyway, that's not important

I'm using a TTF font for the text of the button (Verdana.TTF) and it
keeps cutting the bottom part of the the g's q's and y's off.
hello

may be the problem is in your code, but it is also possibly
in PIL which clips caracters at the top and bottom line;
that's not the typographic names, but these are *font* values,
not characters ones.
There are fonts with caracters far higher than these
conventionnal lines (try Liorah.ttf or any swashed font for
exemple)!
I don't remember for sure but may be there is the same problem
horizontally.
--
Pierre
Jun 16 '07 #2
On 16 Jun, 17:20, Pierre Hanser <han...@club-internet.frwrote:
Matt Haggard a écrit :
I'm using PIL (Python Imaging Library) to generate button images.
They consist of a left end image, a middle, repeating image and a
right side image.... anyway, that's not important
I'm using a TTF font for the text of the button (Verdana.TTF) and it
keeps cutting the bottom part of the the g's q's and y's off.

hello

may be the problem is in your code, but it is also possibly
in PIL which clips caracters at the top and bottom line;
that's not the typographic names, but these are *font* values,
not characters ones.
There are fonts with caracters far higher than these
conventionnal lines (try Liorah.ttf or any swashed font for
exemple)!
I don't remember for sure but may be there is the same problem
horizontally.
--
Pierre
I've had this problem horizontally, and solved it by the high tech
method of adding a leading and trailing space!!!

Peter

Jun 19 '07 #3
Matt Haggard wrote:
I'm using PIL (Python Imaging Library) to generate button images.
They consist of a left end image, a middle, repeating image and a
right side image.... anyway, that's not important

I'm using a TTF font for the text of the button (Verdana.TTF) and it
keeps cutting the bottom part of the the g's q's and y's off.
I've had the same problems. What worked for me was to use
aggdraw instead of PIL's Draw class.
http://effbot.org/zone/aggdraw-index.htm

Mitja
Jun 19 '07 #4
test
Jul 16 '07 #5

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

Similar topics

5
by: Liberal | last post by:
I am looking for the simplest forum, bbs script which has those features? new messages will be displayed only after the administrator reviewed allow users post without signing up display the...
2
by: Edward K. Ream | last post by:
From the documentation for the string module at: C:\Python23\Doc\Python-Docs-2.3.1\lib\module-string.html letters: The concatenation of the strings lowercase and uppercase described below....
19
by: Johannes Nix | last post by:
Hello, yesterday I met a cute person (after my dance class) who told me about an interesting experiment regarding cognition. People were told to read a typed text; However, in every word in the...
2
by: Joachim | last post by:
I'm using the following to transfer the content of two strings containing non-english letters byte responseB = Encoding.ASCII.GetBytes(responseHdr.ToString() + responseBody.ToString()); But...
7
by: stevenkobes | last post by:
A lot of websites have forms with an image at the bottom containing some distorted / noisy letters and numbers that users must type in to prove they are real people. How do they normally implement...
0
by: Jordan Richard | last post by:
I'm designing a new .NET 2.0 Windows Forms application to support users who, amongst other things, need to print letters and envelopes. They currently do such printing by manually managing a...
1
by: Kosmos | last post by:
Since people have been so helpful on this site I thought I'd contribute what little I can...since I am not a programmer but I'm working on an access database for work Anyways I had to remove...
8
by: Paul | last post by:
Hi all, I'm probably missing something obvious here, but occasionally the response stream for pages on my site is cutting off leaving incomplete HTML and an ugly page. Response.Buffer is set...
4
by: abueno | last post by:
//It should count how many characters are letters in the English alphabet, and is displaying the correct letters, but is not counting good. void FunctionCountLetters(char s) { int len; int i;...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: abbasky | last post by:
### Vandf component communication method one: data sharing ​ Vandf components can achieve data exchange through data sharing, state sharing, events, and other methods. Vandf's data exchange method...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
0
Git
by: egorbl4 | last post by:
Скачал я git, хотел начать настройку, а там вылезло вот это Что это? Что мне с этим делать? ...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.