[reportlab-users] sizes of fonts and images

Luc Saffre luc.saffre at gmx.net
Tue Oct 24 09:43:07 EDT 2006


On 23.10.2006 23:40, Andy Robinson wrote:
> 
> If you are using Courier 10 point, the characters are actually 6 points
> wide.  All courier glyphs are 600 ems wide.  10 is the 'height',
> including whatever whitespace the designer wanted at the top.

This was indeed the missing piece in my jigsaw. The size of a font is
the height of its bounding box! And the font metric values in a TTFont
instance (bbox, ascent, descent, defaultWidth...) are expressed in
1/1000 of this size.

> In general, create the string you want and use canvas.stringWidth(text,
> fontName, fontSize) to get its width, then use this for the image width.
> This will work for proportional fonts too.

Yes, in my example this would be useful, but for prn2pdf I needed
another approach.

Thanks for your answer.

Luc
http://lino.saffre-rumma.ee/prn2pdf.html


More information about the reportlab-users mailing list