[reportlab-users] Error in ttfont

Tim Roberts timr at probo.com
Mon Apr 3 16:19:16 EDT 2006


On Fri, 31 Mar 2006 19:34:42 +0200, Dick Kniep <dick at kniep.nl> wrote:

>here is some code
>
><snip>
>        self.CurrFont = TTFont('Lucida Sans','SUSESans-Roman.ttf')
>        pdfmetrics.registerFont(self.CurrFont)
>        thisFont = pdfmetrics.getFont(self.CurrFont)
><snip>
>
>And this is the result
>
><snip>
>2006-03-31 19:30:20,941 INFO GenReportLab 188 self.CurrFont is 
><reportlab.pdfbase.ttfonts.TTFont instance at 0x4264b98c>
>Traceback (most recent call last):
>...  File "/home/dick/CVix/CVix/src/GenReportLab.py", line 189, in __init__
>    thisFont = pdfmetrics.getFont(self.CurrFont)
>  File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/pdfmetrics.py", 
>line 641, in getFont
>    face = getTypeFace(fontName)
>  File "/usr/lib/python2.4/site-packages/reportlab/pdfbase/pdfmetrics.py", 
>line 592, in getTypeFace
>    return _typefaces[faceName]
>KeyError: <reportlab.pdfbase.ttfonts.TTFont instance at 0x4264b98c>
><snip>
>
>Can anyone tell me what I am doing wrong?
>  
>

Yes.  The traceback gave you the hint.  pdfmetrics.getFont wants a font
name, not a TTFont instance.  You want:

    thisFont = pdfmetrics.getFont('Lucida Sans')

-- 
Tim Roberts, timr at probo.com
Providenza & Boekelheide, Inc.



More information about the reportlab-users mailing list