1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
|
/* -*- Mode: C; c-basic-offset: 4 -*- */
%%
headers
#define NO_IMPORT_PYGOBJECT
#include <pygobject.h>
#include <pango/pangocairo.h>
#include <pycairo.h>
extern Pycairo_CAPI_t *Pycairo_CAPI;
GType pypango_layout_line_type; /* See bug 305975 */
#ifndef PANGO_TYPE_LAYOUT_LINE
# define PANGO_TYPE_LAYOUT_LINE pypango_layout_line_type
#endif
%%
import pango.FontMap as PyPangoFontMap_Type
import pango.Context as PyPangoContext_Type
import pango.Layout as PyPangoLayout_Type
import pango.Font as PyPangoFont_Type
%%
define context_get_font_options kwargs
static PyObject *
_wrap_context_get_font_options(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "context", NULL };
PyGObject *context;
const cairo_font_options_t *font_options;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:pangocairo.context_get_font_options",
kwlist, &PyPangoContext_Type, &context))
return NULL;
font_options = pango_cairo_context_get_font_options(PANGO_CONTEXT(context->obj));
if (!font_options) {
Py_INCREF(Py_None);
return Py_None;
}
return PycairoFontOptions_FromFontOptions(cairo_font_options_copy(font_options));
}
%%
define context_set_font_options kwargs
static PyObject *
_wrap_context_set_font_options(PyObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "context", "font_options", NULL };
PyGObject *context;
PyGObject *py_options;
const cairo_font_options_t *options;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:pangocairo.context_set_font_options",
kwlist, &PyPangoContext_Type, &context,
&py_options))
return NULL;
if ((PyObject*)py_options == Py_None)
options = NULL;
else if (pygobject_check(py_options, &PycairoFontOptions_Type))
options = ((PycairoFontOptions *)py_options)->font_options;
else {
PyErr_SetString(PyExc_TypeError, "font_options must be a cairo.FontOptions or None");
return NULL;
}
pango_cairo_context_set_font_options(PANGO_CONTEXT(context->obj), options);
Py_INCREF(Py_None);
return Py_None;
}
%%
body
static PyObject *
pypango_cairo_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
{
PyObject *o;
PycairoContext *ctx;
if (!PyArg_ParseTuple(args, "O!:CairoContext.__new__",
&PycairoContext_Type, &ctx))
return NULL;
cairo_reference(ctx->ctx);
o = PycairoContext_FromContext(ctx->ctx, type, NULL);
return o;
}
static PyObject *
_wrap_pango_cairo_update_context(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "context", NULL };
PyGObject *context;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:CairoContext.update_context", kwlist,
&PyPangoContext_Type, &context))
return NULL;
pango_cairo_update_context(PycairoContext_GET(self), PANGO_CONTEXT(context->obj));
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_pango_cairo_create_layout(PyGObject *self)
{
PangoLayout *ret;
ret = pango_cairo_create_layout(PycairoContext_GET(self));
/* pygobject_new handles NULL checking */
return pygobject_new((GObject *)ret);
}
static PyObject *
_wrap_pango_cairo_update_layout(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "layout", NULL };
PyGObject *layout;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:CairoContext.update_layout",
kwlist, &PyPangoLayout_Type, &layout))
return NULL;
pango_cairo_update_layout(PycairoContext_GET(self), PANGO_LAYOUT(layout->obj));
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_pango_cairo_show_glyph_string(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "font", "glyphs", NULL };
PyGObject *font;
PangoGlyphString *glyphs = NULL;
PyObject *py_glyphs;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:CairoContext.show_glyph_string",
kwlist, &PyPangoFont_Type, &font, &py_glyphs))
return NULL;
if (pyg_boxed_check(py_glyphs, PANGO_TYPE_GLYPH_STRING))
glyphs = pyg_boxed_get(py_glyphs, PangoGlyphString);
else {
PyErr_SetString(PyExc_TypeError, "glyphs should be a PangoGlyphString");
return NULL;
}
pango_cairo_show_glyph_string(PycairoContext_GET(self), PANGO_FONT(font->obj), glyphs);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_pango_cairo_show_layout_line(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "line", NULL };
PangoLayoutLine *line = NULL;
PyObject *py_line;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:CairoContext.show_layout_line",
kwlist, &py_line))
return NULL;
if (pyg_boxed_check(py_line, PANGO_TYPE_LAYOUT_LINE))
line = pyg_boxed_get(py_line, PangoLayoutLine);
else {
PyErr_SetString(PyExc_TypeError, "line should be a PangoLayoutLine");
return NULL;
}
pango_cairo_show_layout_line(PycairoContext_GET(self), line);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_pango_cairo_show_layout(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "layout", NULL };
PyGObject *layout;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:CairoContext.show_layout",
kwlist, &PyPangoLayout_Type, &layout))
return NULL;
pango_cairo_show_layout(PycairoContext_GET(self), PANGO_LAYOUT(layout->obj));
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_pango_cairo_glyph_string_path(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "font", "glyphs", NULL };
PyGObject *font;
PangoGlyphString *glyphs = NULL;
PyObject *py_glyphs;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!O:CairoContext.glyph_string_path",
kwlist, &PyPangoFont_Type, &font, &py_glyphs))
return NULL;
if (pyg_boxed_check(py_glyphs, PANGO_TYPE_GLYPH_STRING))
glyphs = pyg_boxed_get(py_glyphs, PangoGlyphString);
else {
PyErr_SetString(PyExc_TypeError, "glyphs should be a PangoGlyphString");
return NULL;
}
pango_cairo_glyph_string_path(PycairoContext_GET(self), PANGO_FONT(font->obj), glyphs);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_pango_cairo_layout_line_path(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "line", NULL };
PangoLayoutLine *line = NULL;
PyObject *py_line;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O:CairoContext.layout_line_path",
kwlist, &py_line))
return NULL;
if (pyg_boxed_check(py_line, PANGO_TYPE_LAYOUT_LINE))
line = pyg_boxed_get(py_line, PangoLayoutLine);
else {
PyErr_SetString(PyExc_TypeError, "line should be a PangoLayoutLine");
return NULL;
}
pango_cairo_layout_line_path(PycairoContext_GET(self), line);
Py_INCREF(Py_None);
return Py_None;
}
static PyObject *
_wrap_pango_cairo_layout_path(PyGObject *self, PyObject *args, PyObject *kwargs)
{
static char *kwlist[] = { "layout", NULL };
PyGObject *layout;
if (!PyArg_ParseTupleAndKeywords(args, kwargs, "O!:CairoContext.layout_path",
kwlist, &PyPangoLayout_Type, &layout))
return NULL;
pango_cairo_layout_path(PycairoContext_GET(self), PANGO_LAYOUT(layout->obj));
Py_INCREF(Py_None);
return Py_None;
}
static PyMethodDef _PyCairoContext_methods[] = {
{ "update_context", (PyCFunction)_wrap_pango_cairo_update_context, METH_VARARGS|METH_KEYWORDS },
{ "create_layout", (PyCFunction)_wrap_pango_cairo_create_layout, METH_NOARGS },
{ "update_layout", (PyCFunction)_wrap_pango_cairo_update_layout, METH_VARARGS|METH_KEYWORDS },
{ "show_glyph_string", (PyCFunction)_wrap_pango_cairo_show_glyph_string, METH_VARARGS|METH_KEYWORDS },
{ "show_layout_line", (PyCFunction)_wrap_pango_cairo_show_layout_line, METH_VARARGS|METH_KEYWORDS },
{ "show_layout", (PyCFunction)_wrap_pango_cairo_show_layout, METH_VARARGS|METH_KEYWORDS },
{ "glyph_string_path", (PyCFunction)_wrap_pango_cairo_glyph_string_path, METH_VARARGS|METH_KEYWORDS },
{ "layout_line_path", (PyCFunction)_wrap_pango_cairo_layout_line_path, METH_VARARGS|METH_KEYWORDS },
{ "layout_path", (PyCFunction)_wrap_pango_cairo_layout_path, METH_VARARGS|METH_KEYWORDS },
{ NULL, NULL, 0 }
};
PyTypeObject PyPangoCairoContext_Type = {
PyObject_HEAD_INIT(NULL)
0, /* ob_size */
"pangocairo.CairoContext", /* tp_name */
0, /* tp_basicsize */
0, /* tp_itemsize */
/* methods */
(destructor)0, /* tp_dealloc */
(printfunc)0, /* tp_print */
(getattrfunc)0, /* tp_getattr */
(setattrfunc)0, /* tp_setattr */
(cmpfunc)0, /* tp_compare */
(reprfunc)0, /* tp_repr */
0, /* tp_as_number */
0, /* tp_as_sequence */
0, /* tp_as_mapping */
(hashfunc)0, /* tp_hash */
(ternaryfunc)0, /* tp_call */
(reprfunc)0, /* tp_str */
(getattrofunc)0, /* tp_getattro */
(setattrofunc)0, /* tp_setattro */
0, /* tp_as_buffer */
Py_TPFLAGS_DEFAULT, /* tp_flags */
"A cairo.Context enhanced with some additional pango methods", /* Documentation string */
(traverseproc)0, /* tp_traverse */
(inquiry)0, /* tp_clear */
(richcmpfunc)0, /* tp_richcompare */
0, /* tp_weaklistoffset */
(getiterfunc)0, /* tp_iter */
(iternextfunc)0, /* tp_iternext */
_PyCairoContext_methods, /* tp_methods */
0, /* tp_members */
0, /* tp_getset */
(PyTypeObject *)0, /* tp_base */
(PyObject *)0, /* tp_dict */
0, /* tp_descr_get */
0, /* tp_descr_set */
0, /* tp_dictoffset */
(initproc)0, /* tp_init */
0, /* tp_alloc */
pypango_cairo_new, /* tp_new */
0, /* tp_free */
(inquiry)0, /* tp_is_gc */
(PyObject *)0, /* tp_bases */
};
|