[reportlab-users] Re: rotated text (90?) in a table cell

Andy Robinson andy at reportlab.com
Wed Oct 18 18:24:39 EDT 2006

Robin Becker wrote:
> Tim Roberts wrote:
>>     return canv._leading, canv.stringWidth( self.text, canv._fontname,
>> canv._fontsize )
>> Given the fact that virtually all stringWidth calls use the current
>> canvas font and size, I've never understood why the stringWidth method
>> didn't default to those:
> ......
> noted; even I thought it did the 'right' thing :(

You have to go back to the mists of prehistory for that.  In 1999/2000 I 
was trying to squeeze out every byte and wanted the straightest path 
from a canvas call to creating formatted PDF operators, so the canvas 
did no state tracking at all.

Later on, people added extra code to track font changes, so now the 
canvas knows the current font and size.

So, we could add those keyword defaults now.

I think we could and should make 'text objects' unnecessary too.  They 
just served to make sure that all text operations were bracketed inside 
'BT' and 'ET' operations in the PDF, without the overhead of checking if 
the canvas was in 'text mode' on every single call.  Ditto for paths.

Life would be cleaner if all graphics operations went through the 
canvas, and the canvas just raised a helpful exception if you did stuff 
in an illegal order.

- Andy

More information about the reportlab-users mailing list