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):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("OneByteIdentityV")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-17 06:08:00 +00:00
|
|
|
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):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("OneByteIdentityH")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-17 06:08:00 +00:00
|
|
|
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):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("V")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-17 06:08:00 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, CMap)
|
|
|
|
|
|
|
|
def test_cmapname_H(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("H")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-17 06:08:00 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, CMap)
|
|
|
|
|
|
|
|
def test_encoding_identityH(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
spec = {"Encoding": PSLiteral("Identity-H")}
|
2019-07-17 06:08:00 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityV(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
spec = {"Encoding": PSLiteral("Identity-V")}
|
2019-07-17 06:08:00 +00:00
|
|
|
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):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("Identity-H")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-24 06:26:06 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityV_as_PSLiteral_stream(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("Identity-V")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-24 06:26:06 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityH_as_stream(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": "Identity-H"}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-24 06:26:06 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_identityV_as_stream(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": "Identity-V"}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-07-24 06:26:06 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
2019-08-10 05:33:28 +00:00
|
|
|
def test_encoding_DLIdentH(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
spec = {"Encoding": PSLiteral("DLIdent-H")}
|
2019-08-10 05:33:28 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentV(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
spec = {"Encoding": PSLiteral("DLIdent-V")}
|
2019-08-10 05:33:28 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentH_as_PSLiteral_stream(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("DLIdent-H")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-08-10 05:33:28 +00:00
|
|
|
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):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": PSLiteral("DLIdent-V")}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-08-10 05:33:28 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentH_as_stream(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": "DLIdent-H"}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-08-10 05:33:28 +00:00
|
|
|
font = PDFCIDFont(None, spec)
|
|
|
|
assert isinstance(font.cmap, IdentityCMap)
|
|
|
|
|
|
|
|
def test_encoding_DLIdentV_as_stream(self):
|
2022-02-11 21:46:51 +00:00
|
|
|
stream = PDFStream({"CMapName": "DLIdent-V"}, "")
|
|
|
|
spec = {"Encoding": stream}
|
2019-08-10 05:33:28 +00:00
|
|
|
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)
|