[reportlab-users] Re: Where to send a patch?
Thomas Lotze
thomas at thomas-lotze.de
Thu Aug 3 08:21:08 EDT 2006
Andy Robinson wrote:
> This list is fine.
Thanks. I'll put the first one in the bottom of this message. It's a patch
to reportlab/demos/stdfonts/stdfonts.py, making it actually use its
command line arguments and produce much smaller PDFs - without many more
lines of Python code ;o)
> Our patch maintainer, Robin Becker, is on vacation until next week but
> he'll get to it within a few days.
There's no hurry to it; I made the changes anyway for myself and just
don't want them to be useless to the rest.
--
Thomas
Index: stdfonts.py
===================================================================
--- stdfonts.py (Revision 2939)
+++ stdfonts.py (Arbeitskopie)
@@ -24,6 +24,10 @@
label_formatter, caption = label_formats[mode]
+ data = [(72+(66*col), 720-(18*row), label_formatter % byt, chr(byt))
+ for byt, (col, row) in [(byt, divmod(byt-32, 32))
+ for byt in xrange(32, 256)]]
+
for enc in ['MacRoman', 'WinAnsi']:
canv = canvas.Canvas(
'StandardFonts_%s.pdf' % enc,
@@ -47,28 +51,26 @@
canv.setFont('Times-BoldItalic', 12)
canv.drawRightString(515, 744, 'Labels in ' + caption)
-
#for dingbats, we need to use another font for the numbers.
#do two parallel text objects.
- for byt in range(32, 256):
- col, row = divmod(byt - 32, 32)
- x = 72 + (66*col)
- y = 720 - (18*row)
- canv.setFont('Helvetica', 14)
- canv.drawString(x, y, label_formatter % byt)
- canv.setFont(fontName, 14)
- canv.drawString(x+44, y, chr(byt).decode(encLabel,'ignore').encode('utf8'))
+ canv.setFont('Helvetica', 14)
+ for x, y, label, ch in data:
+ canv.drawString(x, y, label)
+ canv.setFont(fontName, 14)
+ for x, y, label, ch in data:
+ canv.drawString(x+44, y, ch.decode(encLabel,'ignore').encode('utf8'))
canv.showPage()
canv.save()
if __name__ == '__main__':
if len(sys.argv)==2:
mode = string.lower(sys.argv[1])
- if mode not in ['dec','oct','hex']:
- print __doc__
-
elif len(sys.argv) == 1:
mode = 'dec'
+ else:
+ print __doc__
+
+ if mode in ['dec','oct','hex']:
run(mode)
else:
print __doc__
More information about the reportlab-users
mailing list