[reportlab-users] ttfonts.py patch
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 @@
elif flags & GF_WE_HAVE_A_TWO_BY_TWO:
- n += 1
numGlyphs = n = len(glyphMap)
while n > 1 and self.hmetrics[n] == self.hmetrics[n - 1]:
More information about the reportlab-users