Commits

Anonymous committed 31383e1

Renamed PyFont to PySDLFont_TTF and PyGenericFont to PyFont.

Comments (0)

Files changed (8)

src/base/basemod.c

         MODINIT_RETURN(NULL);
     if (PyType_Ready (&PySurface_Type) < 0)
         MODINIT_RETURN(NULL);
-    if (PyType_Ready(&PyGenericFont_Type) < 0)
+    if (PyType_Ready(&PyFont_Type) < 0)
         MODINIT_RETURN(NULL);
 
     Py_INCREF (&PyColor_Type);
     Py_INCREF (&PyRect_Type);
     Py_INCREF (&PyBufferProxy_Type);
     Py_INCREF (&PySurface_Type);
-    Py_INCREF (&PyGenericFont_Type);
+    Py_INCREF (&PyFont_Type);
 
 #ifdef IS_PYTHON_3
     mod = PyModule_Create (&_basemodule);
     PyModule_AddObject (mod, "FRect", (PyObject *) &PyFRect_Type);
     PyModule_AddObject (mod, "BufferProxy", (PyObject *) &PyBufferProxy_Type);
     PyModule_AddObject (mod, "Surface", (PyObject *) &PySurface_Type);
-    PyModule_AddObject (mod, "Font", (PyObject *) &PyGenericFont_Type);
+    PyModule_AddObject (mod, "Font", (PyObject *) &PyFont_Type);
     
     /* Setup the pygame exeption */
     PyExc_PyGameError = PyErr_NewException ("base.Error", NULL, NULL);
 
 static PyObject* _font_new(PyTypeObject *type, PyObject *args, PyObject *kwds);
 static int _font_init(PyObject *cursor, PyObject *args, PyObject *kwds);
-static void _font_dealloc(PyGenericFont *self);
+static void _font_dealloc(PyFont *self);
 static PyObject* _font_repr(PyObject *self);
 
 
 /*
  * TYPE OBJECT TABLE
  */
-PyTypeObject PyGenericFont_Type =
+PyTypeObject PyFont_Type =
 {
     TYPE_HEAD(NULL, 0)
     "base.Font",                /* tp_name */
-    sizeof (PyGenericFont),            /* tp_basicsize */
+    sizeof (PyFont),            /* tp_basicsize */
     0,                          /* tp_itemsize */
     (destructor) _font_dealloc, /* tp_dealloc */
     0,                          /* tp_print */
 static PyObject*
 _font_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    PyGenericFont *font = (PyGenericFont *)type->tp_alloc(type, 0);
+    PyFont *font = (PyFont *)type->tp_alloc(type, 0);
 
     if (!font)
         return NULL;
 }
 
 static void
-_font_dealloc(PyGenericFont *self)
+_font_dealloc(PyFont *self)
 {
     ((PyObject*)self)->ob_type->tp_free((PyObject *)self);
 }
 static PyObject*
 _font_getheight(PyObject *self, void *closure)
 {
-    if (((PyGenericFont *)self)->get_height &&
-        ((PyGenericFont *)self)->get_height != _def_f_getheight)
-        return ((PyGenericFont *)self)->get_height(self, closure);
+    if (((PyFont *)self)->get_height &&
+        ((PyFont *)self)->get_height != _def_f_getheight)
+        return ((PyFont *)self)->get_height(self, closure);
 
     PyErr_SetString(PyExc_NotImplementedError,
         "height attribute not implemented");
 static PyObject*
 _font_getsize(PyObject *self, void *closure)
 {
-    if (((PyGenericFont *)self)->get_size &&
-        ((PyGenericFont *)self)->get_size != _def_f_getsize)
-        return ((PyGenericFont *)self)->get_size (self, closure);
+    if (((PyFont *)self)->get_size &&
+        ((PyFont *)self)->get_size != _def_f_getsize)
+        return ((PyFont *)self)->get_size (self, closure);
 
     PyErr_SetString (PyExc_NotImplementedError,
         "size attribute not implemented");
 static PyObject*
 _font_getname(PyObject *self, void *closure)
 {
-    if (((PyGenericFont *)self)->get_name &&
-        ((PyGenericFont *)self)->get_name != _def_f_getname)
-        return ((PyGenericFont *)self)->get_name(self, closure);
+    if (((PyFont *)self)->get_name &&
+        ((PyFont *)self)->get_name != _def_f_getname)
+        return ((PyFont *)self)->get_name(self, closure);
 
     PyErr_SetString (PyExc_NotImplementedError,
         "name attribute not implemented");
 static PyObject*
 _font_getstyle(PyObject *self, void *closure)
 {
-    if (((PyGenericFont *)self)->get_style &&
-        ((PyGenericFont *)self)->get_style != _def_f_getstyle)
-        return ((PyGenericFont *)self)->get_style(self, closure);
+    if (((PyFont *)self)->get_style &&
+        ((PyFont *)self)->get_style != _def_f_getstyle)
+        return ((PyFont *)self)->get_style(self, closure);
 
     PyErr_SetString (PyExc_NotImplementedError,
         "style attribute not implemented");
 static int
 _font_setstyle(PyObject *self, PyObject *args, void *closure)
 {
-    if (((PyGenericFont *)self)->set_style &&
-        ((PyGenericFont *)self)->set_style != _def_f_setstyle)
-        return ((PyGenericFont *)self)->set_style(self, args, closure);
+    if (((PyFont *)self)->set_style &&
+        ((PyFont *)self)->set_style != _def_f_setstyle)
+        return ((PyFont *)self)->set_style(self, args, closure);
 
     PyErr_SetString (PyExc_NotImplementedError,
         "style attribute not implemented");
 static PyObject*
 _font_render(PyObject* self, PyObject *args, PyObject *kwds)
 {
-    if (((PyGenericFont *)self)->render && ((PyGenericFont *)self)->render != _def_f_render)
-        return ((PyGenericFont *)self)->render(self, args, kwds);
+    if (((PyFont *)self)->render && ((PyFont *)self)->render != _def_f_render)
+        return ((PyFont *)self)->render(self, args, kwds);
 
     PyErr_SetString(PyExc_NotImplementedError, "render method not implemented");
 
 static PyObject*
 _font_copy(PyObject* self)
 {
-    if (((PyGenericFont *)self)->copy && ((PyGenericFont *)self)->copy != _def_f_copy)
-        return ((PyGenericFont *)self)->copy (self);
+    if (((PyFont *)self)->copy && ((PyFont *)self)->copy != _def_f_copy)
+        return ((PyFont *)self)->copy (self);
 
     PyErr_SetString(PyExc_NotImplementedError, "copy method not implemented");
 
 
 /* C API */
 PyObject*
-PyGenericFont_New(void)
+PyFont_New(void)
 {
-    return PyGenericFont_Type.tp_new(&PyGenericFont_Type, NULL, NULL);
+    return PyFont_Type.tp_new(&PyFont_Type, NULL, NULL);
 }
 
 void
 font_export_capi(void **capi)
 {
-    capi[PYGAME_FONT_FIRSTSLOT + 0] = &PyGenericFont_Type;
-    capi[PYGAME_FONT_FIRSTSLOT + 1] = PyGenericFont_New;
+    capi[PYGAME_FONT_FIRSTSLOT + 0] = &PyFont_Type;
+    capi[PYGAME_FONT_FIRSTSLOT + 1] = PyFont_New;
 }

src/base/internals.h

 PyObject* PySurface_New (void);
 void surface_export_capi (void **capi);
 
-extern PyTypeObject PyGenericFont_Type;
-#define PyGenericFont_Check(x) (PyObject_TypeCheck(x, &PyGenericFont_Type))
-PyObject* PyGenericFont_New(void);
+extern PyTypeObject PyFont_Type;
+#define PyFont_Check(x) (PyObject_TypeCheck(x, &PyFont_Type))
+PyObject* PyFont_New(void);
 void font_export_capi(void **capi);
 
 #endif /* _PYGAME_BASE_INTERNALS_H_ */

src/base/pgbase.h

 
     PyObject* (*render)(PyObject *self, PyObject *args, PyObject *kwds);
     PyObject* (*copy)(PyObject *self);
-} PyGenericFont;
+} PyFont;
 
 #define PYGAME_FONT_FIRSTSLOT   \
     (PYGAME_SURFACE_FIRSTSLOT + PYGAME_SURFACE_NUMSLOTS)
 #define PYGAME_FONT_NUMSLOTS 2
 
 #ifndef PYGAME_FONT_INTERNAL
-#define PyGenericFont_Type \
+#define PyFont_Type \
     (*(PyTypeObject*)PyGameBase_C_API[PYGAME_FONT_FIRSTSLOT+0])
-#define PyGenericFont_Check(x) \
+#define PyFont_Check(x) \
     (PyObject_TypeCheck(x, \
         (PyTypeObject*)PyGameBase_C_API[PYGAME_FONT_FIRSTSLOT+0]))
-#define PyGenericFont_New \
+#define PyFont_New \
     (*(PyObject*(*)(void))PyGameBase_C_API[PYGAME_FONT_FIRSTSLOT+1])
 #endif /* PYGAME_FONT_INTERNAL */
 

src/sdlttf/font.c

 
 static PyObject *_font_new (PyTypeObject *type, PyObject *args, PyObject *kwds);
 static int _font_init (PyObject *chunk, PyObject *args, PyObject *kwds);
-static void _font_dealloc (PyFont *self);
+static void _font_dealloc (PySDLFont_TTF *self);
 
 static PyObject* _font_glyphmetrics (PyObject *self, PyObject* args);
 static PyObject* _font_getsize (PyObject *self, PyObject* args);
 
 /**
  */
-PyTypeObject PyFont_Type =
+PyTypeObject PySDLFont_TTF_Type =
 {
     TYPE_HEAD(NULL,0)
     "sdlttf.Font",              /* tp_name */
-    sizeof (PyFont),            /* tp_basicsize */
+    sizeof (PySDLFont_TTF),            /* tp_basicsize */
     0,                          /* tp_itemsize */
     (destructor) _font_dealloc, /* tp_dealloc */
     0,                          /* tp_print */
 };
 
 static void
-_font_dealloc (PyFont *self)
+_font_dealloc (PySDLFont_TTF *self)
 {
     TTF_CloseFont (self->font);
     ((PyObject*)self)->ob_type->tp_free ((PyObject *) self);
 static PyObject*
 _font_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
-    PyFont *font = (PyFont*) type->tp_alloc (type, 0);
+    PySDLFont_TTF *font = (PySDLFont_TTF*) type->tp_alloc (type, 0);
     if (!font)
         return NULL;
     font->font = NULL;
         PyErr_SetString (PyExc_PyGameError, TTF_GetError ());
         return -1;
     }
-    ((PyFont*)self)->font = font;
+    ((PySDLFont_TTF*)self)->font = font;
     return 0;
 }
 
 _font_getstyle (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return PyInt_FromLong (TTF_GetFontStyle (((PyFont*)self)->font));
+    return PyInt_FromLong (TTF_GetFontStyle (((PySDLFont_TTF*)self)->font));
 }
 
 static int
     if (!IntFromObj (value, &style))
         return -1;
     
-    TTF_SetFontStyle (((PyFont*)self)->font, style);
+    TTF_SetFontStyle (((PySDLFont_TTF*)self)->font, style);
     return 0;
 }
 
 _font_getheight (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return PyInt_FromLong (TTF_FontHeight (((PyFont*)self)->font));
+    return PyInt_FromLong (TTF_FontHeight (((PySDLFont_TTF*)self)->font));
 }
 
 static PyObject*
 _font_getascent (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return PyInt_FromLong (TTF_FontAscent (((PyFont*)self)->font));
+    return PyInt_FromLong (TTF_FontAscent (((PySDLFont_TTF*)self)->font));
 }
 
 static PyObject*
 _font_getdescent (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return PyInt_FromLong (TTF_FontDescent (((PyFont*)self)->font));
+    return PyInt_FromLong (TTF_FontDescent (((PySDLFont_TTF*)self)->font));
 }
 
 static PyObject*
 _font_getlineskip (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return PyInt_FromLong (TTF_FontLineSkip (((PyFont*)self)->font));
+    return PyInt_FromLong (TTF_FontLineSkip (((PySDLFont_TTF*)self)->font));
 }
 
 static PyObject*
 _font_getfaces (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return PyLong_FromLong (TTF_FontFaces (((PyFont*)self)->font));
+    return PyLong_FromLong (TTF_FontFaces (((PySDLFont_TTF*)self)->font));
 }
 
 static PyObject*
 _font_getisfixedwidth (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return PyBool_FromLong (TTF_FontFaceIsFixedWidth (((PyFont*)self)->font));
+    return PyBool_FromLong (TTF_FontFaceIsFixedWidth (((PySDLFont_TTF*)self)->font));
 }
 
 static PyObject*
 _font_getfamilyname (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return Text_FromUTF8 (TTF_FontFaceFamilyName (((PyFont*)self)->font));
+    return Text_FromUTF8 (TTF_FontFaceFamilyName (((PySDLFont_TTF*)self)->font));
 }
 
 static PyObject*
 _font_getstylename (PyObject *self, void *closure)
 {
     ASSERT_TTF_INIT (NULL);
-    return Text_FromUTF8 (TTF_FontFaceStyleName (((PyFont*)self)->font));
+    return Text_FromUTF8 (TTF_FontFaceStyleName (((PySDLFont_TTF*)self)->font));
 }
 
 /* Methods */
 static PyObject*
 _font_glyphmetrics (PyObject *self, PyObject* args)
 {
-    PyFont *font = (PyFont*) self;
+    PySDLFont_TTF *font = (PySDLFont_TTF*) self;
     int minx, miny, maxx, maxy, advance, isunicode = 0, i;
     PyObject *textobj, *list;
     Py_ssize_t length;
 static PyObject*
 _font_getsize (PyObject *self, PyObject* args)
 {
-    PyFont *font = (PyFont*) self;
+    PySDLFont_TTF *font = (PySDLFont_TTF*) self;
     PyObject *text;
     int w, h;
     
 static PyObject*
 _font_render (PyObject *self, PyObject* args, PyObject *kwds)
 {
-    PyFont *font = (PyFont*) self;
+    PySDLFont_TTF *font = (PySDLFont_TTF*) self;
     PyObject *text, *colorfg, *pysurf, *colorbg = NULL;
     SDL_Surface *surface = NULL;
     SDL_Color fgcolor, bgcolor;
 
 /* C API */
 PyObject*
-PyFont_New (char *file, int ptsize)
+PySDLFont_TTF_New (char *file, int ptsize)
 {
-    PyFont *font;
+    PySDLFont_TTF *font;
     TTF_Font *ttf;
 
     ASSERT_TTF_INIT (NULL);
     if (!file)
         return NULL;
 
-    font = (PyFont*) PyFont_Type.tp_new (&PyFont_Type, NULL, NULL);
+    font = (PySDLFont_TTF*) PySDLFont_TTF_Type.tp_new (&PySDLFont_TTF_Type, NULL, NULL);
     if (!font)
         return NULL;
 
 void
 font_export_capi (void **capi)
 {
-    capi[PYGAME_SDLTTFFONT_FIRSTSLOT] = &PyFont_Type;
-    capi[PYGAME_SDLTTFFONT_FIRSTSLOT+1] = &PyFont_New;
+    capi[PYGAME_SDLTTFFONT_FIRSTSLOT] = &PySDLFont_TTF_Type;
+    capi[PYGAME_SDLTTFFONT_FIRSTSLOT+1] = &PySDLFont_TTF_New;
 }

src/sdlttf/pgttf.h

 {
     PyObject_HEAD
     TTF_Font *font;
-} PyFont;
-#define PyFont_AsFont(x) (((PyFont*)x)->font)
+} PySDLFont_TTF;
+#define PySDLFont_TTF_AsFont(x) (((PySDLFont_TTF*)x)->font)
 #define PYGAME_SDLTTFFONT_FIRSTSLOT \
     (PYGAME_SDLTTF_FIRSTSLOT + PYGAME_SDLTTF_NUMSLOTS)
 #define PYGAME_SDLTTFFONT_NUMSLOTS 1
 #ifndef PYGAME_SDLTTFFONT_INTERNAL
-#define PyFont_Type \
+#define PySDLFont_TTF_Type \
     (*(PyTypeObject*)PyGameSDLTTF_C_API[PYGAME_SDLTTFFONT_FIRSTSLOT+0])
-#define PyFont_Check(x)                                                 \
+#define PySDLFont_TTF_Check(x)                                                 \
     (PyObject_TypeCheck(x,                                              \
         (PyTypeObject*)PyGameSDLTTF_C_API[PYGAME_SDLTTFFONT_FIRSTSLOT+0]))
-#define PyFont_New                                                   \
+#define PySDLFont_TTF_New                                                   \
     (*(PyObject*(*)(char*,int))PyGameSDLTTF_C_API[PYGAME_SDLTTFFONT_FIRSTSLOT+1])
 #endif /* PYGAME_SDLTTFFONT_INTERNAL */
 

src/sdlttf/ttfmod.c

     };
 #endif
 
-    if (PyType_Ready (&PyFont_Type) < 0)
+    if (PyType_Ready (&PySDLFont_TTF_Type) < 0)
         goto fail;
 
-    Py_INCREF (&PyFont_Type);
+    Py_INCREF (&PySDLFont_TTF_Type);
 
 #ifdef IS_PYTHON_3
     mod = PyModule_Create (&_module);
     if (!mod)
         goto fail;
     
-    PyModule_AddObject (mod, "Font", (PyObject *) &PyFont_Type);
+    PyModule_AddObject (mod, "Font", (PyObject *) &PySDLFont_TTF_Type);
 
     /* Export C API */
     font_export_capi (c_api);

src/sdlttf/ttfmod.h

 #define RENDER_SHADED 1
 #define RENDER_BLENDED 2
 
-extern PyTypeObject PyFont_Type;
-#define PyFont_Check(x) (PyObject_TypeCheck (x, &PyFont_Type))
-PyObject* PyFont_New (char *file, int ptsize);
+extern PyTypeObject PySDLFont_TTF_Type;
+#define PySDLFont_TTF_Check(x) (PyObject_TypeCheck (x, &PySDLFont_TTF_Type))
+PyObject* PySDLFont_TTF_New (char *file, int ptsize);
 void font_export_capi (void **capi);
 
 #endif /* _PYGAME_SDLTTFMOD_H_ */