[reportlab-users] Working out height of text

Ian Sparks reportlab-users@reportlab.com
Thu, 10 Apr 2003 09:52:13 -0400


I need to work out the height of a line of text to find out if it will =
fit the box I'm writing it to (using raw canvas commands not Platypus).

>From somewhere I have the following function :

#self is a "font" class which has a fontname and a size e.g. =
"Helvetica",8
h =3D pdfmetrics.TypeFace(self.fontname)
self.textHeight =3D ((h.ascent - h.descent) * self.size) / 1000

I'm not sure that the ascent and descent figures I'm getting back are =
correct however, they are 718 and -207 respectively.

Am I even going about this the correct way?

- Ian Sparks.