[reportlab-users] suggested patch to reportlab.platypus.paragraph._drawBullet

Harald Armin Massa haraldarminmassa at gmail.com
Mon Oct 1 12:20:26 EDT 2007


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


--
GHUM Harald Massa
persuadere et programmare
Harald Armin Massa
Spielberger Straße 49
70435 Stuttgart
0173/9409607
fx 01212-5-13695179
-
EuroPython 2008 will take place in Vilnius, Lithuania - Stay tuned!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20071001/dde927a9/attachment.html>


More information about the reportlab-users mailing list