Skip to content

Commit

Permalink
fix PSTypeError and encoding cmap
Browse files Browse the repository at this point in the history
  • Loading branch information
pantuts committed Dec 12, 2019
1 parent 4477952 commit 4a08159
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
.idea/
15 changes: 15 additions & 0 deletions pdfminer/cmapdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -247,6 +247,10 @@ def get_cmap(klass, name):
return IdentityCMap(WMode=0)
elif name == 'Identity-V':
return IdentityCMap(WMode=1)
elif name == 'OneByteIdentityH':
return IdentityCMapByte(WMode=0)
elif name == 'OneByteIdentityV':
return IdentityCMapByte(WMode=1)
try:
return klass._cmap_cache[name]
except KeyError:
Expand Down Expand Up @@ -560,6 +564,17 @@ def dump_unicodemap(self, fp):
fp.write(marshal.dumps(data))
return


class IdentityCMapByte(IdentityCMap):

def decode(self, code):
n = len(code)
if n:
return struct.unpack('>%dB' % n, code)
else:
return ()


# convert_cmap
def convert_cmap(outdir, regname, enc2codec, paths):
converter = CMapConverter(enc2codec)
Expand Down
6 changes: 5 additions & 1 deletion pdfminer/pdffont.py
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,11 @@ def __init__(self, rsrcmgr, spec):
ordering = bytes_value(self.cidsysteminfo.get('Ordering', b'unknown'))
self.cidcoding = (registry + b'-' + ordering).decode('ascii')
try:
name = literal_name(spec['Encoding'])
spec_encoding = spec['Encoding']
if hasattr(spec_encoding, 'name'):
name = literal_name(spec['Encoding'])
else:
name = literal_name(spec_encoding['CMapName'])
except KeyError:
if STRICT:
raise PDFFontError('Encoding is unspecified')
Expand Down

1 comment on commit 4a08159

@pantuts
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.