another buggy font workaround; sped up unpackPStrings somewhat
git-svn-id: svn://svn.code.sf.net/p/fonttools/code/trunk@177 4cde692c-a291-49d1-8350-778aa11640f8
This commit is contained in:
parent
ae43d92ea9
commit
f9104bcc2c
@ -67,6 +67,12 @@ class table__p_o_s_t(DefaultTable.DefaultTable):
|
|||||||
def decode_format_2_0(self, data, ttFont):
|
def decode_format_2_0(self, data, ttFont):
|
||||||
numGlyphs, = struct.unpack(">H", data[:2])
|
numGlyphs, = struct.unpack(">H", data[:2])
|
||||||
numGlyphs = int(numGlyphs)
|
numGlyphs = int(numGlyphs)
|
||||||
|
if numGlyphs > ttFont['maxp'].numGlyphs:
|
||||||
|
# Assume the numGlyphs field is bogus, so sync with maxp.
|
||||||
|
# I've seen this in one font, and if the assumption is
|
||||||
|
# wrong elsewhere, well, so be it: it's hard enough to
|
||||||
|
# work around _one_ non-conforming post format...
|
||||||
|
numGlyphs = ttFont['maxp'].numGlyphs
|
||||||
data = data[2:]
|
data = data[2:]
|
||||||
indices = array.array("H")
|
indices = array.array("H")
|
||||||
indices.fromstring(data[:2*numGlyphs])
|
indices.fromstring(data[:2*numGlyphs])
|
||||||
@ -200,12 +206,15 @@ class table__p_o_s_t(DefaultTable.DefaultTable):
|
|||||||
|
|
||||||
def unpackPStrings(data):
|
def unpackPStrings(data):
|
||||||
strings = []
|
strings = []
|
||||||
while data:
|
index = 0
|
||||||
length = ord(data[0])
|
dataLen = len(data)
|
||||||
strings.append(data[1:1+length])
|
while index < dataLen:
|
||||||
data = data[1+length:]
|
length = ord(data[index])
|
||||||
|
strings.append(data[index+1:index+1+length])
|
||||||
|
index = index + 1 + length
|
||||||
return strings
|
return strings
|
||||||
|
|
||||||
|
|
||||||
def packPStrings(strings):
|
def packPStrings(strings):
|
||||||
data = ""
|
data = ""
|
||||||
for s in strings:
|
for s in strings:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user