Ejemplo n.º 1
0
 def test_get_set_font_style(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     font = sdlttf.open_font(filename, 10)
     self.assertIsInstance(font, sdlttf.TTF_Font)
     self.assertEqual(sdlttf.get_font_style(font), sdlttf.TTF_STYLE_NORMAL)
     sdlttf.set_font_style(font, sdlttf.TTF_STYLE_BOLD)
     self.assertEqual(sdlttf.get_font_style(font), sdlttf.TTF_STYLE_BOLD)
     sdlttf.set_font_style(font, sdlttf.TTF_STYLE_BOLD |
                           sdlttf.TTF_STYLE_ITALIC)
     self.assertEqual(sdlttf.get_font_style(font), sdlttf.TTF_STYLE_BOLD |
                      sdlttf.TTF_STYLE_ITALIC)
     sdlttf.set_font_style(font, sdlttf.TTF_STYLE_BOLD |
                           sdlttf.TTF_STYLE_UNDERLINE)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_style, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_style, "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_style, 1234)
     self.assertRaises(ArgumentError, sdlttf.set_font_style, font, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_style, "test", None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_style, 1234, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_style, "test", 3)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_style, 1234, 4)
     self.assertRaises(ArgumentError, sdlttf.set_font_style, font, "test")
     sdlttf.close_font(font)
Ejemplo n.º 2
0
 def test_font_faces(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     font = sdlttf.open_font(filename, 10)
     self.assertGreaterEqual(sdlttf.font_faces(font), 1)
     self.assertRaises((AttributeError, TypeError), sdlttf.font_faces, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_faces, "test")
     self.assertRaises((AttributeError, TypeError), sdlttf.font_faces, 1234)
     sdlttf.close_font(font)
Ejemplo n.º 3
0
 def test_open_close_font(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     for x in range(-10, 15):
         font = sdlttf.open_font(filename, x)
         self.assertIsInstance(font, sdlttf.TTF_Font)
         sdlttf.close_font(font)
     self.assertRaises(TypeError, sdlttf.open_font, None, None)
     self.assertRaises(TypeError, sdlttf.open_font, filename, None)
     self.assertRaises(ValueError, sdlttf.open_font, filename, "abcd")
     self.assertRaises(ValueError, sdlttf.open_font, None, "abcd")
     self.assertRaises(sdl.SDLError, sdlttf.open_font, "test", 10)
Ejemplo n.º 4
0
 def test_font_face_style_name(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     font = sdlttf.open_font(filename, 10)
     self.assertEqual(sdlttf.font_face_style_name(font), "Regular")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_face_style_name, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_face_style_name, "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_face_style_name, 1234)
     sdlttf.close_font(font)
Ejemplo n.º 5
0
 def test_font_face_is_fixed_width(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     font = sdlttf.open_font(filename, 10)
     self.assertFalse(sdlttf.font_face_is_fixed_width(font))
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_face_is_fixed_width, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_face_is_fixed_width, "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_face_is_fixed_width, 1234)
     sdlttf.close_font(font)
Ejemplo n.º 6
0
 def test_open_font_rw(self):
     fp = RESOURCES.get("tuffy.ttf")
     fontrw = rwops.rw_from_object(fp)
     for x in range(-10, 15):
         fp.seek(0)
         font = sdlttf.open_font_rw(fontrw, False, x)
         self.assertIsInstance(font, sdlttf.TTF_Font)
         sdlttf.close_font(font)
     fp.seek(0)
     self.assertRaises(TypeError, sdlttf.open_font_rw, None, False, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.open_font_rw, None, False, 10)
     self.assertRaises(TypeError, sdlttf.open_font_rw, fontrw, False, None)
Ejemplo n.º 7
0
 def test_font_line_skip(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     last = cur = 0
     for ptsize in range(-10, 10):
         font = sdlttf.open_font(filename, ptsize)
         cur = sdlttf.font_line_skip(font)
         self.assertGreaterEqual(cur, last)
         last = cur
         sdlttf.close_font(font)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_line_skip, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_line_skip, 1234)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.font_line_skip, "test")
Ejemplo n.º 8
0
 def test_get_set_font_outline(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     font = sdlttf.open_font(filename, 10)
     self.assertEqual(sdlttf.get_font_outline(font), 0)
     for x in range(-10, 10):
         sdlttf.set_font_outline(font, x)
         self.assertEqual(sdlttf.get_font_outline(font), x)
     self.assertRaises(TypeError, sdlttf.set_font_outline, None, None)
     self.assertRaises(TypeError, sdlttf.set_font_outline, font, None)
     self.assertRaises(ValueError, sdlttf.set_font_outline, font, "test")
     self.assertRaises(ValueError, sdlttf.set_font_outline, None, "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_outline, None, 123)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_outline, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_outline, None)
     sdlttf.close_font(font)
Ejemplo n.º 9
0
 def test_get_set_font_hinting(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     font = sdlttf.open_font(filename, 10)
     self.assertEqual(sdlttf.get_font_hinting(font),
                      sdlttf.TTF_HINTING_NORMAL)
     for hint in (sdlttf.TTF_HINTING_NORMAL, sdlttf.TTF_HINTING_LIGHT,
                  sdlttf.TTF_HINTING_MONO, sdlttf.TTF_HINTING_NONE):
         sdlttf.set_font_hinting(font, hint)
         self.assertEqual(sdlttf.get_font_hinting(font), hint)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_hinting, None, None)
     self.assertRaises(ArgumentError, sdlttf.set_font_hinting, font, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_hinting, None, 1)
     self.assertRaises(ArgumentError, sdlttf.set_font_hinting, font, "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_hinting, None, "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_hinting, None)
     sdlttf.close_font(font)
Ejemplo n.º 10
0
 def test_get_set_font_kerning(self):
     filename = RESOURCES.get_path("tuffy.ttf")
     font = sdlttf.open_font(filename, 10)
     self.assertEqual(sdlttf.get_font_kerning(font), True)
     sdlttf.set_font_kerning(font, False)
     self.assertEqual(sdlttf.get_font_kerning(font), False)
     sdlttf.set_font_kerning(font, True)
     self.assertEqual(sdlttf.get_font_kerning(font), True)
     sdlttf.set_font_kerning(font, False)
     self.assertEqual(sdlttf.get_font_kerning(font), False)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_kerning, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_kerning, "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.get_font_kerning, 1234)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_kerning, None, None)
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_kerning, "test", "test")
     self.assertRaises((AttributeError, TypeError),
                       sdlttf.set_font_kerning, 1234, None)
     sdlttf.close_font(font)