[cairo-commit] pycairo/cairo cairomodule.c, 1.32, 1.33 pycairo.h, 1.29, 1.30 pycairo-font.c, 1.14, 1.15 pycairo-private.h, 1.22, 1.23 pycairo-path.c, 1.2, 1.3 pycairo-context.c, 1.48, 1.49 pycairo-matrix.c, 1.15, 1.16

Steve Chaplin commit at pdx.freedesktop.org
Tue May 10 08:34:05 PDT 2005


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory gabe:/tmp/cvs-serv30309/cairo

Modified Files:
	cairomodule.c pycairo.h pycairo-font.c pycairo-private.h 
	pycairo-path.c pycairo-context.c pycairo-matrix.c 
Log Message:
SC

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- cairomodule.c	10 May 2005 00:55:39 -0000	1.32
+++ cairomodule.c	10 May 2005 15:34:03 -0000	1.33
@@ -104,6 +104,7 @@
     &PycairoMatrix_Type,   
     &PycairoPath_Type,  
     &PycairoPattern_Type,  
+    &PycairoScaledFont_Type,  
 
     &PycairoSurface_Type,  
     &PycairoImageSurface_Type,  
@@ -114,6 +115,7 @@
     PycairoMatrix_FromMatrix,
     PycairoPath_FromPath,
     PycairoPattern_FromPattern,
+    PycairoScaledFont_FromScaledFont,
 
     PycairoSurface_FromSurface,
     PycairoImageSurface_FromImageSurface,
@@ -137,6 +139,8 @@
 	return;
     if (PyType_Ready(&PycairoPattern_Type) < 0)
         return;
+    if (PyType_Ready(&PycairoScaledFont_Type) < 0)
+        return;
 
     if (PyType_Ready(&PycairoSurface_Type) < 0)
         return;
@@ -159,6 +163,8 @@
      */
     Py_INCREF(&PycairoPattern_Type);
     PyModule_AddObject(m, "Pattern", (PyObject *)&PycairoPattern_Type);
+    Py_INCREF(&PycairoScaledFont_Type);
+    PyModule_AddObject(m, "ScaledFont", (PyObject *)&PycairoScaledFont_Type);
 
     Py_INCREF(&PycairoSurface_Type);
     PyModule_AddObject(m, "Surface", (PyObject *)&PycairoSurface_Type);

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.29
retrieving revision 1.30
diff -u -d -r1.29 -r1.30
--- pycairo.h	10 May 2005 00:55:39 -0000	1.29
+++ pycairo.h	10 May 2005 15:34:03 -0000	1.30
@@ -72,6 +72,11 @@
 
 typedef struct {
     PyObject_HEAD
+    cairo_scaled_font_t *scaled_font;
+} PycairoScaledFont;
+
+typedef struct {
+    PyObject_HEAD
     cairo_surface_t *surface;
     PyObject *base; /* base object used to create surface, or NULL */
 } PycairoSurface;
@@ -87,6 +92,7 @@
     PyTypeObject *Matrix_Type;
     PyTypeObject *Path_Type;
     PyTypeObject *Pattern_Type;
+    PyTypeObject *ScaledFont_Type;
 
     PyTypeObject *Surface_Type;
     PyTypeObject *ImageSurface_Type;
@@ -98,6 +104,7 @@
     PyObject *(*Matrix_FromMatrix)(const cairo_matrix_t *matrix);
     PyObject *(*Path_FromPath)(cairo_path_t *path);
     PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern);
+    PyObject *(*ScaledFont_FromScaledFont)(cairo_scaled_font_t *scaled_font);
 
     PyObject *(*Surface_FromSurface)(cairo_surface_t *surface, PyObject *base);
     PyObject *(*ImageSurface_FromImageSurface)(cairo_surface_t *surface, PyObject *base);
@@ -115,6 +122,7 @@
 #define PycairoFontFace_Type        *(Pycairo_CAPI->Fontface_Type)
 #define PycairoMatrix_Type          *(Pycairo_CAPI->Matrix_Type)
 #define PycairoPattern_Type         *(Pycairo_CAPI->Pattern_Type)
+#define PycairoScaledFont_Type      *(Pycairo_CAPI->ScaledFont_Type)
 
 #define PycairoSurface_Type         *(Pycairo_CAPI->Surface_Type)
 #define PycairoImageSurface_Type    *(Pycairo_CAPI->ImageSurface_Type)
@@ -124,6 +132,7 @@
 #define PycairoFontFace_FromFontFace (Pycairo_CAPI->Fontface_FromFontFace)
 #define PycairoMatrix_FromMatrix     (Pycairo_CAPI->Matrix_FromMatrix)
 #define PycairoPattern_FromPattern   (Pycairo_CAPI->Pattern_FromPattern)
+#define PycairoScaledFont_FromScaledFont (Pycairo_CAPI->ScaledFont_FromScaledFont)
 
 #define PycairoSurface_FromSurface   (Pycairo_CAPI->Surface_FromSurface)
 #define PycairoImageSurface_FromImageSurface (Pycairo_CAPI->ImageSurface_FromImageSurface)
@@ -139,4 +148,5 @@
                                                           "pycairo_CAPI")
 
 #endif /* ifndef _INSIDE_PYCAIRO_ */
+
 #endif /* ifndef _PYCAIRO_H_ */

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- pycairo-font.c	9 May 2005 09:12:31 -0000	1.14
+++ pycairo-font.c	10 May 2005 15:34:03 -0000	1.15
@@ -34,6 +34,8 @@
 #include "pycairo-private.h"
 
 
+/* PycairoFontFace -------------------------------------------------------- */
+
 /* PycairoFontFace_FromFontFace
  * Create a new PycairoFontFace from a cairo_font_face_t
  * Return value: New reference (NULL on failure)
@@ -130,3 +132,137 @@
     0,                                  /* tp_is_gc */
     0,                                  /* tp_bases */
 };
+
+
+/* PycairoScaledFont ------------------------------------------------------ */
+
+/* PycairoScaledFont_FromScaledFont
+ * Create a new PycairoScaledFont from a cairo_font_face_t
+ * Return value: New reference (NULL on failure)
+ */
+PyObject *
+PycairoScaledFont_FromScaledFont(cairo_scaled_font_t *scaled_font)
+{
+    PycairoScaledFont *f = (PycairoScaledFont *)PycairoScaledFont_Type.tp_new
+	(&PycairoScaledFont_Type, NULL, NULL);
+    if (f)
+	f->scaled_font = scaled_font;
+
+    return (PyObject *) f;
+}
+
+static void
+scaled_font_dealloc(PycairoScaledFont *f)
+{
+#ifdef DEBUG
+    printf("scaled_font_dealloc start\n");
+#endif
+    if (f->scaled_font) {
+	cairo_scaled_font_destroy(f->scaled_font);
+	f->scaled_font = NULL;
+    }
+    f->ob_type->tp_free((PyObject *) f);
+#ifdef DEBUG
+    printf("scaled_font_dealloc end\n");
+#endif
+}
+
+static PyObject *
+scaled_font_new(PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    return type->tp_alloc(type, 0);
+}
+
+static int
+scaled_font_init(PycairoScaledFont *sf, PyObject *args, PyObject *kwds)
+{
+    PycairoFontFace *ff;
+    PycairoMatrix *mx1, *mx2;
+    cairo_scaled_font_t *scaled_font;
+
+    if (!PyArg_ParseTuple(args, "O!O!O!:ScaledFont.__init__",
+			  &PycairoFontFace_Type, &ff,
+			  &PycairoMatrix_Type, &mx1,
+			  &PycairoMatrix_Type, &mx2))
+	return -1;
+
+    sf->scaled_font = cairo_scaled_font_create (ff->font_face, &mx1->matrix, 
+						&mx2->matrix);
+    if (!sf->scaled_font) {
+	Py_DECREF(sf);
+	PyErr_NoMemory();
+	return -1;
+    }
+    return 0;
+}
+
+static PyObject *
+scaled_font_extents (PycairoScaledFont *sf)
+{
+    cairo_font_extents_t e;
+    cairo_status_t status = cairo_scaled_font_extents (sf->scaled_font, &e);
+    if (Pycairo_check_status (status))
+	return NULL;
+    return Py_BuildValue ("(ddddd)", e.ascent, e.descent, e.height, 
+			  e.max_x_advance, e.max_y_advance);
+}
+
+static PyMethodDef scaled_font_methods[] = {
+    /* methods never exposed in a language binding:
+     * cairo_scaled_font_destroy()  
+     * cairo_scaled_font_reference()
+     */
+    /* glyph_extents - undocumented */
+    { NULL, NULL, 0 }
+};
+
+static PyGetSetDef scaled_font_getsets[] = {
+    { "extents",   (getter)scaled_font_extents,     (setter)0 },
+    { NULL, (getter)0, (setter)0 }
+};
+
+
+PyTypeObject PycairoScaledFont_Type = {
+    PyObject_HEAD_INIT(&PyType_Type)
+    0,                                  /* ob_size */
+    "cairo.ScaledFont",                 /* tp_name */
+    sizeof(PycairoScaledFont),          /* tp_basicsize */
+    0,                                  /* tp_itemsize */
+    (destructor)scaled_font_dealloc,    /* tp_dealloc */
+    0,                                  /* tp_print */
+    0,                                  /* tp_getattr */
+    0,                                  /* tp_setattr */
+    0,                                  /* tp_compare */
+    0,                                  /* tp_repr */
+    0,                                  /* tp_as_number */
+    0,                                  /* tp_as_sequence */
+    0,                                  /* tp_as_mapping */
+    0,                                  /* tp_hash */
+    0,                                  /* tp_call */
+    0,                                  /* tp_str */
+    0,                                  /* tp_getattro */
+    0,                                  /* tp_setattro */
+    0,                                  /* tp_as_buffer */
+    Py_TPFLAGS_DEFAULT,                 /* tp_flags */
+    NULL,                               /* tp_doc */
+    0,                                  /* tp_traverse */
+    0,                                  /* tp_clear */
+    0,                                  /* tp_richcompare */
+    0,                                  /* tp_weaklistoffset */
+    0,                                  /* tp_iter */
+    0,                                  /* tp_iternext */
+    scaled_font_methods,                /* tp_methods */
+    0,                                  /* tp_members */
+    scaled_font_getsets,                /* tp_getset */
+    &PyBaseObject_Type,                 /* tp_base */
+    0,                                  /* tp_dict */
+    0,                                  /* tp_descr_get */
+    0,                                  /* tp_descr_set */
+    0,                                  /* tp_dictoffset */
+    (initproc)scaled_font_init,         /* tp_init */
+    0,                                  /* tp_alloc */
+    (newfunc)scaled_font_new,           /* tp_new */
+    0,                                  /* tp_free */
+    0,                                  /* tp_is_gc */
+    0,                                  /* tp_bases */
+};

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- pycairo-private.h	10 May 2005 00:55:39 -0000	1.22
+++ pycairo-private.h	10 May 2005 15:34:03 -0000	1.23
@@ -45,6 +45,7 @@
 extern PyTypeObject PycairoMatrix_Type;
 extern PyTypeObject PycairoPath_Type;
 extern PyTypeObject PycairoPattern_Type;
+extern PyTypeObject PycairoScaledFont_Type;
 
 extern PyTypeObject PycairoSurface_Type;
 extern PyTypeObject PycairoImageSurface_Type;
@@ -55,6 +56,7 @@
 PyObject *PycairoMatrix_FromMatrix(const cairo_matrix_t *matrix);
 PyObject *PycairoPath_FromPath(cairo_path_t *path);
 PyObject *PycairoPattern_FromPattern(cairo_pattern_t *pattern);
+PyObject *PycairoScaledFont_FromScaledFont(cairo_scaled_font_t *scaled_font);
 
 PyObject *PycairoSurface_FromSurface(cairo_surface_t *surface, PyObject *base);
 PyObject *PycairoImageSurface_FromImageSurface(cairo_surface_t *surface, PyObject *base);

Index: pycairo-path.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-path.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- pycairo-path.c	10 May 2005 00:55:39 -0000	1.2
+++ pycairo-path.c	10 May 2005 15:34:03 -0000	1.3
@@ -88,10 +88,9 @@
 path_str(PycairoPath *p)
 {
     PyObject *s, *pieces = NULL, *result = NULL;
-    int i;
-    int ret;
-    cairo_path_t *path;
+    cairo_path_t *path = p->path;
     cairo_path_data_t *data;
+    int i, ret;
     char buf[80];
 
     pieces = PyList_New(0);
@@ -99,8 +98,6 @@
 	goto Done;
 
     /* loop reading elements */
-    path = p->path;
- 
     for (i=0; i < path->num_data; i += path->data[i].header.length) {
 	data = &path->data[i];
 	switch (data->header.type) {
@@ -221,8 +218,6 @@
 
 static PyTypeObject PycairoPathiter_Type;
 
-/* this should go in header file and be public? */
-#define PyPath_Check(op) ((op)->ob_type == &PycairoPath_Type)
 
 static void
 pathiter_dealloc(PycairoPathiter *it)
@@ -236,7 +231,7 @@
 {
     PycairoPathiter *it;
 
-    if (!PyPath_Check(pypath)) {
+    if (!PyObject_TypeCheck (pypath, &PycairoPath_Type)) {
 	PyErr_BadInternalCall();
 	return NULL;
     }
@@ -260,16 +255,14 @@
     pypath = it->pypath;
     if (pypath == NULL)
 	return NULL;
-    assert(PyPath_Check(pypath));
+    assert (PyObject_TypeCheck (pypath, &PycairoPath_Type));
     path = pypath->path;
 
     /* return the next path element, advance index */
     if (it->index < path->num_data) {
-	cairo_path_data_t *data;
-	int type;
+	cairo_path_data_t *data = &path->data[it->index];
+	int type = data->header.type;
 
-	data = &path->data[it->index];
-	type = data->header.type;
 	it->index += data[0].header.length;
 
 	switch (type) {

Index: pycairo-context.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-context.c,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- pycairo-context.c	10 May 2005 00:55:39 -0000	1.48
+++ pycairo-context.c	10 May 2005 15:34:03 -0000	1.49
@@ -285,14 +285,13 @@
 static PyObject *
 pycairo_font_extents(PycairoContext *c)
 {
-    cairo_font_extents_t extents;
+    cairo_font_extents_t e;
 
-    cairo_font_extents(c->ctx, &extents);
+    cairo_font_extents(c->ctx, &e);
     if (Pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
-    return Py_BuildValue("(ddddd)", extents.ascent, extents.descent, 
-			 extents.height, extents.max_x_advance, 
-			 extents.max_y_advance);
+    return Py_BuildValue("(ddddd)", e.ascent, e.descent, e.height, 
+			 e.max_x_advance, e.max_y_advance);
 }
 
 static PyObject *
@@ -331,7 +330,7 @@
 pycairo_get_font_matrix(PycairoContext *c)
 {
     cairo_matrix_t mx1, *mx2;
-    mx1 = cairo_get_font_matrix (c->ctx, mx2); /* cairo does not use mx2! */
+    mx1 = cairo_get_font_matrix (c->ctx, mx2);
     return PycairoMatrix_FromMatrix (&mx1);
 }
 
@@ -379,14 +378,15 @@
     PyObject *p;
     cairo_pattern_t *pattern = cairo_get_source(c->ctx);
 
-    if (!pattern)
-	return PyErr_NoMemory();
+    if (!pattern) {
+	Pycairo_check_status(cairo_status(c->ctx));
+	return NULL;
+    }
 
     p = PycairoPattern_FromPattern(pattern);
     if (p)
 	cairo_pattern_reference(pattern);
     return p;
-
 }
 
 static PyObject *
@@ -749,16 +749,19 @@
 }
 
 static PyObject *
-pycairo_set_font_face(PycairoContext *c, PyObject *args)
+pycairo_set_font_face(PycairoContext *c, PyObject *obj)
 {
-    PycairoFontFace *ff;
-    /* TODO: font_face or None (NULL) should be allowed */
-
-    if (!PyArg_ParseTuple(args, "O!:Context.set_font_face",
-			  &PycairoFontFace_Type, &ff))
+    if (PyObject_TypeCheck(obj, &PycairoFontFace_Type))
+	cairo_set_font_face(c->ctx, ((PycairoFontFace *)obj)->font_face);
+    else if (obj == Py_None)
+	cairo_set_font_face(c->ctx, NULL);
+    else {
+	PyErr_SetString(PyExc_TypeError,
+			"Context.set_font_face() argument must be "
+			"cairo.FontFace or None");
 	return NULL;
+    }
 
-    cairo_set_font_face(c->ctx, ff->font_face);
     if (Pycairo_check_status(cairo_status(c->ctx)))
 	return NULL;
     Py_RETURN_NONE;
@@ -1070,71 +1073,71 @@
      * cairo_destroy()
      * cairo_reference()
      */
-    { "append_path",   (PyCFunction)pycairo_append_path,   METH_VARARGS },
-    { "arc",           (PyCFunction)pycairo_arc,           METH_VARARGS },
-    { "arc_negative",  (PyCFunction)pycairo_arc_negative,  METH_VARARGS },
-    { "clip",          (PyCFunction)pycairo_clip,          METH_NOARGS },
-    { "clip_preserve", (PyCFunction)pycairo_clip_preserve, METH_NOARGS },
-    { "close_path",    (PyCFunction)pycairo_close_path,    METH_NOARGS },
-    { "copy_page",     (PyCFunction)pycairo_copy_page,     METH_NOARGS },
-    { "copy_path",     (PyCFunction)pycairo_copy_path,     METH_NOARGS },
-    { "copy_path_flat",(PyCFunction)pycairo_copy_path_flat,METH_NOARGS },
-    { "curve_to",      (PyCFunction)pycairo_curve_to,      METH_VARARGS },
-    { "device_to_user",(PyCFunction)pycairo_device_to_user,METH_VARARGS },
+    { "append_path",    (PyCFunction)pycairo_append_path,   METH_VARARGS },
+    { "arc",            (PyCFunction)pycairo_arc,           METH_VARARGS },
+    { "arc_negative",   (PyCFunction)pycairo_arc_negative,  METH_VARARGS },
+    { "clip",           (PyCFunction)pycairo_clip,          METH_NOARGS },
+    { "clip_preserve",  (PyCFunction)pycairo_clip_preserve, METH_NOARGS },
+    { "close_path",     (PyCFunction)pycairo_close_path,    METH_NOARGS },
+    { "copy_page",      (PyCFunction)pycairo_copy_page,     METH_NOARGS },
+    { "copy_path",      (PyCFunction)pycairo_copy_path,     METH_NOARGS },
+    { "copy_path_flat", (PyCFunction)pycairo_copy_path_flat,METH_NOARGS },
+    { "curve_to",       (PyCFunction)pycairo_curve_to,      METH_VARARGS },
+    { "device_to_user", (PyCFunction)pycairo_device_to_user,METH_VARARGS },
     { "device_to_user_distance",
-      (PyCFunction)pycairo_device_to_user_distance,        METH_VARARGS },
-    { "fill",          (PyCFunction)pycairo_fill,          METH_NOARGS },
-    { "fill_preserve", (PyCFunction)pycairo_fill_preserve, METH_NOARGS },
+       (PyCFunction)pycairo_device_to_user_distance,        METH_VARARGS },
+    { "fill",           (PyCFunction)pycairo_fill,          METH_NOARGS },
+    { "fill_preserve",  (PyCFunction)pycairo_fill_preserve, METH_NOARGS },
     /* glyph_extents */
-    /* glyph_path */
+    /* glyph_path    - undocumented */
     { "identity_matrix",(PyCFunction)pycairo_identity_matrix,METH_NOARGS },
-    { "in_fill",       (PyCFunction)pycairo_in_fill,       METH_VARARGS },
-    { "in_stroke",     (PyCFunction)pycairo_in_stroke,     METH_VARARGS },
-    { "line_to",       (PyCFunction)pycairo_line_to,       METH_VARARGS },
-    { "mask",          (PyCFunction)pycairo_move_to,       METH_VARARGS },
-    { "mask_surface",  (PyCFunction)pycairo_move_to,       METH_VARARGS },
-    { "move_to",       (PyCFunction)pycairo_move_to,       METH_VARARGS },
-    { "new_path",      (PyCFunction)pycairo_new_path,      METH_NOARGS },
-    { "paint",         (PyCFunction)pycairo_paint,         METH_NOARGS },
+    { "in_fill",        (PyCFunction)pycairo_in_fill,       METH_VARARGS },
+    { "in_stroke",      (PyCFunction)pycairo_in_stroke,     METH_VARARGS },
+    { "line_to",        (PyCFunction)pycairo_line_to,       METH_VARARGS },
+    { "mask",           (PyCFunction)pycairo_move_to,       METH_VARARGS },
+    { "mask_surface",   (PyCFunction)pycairo_move_to,       METH_VARARGS },
+    { "move_to",        (PyCFunction)pycairo_move_to,       METH_VARARGS },
+    { "new_path",       (PyCFunction)pycairo_new_path,      METH_NOARGS },
+    { "paint",          (PyCFunction)pycairo_paint,         METH_NOARGS },
     { "paint_with_alpha",(PyCFunction)pycairo_paint_with_alpha,
-                                                           METH_VARARGS },
-    { "rectangle",     (PyCFunction)pycairo_rectangle,     METH_VARARGS },
-    { "rel_curve_to",  (PyCFunction)pycairo_rel_curve_to,  METH_VARARGS },
-    { "rel_line_to",   (PyCFunction)pycairo_rel_line_to,   METH_VARARGS },
-    { "rel_move_to",   (PyCFunction)pycairo_rel_move_to,   METH_VARARGS },
-    { "reset_clip",    (PyCFunction)pycairo_reset_clip,    METH_NOARGS },
-    { "restore",       (PyCFunction)pycairo_restore,       METH_NOARGS },
-    { "rotate",        (PyCFunction)pycairo_rotate,        METH_VARARGS },
-    { "save",          (PyCFunction)pycairo_save,          METH_NOARGS },
-    { "scale",         (PyCFunction)pycairo_scale,         METH_VARARGS },
+                                                            METH_VARARGS },
+    { "rectangle",      (PyCFunction)pycairo_rectangle,     METH_VARARGS },
+    { "rel_curve_to",   (PyCFunction)pycairo_rel_curve_to,  METH_VARARGS },
+    { "rel_line_to",    (PyCFunction)pycairo_rel_line_to,   METH_VARARGS },
+    { "rel_move_to",    (PyCFunction)pycairo_rel_move_to,   METH_VARARGS },
+    { "reset_clip",     (PyCFunction)pycairo_reset_clip,    METH_NOARGS },
+    { "restore",        (PyCFunction)pycairo_restore,       METH_NOARGS },
+    { "rotate",         (PyCFunction)pycairo_rotate,        METH_VARARGS },
+    { "save",           (PyCFunction)pycairo_save,          METH_NOARGS },
+    { "scale",          (PyCFunction)pycairo_scale,         METH_VARARGS },
     { "select_font_face",(PyCFunction)pycairo_select_font_face,METH_VARARGS },
-    { "set_dash",      (PyCFunction)pycairo_set_dash,      METH_VARARGS },
-    { "set_fill_rule", (PyCFunction)pycairo_set_fill_rule, METH_VARARGS },
-    { "set_font_face", (PyCFunction)pycairo_set_font_face, METH_VARARGS },
+    { "set_dash",       (PyCFunction)pycairo_set_dash,      METH_VARARGS },
+    { "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_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 },
-    { "set_line_width",(PyCFunction)pycairo_set_line_width,METH_VARARGS },
-    { "set_matrix",    (PyCFunction)pycairo_set_matrix,    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 },
+    { "set_line_width", (PyCFunction)pycairo_set_line_width,METH_VARARGS },
+    { "set_matrix",     (PyCFunction)pycairo_set_matrix,    METH_VARARGS },
     { "set_miter_limit",(PyCFunction)pycairo_set_miter_limit,METH_VARARGS },
-    { "set_operator",  (PyCFunction)pycairo_set_operator,  METH_VARARGS },
-    { "set_source",    (PyCFunction)pycairo_set_source,    METH_VARARGS },
+    { "set_operator",   (PyCFunction)pycairo_set_operator,  METH_VARARGS },
+    { "set_source",     (PyCFunction)pycairo_set_source,    METH_VARARGS },
     { "set_source_rgb", (PyCFunction)pycairo_set_source_rgb,METH_VARARGS },
     { "set_source_rgba",(PyCFunction)pycairo_set_source_rgba,METH_VARARGS },
     { "set_source_surface",(PyCFunction)pycairo_set_source_surface,  
-                                                           METH_VARARGS },
-    { "set_tolerance", (PyCFunction)pycairo_set_tolerance, METH_VARARGS },
-    /* show_glyphs */
-    { "show_page",     (PyCFunction)pycairo_show_page,     METH_NOARGS },
-    { "show_text",     (PyCFunction)pycairo_show_text,     METH_VARARGS },
-    { "stroke",        (PyCFunction)pycairo_stroke,        METH_NOARGS },
-    { "stroke_preserve",(PyCFunction)pycairo_stroke,       METH_NOARGS },
-    { "text_extents",  (PyCFunction)pycairo_text_extents,  METH_VARARGS },
-    { "text_path",     (PyCFunction)pycairo_text_path,     METH_VARARGS },
-    { "transform",     (PyCFunction)pycairo_transform,     METH_VARARGS },
-    { "translate",     (PyCFunction)pycairo_translate,     METH_VARARGS },
-    { "user_to_device",(PyCFunction)pycairo_user_to_device,METH_VARARGS },
+                                                            METH_VARARGS },
+    { "set_tolerance",  (PyCFunction)pycairo_set_tolerance, METH_VARARGS },
+    /* show_glyphs - undocumented */
+    { "show_page",      (PyCFunction)pycairo_show_page,     METH_NOARGS },
+    { "show_text",      (PyCFunction)pycairo_show_text,     METH_VARARGS },
+    { "stroke",         (PyCFunction)pycairo_stroke,        METH_NOARGS },
+    { "stroke_preserve",(PyCFunction)pycairo_stroke,        METH_NOARGS },
+    { "text_extents",   (PyCFunction)pycairo_text_extents,  METH_VARARGS },
+    { "text_path",      (PyCFunction)pycairo_text_path,     METH_VARARGS },
+    { "transform",      (PyCFunction)pycairo_transform,     METH_VARARGS },
+    { "translate",      (PyCFunction)pycairo_translate,     METH_VARARGS },
+    { "user_to_device", (PyCFunction)pycairo_user_to_device,METH_VARARGS },
     { "user_to_device_distance",(PyCFunction)pycairo_user_to_device_distance,
       METH_VARARGS },
     { NULL, NULL, 0 }

Index: pycairo-matrix.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-matrix.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- pycairo-matrix.c	9 May 2005 09:12:31 -0000	1.15
+++ pycairo-matrix.c	10 May 2005 15:34:03 -0000	1.16
@@ -77,6 +77,20 @@
     return 0;
 }
 
+/* constructor */
+static PyObject *
+matrix_init_rotate(PyTypeObject *type, PyObject *args)
+{
+    cairo_matrix_t matrix;
+    double radians;
+
+    if (!PyArg_ParseTuple(args, "d:Matrix.init_rotate", &radians))
+	return NULL;
+
+    cairo_matrix_init_rotate (&matrix, radians);
+    return PycairoMatrix_FromMatrix (&matrix);
+}
+
 static PyObject *
 matrix_get_xx(PycairoMatrix *m)
 {
@@ -126,9 +140,8 @@
 static PyObject *
 matrix_invert(PycairoMatrix *m)
 {
-    if (pycairo_check_status(cairo_matrix_invert(&m->matrix))) {
+    if (Pycairo_check_status(cairo_matrix_invert(&m->matrix)))
 	return NULL;
-    }
     Py_RETURN_NONE;
 }
 
@@ -266,6 +279,16 @@
 
 
 static PyMethodDef matrix_methods[] = {
+    /* Do not need to wrap all cairo_matrix_init_*() functions
+     * C API Matrix constructors       Python equivalents
+     * cairo_matrix_init()             cairo.Matrix(xx,yx,xy,yy,x0,y0)
+     * cairo_matrix_init_identity()    cairo.Matrix()
+     * cairo_matrix_init_translate()   cairo.Matrix(x0=x0,y0=y0)
+     * cairo_matrix_init_scale()       cairo.Matrix(xx=xx,yy=yy)
+     * cairo_matrix_init_rotate()      cairo.Matrix.init_rotate(radians)
+     */
+    { "init_rotate", (PyCFunction)matrix_init_rotate,           
+                                                   METH_VARARGS | METH_CLASS },
     { "invert",      (PyCFunction)matrix_invert,                METH_NOARGS },
     { "rotate",      (PyCFunction)matrix_rotate,                METH_VARARGS },
     { "scale",       (PyCFunction)matrix_scale,                 METH_VARARGS },




More information about the cairo-commit mailing list