Mercurial > cpython-lru_cache-weakref
annotate Modules/fmmodule.c @ 5817:48b94de85bf3 legacy-trunk
Extensive changes by AMK.
| author | Guido van Rossum <guido@python.org> |
|---|---|
| date | Thu, 17 Jul 1997 16:29:42 +0000 |
| parents | 4309bc97ecc6 |
| children | 1c7c2dd1beb1 |
| rev | line source |
|---|---|
| 164 | 1 /*********************************************************** |
|
2061
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
2 Copyright 1991-1995 by Stichting Mathematisch Centrum, Amsterdam, |
|
172ba04a5191
Added 1995 to copyright message.
Guido van Rossum <guido@python.org>
parents:
1746
diff
changeset
|
3 The Netherlands. |
| 164 | 4 |
| 5 All Rights Reserved | |
| 6 | |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
7 Permission to use, copy, modify, and distribute this software and its |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
8 documentation for any purpose and without fee is hereby granted, |
| 164 | 9 provided that the above copyright notice appear in all copies and that |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
10 both that copyright notice and this permission notice appear in |
| 164 | 11 supporting documentation, and that the names of Stichting Mathematisch |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
12 Centrum or CWI or Corporation for National Research Initiatives or |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
13 CNRI not be used in advertising or publicity pertaining to |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
14 distribution of the software without specific, written prior |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
15 permission. |
| 164 | 16 |
|
4503
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
17 While CWI is the initial source for this software, a modified version |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
18 is made available by the Corporation for National Research Initiatives |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
19 (CNRI) at the Internet address ftp://ftp.python.org. |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
20 |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
21 STICHTING MATHEMATISCH CENTRUM AND CNRI DISCLAIM ALL WARRANTIES WITH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
22 REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
23 MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL STICHTING MATHEMATISCH |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
24 CENTRUM OR CNRI BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
25 DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
26 PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
27 TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR |
|
65d2d8e67da3
New permission notice, includes CNRI.
Guido van Rossum <guido@python.org>
parents:
2061
diff
changeset
|
28 PERFORMANCE OF THIS SOFTWARE. |
| 164 | 29 |
| 30 ******************************************************************/ | |
| 31 | |
| 32 /* Font Manager module */ | |
| 33 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
34 #include "Python.h" |
| 164 | 35 |
| 36 #include <gl.h> | |
| 37 #include <device.h> | |
| 38 #include <fmclient.h> | |
| 39 | |
| 40 | |
| 41 /* Font Handle object implementation */ | |
| 42 | |
| 43 typedef struct { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
44 PyObject_HEAD |
| 164 | 45 fmfonthandle fh_fh; |
| 46 } fhobject; | |
| 47 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
48 staticforward PyTypeObject Fhtype; |
| 164 | 49 |
| 50 #define is_fhobject(v) ((v)->ob_type == &Fhtype) | |
| 51 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
52 static PyObject * |
| 164 | 53 newfhobject(fh) |
| 54 fmfonthandle fh; | |
| 55 { | |
| 56 fhobject *fhp; | |
| 57 if (fh == NULL) { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
58 PyErr_SetString(PyExc_RuntimeError, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
59 "error creating new font handle"); |
| 164 | 60 return NULL; |
| 61 } | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
62 fhp = PyObject_NEW(fhobject, &Fhtype); |
| 164 | 63 if (fhp == NULL) |
| 64 return NULL; | |
| 65 fhp->fh_fh = fh; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
66 return (PyObject *)fhp; |
| 164 | 67 } |
| 68 | |
| 69 /* Font Handle methods */ | |
| 70 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
71 static PyObject * |
| 164 | 72 fh_scalefont(self, args) |
| 73 fhobject *self; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
74 PyObject *args; |
| 164 | 75 { |
| 76 double size; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
77 if (!PyArg_Parse(args, "d", &size)) |
| 164 | 78 return NULL; |
| 79 return newfhobject(fmscalefont(self->fh_fh, size)); | |
| 80 } | |
| 81 | |
| 82 /* XXX fmmakefont */ | |
| 83 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
84 static PyObject * |
| 164 | 85 fh_setfont(self, args) |
| 86 fhobject *self; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
87 PyObject *args; |
| 164 | 88 { |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
89 if (!PyArg_NoArgs(args)) |
| 164 | 90 return NULL; |
| 91 fmsetfont(self->fh_fh); | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
92 Py_INCREF(Py_None); |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
93 return Py_None; |
| 164 | 94 } |
| 95 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
96 static PyObject * |
| 164 | 97 fh_getfontname(self, args) |
| 98 fhobject *self; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
99 PyObject *args; |
| 164 | 100 { |
| 101 char fontname[256]; | |
| 102 int len; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
103 if (!PyArg_NoArgs(args)) |
| 164 | 104 return NULL; |
| 105 len = fmgetfontname(self->fh_fh, sizeof fontname, fontname); | |
| 106 if (len < 0) { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
107 PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontname"); |
| 164 | 108 return NULL; |
| 109 } | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
110 return PyString_FromStringAndSize(fontname, len); |
| 164 | 111 } |
| 112 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
113 static PyObject * |
| 164 | 114 fh_getcomment(self, args) |
| 115 fhobject *self; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
116 PyObject *args; |
| 164 | 117 { |
| 118 char comment[256]; | |
| 119 int len; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
120 if (!PyArg_NoArgs(args)) |
| 164 | 121 return NULL; |
| 122 len = fmgetcomment(self->fh_fh, sizeof comment, comment); | |
| 123 if (len < 0) { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
124 PyErr_SetString(PyExc_RuntimeError, "error in fmgetcomment"); |
| 164 | 125 return NULL; |
| 126 } | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
127 return PyString_FromStringAndSize(comment, len); |
| 164 | 128 } |
| 129 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
130 static PyObject * |
| 164 | 131 fh_getfontinfo(self, args) |
| 132 fhobject *self; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
133 PyObject *args; |
| 164 | 134 { |
| 135 fmfontinfo info; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
136 if (!PyArg_NoArgs(args)) |
| 164 | 137 return NULL; |
| 138 if (fmgetfontinfo(self->fh_fh, &info) < 0) { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
139 PyErr_SetString(PyExc_RuntimeError, "error in fmgetfontinfo"); |
| 164 | 140 return NULL; |
| 141 } | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
142 return Py_BuildValue("(llllllll)", |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
143 info.printermatched, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
144 info.fixed_width, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
145 info.xorig, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
146 info.yorig, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
147 info.xsize, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
148 info.ysize, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
149 info.height, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
150 info.nglyphs); |
| 164 | 151 } |
| 152 | |
| 153 #if 0 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
154 static PyObject * |
| 164 | 155 fh_getwholemetrics(self, args) |
| 156 fhobject *self; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
157 PyObject *args; |
| 164 | 158 { |
| 159 } | |
| 160 #endif | |
| 161 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
162 static PyObject * |
| 164 | 163 fh_getstrwidth(self, args) |
| 164 fhobject *self; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
165 PyObject *args; |
| 164 | 166 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
167 char *str; |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
168 if (!PyArg_Parse(args, "s", &str)) |
| 164 | 169 return NULL; |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
170 return PyInt_FromLong(fmgetstrwidth(self->fh_fh, str)); |
| 164 | 171 } |
| 172 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
173 static PyMethodDef fh_methods[] = { |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
174 {"scalefont", (PyCFunction)fh_scalefont}, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
175 {"setfont", (PyCFunction)fh_setfont}, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
176 {"getfontname", (PyCFunction)fh_getfontname}, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
177 {"getcomment", (PyCFunction)fh_getcomment}, |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
178 {"getfontinfo", (PyCFunction)fh_getfontinfo}, |
| 164 | 179 #if 0 |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
180 {"getwholemetrics", (PyCFunction)fh_getwholemetrics}, |
| 164 | 181 #endif |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
182 {"getstrwidth", (PyCFunction)fh_getstrwidth}, |
| 164 | 183 {NULL, NULL} /* sentinel */ |
| 184 }; | |
| 185 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
186 static PyObject * |
| 164 | 187 fh_getattr(fhp, name) |
| 188 fhobject *fhp; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
189 char *name; |
| 164 | 190 { |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
191 return Py_FindMethod(fh_methods, (PyObject *)fhp, name); |
| 164 | 192 } |
| 193 | |
| 194 static void | |
| 195 fh_dealloc(fhp) | |
| 196 fhobject *fhp; | |
| 197 { | |
| 198 fmfreefont(fhp->fh_fh); | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
199 PyMem_DEL(fhp); |
| 164 | 200 } |
| 201 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
202 static PyTypeObject Fhtype = { |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
203 PyObject_HEAD_INIT(&PyType_Type) |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
204 0, /*ob_size*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
205 "font handle", /*tp_name*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
206 sizeof(fhobject), /*tp_size*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
207 0, /*tp_itemsize*/ |
| 164 | 208 /* methods */ |
|
1746
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
209 (destructor)fh_dealloc, /*tp_dealloc*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
210 0, /*tp_print*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
211 (getattrfunc)fh_getattr, /*tp_getattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
212 0, /*tp_setattr*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
213 0, /*tp_compare*/ |
|
1940892d2fe3
Merge alpha100 branch back to main trunk
Guido van Rossum <guido@python.org>
parents:
1313
diff
changeset
|
214 0, /*tp_repr*/ |
| 164 | 215 }; |
| 216 | |
| 217 | |
| 218 /* Font Manager functions */ | |
| 219 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
220 static PyObject * |
| 164 | 221 fm_init(self, args) |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
222 PyObject *self, *args; |
| 164 | 223 { |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
224 if (!PyArg_NoArgs(args)) |
| 164 | 225 return NULL; |
| 226 fminit(); | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
227 Py_INCREF(Py_None); |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
228 return Py_None; |
| 164 | 229 } |
| 230 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
231 static PyObject * |
| 164 | 232 fm_findfont(self, args) |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
233 PyObject *self, *args; |
| 164 | 234 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
235 char *str; |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
236 if (!PyArg_Parse(args, "s", &str)) |
| 164 | 237 return NULL; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
238 return newfhobject(fmfindfont(str)); |
| 164 | 239 } |
| 240 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
241 static PyObject * |
| 164 | 242 fm_prstr(self, args) |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
243 PyObject *self, *args; |
| 164 | 244 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
245 char *str; |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
246 if (!PyArg_Parse(args, "s", &str)) |
| 164 | 247 return NULL; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
248 fmprstr(str); |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
249 Py_INCREF(Py_None); |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
250 return Py_None; |
| 164 | 251 } |
| 252 | |
| 253 /* XXX This uses a global variable as temporary! Not re-entrant! */ | |
| 254 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
255 static PyObject *fontlist; |
| 164 | 256 |
| 257 static void | |
| 258 clientproc(fontname) | |
| 259 char *fontname; | |
| 260 { | |
| 261 int err; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
262 PyObject *v; |
| 164 | 263 if (fontlist == NULL) |
| 264 return; | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
265 v = PyString_FromString(fontname); |
| 164 | 266 if (v == NULL) |
| 267 err = -1; | |
| 268 else { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
269 err = PyList_Append(fontlist, v); |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
270 Py_DECREF(v); |
| 164 | 271 } |
| 272 if (err != 0) { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
273 Py_DECREF(fontlist); |
| 164 | 274 fontlist = NULL; |
| 275 } | |
| 276 } | |
| 277 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
278 static PyObject * |
| 164 | 279 fm_enumerate(self, args) |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
280 PyObject *self, *args; |
| 164 | 281 { |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
282 PyObject *res; |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
283 if (!PyArg_NoArgs(args)) |
| 164 | 284 return NULL; |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
285 fontlist = PyList_New(0); |
| 164 | 286 if (fontlist == NULL) |
| 287 return NULL; | |
| 288 fmenumerate(clientproc); | |
| 289 res = fontlist; | |
| 290 fontlist = NULL; | |
| 291 return res; | |
| 292 } | |
| 293 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
294 static PyObject * |
| 164 | 295 fm_setpath(self, args) |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
296 PyObject *self, *args; |
| 164 | 297 { |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
298 char *str; |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
299 if (!PyArg_Parse(args, "s", &str)) |
| 164 | 300 return NULL; |
|
643
02d3f161b7f5
Use getargs() function.
Guido van Rossum <guido@python.org>
parents:
164
diff
changeset
|
301 fmsetpath(str); |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
302 Py_INCREF(Py_None); |
|
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
303 return Py_None; |
| 164 | 304 } |
| 305 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
306 static PyObject * |
| 164 | 307 fm_fontpath(self, args) |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
308 PyObject *self, *args; |
| 164 | 309 { |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
310 if (!PyArg_NoArgs(args)) |
| 164 | 311 return NULL; |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
312 return PyString_FromString(fmfontpath()); |
| 164 | 313 } |
| 314 | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
315 static PyMethodDef fm_methods[] = { |
| 164 | 316 {"init", fm_init}, |
| 317 {"findfont", fm_findfont}, | |
| 318 {"enumerate", fm_enumerate}, | |
| 319 {"prstr", fm_prstr}, | |
| 320 {"setpath", fm_setpath}, | |
| 321 {"fontpath", fm_fontpath}, | |
| 322 {NULL, NULL} /* sentinel */ | |
| 323 }; | |
| 324 | |
| 325 | |
| 326 void | |
| 327 initfm() | |
| 328 { | |
|
4985
4309bc97ecc6
Renamed, but not tested. Guido will you try your test script on this?
Roger E. Masse <rmasse@newcnri.cnri.reston.va.us>
parents:
4600
diff
changeset
|
329 Py_InitModule("fm", fm_methods); |
| 164 | 330 fminit(); |
| 331 } |
