[reportlab-users] valign with large fonts

Robin Becker robin at reportlab.com
Wed Jun 4 05:28:27 EDT 2008

Arkadi Colson wrote:

> So the only option will be detecting the font hight some way and using

> bottom padding to enlarge the cell?



the code that does the alignment for simple cells looks like this
just = cellstyle.alignment
valign = cellstyle.valign
vals = string.split(str(cellval), "\n")
n = len(vals)
leading = cellstyle.leading
fontsize = cellstyle.fontsize
if valign=='BOTTOM':
y = rowpos + cellstyle.bottomPadding+n*leading-fontsize
elif valign=='TOP':
y = rowpos + rowheight - cellstyle.topPadding - fontsize
elif valign=='MIDDLE':
#tim roberts pointed out missing fontsize correction 2004-10-04
y = rowpos + (cellstyle.bottomPadding +
rowheight-cellstyle.topPadding+n*leading)/2.0 - fontsize

so the valign style attribute should be doing something different. Can you send
an example piece of text together with the style that's supposed to be being
used eg font, font size leading etc etc. Then I'll try and have a look to see
what's going on.


........nt size is variable.



>>> Thanks in advance,

>>> Arkadi

>>> nfo/reportlab-users



>> I have a feeling that valign should be middle, but the vertical

>> alignment has always caused trouble so it might be busted.


Robin Becker

More information about the reportlab-users mailing list