[reportlab-users] Text scaling and finding out how much space text will take up

Andy Robinson andy at reportlab.com
Wed Nov 1 11:29:08 EST 2006


Chris Withers wrote:
> pier carteri wrote:
> 
>> Hi,
>> you can obtain the width of a string using the canvas method
>> stringwidth(text, font_name, font_size, encoding)
> 
I should add that the declaration looks like this now:

class Canvas(...):
     def stringWidth(self, text, fontName=None, fontSize=None):

As of last week, fontName and fontSize are optional; if you are busy 
drawing stuff and want to know the size just before drawing, it will 
assume you want the width in the current font.

- Andy


More information about the reportlab-users mailing list