Commits

Marcus von Appen  committed 241b877

- added SDL2_ttf wrapper sdl2.sdlttf
- fixed surface test for latest SDL2 hg version

  • Participants
  • Parent commits 7042315

Comments (0)

Files changed (4)

File sdl2/sdlttf.py

+import os
+from ctypes import Structure, POINTER, c_int, c_long, c_char_p
+from .dll import _DLL
+from .version import SDL_version
+from .rwops import SDL_RWops
+from .stdinc import Uint16, Uint32
+from .pixels import SDL_Color
+from .surface import SDL_Surface 
+from .error import SDL_GetError, SDL_SetError
+
+__all__= ["get_dll_file", "SDL_TTF_MAJOR_VERSION", "SDL_TTF_MINOR_VERSION",
+          "SDL_TTF_PATCHLEVEL", "SDL_TTF_VERSION", "TTF_MAJOR_VERSION",
+          "TTF_MINOR_VERSION", "TTF_PATCHLEVEL", "TTF_VERSION",
+          "TTF_Linked_Version", "UNICODE_BOM_NATIVE", "UNICODE_BOM_SWAPPED",
+          "TTF_ByteSwappedUNICODE", "TTF_Font", "TTF_Init", "TTF_OpenFont",
+          "TTF_OpenFontIndex", "TTF_OpenFontRW", "TTF_OpenFontIndexRW",
+          "TTF_STYLE_NORMAL", "TTF_STYLE_BOLD", "TTF_STYLE_ITALIC",
+          "TTF_STYLE_UNDERLINE", "TTF_STYLE_STRIKETHROUGH", "TTF_GetFontStyle",
+          "TTF_SetFontStyle", "TTF_GetFontOutline", "TTF_SetFontOutline",
+          "TTF_HINTING_NORMAL", "TTF_HINTING_LIGHT", "TTF_HINTING_MONO",
+          "TTF_HINTING_NONE", "TTF_GetFontHinting", "TTF_SetFontHinting",
+          "TTF_FontHeight", "TTF_FontAscent", "TTF_FontDescent",
+          "TTF_FontLineSkip", "TTF_GetFontKerning", "TTF_SetFontKerning",
+          "TTF_FontFaces", "TTF_FontFaceIsFixedWidth", "TTF_FontFaceFamilyName",
+          "TTF_FontFaceStyleName", "TTF_GlyphIsProvided", "TTF_GlyphMetrics",
+          "TTF_SizeText", "TTF_SizeUTF8", "TTF_SizeUNICODE",
+          "TTF_RenderText_Solid", "TTF_RenderUTF8_Solid",
+          "TTF_RenderUNICODE_Solid", "TTF_RenderGlyph_Solid",
+          "TTF_RenderText_Shaded", "TTF_RenderUTF8_Shaded",
+          "TTF_RenderUNICODE_Shaded", "TTF_RenderGlyph_Shaded",
+          "TTF_RenderText_Blended", "TTF_RenderUTF8_Blended",
+          "TTF_RenderUNICODE_Blended", "TTF_RenderText_Blended_Wrapped",
+          "TTF_RenderUTF8_Blended_Wrapped", "TTF_RenderUNICODE_Blended_Wrapped",
+          "TTF_RenderGlyph_Blended", "TTF_RenderText", "TTF_RenderUTF",
+          "TTF_RenderUNICODE", "TTF_CloseFont", "TTF_Quit", "TTF_WasInit",
+          "TTF_GetFontKerningSize", "TTF_SetError", "TTF_GetError"
+          ]
+
+dll = _DLL("SDL2_ttf", ["SDL2_ttf", "SDL2_ttf-2.0"],
+           os.getenv("PYSDL2_DLL_PATH"))
+
+def get_dll_file():
+    """Gets the file name of the loaded SDL2 library."""
+    return dll.libfile
+
+_bind = dll.bind_function
+
+SDL_TTF_MAJOR_VERSION = 2
+SDL_TTF_MINOR_VERSION = 0
+SDL_TTF_PATCHLEVEL = 12
+
+def SDL_TTF_VERSION(x):
+    x.major = SDL_TTF_MAJOR_VERSION
+    x.minor = SDL_TTF_MINOR_VERSION
+    x.patch = SDL_TTF_PATCHLEVEL
+
+TTF_MAJOR_VERSION = SDL_TTF_MAJOR_VERSION
+TTF_MINOR_VERSION = SDL_TTF_MINOR_VERSION
+TTF_PATCHLEVEL = SDL_TTF_PATCHLEVEL
+TTF_VERSION = SDL_TTF_VERSION
+
+TTF_Linked_Version = _bind("TTF_Linked_Version", None, POINTER(SDL_version))
+UNICODE_BOM_NATIVE = 0xFEFF
+UNICODE_BOM_SWAPPED = 0xFFFE
+
+TTF_ByteSwappedUNICODE = _bind("TTF_ByteSwappedUNICODE", [c_int])
+
+class TTF_Font(Structure):
+    pass
+
+TTF_Init = _bind("TTF_Init", None, c_int)
+TTF_OpenFont = _bind("TTF_OpenFont", [c_char_p, c_int], POINTER(TTF_Font))
+TTF_OpenFontIndex = _bind("TTF_OpenFontIndex", [c_char_p, c_int, c_long], POINTER(TTF_Font))
+TTF_OpenFontRW = _bind("TTF_OpenFontRW", [POINTER(SDL_RWops), c_int, c_int], POINTER(TTF_Font))
+TTF_OpenFontIndexRW = _bind("TTF_OpenFontIndexRW", [POINTER(SDL_RWops), c_int, c_int, c_long], POINTER(TTF_Font))
+
+TTF_STYLE_NORMAL = 0x00
+TTF_STYLE_BOLD = 0x01
+TTF_STYLE_ITALIC = 0x02
+TTF_STYLE_UNDERLINE = 0x04
+TTF_STYLE_STRIKETHROUGH = 0x08
+TTF_GetFontStyle = _bind("TTF_GetFontStyle", [POINTER(TTF_Font)], c_int)
+TTF_SetFontStyle = _bind("TTF_SetFontStyle", [POINTER(TTF_Font), c_int])
+TTF_GetFontOutline = _bind("TTF_GetFontOutline", [POINTER(TTF_Font)], c_int)
+TTF_SetFontOutline = _bind("TTF_SetFontOutline", [POINTER(TTF_Font), c_int])
+
+TTF_HINTING_NORMAL = 0
+TTF_HINTING_LIGHT = 1
+TTF_HINTING_MONO = 2
+TTF_HINTING_NONE = 3
+TTF_GetFontHinting = _bind("TTF_GetFontHinting", [POINTER(TTF_Font)], c_int)
+TTF_SetFontHinting = _bind("TTF_SetFontHinting", [POINTER(TTF_Font), c_int])
+
+TTF_FontHeight = _bind("TTF_FontHeight", [POINTER(TTF_Font)], c_int)
+TTF_FontAscent = _bind("TTF_FontAscent", [POINTER(TTF_Font)], c_int)
+TTF_FontDescent = _bind("TTF_FontDescent", [POINTER(TTF_Font)], c_int)
+TTF_FontLineSkip = _bind("TTF_FontLineSkip", [POINTER(TTF_Font)], c_int)
+TTF_GetFontKerning = _bind("TTF_GetFontKerning", [POINTER(TTF_Font)], c_int)
+TTF_SetFontKerning = _bind("TTF_SetFontKerning", [POINTER(TTF_Font), c_int])
+TTF_FontFaces = _bind("TTF_FontFaces", [POINTER(TTF_Font)], c_long)
+TTF_FontFaceIsFixedWidth = _bind("TTF_FontFaceIsFixedWidth", [POINTER(TTF_Font)], c_int)
+TTF_FontFaceFamilyName = _bind("TTF_FontFaceFamilyName", [POINTER(TTF_Font)], c_char_p)
+TTF_FontFaceStyleName = _bind("TTF_FontFaceStyleName", [POINTER(TTF_Font)], c_char_p)
+TTF_GlyphIsProvided = _bind("TTF_GlyphIsProvided", [POINTER(TTF_Font), Uint16], c_int)
+TTF_GlyphMetrics = _bind("TTF_GlyphMetrics", [POINTER(TTF_Font), Uint16, POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int), POINTER(c_int)], c_int)
+TTF_SizeText = _bind("TTF_SizeText", [POINTER(TTF_Font), c_char_p, POINTER(c_int), POINTER(c_int)], c_int)
+TTF_SizeUTF8 = _bind("TTF_SizeUTF8", [POINTER(TTF_Font), c_char_p, POINTER(c_int), POINTER(c_int)], c_int)
+TTF_SizeUNICODE = _bind("TTF_SizeUNICODE", [POINTER(TTF_Font), POINTER(Uint16), POINTER(c_int), POINTER(c_int)], c_int)
+TTF_RenderText_Solid = _bind("TTF_RenderText_Solid", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderUTF8_Solid = _bind("TTF_RenderUTF8_Solid", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderUNICODE_Solid = _bind("TTF_RenderUNICODE_Solid", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color], POINTER(SDL_Surface))
+TTF_RenderGlyph_Solid = _bind("TTF_RenderGlyph_Solid", [POINTER(TTF_Font), Uint16, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderText_Shaded = _bind("TTF_RenderText_Shaded", [POINTER(TTF_Font), c_char_p, SDL_Color, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderUTF8_Shaded = _bind("TTF_RenderUTF8_Shaded", [POINTER(TTF_Font), c_char_p, SDL_Color, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderUNICODE_Shaded = _bind("TTF_RenderUNICODE_Shaded", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderGlyph_Shaded = _bind("TTF_RenderGlyph_Shaded", [POINTER(TTF_Font), Uint16, SDL_Color, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderText_Blended = _bind("TTF_RenderText_Blended", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderUTF8_Blended = _bind("TTF_RenderUTF8_Blended", [POINTER(TTF_Font), c_char_p, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderUNICODE_Blended = _bind("TTF_RenderUNICODE_Blended", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color], POINTER(SDL_Surface))
+TTF_RenderText_Blended_Wrapped = _bind("TTF_RenderText_Blended_Wrapped", [POINTER(TTF_Font), c_char_p, SDL_Color, Uint32], POINTER(SDL_Surface))
+TTF_RenderUTF8_Blended_Wrapped = _bind("TTF_RenderUTF8_Blended_Wrapped", [POINTER(TTF_Font), c_char_p, SDL_Color, Uint32], POINTER(SDL_Surface))
+TTF_RenderUNICODE_Blended_Wrapped = _bind("TTF_RenderUNICODE_Blended_Wrapped", [POINTER(TTF_Font), POINTER(Uint16), SDL_Color, Uint32], POINTER(SDL_Surface))
+TTF_RenderGlyph_Blended = _bind("TTF_RenderGlyph_Blended", [POINTER(TTF_Font), Uint16, SDL_Color], POINTER(SDL_Surface))
+TTF_RenderText = TTF_RenderText_Shaded
+TTF_RenderUTF = TTF_RenderUTF8_Shaded
+TTF_RenderUNICODE = TTF_RenderUNICODE_Shaded
+TTF_CloseFont = _bind("TTF_CloseFont", [POINTER(TTF_Font)])
+TTF_Quit = _bind("TTF_Quit") 
+TTF_WasInit = _bind("TTF_WasInit", None, c_int) 
+TTF_GetFontKerningSize = _bind("TTF_GetFontKerningSize", [POINTER(TTF_Font), c_int, c_int], c_int)
+TTF_SetError = SDL_SetError
+TTF_GetError = SDL_GetError
+

File sdl2/test/resources/tuffy.ttf

Binary file added.

File sdl2/test/sdlttf_test.py

+import os
+import sys
+import unittest
+from ctypes import ArgumentError
+from .. import SDL_Init, SDL_Quit, sdlttf, rwops, pixels
+
+fontfile = os.path.join(os.path.dirname(os.path.abspath(__file__)), "resources", "tuffy.ttf").encode("utf-8")
+
+class SDLTTFTest(unittest.TestCase):
+    __tags__ = ["sdl", "sdlttf"]
+
+    def setUp(self):
+        SDL_Init(0)
+        sdlttf.TTF_Init()
+
+    def tearDown(self):
+        SDL_Quit()
+        sdlttf.TTF_Quit()
+
+    def test_TTF_Font(self):
+        font = sdlttf.TTF_Font()
+        self.assertIsInstance(font, sdlttf.TTF_Font)
+
+    def test_TTF_InitQuit(self):
+        sdlttf.TTF_Init()
+        sdlttf.TTF_Init()
+        sdlttf.TTF_Init()
+        sdlttf.TTF_Quit()
+        sdlttf.TTF_Quit()
+        sdlttf.TTF_Init()
+
+    def test_TTF_OpenCloseFont(self):
+        for x in range(-10, 15):
+            font = sdlttf.TTF_OpenFont(fontfile, x)
+            self.assertIsInstance(font.contents, sdlttf.TTF_Font)
+            sdlttf.TTF_CloseFont(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)
+
+    def test_TTF_OpenFontIndex(self):
+        for x in range(-10, 15):
+            font = sdlttf.TTF_OpenFontIndex(fontfile, x, 0)
+            self.assertIsInstance(font.contents, sdlttf.TTF_Font)
+            sdlttf.TTF_CloseFont(font)
+        #self.assertRaises(TypeError, sdlttf.open_font_index, None, None, None)
+        #self.assertRaises(TypeError, sdlttf.open_font_index, filename, None,
+        #                  None)
+        #self.assertRaises(TypeError, sdlttf.open_font_index, filename, 10,
+        #                  None)
+        #self.assertRaises(TypeError, sdlttf.open_font_index, filename, None, 0)
+        #self.assertRaises(TypeError, sdlttf.open_font_index, filename, None, 0)
+        #self.assertRaises(ValueError, sdlttf.open_font_index, filename, 10, -2)
+        #self.assertRaises(sdl.SDLError, sdlttf.open_font_index, "test", 10, 0)
+
+    def test_TTF_OpenFontRW(self):
+        fp = open(fontfile, "rb")
+        fontrw = rwops.rw_from_object(fp)
+        for x in range(-10, 15):
+            fp.seek(0)
+            font = sdlttf.TTF_OpenFontRW(fontrw, 0, x)
+            self.assertIsInstance(font.contents, sdlttf.TTF_Font)
+            sdlttf.TTF_CloseFont(font)
+        fp.close()
+        #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)
+
+    def test_TTF_OpenFontIndexRW(self):
+        fp = open(fontfile, "rb")
+        fontrw = rwops.rw_from_object(fp)
+        for x in range(-10, 15):
+            fp.seek(0)
+            font = sdlttf.TTF_OpenFontIndexRW(fontrw, 0, x, 0)
+            self.assertIsInstance(font.contents, sdlttf.TTF_Font)
+            sdlttf.TTF_CloseFont(font)
+        fp.close()
+        #self.assertRaises(TypeError, sdlttf.open_font_index_rw, None, False,
+        #                  None, None)
+        #self.assertRaises(TypeError, sdlttf.open_font_index_rw, None, False,
+        #                 10, None)
+        #self.assertRaises(TypeError, sdlttf.open_font_index_rw, None, False,
+        #                  None, 0)
+        #self.assertRaises(TypeError, sdlttf.open_font_index_rw, fontrw, False,
+        #                  None, 0)
+        #self.assertRaises(TypeError, sdlttf.open_font_index_rw, fontrw, False,
+        #                  10, None)
+
+    def test_TTF_GetSetFontStyle(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertIsInstance(font.contents, sdlttf.TTF_Font)
+        self.assertEqual(sdlttf.TTF_GetFontStyle(font), sdlttf.TTF_STYLE_NORMAL)
+        sdlttf.TTF_SetFontStyle(font, sdlttf.TTF_STYLE_BOLD)
+        self.assertEqual(sdlttf.TTF_GetFontStyle(font), sdlttf.TTF_STYLE_BOLD)
+        sdlttf.TTF_SetFontStyle(font, sdlttf.TTF_STYLE_BOLD |
+                                sdlttf.TTF_STYLE_ITALIC)
+        self.assertEqual(sdlttf.TTF_GetFontStyle(font), sdlttf.TTF_STYLE_BOLD |
+                         sdlttf.TTF_STYLE_ITALIC)
+        sdlttf.TTF_SetFontStyle(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.TTF_CloseFont(font)
+
+    def test_TTF_GetSetFontOutline(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertEqual(sdlttf.TTF_GetFontOutline(font), 0)
+        for x in range(-10, 10):
+            sdlttf.TTF_SetFontOutline(font, x)
+            self.assertEqual(sdlttf.TTF_GetFontOutline(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.TTF_CloseFont(font)
+
+    def test_TTF_GetSetFontHinting(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertEqual(sdlttf.TTF_GetFontHinting(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.TTF_SetFontHinting(font, hint)
+            self.assertEqual(sdlttf.TTF_GetFontHinting(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.TTF_CloseFont(font)
+
+    def test_TTF_FontHeight(self):
+        last = cur = 0
+        for ptsize in range(-10, 10):
+            font = sdlttf.TTF_OpenFont(fontfile, ptsize)
+            cur = sdlttf.TTF_FontHeight(font)
+            self.assertGreaterEqual(cur, last)
+            last = cur
+            sdlttf.TTF_CloseFont(font)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_height, None)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_height, 1234)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_height, "test")
+
+    def test_TTF_FontAscent(self):
+        last = cur = 0
+        for ptsize in range(-10, 10):
+            font = sdlttf.TTF_OpenFont(fontfile, ptsize)
+            cur = sdlttf.TTF_FontAscent(font)
+            self.assertGreaterEqual(cur, last)
+            last = cur
+            sdlttf.TTF_CloseFont(font)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_ascent, None)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_ascent, 1234)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_ascent, "test")
+
+    def test_TTF_FontDescent(self):
+        last = cur = 0
+        for ptsize in range(-10, 10):
+            font = sdlttf.TTF_OpenFont(fontfile, ptsize)
+            cur = sdlttf.TTF_FontDescent(font)
+            self.assertLessEqual(cur, last)
+            last = cur
+            sdlttf.TTF_CloseFont(font)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_descent, None)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_descent, 1234)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_descent, "test")
+
+    def test_TTF_FontLineSkip(self):
+        last = cur = 0
+        for ptsize in range(-10, 10):
+            font = sdlttf.TTF_OpenFont(fontfile, ptsize)
+            cur = sdlttf.TTF_FontLineSkip(font)
+            self.assertGreaterEqual(cur, last)
+            last = cur
+            sdlttf.TTF_CloseFont(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")
+
+    def test_TTF_GetSetFontKerning(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertEqual(sdlttf.TTF_GetFontKerning(font), 1)
+        sdlttf.TTF_SetFontKerning(font, 0)
+        self.assertEqual(sdlttf.TTF_GetFontKerning(font), 0)
+        sdlttf.TTF_SetFontKerning(font, 1)
+        self.assertEqual(sdlttf.TTF_GetFontKerning(font), 1)
+        sdlttf.TTF_SetFontKerning(font, 0)
+        self.assertEqual(sdlttf.TTF_GetFontKerning(font), 0)
+#        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.TTF_CloseFont(font)
+
+    def test_TTF_FontFaces(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertGreaterEqual(sdlttf.TTF_FontFaces(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.TTF_CloseFont(font)
+
+    def test_TTF_FontFaceIsFixedWidth(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertFalse(sdlttf.TTF_FontFaceIsFixedWidth(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.TTF_CloseFont(font)
+
+    def test_TTF_FontFaceFamilyName(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertEqual(sdlttf.TTF_FontFaceFamilyName(font), b"Tuffy")
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_face_family_name, None)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_face_family_name, "test")
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.font_face_family_name, 1234)
+        sdlttf.TTF_CloseFont(font)
+
+    def test_TTF_FontFaceStyleName(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertEqual(sdlttf.TTF_FontFaceStyleName(font), b"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.TTF_CloseFont(font)
+
+    def test_TTF_GlyphIsProvided(self):
+        font = sdlttf.TTF_OpenFont(fontfile, 10)
+        self.assertIsInstance(font.contents, sdlttf.TTF_Font)
+        for ch in range(32, 127):
+            self.assertTrue(sdlttf.TTF_GlyphIsProvided(font, ch))
+        self.assertFalse(sdlttf.TTF_GlyphIsProvided(font, 0))
+        self.assertFalse(sdlttf.TTF_GlyphIsProvided(font, 0x0ff9))
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.glyph_is_provided, None, None)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.glyph_is_provided, "test", None)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.glyph_is_provided, "test", 1234)
+#        self.assertRaises((ArgumentError, TypeError),
+#                          sdlttf.glyph_is_provided, font, None)
+#        self.assertRaises((AttributeError, TypeError),
+#                          sdlttf.glyph_is_provided, font, "test")
+
+    @unittest.skip("not implemented")
+    def test_TTF_GlyphMetrics(self):
+        pass
+
+
+if __name__ == '__main__':
+    sys.exit(unittest.main())

File sdl2/test/surface_test.py

             surface.SDL_FreeSurface(sf)
 
     def test_SDL_GetSetClipRect(self):
-        rectlist = ((rect.SDL_Rect(0, 0, 0, 0), SDL_FALSE, False),
+        rectlist = ((rect.SDL_Rect(0, 0, 0, 0), SDL_FALSE, True),
                     (rect.SDL_Rect(2, 2, 0, 0), SDL_FALSE, False),
                     (rect.SDL_Rect(2, 2, 5, 1), SDL_TRUE, True),
                     (rect.SDL_Rect(6, 5, 10, 3), SDL_TRUE, False),