[reportlab-users] suggested patch to reportlab.platypus.paragraph._drawBullet
Robin Becker
robin at reportlab.com
Mon Oct 1 12:31:56 EDT 2007
Harald Armin Massa wrote:
> Hello,
>
> in an actual projet I ran into the challenge to have the bullet text "moved
> up" a little ... the bullet is a smaller fontsize ZapfDingbats-chr(110)
> [=filled square], which must be pushed "higher" to be centered with the
> text.
>
> The required changes are minimal:
>
> def _drawBullet(canvas, offset, cur_y, bulletText, style):
> '''draw a bullet text could be a simple string or a frag list'''
> tx2 = canvas.beginText(style.bulletIndent, cur_y)
> #tx2.setFont(style.bulletFontName, style.bulletFontSize) # replace this
> version by
> tx2 = canvas.beginText(style.bulletIndent,
> cur_y+getattr(style,"bulletOffsetY",0))
> tx2.setFillColor(hasattr(style,'bulletColor') and style.bulletColor or
> style.textColor)
> if isinstance(bulletText,basestring):
> tx2.textOut(bulletText)
> else:
> for f in bulletText:
> tx2.setFont(f.fontName, f.fontSize)
> tx2.setFillColor(f.textColor)
> tx2.textOut(f.text)
>
> canvas.drawText(tx2)
> #AR making definition lists a bit less ugly
> #bulletEnd = tx2.getX()
> bulletEnd = tx2.getX() + style.bulletFontSize * 0.6
> offset = max(offset,bulletEnd - style.leftIndent)
> return offset
>
>
> style grews a new possible attribute "bulletOffsetY", which makes it
> possible to offset the bullet-text up and down.
>
> this patch is put into public domain, and I would be very honoured if it
> gets integrated into core reportlab.
>
> Harald
no problem I'll take a look tomorrow.
--
Robin Becker
More information about the reportlab-users
mailing list