t1Lib: add 'kind' argument to T1Font constructor

fixes issue introduced with last commit
b1fd6fbbcd

t1Lib_test.py::test_parse_lwfn was relying on 'path' being None.
This commit is contained in:
Cosimo Lupo 2018-04-13 12:55:24 +02:00
parent b1fd6fbbcd
commit c5c161c055
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482
2 changed files with 12 additions and 4 deletions

View File

@ -49,8 +49,17 @@ class T1Font(object):
Type 1 fonts.
"""
def __init__(self, path, encoding="ascii"):
self.data, _ = read(path)
def __init__(self, path, encoding="ascii", kind=None):
if kind is None:
self.data, _ = read(path)
elif kind == "LWFN":
self.data = readLWFN(path)
elif kind == "PFB":
self.data = readPFB(path)
elif kind == "OTHER":
self.data = readOther(path)
else:
raise ValueError(kind)
self.encoding = encoding
def saveAs(self, path, type, dohex=False):

View File

@ -67,8 +67,7 @@ class T1FontTest(unittest.TestCase):
def test_parse_lwfn(self):
# the extended attrs are lost on git so we can't auto-detect 'LWFN'
font = t1Lib.T1Font()
font.data = t1Lib.readLWFN(LWFN)
font = t1Lib.T1Font(LWFN, kind="LWFN")
font.parse()
self.assertEqual(font['FontName'], 'TestT1-Regular')
self.assertTrue('Subrs' in font['Private'])