[cairo-commit] pycairo/cairo cairomodule.c, 1.43, 1.44 pycairo.h, 1.40, 1.41 pycairo-private.h, 1.31, 1.32 pycairo-font.c, 1.23, 1.24

Steve Chaplin commit at pdx.freedesktop.org
Fri Jul 22 21:41:43 PDT 2005


Committed by: stevech1097

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

Modified Files:
	cairomodule.c pycairo.h pycairo-private.h pycairo-font.c 
Log Message:
'SC'

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.43
retrieving revision 1.44
diff -u -d -r1.43 -r1.44
--- cairomodule.c	12 Jul 2005 14:06:11 -0000	1.43
+++ cairomodule.c	23 Jul 2005 04:41:41 -0000	1.44
@@ -71,6 +71,7 @@
 static Pycairo_CAPI_t CAPI = {
     &PycairoContext_Type,      PycairoContext_FromContext,
     &PycairoFontFace_Type,     PycairoFontFace_FromFontFace,
+    &PycairoFontOptions_Type,  PycairoFontOptions_FromFontOptions,
     &PycairoMatrix_Type,       PycairoMatrix_FromMatrix,
     &PycairoPath_Type,         PycairoPath_FromPath,
     &PycairoPattern_Type,      PycairoPattern_FromPattern,
@@ -107,6 +108,8 @@
         return;
     if (PyType_Ready(&PycairoFontFace_Type) < 0)
         return;
+    if (PyType_Ready(&PycairoFontOptions_Type) < 0)
+        return;
     if (PyType_Ready(&PycairoMatrix_Type) < 0)
         return;
     if (PyType_Ready(&PycairoPath_Type) < 0)
@@ -139,6 +142,8 @@
     PyModule_AddObject(m, "Context", (PyObject *)&PycairoContext_Type);
     Py_INCREF(&PycairoFontFace_Type);
     PyModule_AddObject(m, "FontFace",(PyObject *)&PycairoFontFace_Type);
+    Py_INCREF(&PycairoFontOptions_Type);
+    PyModule_AddObject(m, "FontOptions",(PyObject *)&PycairoFontOptions_Type);
     Py_INCREF(&PycairoMatrix_Type);
     PyModule_AddObject(m, "Matrix",  (PyObject *)&PycairoMatrix_Type);
     Py_INCREF(&PycairoPath_Type);

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- pycairo.h	6 Jun 2005 03:58:00 -0000	1.40
+++ pycairo.h	23 Jul 2005 04:41:41 -0000	1.41
@@ -49,6 +49,11 @@
 
 typedef struct {
     PyObject_HEAD
+    cairo_font_options_t *font_options;
+} PycairoFontOptions;
+
+typedef struct {
+    PyObject_HEAD
     cairo_matrix_t matrix;
 } PycairoMatrix;
 
@@ -89,6 +94,9 @@
 				     PyObject *base);
     PyTypeObject *FontFace_Type;
     PyObject *(*FontFace_FromFontFace)(cairo_font_face_t *font_face);
+    PyTypeObject *FontOptions_Type;
+    PyObject *(*FontOptions_FromFontOptions)(
+                                       cairo_font_options_t *font_options);
     PyTypeObject *Matrix_Type;
     PyObject *(*Matrix_FromMatrix)(const cairo_matrix_t *matrix);
     PyTypeObject *Path_Type;
@@ -116,8 +124,11 @@
 /* Macros for accessing the C API */
 #define PycairoContext_Type         *(Pycairo_CAPI->Context_Type)
 #define PycairoContext_FromContext   (Pycairo_CAPI->Context_FromContext)
-#define PycairoFontFace_Type        *(Pycairo_CAPI->Fontface_Type)
-#define PycairoFontFace_FromFontFace (Pycairo_CAPI->Fontface_FromFontFace)
+#define PycairoFontFace_Type        *(Pycairo_CAPI->FontFace_Type)
+#define PycairoFontFace_FromFontFace (Pycairo_CAPI->FontFace_FromFontFace)
+#define PycairoFontOptions_Type     *(Pycairo_CAPI->FontOptions_Type)
+#define PycairoFontOptions_FromFontOptions \
+                                    (Pycairo_CAPI->FontOptions_FromFontOptions)
 #define PycairoMatrix_Type          *(Pycairo_CAPI->Matrix_Type)
 #define PycairoMatrix_FromMatrix     (Pycairo_CAPI->Matrix_FromMatrix)
 #define PycairoPath_Type            *(Pycairo_CAPI->Path_Type)
@@ -126,7 +137,7 @@
 #define PycairoPattern_FromPattern   (Pycairo_CAPI->Pattern_FromPattern)
 #define PycairoScaledFont_Type      *(Pycairo_CAPI->ScaledFont_Type)
 #define PycairoScaledFont_FromScaledFont \
-        (Pycairo_CAPI->ScaledFont_FromScaledFont)
+                                     (Pycairo_CAPI->ScaledFont_FromScaledFont)
 
 #define PycairoSurface_Type         *(Pycairo_CAPI->Surface_Type)
 #define PycairoImageSurface_Type    *(Pycairo_CAPI->ImageSurface_Type)

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.31
retrieving revision 1.32
diff -u -d -r1.31 -r1.32
--- pycairo-private.h	20 Jun 2005 02:40:33 -0000	1.31
+++ pycairo-private.h	23 Jul 2005 04:41:41 -0000	1.32
@@ -48,6 +48,10 @@
 extern PyTypeObject PycairoFontFace_Type;
 PyObject *PycairoFontFace_FromFontFace (cairo_font_face_t *font_face);
 
+extern PyTypeObject PycairoFontOptions_Type;
+PyObject *PycairoFontOptions_FromFontOptions (
+                                          cairo_font_options_t *font_options);
+
 extern PyTypeObject PycairoMatrix_Type;
 PyObject *PycairoMatrix_FromMatrix (const cairo_matrix_t *matrix);
 

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- pycairo-font.c	22 Jul 2005 14:37:42 -0000	1.23
+++ pycairo-font.c	23 Jul 2005 04:41:41 -0000	1.24
@@ -182,28 +182,26 @@
 scaled_font_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     PycairoFontFace *ff;
+    PycairoFontOptions *fo;
     PycairoMatrix *mx1, *mx2;
 
-    if (!PyArg_ParseTuple(args, "O!O!O!:ScaledFont.__init__",
+    if (!PyArg_ParseTuple(args, "O!O!O!O!:ScaledFont.__new__",
 			  &PycairoFontFace_Type, &ff,
 			  &PycairoMatrix_Type, &mx1,
-			  &PycairoMatrix_Type, &mx2))
+			  &PycairoMatrix_Type, &mx2,
+			  &PycairoFontOptions_Type, &fo))
 	return NULL;
 
     PyObject *o = type->tp_alloc(type, 0);
     if (o) {
-	cairo_font_options_t *options;
-	options = cairo_font_options_create ();
 	cairo_scaled_font_t *scaled_font = cairo_scaled_font_create 
-	    (ff->font_face, &mx1->matrix, &mx2->matrix, options);
-	cairo_font_options_destroy (options);
+	    (ff->font_face, &mx1->matrix, &mx2->matrix, fo->font_options);
 
 	if (!scaled_font) {
 	    Py_DECREF(o);
 	    return PyErr_NoMemory();
-	} else {
-	    ((PycairoScaledFont *)o)->scaled_font = scaled_font;
 	}
+	((PycairoScaledFont *)o)->scaled_font = scaled_font;
     }
     return o;
 }
@@ -274,3 +272,129 @@
     0,                                  /* tp_is_gc */
     0,                                  /* tp_bases */
 };
+
+
+/* class cairo.FontOptions ------------------------------------------------ */
+
+/* PycairoFontOptions_FromFontOptions
+ * Create a new PycairoFontOptions from a cairo_font_options_t
+ * font_options - a cairo_font_options_t to 'wrap' into a Python object.
+ *                it is unreferenced if the PycairoFontOptions creation fails
+ * Return value: New reference or NULL on failure
+ */
+PyObject *
+PycairoFontOptions_FromFontOptions (cairo_font_options_t *font_options)
+{
+    PyObject *o;
+
+    assert (font_options != NULL);	
+
+    if (Pycairo_Check_Status (cairo_font_options_status (font_options))) {
+	cairo_font_options_destroy (font_options);
+	return NULL;
+    }
+
+    o = PycairoFontOptions_Type.tp_alloc (&PycairoFontOptions_Type, 0);
+    if (o)
+	((PycairoFontOptions *)o)->font_options = font_options;
+    else
+	cairo_font_options_destroy (font_options);
+    return o;
+}
+
+static void
+font_options_dealloc(PycairoFontOptions *o)
+{
+#ifdef DEBUG
+    printf("font_options_dealloc start\n");
+#endif
+    if (o->font_options) {
+	cairo_font_options_destroy (o->font_options);
+	o->font_options = NULL;
+    }
+    o->ob_type->tp_free((PyObject *) o);
+#ifdef DEBUG
+    printf("font_options_dealloc end\n");
+#endif
+}
+
+static PyObject *
+font_options_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    PyObject *o = type->tp_alloc(type, 0);
+    if (o) {
+	cairo_font_options_t *font_options = cairo_font_options_create();
+
+	if (Pycairo_Check_Status (cairo_font_options_status (font_options))) {
+	    cairo_font_options_destroy (font_options);
+	    Py_DECREF(o);
+	    return NULL;
+	}
+	((PycairoFontOptions *)o)->font_options = font_options;
+    }
+    return o;
+}
+
+
+static PyMethodDef font_options_methods[] = {
+    /* methods never exposed in a language binding:
+     * cairo_font_options_destroy()  
+     * cairo_font_options_reference()
+     */
+    /* TODO:
+     * copy
+     * merge
+     * equal (richcmp?)
+     * set/get_antialias
+     * set/get_subpixel_order
+     * set/get_hint_style
+     * set/get_hint_metrics
+     */
+    {NULL, NULL, 0, NULL},
+};
+
+
+PyTypeObject PycairoFontOptions_Type = {
+    PyObject_HEAD_INIT(&PyType_Type)
+    0,                                  /* ob_size */
+    "cairo.FontOptions",                /* tp_name */
+    sizeof(PycairoFontOptions),         /* tp_basicsize */
+    0,                                  /* tp_itemsize */
+    (destructor)font_options_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 */
+    0,                                  /* tp_doc */
+    0,                                  /* tp_traverse */
+    0,                                  /* tp_clear */
+    0,                                  /* tp_richcompare */
+    0,                                  /* tp_weaklistoffset */
+    0,                                  /* tp_iter */
+    0,                                  /* tp_iternext */
+    font_options_methods,               /* tp_methods */
+    0,                                  /* tp_members */
+    0,                                  /* tp_getset */
+    &PyBaseObject_Type,                 /* tp_base */
+    0,                                  /* tp_dict */
+    0,                                  /* tp_descr_get */
+    0,                                  /* tp_descr_set */
+    0,                                  /* tp_dictoffset */
+    0,                                  /* tp_init */
+    0,                                  /* tp_alloc */
+    (newfunc)font_options_new,          /* tp_new */
+    0,                                  /* tp_free */
+    0,                                  /* tp_is_gc */
+    0,                                  /* tp_bases */
+};




More information about the cairo-commit mailing list