[reportlab-users] ttfont checksum fails

matt-lists at comnet.net.nz matt-lists at comnet.net.nz
Wed Dec 27 13:30:22 EST 2006


Hello,

I'm new to this list, so please excuse any indiscretions.

I'm in the middle of putting together a function in an application I maintain
to create reports in pdf format. The application has been translated into a
number of different languages, and so I need to generate a report using a
font that has good non-latin character support. At the moment, I've chosen
verdana.

I'm using the following code:

import reportlab.rl_config
reportlab.rl_config.warnOnMissingFontGlyphs = 0
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont
import time
enc = 'UTF-8'
pdfmetrics.registerFont(TTFont('Verdana', config_directory
+ '/verdana.ttf',enc))
pdfmetrics.registerFont(TTFont('Verdana Bold', config_directory
+ '/Verdana_Bold.ttf',enc))

to register the font with reportlab (config_directory is a variable holding
the path to the directory where the verdana fonts I want to use are held).
However, on executing this code, I'm getting the following error:

Traceback (most recent call last):
File "liquid_weather.py", line 4022, in menuOptionChanged
printForecast(widget,0)
File "liquid_weather.py", line 3330, in printForecast
pdfmetrics.registerFont(TTFont('Verdana', config_directory
+ '/verdana.ttf',enc))
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py", line
1000, in __init__
self.face = TTFontFace(filename, validate=validate,
subfontIndex=subfontIndex)
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py", line
915, in __init__
TTFontFile.__init__(self, filename, validate=validate,
subfontIndex=subfontIndex)
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py", line
433, in __init__
TTFontParser.__init__(self, file,
validate=validate,subfontIndex=subfontIndex)
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py", line
221, in __init__
if self.validate: self.checksumFile()
File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py", line
309, in checksumFile
raise TTFError('TTF file "%s": invalid checksum %s len: %d &3: %d' %
(self.filename,hex32(checkSum),len(self._ttf_data),(len(self._ttf_data)&3)))
reportlab.pdfbase.ttfonts.TTFError: TTF
file "/home/matt/.superkaramba/lwp/verdana.ttf": invalid checksum 0XBBB0AFBA
len: 149753 &3: 1

It appears that the checksum is failing. Is it possible to disable checksum
validation. I've had a quick look through the code, but can't find a way to
do this (although, it was a very quick look). I note their is an option
within the various methods to set validate=false, but I can't see how to do
that from within my application when I call the registerFont function.

Any help would be appreciated. Thanks in advance.

Regards

Matt


More information about the reportlab-users mailing list