[cairo-commit] pycairo/cairo cairomodule.c, 1.75, 1.76 pycairo-font.c, 1.39, 1.40 pycairo.h, 1.48, 1.49 pycairo-private.h, 1.46, 1.47 pycairo-pattern.c, 1.42, 1.43

Steve Chaplin commit at pdx.freedesktop.org
Thu Feb 12 01:04:31 PST 2009


Committed by: stevech1097

Update of /cvs/cairo/pycairo/cairo
In directory kemper:/tmp/cvs-serv26561/cairo

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

Index: cairomodule.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/cairomodule.c,v
retrieving revision 1.75
retrieving revision 1.76
diff -u -d -r1.75 -r1.76
--- cairomodule.c	15 Jan 2009 10:06:15 -0000	1.75
+++ cairomodule.c	12 Feb 2009 09:04:29 -0000	1.76
@@ -88,7 +88,10 @@
  */
 static Pycairo_CAPI_t CAPI = {
     &PycairoContext_Type,      PycairoContext_FromContext,
-    &PycairoFontFace_Type,     PycairoFontFace_FromFontFace,
+
+    &PycairoFontFace_Type,
+    &PycairoToyFontFace_Type,  PycairoFontFace_FromFontFace,
+
     &PycairoFontOptions_Type,  PycairoFontOptions_FromFontOptions,
     &PycairoMatrix_Type,       PycairoMatrix_FromMatrix,
     &PycairoPath_Type,         PycairoPath_FromPath,
@@ -170,6 +173,9 @@
     PycairoFontFace_Type.tp_base = &PyBaseObject_Type;
     if (PyType_Ready(&PycairoFontFace_Type) < 0)
         return;
+    PycairoToyFontFace_Type.tp_base = &PyBaseObject_Type;
+    if (PyType_Ready(&PycairoToyFontFace_Type) < 0)
+        return;
     PycairoFontOptions_Type.tp_base = &PyBaseObject_Type;
     if (PyType_Ready(&PycairoFontOptions_Type) < 0)
         return;
@@ -249,6 +255,8 @@
     PyModule_AddObject(m, "Context", (PyObject *)&PycairoContext_Type);
     Py_INCREF(&PycairoFontFace_Type);
     PyModule_AddObject(m, "FontFace",(PyObject *)&PycairoFontFace_Type);
+    Py_INCREF(&PycairoToyFontFace_Type);
+    PyModule_AddObject(m, "ToyFontFace",(PyObject *)&PycairoToyFontFace_Type);
     Py_INCREF(&PycairoFontOptions_Type);
     PyModule_AddObject(m, "FontOptions",(PyObject *)&PycairoFontOptions_Type);
     Py_INCREF(&PycairoMatrix_Type);

Index: pycairo-font.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-font.c,v
retrieving revision 1.39
retrieving revision 1.40
diff -u -d -r1.39 -r1.40
--- pycairo-font.c	10 Dec 2008 06:51:30 -0000	1.39
+++ pycairo-font.c	12 Feb 2009 09:04:29 -0000	1.40
@@ -48,6 +48,7 @@
 PyObject *
 PycairoFontFace_FromFontFace (cairo_font_face_t *font_face)
 {
+    PyTypeObject *type = NULL;
     PyObject *o;
 
     assert (font_face != NULL);
@@ -57,7 +58,15 @@
 	return NULL;
     }
 
-    o = PycairoFontFace_Type.tp_alloc (&PycairoFontFace_Type, 0);
+    switch (cairo_font_face_get_type (font_face)) {
+    case CAIRO_FONT_TYPE_TOY:
+        type = &PycairoToyFontFace_Type;
+        break;
+    default:
+        type = &PycairoFontFace_Type;
+        break;
+    }
+    o = type->tp_alloc (type, 0);
     if (o == NULL)
 	cairo_font_face_destroy (font_face);
     else
@@ -141,6 +150,95 @@
 };
 
 
+/* class cairo.ToyFontFace ------------------------------------------------- */
+
+static PyObject *
+toy_font_face_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
+{
+    char *family;
+    cairo_font_slant_t slant = CAIRO_FONT_SLANT_NORMAL;
+    cairo_font_weight_t weight = CAIRO_FONT_WEIGHT_NORMAL;
+
+    if (!PyArg_ParseTuple(args, "s|II:ToyFont.__new__", &family, &slant,
+			  &weight))
+	return NULL;
+
+    return PycairoFontFace_FromFontFace (
+             cairo_toy_font_face_create (family, slant, weight));
+}
+
+static PyObject *
+toy_font_get_family (PycairoToyFontFace *o)
+{
+    return PyString_FromString (cairo_toy_font_face_get_family (o->font_face));
+}
+
+static PyObject *
+toy_font_get_slant (PycairoToyFontFace *o)
+{
+    return PyInt_FromLong (cairo_toy_font_face_get_slant (o->font_face));
+}
+
+static PyObject *
+toy_font_get_weight (PycairoToyFontFace *o)
+{
+    return PyInt_FromLong (cairo_toy_font_face_get_weight (o->font_face));
+}
+
+static PyMethodDef toy_font_face_methods[] = {
+    {"get_family",       (PyCFunction)toy_font_get_family, METH_NOARGS},
+    {"get_slant",        (PyCFunction)toy_font_get_slant,  METH_NOARGS},
+    {"get_weight",       (PyCFunction)toy_font_get_weight, METH_NOARGS},
+    {NULL, NULL, 0, NULL},
+};
+
+
+PyTypeObject PycairoToyFontFace_Type = {
+    PyObject_HEAD_INIT(NULL)
+    0,                                  /* ob_size */
+    "cairo.ToyFontFace",                /* tp_name */
+    sizeof(PycairoToyFontFace),         /* tp_basicsize */
+    0,                                  /* tp_itemsize */
+    0,                                  /* 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 */
+    toy_font_face_methods,              /* tp_methods */
+    0,                                  /* tp_members */
+    0,                                  /* tp_getset */
+    0, /* &PycairoFontFace_Type, */     /* tp_base */
+    0,                                  /* tp_dict */
+    0,                                  /* tp_descr_get */
+    0,                                  /* tp_descr_set */
+    0,                                  /* tp_dictoffset */
+    0,                                  /* tp_init */
+    0,                                  /* tp_alloc */
+    (newfunc)toy_font_face_new,         /* tp_new */
+    0,                                  /* tp_free */
+    0,                                  /* tp_is_gc */
+    0,                                  /* tp_bases */
+};
+
+
 /* class cairo.ScaledFont ------------------------------------------------- */
 
 /* PycairoScaledFont_FromScaledFont

Index: pycairo.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo.h,v
retrieving revision 1.48
retrieving revision 1.49
diff -u -d -r1.48 -r1.49
--- pycairo.h	10 Dec 2008 08:18:58 -0000	1.48
+++ pycairo.h	12 Feb 2009 09:04:29 -0000	1.49
@@ -47,6 +47,8 @@
     cairo_font_face_t *font_face;
 } PycairoFontFace;
 
+#define PycairoToyFontFace PycairoFontFace
+
 typedef struct {
     PyObject_HEAD
     cairo_font_options_t *font_options;
@@ -102,6 +104,7 @@
     PyObject *(*Context_FromContext)(cairo_t *ctx, PyTypeObject *type,
 				     PyObject *base);
     PyTypeObject *FontFace_Type;
+    PyTypeObject *ToyFontFace_Type;
     PyObject *(*FontFace_FromFontFace)(cairo_font_face_t *font_face);
     PyTypeObject *FontOptions_Type;
     PyObject *(*FontOptions_FromFontOptions)(
@@ -117,7 +120,7 @@
     PyTypeObject *Gradient_Type;
     PyTypeObject *LinearGradient_Type;
     PyTypeObject *RadialGradient_Type;
-    PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern);
+    PyObject *(*Pattern_FromPattern)(cairo_pattern_t *pattern, PyObject *base);
 
     PyTypeObject *ScaledFont_Type;
     PyObject *(*ScaledFont_FromScaledFont)(cairo_scaled_font_t *scaled_font);
@@ -142,6 +145,7 @@
 #define PycairoContext_Type         *(Pycairo_CAPI->Context_Type)
 #define PycairoContext_FromContext   (Pycairo_CAPI->Context_FromContext)
 #define PycairoFontFace_Type        *(Pycairo_CAPI->FontFace_Type)
+#define PycairoToyFontFace_Type     *(Pycairo_CAPI->ToyFontFace_Type)
 #define PycairoFontFace_FromFontFace (Pycairo_CAPI->FontFace_FromFontFace)
 #define PycairoFontOptions_Type     *(Pycairo_CAPI->FontOptions_Type)
 #define PycairoFontOptions_FromFontOptions \

Index: pycairo-private.h
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-private.h,v
retrieving revision 1.46
retrieving revision 1.47
diff -u -d -r1.46 -r1.47
--- pycairo-private.h	10 Dec 2008 08:18:58 -0000	1.46
+++ pycairo-private.h	12 Feb 2009 09:04:29 -0000	1.47
@@ -50,6 +50,7 @@
 				      PyObject *base);
 
 extern PyTypeObject PycairoFontFace_Type;
+extern PyTypeObject PycairoToyFontFace_Type;
 PyObject *PycairoFontFace_FromFontFace (cairo_font_face_t *font_face);
 
 extern PyTypeObject PycairoFontOptions_Type;

Index: pycairo-pattern.c
===================================================================
RCS file: /cvs/cairo/pycairo/cairo/pycairo-pattern.c,v
retrieving revision 1.42
retrieving revision 1.43
diff -u -d -r1.42 -r1.43
--- pycairo-pattern.c	15 Dec 2008 06:13:58 -0000	1.42
+++ pycairo-pattern.c	12 Feb 2009 09:04:29 -0000	1.43
@@ -273,12 +273,11 @@
 surface_pattern_new (PyTypeObject *type, PyObject *args, PyObject *kwds)
 {
     PycairoSurface *s;
-    PyObject *o;
     if (!PyArg_ParseTuple (args, "O!:SurfacePattern.__new__",
 			   &PycairoSurface_Type, &s))
 	return NULL;
     return PycairoPattern_FromPattern (
-              cairo_pattern_create_for_surface (s->surface), s);
+		cairo_pattern_create_for_surface (s->surface), (PyObject *)s);
 }
 
 static PyObject *



More information about the cairo-commit mailing list