subset_test: add test for --retain-gids option

This commit is contained in:
Cosimo Lupo 2019-01-15 11:31:16 +00:00
parent c7b66dc59c
commit 71dbe2daea
No known key found for this signature in database
GPG Key ID: 59D54DB0C9976482

View File

@ -475,6 +475,38 @@ class SubsetTest(unittest.TestCase):
subset.main([fontpath, "--recalc-timestamp", "--output-file=%s" % subsetpath, "*"]) subset.main([fontpath, "--recalc-timestamp", "--output-file=%s" % subsetpath, "*"])
self.assertLess(modified, TTFont(subsetpath)['head'].modified) self.assertLess(modified, TTFont(subsetpath)['head'].modified)
def test_retain_gids(self):
_, fontpath = self.compile_font(self.getpath("TestTTF-Regular.ttx"), ".ttf")
font = TTFont(fontpath)
self.assertEqual(font["hmtx"]["A"], (500, 132))
self.assertEqual(font["hmtx"]["B"], (400, 132))
self.assertGreater(font["glyf"]["A"].numberOfContours, 0)
self.assertGreater(font["glyf"]["B"].numberOfContours, 0)
subsetpath = self.temp_path(".ttf")
subset.main(
[
fontpath,
"--retain-gids",
"--output-file=%s" % subsetpath,
"--glyph-names",
"A",
]
)
subsetfont = TTFont(subsetpath)
self.assertEqual(subsetfont.getGlyphOrder(), font.getGlyphOrder())
hmtx = subsetfont["hmtx"]
self.assertEqual(hmtx["A"], (500, 132))
self.assertEqual(hmtx["B"], (0, 0))
glyf = subsetfont["glyf"]
self.assertGreater(glyf["A"].numberOfContours, 0)
self.assertEqual(glyf["B"].numberOfContours, 0)
if __name__ == "__main__": if __name__ == "__main__":
sys.exit(unittest.main()) sys.exit(unittest.main())