[reportlab-users] Paragraph wrapping and height calculation

Tim Hoffman reportlab-users@reportlab.com
Tue, 06 Apr 2004 12:49:30 +0800


Hi

There seems to be some problems with the height calculation of 
Paragraphs when wrap() is called.

Reading the docs/code etc I believe wrapOn and wrap when called on 
flowables (and specifically the Paragraph)
should return the width and height that was used of the available width 
and height, but thats certainly not what is happending for me.
(I have one line of text with a 139 pt font) and I get a height back of 12.


Looking at the code I see the following.

    def wrap(self, availWidth, availHeight):
        # work out widths array for breaking
        self.width = availWidth
        leftIndent = self.style.leftIndent
        first_line_width = availWidth - 
(leftIndent+self.style.firstLineIndent) - self.style.rightIndent
        later_widths = availWidth - leftIndent - self.style.rightIndent
        self.blPara = self.breakLines([first_line_width, later_widths])
        self.height = len(self.blPara.lines) * self.style.leading
        return (self.width, self.height)

Which as far as I can tell doesn't take into account the height of each 
line in the wrapped text, just the number of lines and the leading specified
in the style.

Am I reading this wrong or am I missing something else.

Regards

Tim Hoffman