Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 1 | |
| 2 | /* Font Manager module */ |
| 3 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 4 | #include "Python.h" |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 5 | |
| 6 | #include <gl.h> |
| 7 | #include <device.h> |
| 8 | #include <fmclient.h> |
| 9 | |
| 10 | |
| 11 | /* Font Handle object implementation */ |
| 12 | |
| 13 | typedef struct { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 14 | PyObject_HEAD |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 15 | fmfonthandle fh_fh; |
| 16 | } fhobject; |
| 17 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 18 | staticforward PyTypeObject Fhtype; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 19 | |
| 20 | #define is_fhobject(v) ((v)->ob_type == &Fhtype) |
| 21 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 22 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 23 | newfhobject(fmfonthandle fh) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 24 | { |
| 25 | fhobject *fhp; |
| 26 | if (fh == NULL) { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 27 | PyErr_SetString(PyExc_RuntimeError, |
| 28 | "error creating new font handle"); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 29 | return NULL; |
| 30 | } |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 31 | fhp = PyObject_New(fhobject, &Fhtype); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 32 | if (fhp == NULL) |
| 33 | return NULL; |
| 34 | fhp->fh_fh = fh; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 35 | return (PyObject *)fhp; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 36 | } |
| 37 | |
| 38 | /* Font Handle methods */ |
| 39 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 40 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 41 | fh_scalefont(fhobject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 42 | { |
| 43 | double size; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 44 | if (!PyArg_Parse(args, "d", &size)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 45 | return NULL; |
| 46 | return newfhobject(fmscalefont(self->fh_fh, size)); |
| 47 | } |
| 48 | |
| 49 | /* XXX fmmakefont */ |
| 50 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 51 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 52 | fh_setfont(fhobject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 53 | { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 54 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 55 | return NULL; |
| 56 | fmsetfont(self->fh_fh); |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 57 | Py_INCREF(Py_None); |
| 58 | return Py_None; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 59 | } |
| 60 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 61 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 62 | fh_getfontname(fhobject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 63 | { |
| 64 | char fontname[256]; |
| 65 | int len; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 66 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 67 | return NULL; |
| 68 | len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); |
| 69 | if (len < 0) { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 70 | PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname"); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 71 | return NULL; |
| 72 | } |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 73 | return PyString_FromStringAndSize(fontname, len); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 74 | } |
| 75 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 76 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 77 | fh_getcomment(fhobject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 78 | { |
| 79 | char comment[256]; |
| 80 | int len; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 81 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 82 | return NULL; |
| 83 | len = fmgetcomment(self->fh_fh, sizeof comment, comment); |
| 84 | if (len < 0) { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 85 | PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment"); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 86 | return NULL; |
| 87 | } |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 88 | return PyString_FromStringAndSize(comment, len); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 89 | } |
| 90 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 91 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 92 | fh_getfontinfo(fhobject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 93 | { |
| 94 | fmfontinfo info; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 95 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 96 | return NULL; |
| 97 | if (fmgetfontinfo(self->fh_fh, &info) < 0) { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 98 | PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 99 | return NULL; |
| 100 | } |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 101 | return Py_BuildValue("(llllllll)", |
| 102 | info.printermatched, |
| 103 | info.fixed_width, |
| 104 | info.xorig, |
| 105 | info.yorig, |
| 106 | info.xsize, |
| 107 | info.ysize, |
| 108 | info.height, |
| 109 | info.nglyphs); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 110 | } |
| 111 | |
| 112 | #if 0 |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 113 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 114 | fh_getwholemetrics(fhobject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 115 | { |
| 116 | } |
| 117 | #endif |
| 118 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 119 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 120 | fh_getstrwidth(fhobject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 121 | { |
Guido van Rossum | ef0a00e | 1992-01-27 16:51:30 +0000 | [diff] [blame] | 122 | char *str; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 123 | if (!PyArg_Parse(args, "s", &str)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 124 | return NULL; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 125 | return PyInt_FromLong(fmgetstrwidth(self->fh_fh, str)); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 126 | } |
| 127 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 128 | static PyMethodDef fh_methods[] = { |
| 129 | {"scalefont", (PyCFunction)fh_scalefont}, |
| 130 | {"setfont", (PyCFunction)fh_setfont}, |
| 131 | {"getfontname", (PyCFunction)fh_getfontname}, |
| 132 | {"getcomment", (PyCFunction)fh_getcomment}, |
| 133 | {"getfontinfo", (PyCFunction)fh_getfontinfo}, |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 134 | #if 0 |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 135 | {"getwholemetrics", (PyCFunction)fh_getwholemetrics}, |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 136 | #endif |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 137 | {"getstrwidth", (PyCFunction)fh_getstrwidth}, |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 138 | {NULL, NULL} /* sentinel */ |
| 139 | }; |
| 140 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 141 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 142 | fh_getattr(fhobject *fhp, char *name) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 143 | { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 144 | return Py_FindMethod(fh_methods, (PyObject *)fhp, name); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 145 | } |
| 146 | |
| 147 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 148 | fh_dealloc(fhobject *fhp) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 149 | { |
| 150 | fmfreefont(fhp->fh_fh); |
Guido van Rossum | b18618d | 2000-05-03 23:44:39 +0000 | [diff] [blame] | 151 | PyObject_Del(fhp); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 152 | } |
| 153 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 154 | static PyTypeObject Fhtype = { |
| 155 | PyObject_HEAD_INIT(&PyType_Type) |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 156 | 0, /*ob_size*/ |
| 157 | "font handle", /*tp_name*/ |
| 158 | sizeof(fhobject), /*tp_size*/ |
| 159 | 0, /*tp_itemsize*/ |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 160 | /* methods */ |
Guido van Rossum | b6775db | 1994-08-01 11:34:53 +0000 | [diff] [blame] | 161 | (destructor)fh_dealloc, /*tp_dealloc*/ |
| 162 | 0, /*tp_print*/ |
| 163 | (getattrfunc)fh_getattr, /*tp_getattr*/ |
| 164 | 0, /*tp_setattr*/ |
| 165 | 0, /*tp_compare*/ |
| 166 | 0, /*tp_repr*/ |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 167 | }; |
| 168 | |
| 169 | |
| 170 | /* Font Manager functions */ |
| 171 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 172 | static PyObject * |
Sjoerd Mullender | 0ae5284 | 2000-07-12 10:43:11 +0000 | [diff] [blame] | 173 | fm_init(PyObject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 174 | { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 175 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 176 | return NULL; |
| 177 | fminit(); |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 178 | Py_INCREF(Py_None); |
| 179 | return Py_None; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 180 | } |
| 181 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 182 | static PyObject * |
Sjoerd Mullender | 0ae5284 | 2000-07-12 10:43:11 +0000 | [diff] [blame] | 183 | fm_findfont(PyObject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 184 | { |
Guido van Rossum | ef0a00e | 1992-01-27 16:51:30 +0000 | [diff] [blame] | 185 | char *str; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 186 | if (!PyArg_Parse(args, "s", &str)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 187 | return NULL; |
Guido van Rossum | ef0a00e | 1992-01-27 16:51:30 +0000 | [diff] [blame] | 188 | return newfhobject(fmfindfont(str)); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 189 | } |
| 190 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 191 | static PyObject * |
Sjoerd Mullender | 0ae5284 | 2000-07-12 10:43:11 +0000 | [diff] [blame] | 192 | fm_prstr(PyObject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 193 | { |
Guido van Rossum | ef0a00e | 1992-01-27 16:51:30 +0000 | [diff] [blame] | 194 | char *str; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 195 | if (!PyArg_Parse(args, "s", &str)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 196 | return NULL; |
Guido van Rossum | ef0a00e | 1992-01-27 16:51:30 +0000 | [diff] [blame] | 197 | fmprstr(str); |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 198 | Py_INCREF(Py_None); |
| 199 | return Py_None; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 200 | } |
| 201 | |
| 202 | /* XXX This uses a global variable as temporary! Not re-entrant! */ |
| 203 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 204 | static PyObject *fontlist; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 205 | |
| 206 | static void |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 207 | clientproc(char *fontname) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 208 | { |
| 209 | int err; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 210 | PyObject *v; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 211 | if (fontlist == NULL) |
| 212 | return; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 213 | v = PyString_FromString(fontname); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 214 | if (v == NULL) |
| 215 | err = -1; |
| 216 | else { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 217 | err = PyList_Append(fontlist, v); |
| 218 | Py_DECREF(v); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 219 | } |
| 220 | if (err != 0) { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 221 | Py_DECREF(fontlist); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 222 | fontlist = NULL; |
| 223 | } |
| 224 | } |
| 225 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 226 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 227 | fm_enumerate(PyObject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 228 | { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 229 | PyObject *res; |
| 230 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 231 | return NULL; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 232 | fontlist = PyList_New(0); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 233 | if (fontlist == NULL) |
| 234 | return NULL; |
| 235 | fmenumerate(clientproc); |
| 236 | res = fontlist; |
| 237 | fontlist = NULL; |
| 238 | return res; |
| 239 | } |
| 240 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 241 | static PyObject * |
Peter Schneider-Kamp | 6a85027 | 2000-07-10 17:04:33 +0000 | [diff] [blame] | 242 | fm_setpath(PyObject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 243 | { |
Guido van Rossum | ef0a00e | 1992-01-27 16:51:30 +0000 | [diff] [blame] | 244 | char *str; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 245 | if (!PyArg_Parse(args, "s", &str)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 246 | return NULL; |
Guido van Rossum | ef0a00e | 1992-01-27 16:51:30 +0000 | [diff] [blame] | 247 | fmsetpath(str); |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 248 | Py_INCREF(Py_None); |
| 249 | return Py_None; |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 250 | } |
| 251 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 252 | static PyObject * |
Sjoerd Mullender | 0ae5284 | 2000-07-12 10:43:11 +0000 | [diff] [blame] | 253 | fm_fontpath(PyObject *self, PyObject *args) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 254 | { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 255 | if (!PyArg_NoArgs(args)) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 256 | return NULL; |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 257 | return PyString_FromString(fmfontpath()); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 258 | } |
| 259 | |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 260 | static PyMethodDef fm_methods[] = { |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 261 | {"init", fm_init}, |
| 262 | {"findfont", fm_findfont}, |
| 263 | {"enumerate", fm_enumerate}, |
| 264 | {"prstr", fm_prstr}, |
| 265 | {"setpath", fm_setpath}, |
| 266 | {"fontpath", fm_fontpath}, |
| 267 | {NULL, NULL} /* sentinel */ |
| 268 | }; |
| 269 | |
| 270 | |
| 271 | void |
Thomas Wouters | f3f33dc | 2000-07-21 06:00:07 +0000 | [diff] [blame] | 272 | initfm(void) |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 273 | { |
Roger E. Masse | ed648a2 | 1997-01-17 16:08:55 +0000 | [diff] [blame] | 274 | Py_InitModule("fm", fm_methods); |
Guido van Rossum | a0c191e | 1991-04-03 19:02:31 +0000 | [diff] [blame] | 275 | fminit(); |
| 276 | } |