diff --git a/pdfminer/cmapdb.py b/pdfminer/cmapdb.py index 6760b6c..d1d24ba 100644 --- a/pdfminer/cmapdb.py +++ b/pdfminer/cmapdb.py @@ -118,6 +118,15 @@ def decode(self, code): return () +class IdentityCMapByte(IdentityCMap): + def decode(self, code): + n = len(code) + if n: + return struct.unpack('>%dB' % n, code) + else: + return () + + class UnicodeMap(CMapBase): def __init__(self, **kwargs): CMapBase.__init__(self, **kwargs) @@ -224,6 +233,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: diff --git a/pdfminer/pdffont.py b/pdfminer/pdffont.py index 8d8242a..a735182 100644 --- a/pdfminer/pdffont.py +++ b/pdfminer/pdffont.py @@ -946,7 +946,11 @@ def __init__(self, rsrcmgr, spec, strict=settings.STRICT): self.cidcoding = '%s-%s' % (resolve1(self.cidsysteminfo.get('Registry', b'unknown')).decode("latin1"), resolve1(self.cidsysteminfo.get('Ordering', b'unknown')).decode("latin1")) 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') diff --git a/samples/Makefile b/samples/Makefile index 6634748..0a6143b 100644 --- a/samples/Makefile +++ b/samples/Makefile @@ -18,7 +18,8 @@ NONFREE= \ nonfree/i1040nr \ nonfree/kampo \ nonfree/naacl06-shinyama \ - nonfree/nlp2004slides + nonfree/nlp2004slides \ + nonfree/one-byte-identity TESTS=$(FREE) $(NONFREE) diff --git a/samples/nonfree/one-byte-identity.html.ref b/samples/nonfree/one-byte-identity.html.ref new file mode 100644 index 0000000..9528b3a --- /dev/null +++ b/samples/nonfree/one-byte-identity.html.ref @@ -0,0 +1,8 @@ +
+ + + + +