home *** CD-ROM | disk | FTP | other *** search
/ Freelog 59 / Freelog059.iso / Dossier / Python / pygame-1.6.win32-py2.3.exe / HEADERS / Include / pygame / font.h next >
C/C++ Source or Header  |  2002-08-19  |  2KB  |  60 lines

  1. /*
  2.     pygame - Python Game Library
  3.     Copyright (C) 2000-2001  Pete Shinners
  4.  
  5.     This library is free software; you can redistribute it and/or
  6.     modify it under the terms of the GNU Library General Public
  7.     License as published by the Free Software Foundation; either
  8.     version 2 of the License, or (at your option) any later version.
  9.  
  10.     This library is distributed in the hope that it will be useful,
  11.     but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.     Library General Public License for more details.
  14.  
  15.     You should have received a copy of the GNU Library General Public
  16.     License along with this library; if not, write to the Free
  17.     Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
  18.  
  19.     Pete Shinners
  20.     pete@shinners.org
  21. */
  22.  
  23. #include <Python.h>
  24. #include <SDL_ttf.h>
  25.  
  26.  
  27. /* test font initialization */
  28. #define FONT_INIT_CHECK() \
  29.     if(!(*(int*)PyFONT_C_API[2])) \
  30.         return RAISE(PyExc_SDLError, "font system not initialized")
  31.  
  32.  
  33.  
  34. #define PYGAMEAPI_FONT_NUMSLOTS 3
  35. typedef struct {
  36.   PyObject_HEAD
  37.   TTF_Font* font;
  38. } PyFontObject;
  39. #define PyFont_AsFont(x) (((PyFontObject*)x)->font)
  40. #ifndef PYGAMEAPI_FONT_INTERNAL
  41. #define PyFont_Check(x) ((x)->ob_type == (PyTypeObject*)PyFONT_C_API[0])
  42. #define PyFont_Type (*(PyTypeObject*)PyFONT_C_API[0])
  43. #define PyFont_New (*(PyObject*(*)(TTF_Font*))PyFONT_C_API[1])
  44. /*slot 2 taken by FONT_INIT_CHECK*/
  45. #define import_pygame_font() { \
  46.     PyObject *module = PyImport_ImportModule("pygame.font"); \
  47.     if (module != NULL) { \
  48.         PyObject *dict = PyModule_GetDict(module); \
  49.         PyObject *c_api = PyDict_GetItemString(dict, PYGAMEAPI_LOCAL_ENTRY); \
  50.         if(PyCObject_Check(c_api)) {\
  51.             void** localptr = (void**)PyCObject_AsVoidPtr(c_api); \
  52.             memcpy(PyFONT_C_API, localptr, sizeof(void*)*PYGAMEAPI_FONT_NUMSLOTS); \
  53. } Py_DECREF(module); } }
  54. #endif
  55.  
  56.  
  57.  
  58.  
  59. static void* PyFONT_C_API[PYGAMEAPI_FONT_NUMSLOTS] = {NULL};
  60.