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,
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
)
34 unsigned char glyphs
[256];
36 if (PyArg_ParseTuple(args
, "O!sO!|s", &PyFile_Type
, &py_file
, &fontname
, &PyList_Type
, &py_glyphs
, &encname
)) {
38 int size
= PyList_Size(py_glyphs
);
42 for (i
=0; i
<size
; i
++) {
43 PyObject
*py_int
= PyList_GetItem(py_glyphs
, i
);
44 if (!PyInt_Check(py_int
))
46 glyphs
[i
] = PyInt_AsLong(py_int
) ? 1 : 0;
48 for (i
=size
; i
<256; i
++)
51 bitfile
= PyFile_AsFile(py_file
);
53 if (strcmp(encname
, "")!=0)
54 t1_subset(fontname
, encname
, glyphs
);
56 t1_subset_2(fontname
, glyphs
, 0);
64 /* exported methods */
66 static PyMethodDef t1strip_methods
[] = {
67 {"t1strip", py_t1strip
, METH_VARARGS
},
71 void init_t1strip(void) {
72 (void) Py_InitModule("_t1strip", t1strip_methods
);