[reportlab-users] Font re-registration annoyance

Dinu Gherman gherman at darwin.in-berlin.de
Fri Jan 12 11:35:56 EST 2007


Hi!

I have some code which might try to register a TrueType font
multiple times. It's more convenient like this, although my code
could be smarter an avoid registering the font more than once.

Without that smarts I get the traceback below for the attached
code snippet, which does surprises me a bit. While I can change
my own code to handle this, I might not be able to change code
from others that uses fonts inside external Platypus flowables.

Therefore, I think that detecting the re-registration of a font
might be something to be moved / developed into the RL code base
itself.

Regards,

Dinu

PS: Tested on Python 2.4, RL 2.0, with the TTF "Code2000"
and the TTF "Rina" (included in RL 2.0).


-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_register_fonts.pdf
Type: application/pdf
Size: 12593 bytes
Desc: not available
Url : http://two.pairlist.net/pipermail/reportlab-users/attachments/20070112/1c33f9c2/attachment-0001.pdf
-------------- next part --------------
A non-text attachment was scrubbed...
Name: test_register_fonts.py
Type: application/octet-stream
Size: 1112 bytes
Desc: not available
Url : http://two.pairlist.net/pipermail/reportlab-users/attachments/20070112/1c33f9c2/attachment-0001.obj
-------------- next part --------------


localhost:~/dev/test dinu$ /opt/bin/python2.4 test_register_fonts.py
Traceback (most recent call last):
File "test_register_fonts.py", line 47, in ?
main()
File "test_register_fonts.py", line 43, in main
canv.save()
File "/opt/lib/python2.4/site-packages/reportlab/pdfgen/canvas.py",
line 843, in save
self._doc.SaveToFile(self._filename, self)
File "/opt/lib/python2.4/site-packages/reportlab/pdfbase/pdfdoc.py",
line 218, in SaveToFile
f.write(self.GetPDFData(canvas))
File "/opt/lib/python2.4/site-packages/reportlab/pdfbase/pdfdoc.py",
line 230, in GetPDFData
fnt.addObjects(self)
File "/opt/lib/python2.4/site-packages/reportlab/pdfbase/ttfonts.py",
line 1099, in addObjects
pdfFont.ToUnicode = doc.Reference(cmapStream, 'toUnicodeCMap:' +
baseFontName)
File "/opt/lib/python2.4/site-packages/reportlab/pdfbase/pdfdoc.py",
line 459, in Reference
raise ValueError, "redefining named object: "+repr(name)
ValueError: redefining named object: 'toUnicodeCMap:AAAAAA+Code2000'


More information about the reportlab-users mailing list