[reportlab-users] Re: ReportLab + Macintosh TTFs

Marius Gedminas reportlab-users@reportlab.com
Wed, 3 Jul 2002 10:33:18 +0200


On Tue, Jul 02, 2002 at 09:00:40PM +0200, Dinu Gherman wrote:
> There are only two left where I still get a traceback,
> which I can send you as usual if you like. One is some
> "HelveticaNeue" family and one is "Didot".

Fixed:

Index: pdfbase/ttfonts.py
===================================================================
RCS file: /cvsroot/reportlab/reportlab/pdfbase/ttfonts.py,v
retrieving revision 1.2
diff -u -p -r1.2 ttfonts.py
--- pdfbase/ttfonts.py  2 Jul 2002 21:28:29 -0000       1.2
+++ pdfbase/ttfonts.py  3 Jul 2002 08:26:55 -0000
@@ -709,7 +709,13 @@ class TTFontFile(TTFontParser):
 
         # The following tables are simply copied from the original
         for tag in ('name', 'OS/2', 'cvt ', 'fpgm', 'prep'):
-            output.add(tag, self.get_table(tag))
+            try:
+                output.add(tag, self.get_table(tag))
+            except KeyError:
+                # Apparently some of the tables are optional (cvt, fpgm, prep).
+                # The lack of the required ones (name, OS/2) would have already
+                # been caught before.
+                pass
 
         # post - PostScript
         post = "\x00\x03\x00\x00" + self.get_table('post')[4:16] + "\x00" * 16


BTW what about adding *.pyc into the global CVSROOT/cvsignore in the
repository?  reportlab/tests/.cvsignore could also list *.pdf and *.log.

> There are even more fonts on an OS X box, but they are 
> in some other format that I don't know yet how to con-
> vert.

A couple of related formats are OpenType fonts with PostScript shapes
(probably they'd need to be converted to Type1 before embedding) and
font collections.  Check the first 4 bytes -- 'OTTO' means it's OpenType
with PostScript outlines, 0x00010000 means TrueType (= OpenType with
TTF outlines), 'ttcf' means TrueType Collection.

Marius Gedminas
-- 
The clothes have no emperor.
                -- C.A.R. Hoare, commenting on ADA.