cmap bytes and decode
parent
cc733c8217
commit
a6f31a713d
|
@ -180,11 +180,11 @@ class FileUnicodeMap(UnicodeMap):
|
||||||
if isinstance(code, PSLiteral):
|
if isinstance(code, PSLiteral):
|
||||||
# Interpret as an Adobe glyph name.
|
# Interpret as an Adobe glyph name.
|
||||||
self.cid2unichr[cid] = name2unicode(code.name)
|
self.cid2unichr[cid] = name2unicode(code.name)
|
||||||
elif isinstance(code, str):
|
elif isinstance(code, bytes):
|
||||||
# Interpret as UTF-16BE.
|
# Interpret as UTF-16BE.
|
||||||
self.cid2unichr[cid] = unicode(code, 'UTF-16BE', 'ignore')
|
self.cid2unichr[cid] = code.decode('UTF-16BE', 'ignore')
|
||||||
elif isinstance(code, int):
|
elif isinstance(code, int):
|
||||||
self.cid2unichr[cid] = unichr(code)
|
self.cid2unichr[cid] = six.unichr(code)
|
||||||
else:
|
else:
|
||||||
raise TypeError(code)
|
raise TypeError(code)
|
||||||
return
|
return
|
||||||
|
@ -379,7 +379,7 @@ class CMapParser(PSStackParser):
|
||||||
if token is self.KEYWORD_ENDBFRANGE:
|
if token is self.KEYWORD_ENDBFRANGE:
|
||||||
objs = [obj for (__, obj) in self.popall()]
|
objs = [obj for (__, obj) in self.popall()]
|
||||||
for (s, e, code) in choplist(3, objs):
|
for (s, e, code) in choplist(3, objs):
|
||||||
if (not isinstance(s, str) or not isinstance(e, str) or
|
if (not isinstance(s, bytes) or not isinstance(e, bytes) or
|
||||||
len(s) != len(e)):
|
len(s) != len(e)):
|
||||||
continue
|
continue
|
||||||
s1 = nunpack(s)
|
s1 = nunpack(s)
|
||||||
|
@ -404,7 +404,7 @@ class CMapParser(PSStackParser):
|
||||||
if token is self.KEYWORD_ENDBFCHAR:
|
if token is self.KEYWORD_ENDBFCHAR:
|
||||||
objs = [obj for (__, obj) in self.popall()]
|
objs = [obj for (__, obj) in self.popall()]
|
||||||
for (cid, code) in choplist(2, objs):
|
for (cid, code) in choplist(2, objs):
|
||||||
if isinstance(cid, str) and isinstance(code, str):
|
if isinstance(cid, bytes) and isinstance(code, bytes):
|
||||||
self.cmap.add_cid2unichr(nunpack(cid), code)
|
self.cmap.add_cid2unichr(nunpack(cid), code)
|
||||||
return
|
return
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue