[reportlab-users] Type 1 fonts and renderPM on Windows
Leighton Pritchard
reportlab-users@reportlab.com
Thu, 28 Aug 2003 09:23:54 +0100
Robin Becker wrote:
>...... this is what happens when reportlab can't see the right fonts. I
>seem to remember we have an explicit list of font filenames for the
>Win32 version. That list is in pdfbase/_fontdata.py. For times roman we
>probably need the file '_er_____.pfb' somewhere on the T1 search path.
Thanks for the help, Robin.
I couldn't find a suitable font file on my machine (even with Adobe Reader
6 installed), or on the linux machine, so I grabbed it -along with others -
from
http://www.genesys.ro/download/Networking/Allied_Telesyn/Switchblade_1/ACROBAT/RESOURCE/FONT/
(I couldn't find any such downloads at adobe.com or adobe.co.uk).
I placed these in the reportlab/fonts folder, with no luck. When I placed
them in the Adobe Reader fonts directory, however, things started working.
For the most part.
Now, renderPM works fine with BMP, JPG, TIFF and GIF formats, but with PNG
crashes Python without an error message or traceback. This behaviour
doesn't occur on my Linux installation with the same code. The offending
code seems pretty innocuous to me:
A drawing is made, and several methods are callable to write it:
[...]
def t_bmp(self):
""" Test the creation of .bmp format
"""
outfile = os.path.join("Graphics", "linear_plot.bmp")
self.diagram.write(outfile, output='BMP')
def t_gif(self):
""" Test the creation of .gif format
"""
outfile = os.path.join("Graphics", "linear_plot.gif")
self.diagram.write(outfile, output='GIF')
def t_png(self):
""" Test the creation of .png format
"""
outfile = os.path.join("Graphics", "linear_plot.png")
self.diagram.write(outfile, output='PNG')
Of the above, only the t_png method causes the crash. self.diagram.write
calls the following method:
def write(self, filename='test1.ps', output='PS', title='Genome
Schematic'):
""" write(self, filename='test1.ps', title='Genome Schematic',
output='PS')
Write the drawing out to a file in a prescribed format
"""
formatdict = {'PS': renderPS,
'PDF': renderPDF,
'SVG': renderSVG,
'JPG': renderPM,
'BMP': renderPM,
'GIF': renderPM,
'PNG': renderPM,
'TIFF': renderPM
}
drawmethod = formatdict[output]
if drawmethod == renderPM:
drawmethod.drawToFile(self._drawing, filename, output)
else:
drawmethod.drawToFile(self._drawing, filename)
Can anyone please help me with what's going wrong? Again, I'm on WindowsXP
with Python2.2 and ReportLab 1.18.