[reportlab-users] ValueError: redefining named object: 'toUnicodeCMap:SUBSET+ArialMT+0'

Robin Becker reportlab-users@reportlab.com
Mon, 01 Nov 2004 09:43:13 +0000


CKennedy@kennedytech.com wrote:
> I'm trying to use truetype fonts w/ ReportLab.  I am able to add all of my 
> frames, however, when I try to save the PDF I get the following traceback:
> 
......
> 
>             fontDBO = element.getFontDBO()              #this is a 
> database object that has my font info
>             fweight = fontDBO.get_weight_name()
>             fstyle = fontDBO.get_style_name()
>             fkey = fontDBO.face + fweight + fstyle  #face attribute 
> contains "arial"
> 
>             if fkey not in self.pstyles.keys():
>               pstyle = ParagraphStyle({})
>               pstyle.bulletFontName = fontDBO.face
>               pstyle.fontSize = fontDBO.points * 0.85
>               pstyle.bulletFontSize = fontDBO.points * 0.85
>               pstyle.leading = pstyle.fontSize * 1.2
>               r, g, b = fontDBO.getColor().Get()
>               pstyle.textColor = colors.Color(r, g, b)
>               fmodlist = [] 
>               fbold = 0
>               fital = 0
>               if fweight == "Bold":
>                 fmodlist.append("bold")
>                 fbold = 1
>               if fstyle == "Italic":
>                 fmodlist.append("italic")
>                 fital = 1
>               if len(fmodlist):
>                 pstyle.fontName = fontDBO.face.lower() + " " + " 
> ".join(fmodlist)
>               else:
>                 pstyle.fontName = fontDBO.face.lower()
>               isTT = 0
>               if pstyle.fontName in fontinfo:
>                 isTT = 1
>                 ttffile = fontinfo[pstyle.fontName]
>                 pdfmetrics.registerFont(TTFont(pstyle.fontName, ttffile))
>               addMapping(fontDBO.face, fbold, fital, pstyle.fontName) 
>               self.pstyles[fkey] = pstyle
>             else:
>               pstyle = self.pstyles[fkey]
> 
>             flow = []
>             textdata = element.static_text
>             for line in textdata.split('\n'):
>               flow.append( Paragraph(line, pstyle) )
>             self.addFrame(posx, posy, sizew, sizeh, flow)

I'm not exactly sure what you're doing above, but I suspect that the font is 
being registered more than once. With TTF we're trying to do dynamic subsetting, 
so I guess that your process ha already declared a subset0 and then later 
reregisters and tries to do it again. Probably we should notice this and report 
an error at the rereg. I'm not absolutely sure this is the problem.
-- 
Robin Becker