Since version 1.11.0 Pycairo uses `Semantic Versioning
<http://semver.org/>`__ i.e. the newest version is the latest stable one.
+.. _v1.15.4:
+
+1.15.4 - 2017-11-08
+-------------------
+
+Fixes:
+ * Fix some enum conversation errors with (unused) large and negative values.
+ :pr:`81`
+
+Tests:
+ * Fix a rare test error :pr:`80` (:user:`Sergei Trofimovich <trofi>`)
+
+
.. _v1.15.3:
1.15.3 - 2017-09-17
Metadata-Version: 1.1
Name: pycairo
-Version: 1.15.3
+Version: 1.15.4
Summary: Python interface for cairo
Home-page: https://pycairo.readthedocs.io
Author: Christoph Reiter
|
Pycairo is a Python module providing bindings for the `cairo graphics library
- <https://cairographics.org/>`__.
+ <https://cairographics.org/>`__. It depends on **cairo >= 1.13.1** and
+ works with **Python 2.7+** as well as **Python 3.3+**. Pycairo, including this
+ documentation, is licensed under the **LGPLv2.1** as well as the **MPLv1.1**.
The Pycairo bindings are designed to match the cairo C API as closely as
possible, and to deviate only in cases which are clearly better implemented in
* Queries the error status of objects and translates them to exceptions.
* Provides a C API that can be used by other Python extensions.
- Pycairo depends on **cairo >= 1.14** (the 1.13 git snapshot present in Ubuntu
- 14.04 works as well) and works with **Python 2.7+** as well as **Python
- 3.3+**. Pycairo, including this documentation, is licensed under the
- **LGPLv2.1** as well as the **MPLv1.1**.
+ ----
+
+ .. image:: https://cdn.rawgit.com/pygobject/pycairo/master/docs/images/example.svg
+ :align: right
+ :width: 200px
+
+ .. code:: python
+
+ import cairo
+
+ surface = cairo.SVGSurface("example.svg", 200, 200)
+ context = cairo.Context(surface)
+ x, y, x1, y1 = 0.1, 0.5, 0.4, 0.9
+ x2, y2, x3, y3 = 0.6, 0.1, 0.9, 0.5
+ context.scale(200, 200)
+ context.set_line_width(0.04)
+ context.move_to(x, y)
+ context.curve_to(x1, y1, x2, y2, x3, y3)
+ context.stroke()
+ context.set_source_rgba(1, 0.2, 0.2, 0.6)
+ context.set_line_width(0.02)
+ context.move_to(x, y)
+ context.line_to(x1, y1)
+ context.move_to(x2, y2)
+ context.line_to(x3, y3)
+ context.stroke()
+ surface.finish()
+
+ ----
If Pycairo is not what you need, have a look at `cairocffi
<https://cairocffi.readthedocs.io>`__, which is an API compatible package
|
Pycairo is a Python module providing bindings for the `cairo graphics library
-<https://cairographics.org/>`__.
+<https://cairographics.org/>`__. It depends on **cairo >= 1.13.1** and
+works with **Python 2.7+** as well as **Python 3.3+**. Pycairo, including this
+documentation, is licensed under the **LGPLv2.1** as well as the **MPLv1.1**.
The Pycairo bindings are designed to match the cairo C API as closely as
possible, and to deviate only in cases which are clearly better implemented in
* Queries the error status of objects and translates them to exceptions.
* Provides a C API that can be used by other Python extensions.
-Pycairo depends on **cairo >= 1.14** (the 1.13 git snapshot present in Ubuntu
-14.04 works as well) and works with **Python 2.7+** as well as **Python
-3.3+**. Pycairo, including this documentation, is licensed under the
-**LGPLv2.1** as well as the **MPLv1.1**.
+----
+
+.. image:: https://cdn.rawgit.com/pygobject/pycairo/master/docs/images/example.svg
+ :align: right
+ :width: 200px
+
+.. code:: python
+
+ import cairo
+
+ surface = cairo.SVGSurface("example.svg", 200, 200)
+ context = cairo.Context(surface)
+ x, y, x1, y1 = 0.1, 0.5, 0.4, 0.9
+ x2, y2, x3, y3 = 0.6, 0.1, 0.9, 0.5
+ context.scale(200, 200)
+ context.set_line_width(0.04)
+ context.move_to(x, y)
+ context.curve_to(x1, y1, x2, y2, x3, y3)
+ context.stroke()
+ context.set_source_rgba(1, 0.2, 0.2, 0.6)
+ context.set_line_width(0.02)
+ context.move_to(x, y)
+ context.line_to(x1, y1)
+ context.move_to(x2, y2)
+ context.line_to(x3, y3)
+ context.stroke()
+ surface.finish()
+
+----
If Pycairo is not what you need, have a look at `cairocffi
<https://cairocffi.readthedocs.io>`__, which is an API compatible package
static PyObject *
pycairo_push_group_with_content (PycairoContext *o, PyObject *args) {
cairo_content_t content;
+ int content_arg;
- if (!PyArg_ParseTuple(args, "i:Context.push_group_with_content",
- &content))
+ if (!PyArg_ParseTuple (args, "i:Context.push_group_with_content",
+ &content_arg))
return NULL;
+
+ content = (cairo_content_t)content_arg;
+
cairo_push_group_with_content (o->ctx, content);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
static PyObject *
pycairo_select_font_face (PycairoContext *o, PyObject *args) {
const char *utf8;
- cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
- cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
+ cairo_font_slant_t slant;
+ cairo_font_weight_t weight;
+ int slant_arg = CAIRO_FONT_SLANT_NORMAL;
+ int weight_arg = CAIRO_FONT_WEIGHT_NORMAL;
if (!PyArg_ParseTuple (args, PYCAIRO_ENC_TEXT_FORMAT "|ii:Context.select_font_face",
- "utf-8", &utf8, &slant, &weight))
+ "utf-8", &utf8, &slant_arg, &weight_arg))
return NULL;
+ slant = (cairo_font_slant_t)slant_arg;
+ weight = (cairo_font_weight_t)weight_arg;
+
cairo_select_font_face (o->ctx, utf8, slant, weight);
PyMem_Free((void *)utf8);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
static PyObject *
pycairo_set_antialias (PycairoContext *o, PyObject *args) {
- cairo_antialias_t antialias = CAIRO_ANTIALIAS_DEFAULT;
+ cairo_antialias_t antialias;
+ int antialias_arg = CAIRO_ANTIALIAS_DEFAULT;
- if (!PyArg_ParseTuple(args, "|i:Context.set_antialias", &antialias))
+ if (!PyArg_ParseTuple (args, "|i:Context.set_antialias", &antialias_arg))
return NULL;
+ antialias = (cairo_antialias_t)antialias_arg;
+
cairo_set_antialias (o->ctx, antialias);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
static PyObject *
pycairo_set_fill_rule (PycairoContext *o, PyObject *args) {
cairo_fill_rule_t fill_rule;
+ int fill_rule_arg;
- if (!PyArg_ParseTuple (args, "i:Context.set_fill_rule", &fill_rule))
+ if (!PyArg_ParseTuple (args, "i:Context.set_fill_rule", &fill_rule_arg))
return NULL;
+ fill_rule = (cairo_fill_rule_t)fill_rule_arg;
+
cairo_set_fill_rule (o->ctx, fill_rule);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
static PyObject *
pycairo_set_line_cap (PycairoContext *o, PyObject *args) {
cairo_line_cap_t line_cap;
+ int line_cap_arg;
- if (!PyArg_ParseTuple (args, "i:Context.set_line_cap", &line_cap))
+ if (!PyArg_ParseTuple (args, "i:Context.set_line_cap", &line_cap_arg))
return NULL;
+ line_cap = (cairo_line_cap_t)line_cap_arg;
+
cairo_set_line_cap (o->ctx, line_cap);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
static PyObject *
pycairo_set_line_join (PycairoContext *o, PyObject *args) {
cairo_line_join_t line_join;
+ int line_join_arg;
- if (!PyArg_ParseTuple (args, "i:Context.set_line_join", &line_join))
+ if (!PyArg_ParseTuple (args, "i:Context.set_line_join", &line_join_arg))
return NULL;
+ line_join = (cairo_line_join_t)line_join_arg;
+
cairo_set_line_join (o->ctx, line_join);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
static PyObject *
pycairo_set_operator(PycairoContext *o, PyObject *args) {
- cairo_operator_t op;
+ cairo_operator_t operator;
+ int operator_arg;
- if (!PyArg_ParseTuple(args, "i:Context.set_operator", &op))
+ if (!PyArg_ParseTuple (args, "i:Context.set_operator", &operator_arg))
return NULL;
- cairo_set_operator(o->ctx, op);
+ operator = (cairo_operator_t)operator_arg;
+
+ cairo_set_operator(o->ctx, operator);
RETURN_NULL_IF_CAIRO_CONTEXT_ERROR(o->ctx);
Py_RETURN_NONE;
}
PyObject *glyphs_arg, *glyphs_seq = NULL;
PyObject *clusters_arg, *clusters_seq = NULL;
cairo_text_cluster_flags_t cluster_flags;
+ int cluster_flags_arg;
PyObject *py_item;
cairo_glyph_t *glyphs = NULL;
cairo_text_cluster_t *clusters = NULL;
if (!PyArg_ParseTuple (args,
PYCAIRO_ENC_TEXT_FORMAT "OOi:Context.show_text_glyphs",
- "utf-8", &utf8, &glyphs_arg, &clusters_arg, &cluster_flags))
+ "utf-8", &utf8, &glyphs_arg, &clusters_arg, &cluster_flags_arg))
return NULL;
+ cluster_flags = (cairo_text_cluster_flags_t)cluster_flags_arg;
+
glyphs_seq = PySequence_Fast (glyphs_arg, "glyphs must be a sequence");
if (glyphs_seq == NULL)
goto error;
static PyObject *
script_device_set_mode (PycairoDevice *obj, PyObject *args) {
cairo_script_mode_t mode;
+ int mode_arg;
- if (!PyArg_ParseTuple(args, "i:ScriptDevice.set_mode", &mode))
+ if (!PyArg_ParseTuple (args, "i:ScriptDevice.set_mode", &mode_arg))
return NULL;
+ mode = (cairo_script_mode_t)mode_arg;
+
Py_BEGIN_ALLOW_THREADS;
cairo_script_set_mode (obj->device, mode);
Py_END_ALLOW_THREADS;
static PyObject *
error_check_status (PyTypeObject *type, PyObject *args) {
cairo_status_t status;
+ int status_arg;
- if (!PyArg_ParseTuple(args, "i:Error._check_status", &status))
+ if (!PyArg_ParseTuple (args, "i:Error._check_status", &status_arg))
return NULL;
+ status = (cairo_status_t)status_arg;
+
if (Pycairo_Check_Status (status))
return NULL;
toy_font_face_new (PyTypeObject *type, PyObject *args, PyObject *kwds) {
const char *utf8;
PyObject *o;
- cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
- cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
+ cairo_font_slant_t slant;
+ cairo_font_weight_t weight;
+ int slant_arg = CAIRO_FONT_SLANT_NORMAL;
+ int weight_arg = CAIRO_FONT_WEIGHT_NORMAL;
if (!PyArg_ParseTuple (args, PYCAIRO_ENC_TEXT_FORMAT "|ii:ToyFontFace.__new__",
- "utf-8", &utf8, &slant, &weight))
+ "utf-8", &utf8, &slant_arg, &weight_arg))
return NULL;
+ slant = (cairo_font_slant_t)slant_arg;
+ weight = (cairo_font_weight_t)weight_arg;
+
o = PycairoFontFace_FromFontFace (
cairo_toy_font_face_create (utf8, slant, weight));
PyMem_Free((void *)utf8);
static PyObject *
font_options_set_antialias (PycairoFontOptions *o, PyObject *args) {
- cairo_antialias_t aa = CAIRO_ANTIALIAS_DEFAULT;
+ cairo_antialias_t antialias;
+ int antialias_arg = CAIRO_ANTIALIAS_DEFAULT;
- if (!PyArg_ParseTuple(args, "|i:FontOptions.set_antialias", &aa))
+ if (!PyArg_ParseTuple (args, "|i:FontOptions.set_antialias", &antialias_arg))
return NULL;
- cairo_font_options_set_antialias (o->font_options, aa);
+ antialias = (cairo_antialias_t)antialias_arg;
+
+ cairo_font_options_set_antialias (o->font_options, antialias);
RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
Py_RETURN_NONE;
}
static PyObject *
font_options_set_hint_metrics (PycairoFontOptions *o, PyObject *args) {
- cairo_hint_metrics_t hm = CAIRO_HINT_METRICS_DEFAULT;
+ cairo_hint_metrics_t hint_metrics;
+ int hint_metrics_arg = CAIRO_HINT_METRICS_DEFAULT;
- if (!PyArg_ParseTuple(args, "|i:FontOptions.set_hint_metrics", &hm))
+ if (!PyArg_ParseTuple (args, "|i:FontOptions.set_hint_metrics",
+ &hint_metrics_arg))
return NULL;
- cairo_font_options_set_hint_metrics (o->font_options, hm);
+ hint_metrics = (cairo_hint_metrics_t)hint_metrics_arg;
+
+ cairo_font_options_set_hint_metrics (o->font_options, hint_metrics);
RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
Py_RETURN_NONE;
}
static PyObject *
font_options_set_hint_style (PycairoFontOptions *o, PyObject *args) {
- cairo_hint_style_t hs = CAIRO_HINT_STYLE_DEFAULT;
+ cairo_hint_style_t hint_style;
+ int hint_style_arg = CAIRO_HINT_STYLE_DEFAULT;
- if (!PyArg_ParseTuple(args, "|i:FontOptions.set_hint_style", &hs))
+ if (!PyArg_ParseTuple (args, "|i:FontOptions.set_hint_style",
+ &hint_style_arg))
return NULL;
- cairo_font_options_set_hint_style (o->font_options, hs);
+ hint_style = (cairo_hint_style_t)hint_style_arg;
+
+ cairo_font_options_set_hint_style (o->font_options, hint_style);
RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
Py_RETURN_NONE;
}
static PyObject *
font_options_set_subpixel_order (PycairoFontOptions *o, PyObject *args) {
- cairo_subpixel_order_t so = CAIRO_SUBPIXEL_ORDER_DEFAULT;
+ cairo_subpixel_order_t subpixel_order;
+ int subpixel_order_arg = CAIRO_SUBPIXEL_ORDER_DEFAULT;
- if (!PyArg_ParseTuple(args, "|i:FontOptions.set_subpixel_order", &so))
+ if (!PyArg_ParseTuple (args, "|i:FontOptions.set_subpixel_order",
+ &subpixel_order_arg))
return NULL;
- cairo_font_options_set_subpixel_order (o->font_options, so);
+ subpixel_order = (cairo_subpixel_order_t)subpixel_order_arg;
+
+ cairo_font_options_set_subpixel_order (o->font_options, subpixel_order);
RETURN_NULL_IF_CAIRO_FONT_OPTIONS_ERROR(o->font_options);
Py_RETURN_NONE;
}
static PyObject *
pattern_set_extend (PycairoPattern *o, PyObject *args) {
cairo_extend_t extend;
+ int extend_arg;
- if (!PyArg_ParseTuple(args, "i:Pattern.set_extend", &extend))
+ if (!PyArg_ParseTuple (args, "i:Pattern.set_extend", &extend_arg))
return NULL;
+ extend = (cairo_extend_t)extend_arg;
+
cairo_pattern_set_extend (o->pattern, extend);
Py_RETURN_NONE;
}
static PyObject *
pattern_set_filter (PycairoPattern *o, PyObject *args) {
cairo_filter_t filter;
+ int filter_arg;
- if (!PyArg_ParseTuple (args, "i:Pattern.set_filter", &filter))
+ if (!PyArg_ParseTuple (args, "i:Pattern.set_filter", &filter_arg))
return NULL;
+ filter = (cairo_filter_t)filter_arg;
+
Py_BEGIN_ALLOW_THREADS;
cairo_pattern_set_filter (o->pattern, filter);
Py_END_ALLOW_THREADS;
static PyObject *
raster_source_pattern_new (PyTypeObject *type, PyObject *args, PyObject *kwds) {
cairo_content_t content;
- int width, height;
+ int width, height, content_arg;
if (!PyArg_ParseTuple (args, "iii:RasterSourcePattern.__new__",
- &content, &width, &height))
+ &content_arg, &width, &height))
return NULL;
+ content = (cairo_content_t)content_arg;
+
return PycairoPattern_FromPattern (
cairo_pattern_create_raster_source (NULL, content, width, height), NULL);
}
#define DECL_ENUM(name) extern PyTypeObject Pycairo_##name##_Type;
+/* A defined variant of (int)(unsigned int)(u). The cast from unsigned to
+ * signed gives the reverse result of a signed to unsigned cast. */
+#define _ENSURE_INT(u) ( \
+ ((unsigned int)(u) > INT_MAX) ? \
+ -(int)(UINT_MAX - (unsigned int)(u)) - 1 : (int)(unsigned int)(u) \
+ )
+
#define CREATE_INT_ENUM(type_name, value) \
- (int_enum_create(&Pycairo_##type_name##_Type, value))
+ (int_enum_create(&Pycairo_##type_name##_Type, _ENSURE_INT(value)))
#define RETURN_INT_ENUM(type_name, value) \
return CREATE_INT_ENUM(type_name, value);
static PyObject *
surface_create_similar (PycairoSurface *o, PyObject *args) {
cairo_content_t content;
- int width, height;
+ int width, height, content_arg;
if (!PyArg_ParseTuple (args, "iii:Surface.create_similar",
- &content, &width, &height))
+ &content_arg, &width, &height))
return NULL;
+
+ content = (cairo_content_t)content_arg;
+
return PycairoSurface_FromSurface (
cairo_surface_create_similar (o->surface, content, width, height),
NULL);
static PyObject *
surface_create_similar_image (PycairoSurface *o, PyObject *args) {
cairo_format_t format;
- int width, height;
+ int width, height, format_arg;
cairo_surface_t *new;
if (!PyArg_ParseTuple (args, "iii:Surface.create_similar_image",
- &format, &width, &height))
+ &format_arg, &width, &height))
return NULL;
+ format = (cairo_format_t)format_arg;
+
Py_BEGIN_ALLOW_THREADS;
new = cairo_surface_create_similar_image (o->surface, format, width, height);
Py_END_ALLOW_THREADS;
static PyObject *
image_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds) {
cairo_format_t format;
- int width, height;
+ int width, height, format_arg;
if (!PyArg_ParseTuple (args, "iii:ImageSurface.__new__",
- &format, &width, &height))
+ &format_arg, &width, &height))
return NULL;
+
+ format = (cairo_format_t)format_arg;
+
return PycairoSurface_FromSurface (
cairo_image_surface_create (format, width, height),
NULL);
cairo_surface_t *surface;
cairo_format_t format;
unsigned char *buffer;
- int width, height, stride = -1, res;
+ int width, height, stride = -1, res, format_arg;
Py_ssize_t buffer_len;
PyObject *obj;
- if (!PyArg_ParseTuple(args, "Oiii|i:ImageSurface.create_for_data",
- &obj, &format, &width, &height, &stride))
+ if (!PyArg_ParseTuple (args, "Oiii|i:ImageSurface.create_for_data",
+ &obj, &format_arg, &width, &height, &stride))
return NULL;
+ format = (cairo_format_t)format_arg;
+
res = PyObject_AsWriteBuffer (obj, (void **)&buffer, &buffer_len);
if (res == -1)
return NULL;
static PyObject *
image_surface_format_stride_for_width (PyObject *self, PyObject *args) {
cairo_format_t format;
- int width;
- if (!PyArg_ParseTuple(args, "ii:format_stride_for_width", &format, &width))
+ int width, format_arg;
+
+ if (!PyArg_ParseTuple (args, "ii:format_stride_for_width",
+ &format_arg, &width))
return NULL;
+
+ format = (cairo_format_t)format_arg;
+
return PYCAIRO_PyLong_FromLong (cairo_format_stride_for_width (format, width));
}
static PyObject *
pdf_version_to_string (PyObject *self, PyObject *args) {
cairo_pdf_version_t version;
+ int version_arg;
const char *version_string;
- if (!PyArg_ParseTuple(args, "i:PDFSurface.version_to_string", &version))
+ if (!PyArg_ParseTuple (args, "i:PDFSurface.version_to_string", &version_arg))
return NULL;
+ version = (cairo_pdf_version_t)version_arg;
+
Py_BEGIN_ALLOW_THREADS;
version_string = cairo_pdf_version_to_string (version);
Py_END_ALLOW_THREADS;
static PyObject *
pdf_surface_restrict_to_version (PycairoPDFSurface *o, PyObject *args) {
cairo_pdf_version_t version;
+ int version_arg;
- if (!PyArg_ParseTuple(args, "i:PDFSurface.restrict_to_version", &version))
+ if (!PyArg_ParseTuple (args, "i:PDFSurface.restrict_to_version",
+ &version_arg))
return NULL;
+ version = (cairo_pdf_version_t)version_arg;
+
Py_BEGIN_ALLOW_THREADS;
cairo_pdf_surface_restrict_to_version (o->surface, version);
Py_END_ALLOW_THREADS;
static PyObject *
script_surface_new (PyTypeObject *type, PyObject *args, PyObject *kwds) {
cairo_content_t content;
+ int content_arg;
double width, height;
PyObject *pydevice;
if (!PyArg_ParseTuple (args, "O!idd:ScriptSurface.__new__",
- &PycairoScriptDevice_Type, &pydevice, &content, &width, &height))
+ &PycairoScriptDevice_Type, &pydevice, &content_arg, &width, &height))
return NULL;
+ content = (cairo_content_t)content_arg;
+
return PycairoSurface_FromSurface (
cairo_script_surface_create (
((PycairoDevice*)pydevice)->device, content, width, height),
static PyObject *
ps_level_to_string (PyObject *self, PyObject *args) {
cairo_ps_level_t level;
+ int level_arg;
const char *s;
- if (!PyArg_ParseTuple(args, "i:PSSurface.level_to_string", &level))
+
+ if (!PyArg_ParseTuple (args, "i:PSSurface.level_to_string", &level_arg))
return NULL;
+
+ level = (cairo_ps_level_t)level_arg;
+
s = cairo_ps_level_to_string (level);
if (s == NULL){
PyErr_SetString(PyExc_ValueError, "level_to_string: "
static PyObject *
ps_surface_restrict_to_level (PycairoPSSurface *o, PyObject *args) {
cairo_ps_level_t level;
+ int level_arg;
- if (!PyArg_ParseTuple(args, "i:PSSurface.restrict_to_level", &level))
+ if (!PyArg_ParseTuple (args, "i:PSSurface.restrict_to_level", &level_arg))
return NULL;
+
+ level = (cairo_ps_level_t)level_arg;
+
cairo_ps_surface_restrict_to_level (o->surface, level);
RETURN_NULL_IF_CAIRO_SURFACE_ERROR(o->surface);
Py_RETURN_NONE;
cairo_content_t content;
cairo_rectangle_t extents, *extents_ptr;
cairo_surface_t *sfc;
+ int content_arg;
PyObject *extents_tuple;
- if (!PyArg_ParseTuple(args, "iO:RecordingSurface.__new__",
- &content, &extents_tuple))
+ if (!PyArg_ParseTuple (args, "iO:RecordingSurface.__new__",
+ &content_arg, &extents_tuple))
return NULL;
+ content = (cairo_content_t)content_arg;
+
if (extents_tuple == Py_None) {
extents_ptr = NULL;
} else {
static PyObject *
svg_version_to_string (PyObject *self, PyObject *args) {
cairo_svg_version_t version;
+ int version_arg;
const char *version_string;
- if (!PyArg_ParseTuple(args, "i:SVGSurface.version_to_string", &version))
+ if (!PyArg_ParseTuple (args, "i:SVGSurface.version_to_string", &version_arg))
return NULL;
+ version = (cairo_svg_version_t)version_arg;
+
Py_BEGIN_ALLOW_THREADS;
version_string = cairo_svg_version_to_string (version);
Py_END_ALLOW_THREADS;
static PyObject *
svg_surface_restrict_to_version (PycairoPDFSurface *o, PyObject *args) {
cairo_svg_version_t version;
+ int version_arg;
- if (!PyArg_ParseTuple(args, "i:SVGSurface.restrict_to_version", &version))
+ if (!PyArg_ParseTuple (args, "i:SVGSurface.restrict_to_version",
+ &version_arg))
return NULL;
+ version = (cairo_svg_version_t)version_arg;
+
Py_BEGIN_ALLOW_THREADS;
cairo_svg_surface_restrict_to_version (o->surface, version);
Py_END_ALLOW_THREADS;
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="200pt" height="200pt" viewBox="0 0 200 200" version="1.1">
+<g id="surface1">
+<path style="fill:none;stroke-width:0.04;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(0%,0%,0%);stroke-opacity:1;stroke-miterlimit:10;" d="M 0.1 0.5 C 0.4 0.9 0.6 0.1 0.9 0.5 " transform="matrix(200,0,0,200,0,0)"/>
+<path style="fill:none;stroke-width:0.02;stroke-linecap:butt;stroke-linejoin:miter;stroke:rgb(100%,20%,20%);stroke-opacity:0.6;stroke-miterlimit:10;" d="M 0.1 0.5 L 0.4 0.9 M 0.6 0.1 L 0.9 0.5 " transform="matrix(200,0,0,200,0,0)"/>
+</g>
+</svg>
[flake8]
-ignore=E402
+ignore=E402,E741
builtins=buffer,unichr
[coverage:run]
from distutils.ccompiler import new_compiler
-PYCAIRO_VERSION = '1.15.3'
+PYCAIRO_VERSION = '1.15.4'
CAIRO_VERSION_REQUIRED = '1.13.1'
XPYB_VERSION_REQUIRED = '1.3'
import cairo
import pytest
+import ctypes
@pytest.fixture
assert isinstance(context.get_operator(), cairo.Operator)
+def test_get_set_operator_limits(context):
+ max_int = 2 ** (ctypes.sizeof(ctypes.c_int()) * 8 - 1) - 1
+ min_int = -max_int - 1
+
+ for val in [-1, 0, max_int, min_int]:
+ context.set_operator(val)
+ assert context.get_operator() == val
+
+
def test_show_text_glyphs():
surface = cairo.PDFSurface(None, 300, 300)
context = cairo.Context(surface)