From c5c161c05514366f3008b3f110ce1ff32649d287 Mon Sep 17 00:00:00 2001 From: Cosimo Lupo Date: Fri, 13 Apr 2018 12:55:24 +0200 Subject: [PATCH] t1Lib: add 'kind' argument to T1Font constructor fixes issue introduced with last commit https://github.com/fonttools/fonttools/commit/b1fd6fbbcdb3dc87b05e2b7ebcf89afc92fd010e t1Lib_test.py::test_parse_lwfn was relying on 'path' being None. --- Lib/fontTools/t1Lib/__init__.py | 13 +++++++++++-- Tests/t1Lib/t1Lib_test.py | 3 +-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/Lib/fontTools/t1Lib/__init__.py b/Lib/fontTools/t1Lib/__init__.py index b77bb69de..5da9cea46 100644 --- a/Lib/fontTools/t1Lib/__init__.py +++ b/Lib/fontTools/t1Lib/__init__.py @@ -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): diff --git a/Tests/t1Lib/t1Lib_test.py b/Tests/t1Lib/t1Lib_test.py index 0e0fcbe35..f5e934de3 100644 --- a/Tests/t1Lib/t1Lib_test.py +++ b/Tests/t1Lib/t1Lib_test.py @@ -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'])