예제 #1
0
    def test_find_font_for_language(self):
        font = Font(face_name="")

        # Nearly every font supports Latin script, so this shouldn't fail
        spec = font.findfont(language="Latin")
        self.assertTrue(os.path.exists(spec.filename))

        # There will be warnings for an unknown language
        with self.assertWarns(UserWarning):
            spec = font.findfont(language="FancyTalk")
        self.assertTrue(os.path.exists(spec.filename))
예제 #2
0
    def test_add_application_font(self):
        path = os.path.join(data_dir, "TestTTF.ttf")
        family = "Test TTF"
        kivafont = Font(family)

        # Before adding the font
        with self.assertWarns(UserWarning):
            self.assertNotEqual(kivafont.findfont().filename, path)

        add_application_fonts([path])

        # After adding the font
        self.assertEqual(kivafont.findfont().filename, path)
예제 #3
0
    def test_find_font_some_face_name(self):
        font = Font(face_name="ProbablyNotFound")

        # There will be warnings as there will be no match for the requested
        # face name.
        with self.assertWarns(UserWarning):
            spec = font.findfont()
        self.assertTrue(os.path.exists(spec.filename))
예제 #4
0
 def test_find_font_empty_name(self):
     # This test relies on the fact there exists some fonts on the system
     # that the font manager can load. Ideally we should be able to redirect
     # the path from which the font manager loads font files, then this test
     # can be less fragile.
     font = Font(face_name="")
     spec = font.findfont()
     self.assertTrue(os.path.exists(spec.filename))