font.h 1.8 KB

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