[reportlab-users] Paragraph "Hack"

Henning von Bargen H.vonBargen at t-p.com
Tue Oct 21 03:51:19 EDT 2008


> I've upgraded to ReportLab 2.2, and I'm having visual problems with

> Paragraphs. There is a border around the top of the text of the

> paragraph in earlier versions (I was previously using 2.1),

> which is not

> there in 2.2. I'm using Paragraphs with background colours

> and the text

> is now touching the top of the box forming the background. I

> know there

> is a 'borderWidth' attribute, but that gives an

> unsatisfactory result,

> as the border is added to all four sides to the Paragraph, meaning it

> becomes too wide and the border at the bottom is too large with any

> sensible leading.


> Looking to the source, I've found that


> cur_y = self.height - f.fontSize


> has become


> cur_y = self.height -

> getattr(f,'ascent',f.fontSize)

> #TODO fix XPreformatted to remove this hack


> Reversing this change returns the Paragraph to it's old

> behaviour, but

> I'm not sure what it breaks in XPreformatted.


> Has anybody else experienced this issue or know if my

> workaround won't

> lead to Bad Things happening?


> Thanks,

> Paul Barrass.


I noticed the same effect.

On another (but similar) topic, I'd like to mention that the "leading" attribute
in the Paragraph implementation differs from its usual meaning:
According to Wikipedia, in type-setting, "leading" is the inter-line distance
(such that line_height = ascent + descent + leading),
whereas in ReportLab, "leading" is the same as line_height, AFAIK.

A clear definition of the box-model in the documentation would help a lot,
in particular for the case of different fonts in the paragraph, for the
spacing between the lines of the same paragraph, for the spacing between
different paragraph instances and for the the spacing between the paragraph
and the frame or other flowables.

Unfortunately I cannot provide one myself, 'cause I dont fully
understand the way it's supposed to work.


More information about the reportlab-users mailing list