~ubuntu-branches/ubuntu/trusty/pyx/trusty

« back to all changes in this revision

Viewing changes to pyx/t1strip/t1strip.c

  • Committer: Bazaar Package Importer
  • Author(s): Thomas Viehmann
  • Date: 2006-11-26 14:04:53 UTC
  • mfrom: (2.1.3 edgy)
  • Revision ID: james.westby@ubuntu.com-20061126140453-1dq3cycpspmlik2t
Tags: 0.9-3
* New maintainer. Thank you for more than three years of
  maintenance,  Graham! Closes: #400087
* Don't hard-code python 2.3 in manual/Makefile.
  Thanks to Matthias Klose for the bug report and patch.
  Closes: #392634
* Remove obsolete dh_python call from debian/rules.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*  t1strip.c: Copyright 2003 J�rg Lehmann, Andr� Wobst
2
 
 *
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.
7
 
 *
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.
12
 
 *
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.
17
 
 */
18
 
 
19
 
 
20
 
#include <Python.h>
21
 
#include <stdio.h>
22
 
#include <string.h>
23
 
 
24
 
FILE *bitfile;
25
 
int t1_subset(char*, char *, unsigned char *g);
26
 
int t1_subset_2(char*, unsigned char *g, char *);
27
 
 
28
 
static PyObject *py_t1strip(PyObject *self, PyObject *args)
29
 
{
30
 
    PyObject *py_glyphs;
31
 
    PyObject *py_file;
32
 
    char *fontname;
33
 
    char *encname="";
34
 
    unsigned char glyphs[256];
35
 
 
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;
41
 
 
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;
47
 
        }
48
 
        for (i=size; i<256; i++)
49
 
            glyphs[i] = 0;
50
 
 
51
 
        bitfile = PyFile_AsFile(py_file);
52
 
 
53
 
        if (strcmp(encname, "")!=0)
54
 
            t1_subset(fontname, encname, glyphs);
55
 
        else
56
 
            t1_subset_2(fontname, glyphs, 0);
57
 
    }
58
 
    else return NULL;
59
 
 
60
 
    Py_INCREF(Py_None);
61
 
    return Py_None;
62
 
}
63
 
 
64
 
/* exported methods */
65
 
 
66
 
static PyMethodDef t1strip_methods[] = {
67
 
    {"t1strip", py_t1strip,  METH_VARARGS},
68
 
    {NULL, NULL}
69
 
};
70
 
 
71
 
void init_t1strip(void) {
72
 
    (void) Py_InitModule("_t1strip", t1strip_methods);
73
 
}