471,596 Members | 1,218 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,596 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 2602
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by Liberal | last post: by
2 posts views Thread by Edward K. Ream | last post: by
19 posts views Thread by Johannes Nix | last post: by
8 posts views Thread by Paul | last post: by

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.