[reportlab-users] the size of the lower_part of a character
Fri, 23 Apr 2004 08:16:33 +0100
We don't provide an API to do this directly. Each font has an ascent
and descent attribute which you can query like this:
>>> from reportlab.pdfbase import pdfmetrics
>>> f = pdfmetrics.getTypeFace('Helvetica')
The units are in a logical 1000x1000 box. So, if you
had ten point text, this would tell you Helvetica descends
2.07 points below the baseline. Thus, if you did
canvas.drawString(100,200, 'Happy New Year')
then the baseline of the characters (bottom of 'Happ')
would be at y=200; the 'y' would PROBABLY be at or near
y = 197.03 (200-2.07); and the top of the capital letters
would probably be at y = 207.18.
BUT this is a single number for the whole font, and is
just a guideline provided by the font designer. It is
not necessarily accurate for each character.
You need extra software to find the bounding box of each
character. Just van Rossum's fonttools package can tell
you - it converts a font file to an XML description which
you can read with lots of data.
I hope this helps,
[mailto:email@example.com]On Behalf Of
Sent: 23 April 2004 03:18
Subject: [reportlab-users] the size of the lower_part of a character
First ,I'm a Chinese and my English is not very good,so there maybe
some wrongs in my words,please forgive me.
My question is:
How Can I know the size of the lower_part(I don't know how describe it
correctly) of a character?Is it has some relation to it's fontsize?
Can you understand me?
Do You Yahoo!?