[reportlab-users] TTF-Font Support
Marius Gedminas
marius at gedmin.as
Thu Jan 24 06:56:15 EST 2013
On Thu, Jan 24, 2013 at 11:12:37AM +0100, Tom Py wrote:
> Hi Tim,
>
> thats the code:
>
> import os
> from reportlab.pdfbase import pdfmetrics
> from reportlab.pdfbase.ttfonts import TTFont
> from reportlab.pdfgen import canvas
> from reportlab.lib.pagesizes import A4, landscape
>
> actFolder = os.getcwd() + os.sep
>
> fontFile = 'futural.ttf'
> fontName = 'FuturaBT-Light'
>
> pdfmetrics.registerFont(TTFont(fontName, actFolder + fontFile))
>
> myCanvas = canvas.Canvas("test.pdf", pagesize = landscape(A4))
> myCanvas.setFont(fontName, 10.)
> myCanvas.drawCentredString(100, 100, 'Hello World')
> myCanvas.showPage()
> myCanvas.save()
> #myCanvas.getpdfdata()
>
> In this case, everything works fine. But when I use
> 'myCanvas.getpdfdata()', I'll get this error:
>
> Traceback (most recent call last):
...
> ValueError: redefining named object: 'toUnicodeCMap:AAAAAA+FuturaBT-Light'
I can reproduce this if (and only if) I call both myCanvas.save() and
then myCanvas.getpdfdata().
I can also reproduce by calling myCanvas.save() twice (which is
pointless). Or by calling myCanvas.getpdfdata() twice.
Marius Gedminas
--
"I may not understand what I'm installing, but that's not my job. I
just need to click Next, Next, Finish here so I can walk to the next
system and repeat the process"
-- Anonymous NT Admin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: Digital signature
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20130124/354e21f8/attachment.pgp>
More information about the reportlab-users
mailing list