- plotitem acts as a container for data now (i.e. data instances
[PyX/mjg.git] / pyx / t1strip / t1strip.c
blob7ef94a11f4aedc04a8946252a36883710d761c87
1 /* t1strip.c: Copyright 2003 Jörg Lehmann, André Wobst
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License as published by
5 * the Free Software Foundation; either version 2 of the License, or
6 * (at your option) any later version.
8 * This program 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
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program; if not, write to the Free Software
15 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
16 * USA.
20 #include <Python.h>
21 #include <stdio.h>
22 #include <string.h>
24 FILE *bitfile;
25 int t1_subset(char*, char *, unsigned char *g);
26 int t1_subset_2(char*, unsigned char *g, char *);
28 static PyObject *py_t1strip(PyObject *self, PyObject *args)
30 PyObject *py_glyphs;
31 PyObject *py_file;
32 char *fontname;
33 char *encname="";
34 unsigned char glyphs[256];
36 if (PyArg_ParseTuple(args, "O!sO!|s", &PyFile_Type, &py_file, &fontname, &PyList_Type, &py_glyphs, &encname)) {
37 int i;
38 int size = PyList_Size(py_glyphs);
39 if (size>256)
40 return NULL;
42 for (i=0; i<size; i++) {
43 PyObject *py_int = PyList_GetItem(py_glyphs, i);
44 if (!PyInt_Check(py_int))
45 return NULL;
46 glyphs[i] = PyInt_AsLong(py_int) ? 1 : 0;
48 for (i=size; i<256; i++)
49 glyphs[i] = 0;
51 bitfile = PyFile_AsFile(py_file);
53 if (strcmp(encname, "")!=0)
54 t1_subset(fontname, encname, glyphs);
55 else
56 t1_subset_2(fontname, glyphs, 0);
58 else return NULL;
60 Py_INCREF(Py_None);
61 return Py_None;
64 /* exported methods */
66 static PyMethodDef t1strip_methods[] = {
67 {"t1strip", py_t1strip, METH_VARARGS},
68 {NULL, NULL}
71 void init_t1strip(void) {
72 (void) Py_InitModule("_t1strip", t1strip_methods);