예제 #1
0
    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")
예제 #2
0
    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")
예제 #3
0
    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")