pdfminer.six/tests/test_pdfencoding.py

107 lines
3.9 KiB
Python
Raw Normal View History

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
2019-08-10 05:33:28 +00:00
from pdfminer.cmapdb import IdentityCMap, CMap, IdentityCMapByte
from pdfminer.pdffont import PDFCIDFont
from pdfminer.pdftypes import PDFStream
from pdfminer.psparser import PSLiteral
class TestPDFEncoding:
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)
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)
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)
def test_encoding_identityH_as_PSLiteral_stream(self):
stream = PDFStream({"CMapName": PSLiteral("Identity-H")}, "")
spec = {"Encoding": stream}
font = PDFCIDFont(None, spec)
assert isinstance(font.cmap, IdentityCMap)
def test_encoding_identityV_as_PSLiteral_stream(self):
stream = PDFStream({"CMapName": PSLiteral("Identity-V")}, "")
spec = {"Encoding": stream}
font = PDFCIDFont(None, spec)
assert isinstance(font.cmap, IdentityCMap)
def test_encoding_identityH_as_stream(self):
stream = PDFStream({"CMapName": "Identity-H"}, "")
spec = {"Encoding": stream}
font = PDFCIDFont(None, spec)
assert isinstance(font.cmap, IdentityCMap)
def test_encoding_identityV_as_stream(self):
stream = PDFStream({"CMapName": "Identity-V"}, "")
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")}
2019-08-10 05:33:28 +00:00
font = PDFCIDFont(None, spec)
assert isinstance(font.cmap, IdentityCMap)
def test_encoding_DLIdentV(self):
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):
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)
Enforce pep8 coding-style (#345) * Code Refractor: Use code-style enforcement #312 * Add flake8 to travis-ci * Remove python 2 3 comment on six library. 891 errors > 870 errors. * Remove class and functions comments that consist of just the name. 870 errors > 855 errors. * Fix flake8 errors in pdftypes.py. 855 errors > 833 errors. * Moving flake8 testing from .travis.yml to tox.ini to ensure local testing before commiting * Cleanup pdfinterp.py and add documentation from PDF Reference * Cleanup pdfpage.py * Cleanup pdffont.py * Clean psparser.py * Cleanup high_level.py * Cleanup layout.py * Cleanup pdfparser.py * Cleanup pdfcolor.py * Cleanup rijndael.py * Cleanup converter.py * Rename klass to cls if it is the class variable, to be more consistent with standard practice * Cleanup cmap.py * Cleanup pdfdevice.py * flake8 ignore fontmetrics.py * Cleanup test_pdfminer_psparser.py * Fix flake8 in pdfdocument.py; 339 errors to go * Fix flake8 utils.py; 326 errors togo * pep8 correction for few files in /tools/ 328 > 160 to go (#342) * pep8 correction for few files in /tools/ 328 > 160 to go * pep8 correction: 160 > 5 to go * Fix ascii85.py errors * Fix error in getting index from target that does not exists * Remove commented print lines * Fix flake8 error in pdfinterp.py * Fix python2 specific error by removing argument from print statement * Ignore invalid python2 syntax * Update contributing.md * Added changelog * Remove unused import Co-authored-by: Fakabbir Amin <f4amin@gmail.com>
2019-12-29 20:20:20 +00:00
def test_encoding_DLIdentV_as_PSLiteral_stream(self):
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):
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):
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)
def test_font_without_spec(self):
font = PDFCIDFont(None, {})
assert isinstance(font.cmap, CMap)