[cairo-commit] pycairo/cairo pycairo-surface.c, 1.50,
1.51 pycairo-context.c, 1.59, 1.60 cairomodule.c, 1.44, 1.45
Steve Chaplin
commit at pdx.freedesktop.org
Mon Aug 1 08:24:40 PDT 2005
- Previous message: [cairo-commit] pycairo ChangeLog,1.156,1.157
- Next message: [cairo-commit] pycairo ChangeLog, 1.157, 1.158 configure.ac, 1.30,
1.31 README, 1.16, 1.17 setup.py, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
Committed by: stevech1097
Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv16868/cairo
Modified Files:
pycairo-surface.c pycairo-context.c cairomodule.c
Log Message:
'SC'
Index: pycairo-surface.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-surface.c,v
retrieving revision 1.50
retrieving revision 1.51
diff -u -d -r1.50 -r1.51
--- pycairo-surface.c 1 Aug 2005 10:25:47 -0000 1.50
+++ pycairo-surface.c 1 Aug 2005 15:24:38 -0000 1.51
@@ -140,6 +140,16 @@
}
static PyObject *
+surface_get_font_options (PycairoSurface *o)
+{
+ cairo_font_options_t *options = cairo_font_options_create();
+
+ cairo_surface_get_font_options (o->surface, options);
+ /* there is no reference fn */
+ return PycairoFontOptions_FromFontOptions (options);
+}
+
+static PyObject *
surface_set_device_offset (PycairoSurface *o, PyObject *args)
{
double x_offset, y_offset;
@@ -179,6 +189,7 @@
*/
{"create_similar", (PyCFunction)surface_create_similar, METH_VARARGS },
{"finish", (PyCFunction)surface_finish, METH_NOARGS },
+ {"get_font_options",(PyCFunction)surface_get_font_options, METH_NOARGS },
{"set_device_offset",(PyCFunction)surface_set_device_offset,
METH_VARARGS },
#ifdef CAIRO_HAS_PNG_FUNCTIONS
@@ -393,8 +404,14 @@
if (PyObject_TypeCheck (o, &PyBaseString_Type)) {
fp = fopen (PyString_AsString(o), "rb");
+ if (fp == NULL) {
+ PyErr_SetString(PyExc_IOError, "unable to open file for reading");
+ return NULL;
+ }
+
} else if (PyObject_TypeCheck (o, &PyFile_Type)) {
- fp = PyFile_AsFile((PyFileObject *)o);
+ fp = PyFile_AsFile(o);
+
} else {
PyErr_SetString(PyExc_TypeError,
"ImageSurface.create_from_png takes one argument "
@@ -402,10 +419,6 @@
return NULL;
}
- if (fp == NULL) {
- PyErr_SetString(PyExc_IOError, "unable to open file");
- return NULL;
- }
surface = cairo_image_surface_create_from_png_stream (pycairo_read_func,
fp);
if (PyObject_TypeCheck (o, &PyBaseString_Type))
Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.59
retrieving revision 1.60
diff -u -d -r1.59 -r1.60
--- pycairo-context.c 14 Jun 2005 08:42:33 -0000 1.59
+++ pycairo-context.c 1 Aug 2005 15:24:38 -0000 1.60
@@ -308,7 +308,8 @@
pycairo_get_font_face (PycairoContext *o)
{
cairo_font_face_t *font_face = cairo_get_font_face (o->ctx);
- if (!font_face) {
+ /* remove this block when cairo_get_font_face returns _cairo_font_face_nil;*/
+ if (!font_face) {
Pycairo_Check_Status (cairo_status (o->ctx));
return NULL;
}
@@ -325,6 +326,16 @@
}
static PyObject *
+pycairo_get_font_options (PycairoContext *o)
+{
+ cairo_font_options_t *options = cairo_font_options_create();
+
+ cairo_get_font_options (o->ctx, options);
+ /* there is no reference fn */
+ return PycairoFontOptions_FromFontOptions (options);
+}
+
+static PyObject *
pycairo_get_line_cap (PycairoContext *o)
{
return PyInt_FromLong(cairo_get_line_cap (o->ctx));
@@ -374,10 +385,6 @@
pycairo_get_target (PycairoContext *o)
{
cairo_surface_t *surface = cairo_get_target (o->ctx);
- if (!surface) {
- Pycairo_Check_Status (cairo_status (o->ctx));
- return NULL;
- }
cairo_surface_reference (surface);
/* bug #2765 - "How do we identify surface types?"
* should pass surface type as arg2
@@ -718,20 +725,6 @@
}
static PyObject *
-pycairo_set_font_size (PycairoContext *o, PyObject *args)
-{
- double size;
-
- if (!PyArg_ParseTuple (args, "d:Context.set_font_size", &size))
- return NULL;
-
- cairo_set_font_size (o->ctx, size);
- if (Pycairo_Check_Status (cairo_status (o->ctx)))
- return NULL;
- Py_RETURN_NONE;
-}
-
-static PyObject *
pycairo_set_font_face (PycairoContext *o, PyObject *obj)
{
if (PyObject_TypeCheck(obj, &PycairoFontFace_Type))
@@ -751,6 +744,35 @@
}
static PyObject *
+pycairo_set_font_options (PycairoContext *o, PyObject *args)
+{
+ PycairoFontOptions *options;
+
+ if (!PyArg_ParseTuple (args, "O!:Context.set_font_options",
+ &PycairoFontOptions_Type, &options))
+ return NULL;
+
+ cairo_set_font_options (o->ctx, options->font_options);
+ if (Pycairo_Check_Status (cairo_status (o->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
+pycairo_set_font_size (PycairoContext *o, PyObject *args)
+{
+ double size;
+
+ if (!PyArg_ParseTuple (args, "d:Context.set_font_size", &size))
+ return NULL;
+
+ cairo_set_font_size (o->ctx, size);
+ if (Pycairo_Check_Status (cairo_status (o->ctx)))
+ return NULL;
+ Py_RETURN_NONE;
+}
+
+static PyObject *
pycairo_set_line_cap (PycairoContext *o, PyObject *args)
{
cairo_line_cap_t line_cap;
@@ -1081,6 +1103,7 @@
{"get_fill_rule", (PyCFunction)pycairo_get_fill_rule, METH_NOARGS},
{"get_font_face", (PyCFunction)pycairo_get_font_face, METH_NOARGS},
{"get_font_matrix", (PyCFunction)pycairo_get_font_matrix,METH_NOARGS},
+ {"get_font_options",(PyCFunction)pycairo_get_font_options,METH_NOARGS},
{"get_line_cap", (PyCFunction)pycairo_get_line_cap, METH_NOARGS},
{"get_line_join", (PyCFunction)pycairo_get_line_join, METH_NOARGS},
{"get_line_width", (PyCFunction)pycairo_get_line_width, METH_NOARGS},
@@ -1117,6 +1140,7 @@
{"set_fill_rule", (PyCFunction)pycairo_set_fill_rule, METH_VARARGS},
{"set_font_face", (PyCFunction)pycairo_set_font_face, METH_O},
{"set_font_matrix", (PyCFunction)pycairo_set_font_matrix,METH_VARARGS},
+ {"set_font_options",(PyCFunction)pycairo_set_font_options,METH_VARARGS},
{"set_font_size", (PyCFunction)pycairo_set_font_size, METH_VARARGS},
{"set_line_cap", (PyCFunction)pycairo_set_line_cap, METH_VARARGS},
{"set_line_join", (PyCFunction)pycairo_set_line_join, METH_VARARGS},
Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- cairomodule.c 23 Jul 2005 04:41:41 -0000 1.44
+++ cairomodule.c 1 Aug 2005 15:24:38 -0000 1.45
@@ -51,6 +51,10 @@
case CAIRO_STATUS_NO_MEMORY:
PyErr_NoMemory();
break;
+ case CAIRO_STATUS_READ_ERROR:
+ case CAIRO_STATUS_WRITE_ERROR:
+ PyErr_SetString(PyExc_IOError, cairo_status_to_string (status));
+ break;
case CAIRO_STATUS_INVALID_RESTORE:
PyErr_SetString(CairoError, "Context.restore without matching "
"Context.save");
- Previous message: [cairo-commit] pycairo ChangeLog,1.156,1.157
- Next message: [cairo-commit] pycairo ChangeLog, 1.157, 1.158 configure.ac, 1.30,
1.31 README, 1.16, 1.17 setup.py, 1.2, 1.3
- Messages sorted by:
[ date ]
[ thread ]
[ subject ]
[ author ]
More information about the cairo-commit
mailing list