[reportlab-users] what's wrong with this renderPM code?

Andy Robinson reportlab-users@reportlab.com
Mon, 26 Jan 2004 12:03:38 -0000


To make bitmaps, you need to have font files present for the
standard fonts (Helvetica, Times-Roman, Courier).  This is
different to making PDF files where we just refer to them
by name, and the displaying app has the files. We don't ship
these.  Instead we look for an Acrobat Reader copy in well
known locations and look under there.  If it does not find
it, you will get this problem.  

Look in reportlab/rl_config.py.  Your best bet is either to install
Acrobat Reader 4 or 5, or copy the font files in the resource
subdirectory of an Acri installation into reportlab/fonts.

thanks,

Andy Robinson

p.s. this is an FAQ - Richard, can you get it on our site 
somewhere?

> -----Original Message-----
> From: reportlab-users-admin@reportlab.com
> [mailto:reportlab-users-admin@reportlab.com]On Behalf Of Matthew Wilson
> Sent: 23 January 2004 20:37
> To: reportlab-users@reportlab.com
> Subject: [reportlab-users] what's wrong with this renderPM code?
> 
> 
> Hi -
> 
> I want to use reportlab graphics to make some web-viewable charts.  I
> tried this code and it fails:
> 
> #! /usr/bin/env python
> 
> import reportlab
> 
> from reportlab.lib import colors
> from reportlab.graphics.shapes import *
> 
> d = Drawing(400,200)
> d.add(Rect(50,50,300,100, fillColor=colors.yellow))
> 
> from reportlab.graphics import renderPM
> renderPM.drawToFile(d, 'out.jpg', 'JPG')
> 
> 
> This is the error I get:
> 
> [d1wmw01@d135linuxserver public_html]$ python rlfun.py 
> Warn: Can't find .pfb for face 'Times-Roman'
> Traceback (most recent call last):
>   File "rlfun.py", line 12, in ?
>     renderPM.drawToFile(d, 'out.jpg', 'JPG')
>   File "/usr/local/python-modules/reportlab/graphics/renderPM.py", line
> 541, in drawToFile
>     c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL,
> showBoundary=showBoundary)
>   File "/usr/local/python-modules/reportlab/graphics/renderPM.py", line
> 527, in drawToPMCanvas
>     draw(d, c, 0, 0)
>   File "/usr/local/python-modules/reportlab/graphics/renderPM.py", line
> 50, in draw
>     R.draw(drawing, canvas, x, y)
>   File "/usr/local/python-modules/reportlab/graphics/renderPM.py", line
> 96, in draw
>     self.applyState()
>   File "/usr/local/python-modules/reportlab/graphics/renderPM.py", line
> 81, in applyState
>     self._canvas.setFont(s['fontName'], s['fontSize'])
>   File "/usr/local/python-modules/reportlab/graphics/renderPM.py", line
> 349, in setFont
>     _setFont(self._gs,fontName,fontSize)
>   File "/usr/local/python-modules/reportlab/graphics/renderPM.py", line
> 232, 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 exceptions.TypeError: makeT1Font() argument 2 must be string,
> not None
> 
> 
> What am I doing wrong?
> 
> Thanks for the help.
> 
> Matt
> 
> 
> 
> -- 
> My public key:
> gpg --recv-keys --keyserver www.mandrakesecure.net 0x8D10BFD5
> _______________________________________________
> reportlab-users mailing list
> reportlab-users@reportlab.com
> http://two.pairlist.net/mailman/listinfo/reportlab-users
>