[reportlab-users] barcode - .RenderPMError: Can't setFont

Carl Karsten carl at personnelware.com
Fri Apr 26 18:55:44 EDT 2013


Trying to use the code here:

https://code.djangoproject.com/wiki/Barcodes

# mybarcode.py
from reportlab.lib.units import mm
from reportlab.graphics.barcode import createBarcodeDrawing
from reportlab.graphics.shapes import Drawing, String
from reportlab.graphics.charts.barcharts import HorizontalBarChart

class MyBarcodeDrawing(Drawing):
def __init__(self, text_value, *args, **kw):
barcode = createBarcodeDrawing('Code128', value=text_value,
barHeight=10*mm, humanReadable=True)
Drawing.__init__(self,barcode.width,barcode.height,*args,**kw)
self.add(barcode, name='barcode')

if __name__=='__main__':
#use the standard 'save' method to save barcode.gif, barcode.pdf etc
#for quick feedback while working.
MyBarcodeDrawing("HELLO
WORLD").save(formats=['gif','pdf'],outDir='.',fnRoot='barcode')

I does create the pdf, but errors trying to create the gif:

(veyepar)carl at dc10:~/src/veyepar/tests/barcode/reportlab$ python mybarcode.py
Traceback (most recent call last):
File "mybarcode.py", line 17, in <module>
MyBarcodeDrawing("HELLO
WORLD").save(formats=['gif','pdf'],outDir='.',fnRoot='barcode')
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/shapes.py",
line 720, in save
renderPM.drawToFile(self,
filename,fmt=bmFmt,showBoundary=getattr(self,'showBorder',rl_config.showBoundary),**_extraKW(self,'_renderPM_',**kw))
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py",
line 651, in drawToFile
c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL,
showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py",
line 637, in drawToPMCanvas
draw(d, c, 0, 0, showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py",
line 50, in draw
R.draw(renderScaledDrawing(drawing), canvas, x, y,
showBoundary=showBoundary)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderbase.py",
line 198, in draw
self.initState(x,y) #this is the push()
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py",
line 93, in initState
self.applyState()
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py",
line 87, in applyState
self._canvas.setFont(s['fontName'], s['fontSize'])
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py",
line 368, in setFont
_setFont(self._gs,fontName,fontSize)
File "/usr/lib/python2.7/dist-packages/reportlab/graphics/renderPM.py",
line 221, in _setFont
raise RenderPMError, "Can't setFont(%s) missing the T1
files?\nOriginally %s: %s" % (fontName,s1,s2)
reportlab.graphics.renderPM.RenderPMError: Can't setFont(Times-Roman)
missing the T1 files?
Originally <type 'exceptions.TypeError'>: makeT1Font() argument 2 must
be string, not None

This is on Ubuntu 11.10 and 13.04

--
Carl K


More information about the reportlab-users mailing list