forked from pdfminer/pdfminer.six
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request pdfminer#264 from fakabbir/pdfstream-as-cmap
Pdfstream as cmap
- Loading branch information
Showing
2 changed files
with
111 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
#!/usr/bin/env python | ||
|
||
# -*- coding: utf-8 -*- | ||
|
||
import nose, logging, os | ||
from pdfminer.cmapdb import IdentityCMap, CMap | ||
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) | ||
assert isinstance(font.cmap, CMap) | ||
|
||
def test_cmapname_onebyteidentityH(self): | ||
stream = PDFStream({'CMapName': PSLiteral('OneByteIdentityH')}, '') | ||
spec = {'Encoding': stream} | ||
font = PDFCIDFont(None, spec) | ||
assert isinstance(font.cmap, CMap) | ||
|
||
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) | ||
|
||
def test_font_without_spec(self): | ||
font = PDFCIDFont(None, {}) | ||
assert isinstance(font.cmap, CMap) | ||
|
||
|
||
if __name__ == '__main__': | ||
nose.runmodule() |