[reportlab-users] Paragraph "Hack"

Robin Becker robin at reportlab.com
Tue Oct 21 07:10:37 EDT 2008


Paul Barrass wrote:
.......

> The problem I'm experiencing (which is probably totally unrelated to the

> "right" way of doing things) is that the text of the Paragraph has

> visually moved from being v_aligned middle to being v_aligned top. This

> leads to the text touching the top of the box, and leaving empty space

> at the bottom, which can be relatively large where leading > font_height

> (which it usually is, at least by a few points). The HTML/CSS

> "padding-top" variable padding would certainly solve the problem, though

> that seems overkill to fix something I initially thought was just a

> temporary hack on someone's TODO list - that'll teach me never to read

> comments again ;)

>

> If it's not clear what I'm referring to, I can try to produce a "before

> and after" to demonstrate.

......
I know exactly what the change did. In the old way of doing things we assumed
(without justification) that the baseline was fontSize below the top of the text.


ascender--------------------------
^ A

|

fontSize

|

|

baseline--------------------------

|

0.2*fontSize

| y

descender-------------------------


Now we attempt to improve matters by using the actual ascent and descent to
specify the ascender and descender lines. In addition there's the leading which
is supposed to be larger than ascender - descender. I assume that you're seeing
a visual difference because your fontSize is larger than the ascent. There was
never any intention to visually vertically centre anything, western fonts are by
nature not vertically symmetric. If you adjust this locally all that will happen
is that XPreformatteds will also be adjusted by your reversion. However, your
change to the initial y will not change the internal way that the lines are
spaced ie most of the code will continue to use ascent and descent.

My impression is that if we could allow you to adjust the top/bottom padding you
could achieve the visual style that is required. Currently borderPadding is a
singleton. That would not alter the exact positioning of the paragraph topline
though.
--
Robin Becker


More information about the reportlab-users mailing list