2
pygame - Python Game Library
3
Copyright (C) 2000-2001 Pete Shinners
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.
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.
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
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")
34
#define PYGAMEAPI_FONT_NUMSLOTS 3
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); } }
59
static void* PyFONT_C_API[PYGAMEAPI_FONT_NUMSLOTS] = {NULL};