def test_write_kern_ttf(self): f = TTFont("test-fonts/OpenSans-Regular.ttf") f.kerning[("A","V")] = -100 f.save("OS-AV100.ttf") f2 = TTFont("OS-AV100.ttf") self.assertEqual(f2.kerning[("A","V")],-100) os.unlink("OS-AV100.ttf")
def test_write_info(self): f = TTFont("test-fonts/OpenSans-Regular.ttf") f.info.versionMinor = 9 f.info.versionMajor = 2 f.info.familyName = "Renamed Open Sans" f.save("test-fonts/OpenSans-Renamed.ttf") g = TTFont("test-fonts/OpenSans-Renamed.ttf") self.assertEqual(f.info.versionMinor, 9) self.assertEqual(f.info.versionMajor, 2) self.assertEqual(f.info.familyName, "Renamed Open Sans")
def test_write_sidebearings2(self): f = TTFont("test-fonts/OpenSans-Regular.ttf") self.assertEqual(f.layers[0]["H"].leftMargin, 201) self.assertEqual(f.layers[0]["H"].rightMargin, 200) f.layers[0]["H"].rightMargin = 52 self.assertEqual(f.layers[0]["H"].leftMargin, 201) self.assertEqual(f.layers[0]["H"].rightMargin, 52) f.layers[0]["H"].leftMargin = 51 self.assertEqual(f.layers[0]["H"].leftMargin, 51) self.assertEqual(f.layers[0]["H"].rightMargin, 52) self.assertEqual(f.layers[0]["H"].width,1213) f.save("OS-H51.ttf") tt = fontTools.ttLib.TTFont("OS-H51.ttf") self.assertEqual(tt["hmtx"]["H"][1], 51) os.unlink("OS-H51.ttf")