[reportlab-users] OTF fonts supported by Reportlab?

Mike Driscoll mike at pythonlibrary.org
Tue Jul 23 09:47:28 EDT 2013


Hi,

After writing a tutorial on fonts in Reportlab, I got a comment asking if
OTF fonts are supported. So far, I've found conflicting information.

This old thread seems to indicate that it should work:
http://two.pairlist.net/pipermail/reportlab-users/2008-August/007120.html

While this one says that if the font uses CFF format, Reportlab will spit
out an error:

http://stackoverflow.com/questions/895596/can-anyone-recomend-a-python-pdf-generator-with-opentype-otf-support

So I tried it. I went to http://www.fontsquirrel.com/ and downloaded the
first OTF font on there, specifically "Source Sans Pro Black". Then I ran
the attached code which gave me the following traceback:

reportlab.pdfbase.ttfonts.TTFError: TTF file
"C:\Users\mdriscoll\Desktop\rep-fonts\otf\SourceSansPro-Black.otf":
postscript outlines are not supported
File "c:\Users\mdriscoll\Desktop\rep-fonts\otfDemo.py", line 29, in <module>
embedOTF(r"C:\Users\mdriscoll\Desktop\rep-fonts\otf.pdf")
File "c:\Users\mdriscoll\Desktop\rep-fonts\otfDemo.py", line 17, in embedOTF
pdfmetrics.registerFont(TTFont("Source Sans Pro Black", otf_font))
File "C:\Python26\Lib\site-packages\reportlab\pdfbase\ttfonts.py", line
1009, in __init__
self.face = TTFontFace(filename, validate=validate,
subfontIndex=subfontIndex)
File "C:\Python26\Lib\site-packages\reportlab\pdfbase\ttfonts.py", line
915, in __init__
TTFontFile.__init__(self, filename, validate=validate,
subfontIndex=subfontIndex)
File "C:\Python26\Lib\site-packages\reportlab\pdfbase\ttfonts.py", line
412, in __init__
TTFontParser.__init__(self, file,
validate=validate,subfontIndex=subfontIndex)
File "C:\Python26\Lib\site-packages\reportlab\pdfbase\ttfonts.py", line
190, in __init__
isCollection = self.readHeader()
File "C:\Python26\Lib\site-packages\reportlab\pdfbase\ttfonts.py", line
253, in readHeader
raise TTFError('%s file "%s": postscript outlines are not
supported'%(self.fileKind,self.filename))

Is there a way to make Reportlab accept this font or fonts like it?

Thanks,
Mike Driscoll
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://two.pairlist.net/pipermail/reportlab-users/attachments/20130723/5df70c34/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: otfDemo.py
Type: application/octet-stream
Size: 1074 bytes
Desc: not available
Url : <http://two.pairlist.net/pipermail/reportlab-users/attachments/20130723/5df70c34/attachment.obj>


More information about the reportlab-users mailing list