[cairo-commit] rcairo/src rb_cairo_matrix.c, 1.4, 1.5 rb_cairo_scaled_font.c, 1.4, 1.5

Kouhei Sutou commit at pdx.freedesktop.org
Thu Aug 14 05:37:53 PDT 2008


Committed by: kou

Update of /cvs/cairo/rcairo/src
In directory kemper:/tmp/cvs-serv31498/src

Modified Files:
	rb_cairo_matrix.c rb_cairo_scaled_font.c 
Log Message:
        * src/rb_cairo_scaled_font.c: support Cairo::ScaledFont#scale_matrix.

        * test/test_scaled_font.rb: add.

        * src/rb_cairo_matrix.c (cr_matrix_equal): add Cairo::Matrix#==.


Index: rb_cairo_matrix.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_matrix.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rb_cairo_matrix.c	21 May 2007 11:54:44 -0000	1.4
+++ rb_cairo_matrix.c	14 Aug 2008 12:37:50 -0000	1.5
@@ -5,6 +5,7 @@
  * $Author$
  * $Date$
  *
+ * Copyright 2006-2008 Kouhei Sutou <kou at cozmixng.org>
  * Copyright 2005 Øyvind Kolås <pippin at freedesktop.org>
  * Copyright 2004-2005 MenTaLguY <mental at rydia.com>
  *
@@ -18,6 +19,8 @@
 
 VALUE rb_cCairo_Matrix;
 
+static ID cr_id_equal;
+
 #define _SELF  (RVAL2CRMATRIX(self))
 
 cairo_matrix_t *
@@ -295,10 +298,22 @@
   return ret;
 }
 
+static VALUE
+cr_matrix_equal (VALUE self, VALUE other)
+{
+  if (!rb_cairo__is_kind_of (other, rb_cCairo_Matrix))
+    return Qfalse;
+
+  return rb_funcall (cr_matrix_to_a (self),
+                     cr_id_equal, 1,
+                     cr_matrix_to_a (other));
+}
 
 void
 Init_cairo_matrix (void)
 {
+  cr_id_equal = rb_intern ("==");
+
   rb_cCairo_Matrix =
     rb_define_class_under (rb_mCairo, "Matrix", rb_cObject);
 
@@ -344,6 +359,7 @@
   rb_define_method (rb_cCairo_Matrix, "set", cr_matrix_set, 6);
   rb_define_method (rb_cCairo_Matrix, "to_a", cr_matrix_to_a, 0);
   rb_define_method (rb_cCairo_Matrix, "to_s", cr_matrix_to_s, 0);
+  rb_define_method (rb_cCairo_Matrix, "==", cr_matrix_equal, 1);
 
 
   RB_CAIRO_DEF_SETTERS (rb_cCairo_Matrix);

Index: rb_cairo_scaled_font.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_scaled_font.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rb_cairo_scaled_font.c	20 May 2007 09:18:49 -0000	1.4
+++ rb_cairo_scaled_font.c	14 Aug 2008 12:37:51 -0000	1.5
@@ -5,7 +5,7 @@
  * $Author$
  * $Date$
  *
- * Copyright 2005 Kouhei Sutou <kou at cozmixng.org>
+ * Copyright 2005-2008 Kouhei Sutou <kou at cozmixng.org>
  *
  * This file is made available under the same terms as Ruby
  *
@@ -144,13 +144,27 @@
 static VALUE
 cr_scaled_font_get_font_options (VALUE self)
 {
-  cairo_font_options_t *options = cairo_font_options_create();
+  cairo_font_options_t *options;
+
+  options = cairo_font_options_create();
   cairo_scaled_font_get_font_options (_SELF (self), options);
   cr_scaled_font_check_status (_SELF (self));
   rb_cairo_check_status (cairo_font_options_status (options));
   return CRFONTOPTIONS2RVAL (options);
 }
 
+#if CAIRO_CHECK_VERSION(1, 7, 2)
+static VALUE
+cr_scaled_font_get_scale_matrix (VALUE self)
+{
+  cairo_matrix_t matrix;
+
+  cairo_scaled_font_get_scale_matrix (_SELF (self), &matrix);
+  cr_scaled_font_check_status (_SELF (self));
+  return CRMATRIX2RVAL (&matrix);
+}
+#endif
+
 void
 Init_cairo_scaled_font (void)
 {
@@ -174,4 +188,8 @@
   rb_define_method (rb_cCairo_ScaledFont, "ctm", cr_scaled_font_get_ctm, 0);
   rb_define_method (rb_cCairo_ScaledFont, "font_options",
                     cr_scaled_font_get_font_options, 0);
+#if CAIRO_CHECK_VERSION(1, 7, 2)
+  rb_define_method (rb_cCairo_ScaledFont, "scale_matrix",
+                    cr_scaled_font_get_scale_matrix, 0);
+#endif
 }



More information about the cairo-commit mailing list