2020-04-28 08:58:42 +00:00
|
|
|
#!/usr/bin/env python3
|
2019-07-17 06:08:00 +00:00
|
|
|
|
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2019-08-10 05:33:28 +00:00
|
|
|
from pdfminer.cmapdb import IdentityCMap, CMap, IdentityCMapByte
|
2019-07-17 06:08:00 +00:00
|
|
|
from pdfminer.pdffont import PDFCIDFont
|
|
|
|
from pdfminer.pdftypes import PDFStream
|
|
|
|
from pdfminer.psparser import PSLiteral
|
|
|
|
|
2019-10-26 16:42:33 +00:00
|
|
|
|
2022-02-02 21:24:32 +00:00
|
|
|
class TestPDFEncoding:
|
2019-07-17 06:08:00 +00:00
|
|
|
|
|
|
|
def test_cmapname_onebyteidentityV(self):
|
|
|
|
stream = PDFStream({'CMapName': PSLiteral('OneByteIdentityV')}, '')
|
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
2019-08-10 05:33:28 +00:00
|
|
|
assert isinstance(font.cmap, IdentityCMapByte)
|
2019-07-17 06:08:00 +00:00
|
|
|
|
|
|
|
def test_cmapname_onebyteidentityH(self):
|
|
|
|
stream = PDFStream({'CMapName': PSLiteral('OneByteIdentityH')}, '')
|
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
2019-08-10 05:33:28 +00:00
|
|
|
assert isinstance(font.cmap, IdentityCMapByte)
|
2019-07-17 06:08:00 +00:00
|
|
|
|
|
|
|
def test_cmapname_V(self):
|
|
|
|
stream = PDFStream({'CMapName': PSLiteral('V')}, '')
|
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, CMap)
|
|
|
|
|
|
|
|
def test_cmapname_H(self):
|
|
|
|
stream = PDFStream({'CMapName': PSLiteral('H')}, '')
|
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, CMap)
|
|
|
|
|
|
|
|
def test_encoding_identityH(self):
|
|
|
|
spec = {'Encoding': PSLiteral('Identity-H')}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityV(self):
|
|
|
|
spec = {'Encoding': PSLiteral('Identity-V')}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
2019-07-24 06:26:06 +00:00
|
|
|
def test_encoding_identityH_as_PSLiteral_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': PSLiteral('Identity-H')}, '')
|
2019-07-24 06:26:06 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityV_as_PSLiteral_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': PSLiteral('Identity-V')}, '')
|
2019-07-24 06:26:06 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityH_as_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': 'Identity-H'}, '')
|
2019-07-24 06:26:06 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityV_as_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': 'Identity-V'}, '')
|
2019-07-24 06:26:06 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
2019-08-10 05:33:28 +00:00
|
|
|
def test_encoding_DLIdentH(self):
|
|
|
|
spec = {'Encoding': PSLiteral('DLIdent-H')}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentV(self):
|
|
|
|
spec = {'Encoding': PSLiteral('DLIdent-V')}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentH_as_PSLiteral_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': PSLiteral('DLIdent-H')}, '')
|
2019-08-10 05:33:28 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
2019-12-29 20:20:20 +00:00
|
|
|
def test_encoding_DLIdentV_as_PSLiteral_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': PSLiteral('DLIdent-V')}, '')
|
2019-08-10 05:33:28 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentH_as_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': 'DLIdent-H'}, '')
|
2019-08-10 05:33:28 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentV_as_stream(self):
|
2019-10-26 16:42:33 +00:00
|
|
|
stream = PDFStream({'CMapName': 'DLIdent-V'}, '')
|
2019-08-10 05:33:28 +00:00
|
|
|
spec = {'Encoding': stream}
|
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
2019-07-24 06:26:06 +00:00
|
|
|
def test_font_without_spec(self):
|
|
|
|
font = PDFCIDFont(None, {})
|
|
|
|
assert isinstance(font.cmap, CMap)
|