| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
r |
| 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 |
#define PY_SSIZE_T_CLEAN |
| 32 |
#include <Python.h> |
| 33 |
|
| 34 |
#include "private.h" |
| 35 |
|
| 36 |
static char *KWDS[] = {"x_bearing", "y_bearing", "width", "height", |
| 37 |
"x_advance", "y_advance", NULL}; |
| 38 |
|
| 39 |
static PyObject * |
| 40 |
text_extents_new (PyTypeObject *type, PyObject *args, PyObject *kwds) { |
| 41 |
cairo_text_extents_t e; |
| 42 |
PyObject *tuple_args, *result; |
| 43 |
|
| 44 |
if (!PyArg_ParseTupleAndKeywords (args, kwds, "dddddd:TextExtents.__new__", |
| 45 |
KWDS, &e.x_bearing, &e.y_bearing, &e.width, &e.height, |
| 46 |
&e.x_advance, &e.y_advance)) |
| 47 |
return NULL; |
| 48 |
|
| 49 |
tuple_args = Py_BuildValue ("((dddddd))", e.x_bearing, e.y_bearing, |
| 50 |
e.width, e.height, e.x_advance, e.y_advance); |
| 51 |
if (tuple_args == NULL) |
| 52 |
return NULL; |
| 53 |
result = PyTuple_Type.tp_new (type, tuple_args, NULL); |
| 54 |
Py_DECREF (tuple_args); |
| 55 |
return result; |
| 56 |
} |
| 57 |
|
| 58 |
static PyObject* |
| 59 |
text_extents_repr(PyObject *self) { |
| 60 |
PyObject *format, *result; |
| 61 |
|
| 62 |
format = PyUnicode_FromString ( |
| 63 |
"cairo.TextExtents(x_bearing=%r, y_bearing=%r, width=%r, height=%r, " |
| 64 |
"x_advance=%r, y_advance=%r)"); |
| 65 |
if (format == NULL) |
| 66 |
return NULL; |
| 67 |
result = PyUnicode_Format (format, self); |
| 68 |
Py_DECREF (format); |
| 69 |
return result; |
| 70 |
} |
| 71 |
|
| 72 |
static PyObject * |
| 73 |
text_extents_get_x_bearing(PyObject *self, void *closure) |
| 74 |
{ |
| 75 |
PyObject *obj = PyTuple_GetItem (self, 0); |
| 76 |
Py_XINCREF (obj); |
| 77 |
return obj; |
| 78 |
} |
| 79 |
|
| 80 |
static PyObject * |
| 81 |
text_extents_get_y_bearing(PyObject *self, void *closure) |
| 82 |
{ |
| 83 |
PyObject *obj = PyTuple_GetItem (self, 1); |
| 84 |
Py_XINCREF (obj); |
| 85 |
return obj; |
| 86 |
} |
| 87 |
|
| 88 |
static PyObject * |
| 89 |
text_extents_get_width(PyObject *self, void *closure) |
| 90 |
{ |
| 91 |
PyObject *obj = PyTuple_GetItem (self, 2); |
| 92 |
Py_XINCREF (obj); |
| 93 |
return obj; |
| 94 |
} |
| 95 |
|
| 96 |
static PyObject * |
| 97 |
text_extents_get_height(PyObject *self, void *closure) |
| 98 |
{ |
| 99 |
PyObject *obj = PyTuple_GetItem (self, 3); |
| 100 |
Py_XINCREF (obj); |
| 101 |
return obj; |
| 102 |
} |
| 103 |
|
| 104 |
static PyObject * |
| 105 |
text_extents_get_x_advance(PyObject *self, void *closure) |
| 106 |
{ |
| 107 |
PyObject *obj = PyTuple_GetItem (self, 4); |
| 108 |
Py_XINCREF (obj); |
| 109 |
return obj; |
| 110 |
} |
| 111 |
|
| 112 |
static PyObject * |
| 113 |
text_extents_get_y_advance(PyObject *self, void *closure) |
| 114 |
{ |
| 115 |
PyObject *obj = PyTuple_GetItem (self, 5); |
| 116 |
Py_XINCREF (obj); |
| 117 |
return obj; |
| 118 |
} |
| 119 |
|
| 120 |
static PyGetSetDef text_cluster_getset[] = { |
| 121 |
{"x_bearing", (getter)text_extents_get_x_bearing}, |
| 122 |
{"y_bearing", (getter)text_extents_get_y_bearing}, |
| 123 |
{"width", (getter)text_extents_get_width}, |
| 124 |
{"height", (getter)text_extents_get_height}, |
| 125 |
{"x_advance", (getter)text_extents_get_x_advance}, |
| 126 |
{"y_advance", (getter)text_extents_get_y_advance}, |
| 127 |
{NULL,}, |
| 128 |
}; |
| 129 |
|
| 130 |
PyTypeObject PycairoTextExtents_Type = { |
| 131 |
PyVarObject_HEAD_INIT(NULL, 0) |
| 132 |
"cairo.TextExtents", |
| 133 |
sizeof(PycairoTextExtents), |
| 134 |
0, |
| 135 |
0, |
| 136 |
0, |
| 137 |
0, |
| 138 |
0, |
| 139 |
0, |
| 140 |
(reprfunc)text_extents_repr, |
| 141 |
0, |
| 142 |
0, |
| 143 |
0, |
| 144 |
0, |
| 145 |
0, |
| 146 |
0, |
| 147 |
0, |
| 148 |
0, |
| 149 |
0, |
| 150 |
Py_TPFLAGS_DEFAULT, |
| 151 |
0, |
| 152 |
0, |
| 153 |
0, |
| 154 |
0, |
| 155 |
0, |
| 156 |
0, |
| 157 |
0, |
| 158 |
0, |
| 159 |
0, |
| 160 |
text_cluster_getset, |
| 161 |
0, |
| 162 |
0, |
| 163 |
0, |
| 164 |
0, |
| 165 |
0, |
| 166 |
0, |
| 167 |
0, |
| 168 |
(newfunc)text_extents_new, |
| 169 |
0, |
| 170 |
0, |
| 171 |
0, |
| 172 |
}; |