BOMBOLOM.COM

(python) ReportLab Installation Error

Posted by: José Lopes

Sometimes you may get the installation error for ReportLab:

RenderPMError: Can't setFont(Times-Roman) missing
the T1 files?

On the ReportLab installation, both in Windows and Linux, you get sometimes the error message:

> Traceback (most recent call last):
>   File "reportlab.test", line 11, in ?
>     d.save(formats=['png'],outDir='/tmp',fnRoot='example1')
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/shapes.py", line 689, in save
>     renderPM.drawToFile(self,filename,fmt=bmFmt,showBoundary=getattr(self,'showBorder',rl_config.showBoundary),**_extraKW(self,'_renderPM_',**kw))
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderPM.py", line 591, in drawToFile
>     c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary)
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderPM.py", line 577, in drawToPMCanvas
>     draw(d, c, 0, 0, showBoundary=showBoundary)
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderPM.py", line 49, in draw
>     R.draw(renderScaledDrawing(drawing), canvas, x, y, showBoundary=showBoundary)
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderbase.py", line 200, in draw
>     self.initState(x,y)  #this is the push()
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderPM.py", line 86, in initState
>     self.applyState()
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderPM.py", line 80, in applyState
>     self._canvas.setFont(s['fontName'], s['fontSize'])
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderPM.py", line 358, in setFont
>     _setFont(self._gs,fontName,fontSize)
>   File "/usr/lib/python2.4/site-packages/reportlab/graphics/renderPM.py", line 238, 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

For Windows you get:

> Traceback (most recent call last):
>   File "L:\HereAndThere\Stairs\test.py", line 9, in -toplevel-
>     renderPM.drawToFile(drawing, 'example1.gif', 'GIF')
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderPM.py", line 559, in drawToFile
>     c = drawToPMCanvas(d, dpi=dpi, bg=bg, configPIL=configPIL, showBoundary=showBoundary)
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderPM.py", line 545, in drawToPMCanvas
>     draw(d, c, 0, 0, showBoundary=showBoundary)
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderPM.py", line 49, in draw
>     R.draw(drawing, canvas, x, y, showBoundary=showBoundary)
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderbase.py", line 188, in draw
>     self.initState(x,y)
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderPM.py", line 86, in initState
>     self.applyState()
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderPM.py", line 80, in applyState
>     self._canvas.setFont(s['fontName'], s['fontSize'])
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderPM.py", line 327, in setFont
>     _setFont(self._gs,fontName,fontSize)
>   File "C:\Python23\lib\site-packages\reportlab\graphics\renderPM.py", line 207, in _setFont
>     raise RenderPMError, "Can't setFont(%s) missing the T1 files?\nOriginally %s: %s" % (fontName,s1,s2)
> RenderPMError: Can't setFont(Times-Roman) missing the T1 files?
> Originally exceptions.TypeError: makeT1Font() argument 2 must be string, not None

In both cases the problem is due to missing fonts on your computer or due to RenderPM being unable to find them.

Fixing the problem is similar for both OS but with some different details.

LINUX

The missing fonts are:

AdobeSansMM.MMM.pfb
AdobeSansMM.pfb
AdobeSerifMM.MMM.pfb
AdobeSerifMM.pfb
Arial-BoldItalic.pfb
Arial-Bold.pfb
Arial-Italic.pfb
Arial.pfb
Courier-BoldOblique.pfb
Courier-Bold.pfb
Courier-Oblique.pfb
Courier.pfb
Symbol.pfb
TimesNewRoman-BoldItalic.pfb
TimesNewRoman-Bold.pfb
TimesNewRoman-Italic.pfb
TimesNewRoman.pfb

You can download them here:

ReportLab will look for these fonts on the paths defined on the file rl_config.py

This file relevant part looks like:

# places to look for T1Font information
T1SearchPath =  (
                'c:/Program Files/Adobe/Acrobat 6.0/Resource/Font', #Win32, Acrobat 6
                'c:/Program Files/Adobe/Acrobat 5.0/Resource/Font', #Win32, Acrobat 5
                'c:/Program Files/Adobe/Acrobat 4.0/Resource/Font', #Win32, Acrobat 4
                '%(disk)s/Applications/Python %(sys_version)s/reportlab/fonts', #Mac?
                '/usr/lib/Acrobat5/Resource/Font',      #Linux, Acrobat 5?
                '/usr/lib/Acrobat4/Resource/Font',      #Linux, Acrobat 4
                '/usr/local/Acrobat6/Resource/Font',    #Linux, Acrobat 5?
                '/usr/local/Acrobat5/Resource/Font',    #Linux, Acrobat 5?
                '/usr/local/Acrobat4/Resource/Font',    #Linux, Acrobat 4
                '%(REPORTLAB_DIR)s/fonts',              #special
                '%(REPORTLAB_DIR)s/../fonts',           #special
                '%(REPORTLAB_DIR)s/../../fonts',        #special
                '%(HOME)s/fonts',                       #special
                 )

Placing the downloaded fonts on any of these paths is enough to fix the problem. Of course that you can add instead another path if you prefer.

WINDOWS:

The missing fonts are:

_abi____.pfb
_ab_____.pfb
_ai_____.pfb
_a______.pfb
cobo____.pfb
cob_____.pfb
com_____.pfb
coo_____.pfb
_ebi____.pfb
_eb_____.pfb
_ei_____.pfb
_er_____.pfb
Sy______.pfb
Zd______.pfb
Zx______.pfb
Zy______.pfb

You can download them at:

The situation is a little special for Windows.
If you are using Acrobat 4 you won't even have this problem, but with newer versions the fonts are simply not available and you must download them.

ReportLab will search the fonts on the paths defined on the same file rl_config.py as for Linux.

2007.01.17 | There's more... | Comments 0 | Tags ,

Deixe a sua mensagem:

Nome:


E-mail:


URL:


Comment:

Secret number

To send you comment you must insert the "secret number" on the box


Made with PyBlosxom | Add to Google