[reportlab-users] the size of the lower_part of a character

Andy Robinson reportlab-users@reportlab.com
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')
>>> f.descent
-207
>>> f.ascent
718
>>>
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.setFont('Helvetica', 10)
  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,

Andy Robinson
-----Original Message-----
From: reportlab-users-admin@reportlab.com
[mailto:reportlab-users-admin@reportlab.com]On Behalf Of
ÿffffcaÿffffbfÿffffb7ÿffffbc ÿffffcdÿfffff5
Sent: 23 April 2004 03:18
To: reportlab-users@reportlab.com
Subject: [reportlab-users] the size of the lower_part of a character


Hello:
    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!?
»ÝÆÕTTÓÎÏ·¾ç£¬ÍæÓÎÏ·£¬Öд󽱣¡