Adds decoder for OnebyteIdentityH/V instead of using default CMap

pull/283/head
Fakabbir Amin 2019-08-10 10:07:23 +05:30
parent f1a4dcea88
commit 5a0d8db052
2 changed files with 21 additions and 2 deletions

View File

@ -131,6 +131,15 @@ class IdentityCMap(CMapBase):
return ()
class IdentityCMapByte(IdentityCMap):
def decode(self, code):
n = len(code)
if n:
return struct.unpack('>%dB' % n, code)
else:
return ()
## UnicodeMap
##
class UnicodeMap(CMapBase):
@ -252,6 +261,10 @@ class CMapDB(object):
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:

View File

@ -128,7 +128,13 @@ class Type1FontHeaderParser(PSStackParser):
NIBBLES = ('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '.', 'e', 'e-', None, '-')
IDENTITY_ENCODER = ('Identity-H', 'Identity-V')
IDENTITY_ENCODER = {'Identity-H':'Identity-H',
'Identity-V':'Identity-V',
'DLIdent-H':'Identity-H',
'DLIdent-V':'Identity-V',
'OneByteIdentityH':'OneByteIdentityH',
'OneByteIdentityV':'OneByteIdentityV',
}
## CFFFont
## (Format specified in Adobe Technical Note: #5176
@ -723,7 +729,7 @@ class PDFCIDFont(PDFFont):
raise PDFFontError('CMapName unspecified for encoding')
cmap_name = 'unknown'
if cmap_name in IDENTITY_ENCODER:
return CMapDB.get_cmap(cmap_name)
return CMapDB.get_cmap(IDENTITY_ENCODER[cmap_name])
else:
return CMap()