@@ -386,15 +386,18 @@ def test_get_major_minorVersion(self):
386
386
self .assertEqual (flavorData .minorVersion , 1 )
387
387
388
388
def test_mutually_exclusive_args (self ):
389
+ msg = "arguments are mutually exclusive"
389
390
reader = DummyReader (self .file )
390
- with self .assertRaisesRegex (TypeError , "arguments are mutually exclusive" ):
391
+ with self .assertRaisesRegex (TypeError , msg ):
391
392
WOFF2FlavorData (reader , transformedTables = {"hmtx" })
393
+ with self .assertRaisesRegex (TypeError , msg ):
394
+ WOFF2FlavorData (reader , data = WOFF2FlavorData ())
392
395
393
- def test_transformTables_default (self ):
396
+ def test_transformedTables_default (self ):
394
397
flavorData = WOFF2FlavorData ()
395
398
self .assertEqual (flavorData .transformedTables , set (woff2TransformedTableTags ))
396
399
397
- def test_transformTables_invalid (self ):
400
+ def test_transformedTables_invalid (self ):
398
401
msg = r"'glyf' and 'loca' must be transformed \(or not\) together"
399
402
400
403
with self .assertRaisesRegex (ValueError , msg ):
@@ -1258,6 +1261,24 @@ def test_compress_otf(self, tmpdir):
1258
1261
1259
1262
assert (tmpdir / "TestOTF-Regular.woff2" ).check (file = True )
1260
1263
1264
+ def test_recompress_woff2_keeps_flavorData (self , tmpdir ):
1265
+ woff2_font = ttLib .TTFont (BytesIO (TT_WOFF2 .getvalue ()))
1266
+ woff2_font .flavorData .privData = b"FOOBAR"
1267
+ woff2_file = tmpdir / "TestTTF-Regular.woff2"
1268
+ woff2_font .save (str (woff2_file ))
1269
+
1270
+ assert woff2_font .flavorData .transformedTables == {"glyf" , "loca" }
1271
+
1272
+ woff2 .main (["compress" , "--hmtx-transform" , str (woff2_file )])
1273
+
1274
+ output_file = tmpdir / "TestTTF-Regular#1.woff2"
1275
+ assert output_file .check (file = True )
1276
+
1277
+ new_woff2_font = ttLib .TTFont (str (output_file ))
1278
+
1279
+ assert new_woff2_font .flavorData .transformedTables == {"glyf" , "loca" , "hmtx" }
1280
+ assert new_woff2_font .flavorData .privData == b"FOOBAR"
1281
+
1261
1282
def test_decompress_ttf (self , tmpdir ):
1262
1283
input_file = tmpdir / "TestTTF-Regular.woff2"
1263
1284
input_file .write_binary (TT_WOFF2 .getvalue ())
0 commit comments