[reportlab-users] ttfonts.py patch

Robin Becker robin at reportlab.com
Fri Dec 4 06:05:41 EST 2009


.......

Jerry, can you see if the following small patch improves your outcomes.

It seems that the error you were getting related to number of contours occurs
when we see glyphLen == 0. That could be because it's not really right to assume
that all fonts have all the glyphs in the 0-128 range.

I tried the following patch on ttfonts.py and that at least prevents the error
from being raised.

@@ -735,6 +748,8 @@
originalGlyphIdx = glyphMap[n]
glyphPos = self.glyphPos[originalGlyphIdx]
glyphLen = self.glyphPos[originalGlyphIdx + 1] - glyphPos
+ n += 1
+ if not glyphLen: continue
self.seek(start + glyphPos)
numberOfContours = self.read_short()
if numberOfContours < 0:
@@ -757,7 +772,6 @@
self.skip(4)
elif flags & GF_WE_HAVE_A_TWO_BY_TWO:
self.skip(8)
- n += 1

numGlyphs = n = len(glyphMap)
while n > 1 and self.hmetrics[n][0] == self.hmetrics[n - 1][0]:
--
Robin Becker


More information about the reportlab-users mailing list