[cairo-commit] rcairo/src rb_cairo_font_extents.c,1.3,1.4

Kouhei Sutou commit at pdx.freedesktop.org
Sat Aug 16 22:12:40 PDT 2008


Committed by: kou

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

Modified Files:
	rb_cairo_font_extents.c 
Log Message:
        * src/rb_cairo_font_extents.c: add Cairo::FontExtents#initialize
        and setters.

        * test/test_font_extents.rb: add.


Index: rb_cairo_font_extents.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_font_extents.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- rb_cairo_font_extents.c	3 May 2007 02:47:39 -0000	1.3
+++ rb_cairo_font_extents.c	17 Aug 2008 05:12:37 -0000	1.4
@@ -46,37 +46,95 @@
     }
 }
 
-static    VALUE
+static VALUE
+cr_font_extents_allocate (VALUE klass)
+{
+  return Data_Wrap_Struct (klass, NULL, -1, NULL);
+}
+
+static VALUE
+cr_font_extents_initialize (VALUE self)
+{
+  cairo_font_extents_t *extents;
+
+  extents = ALLOC (cairo_font_extents_t);
+  extents->ascent = 1.0;
+  extents->descent = 0.0;
+  extents->height = 1.0;
+  extents->max_x_advance = 1.0;
+  extents->max_y_advance = 0.0;
+
+  DATA_PTR (self) = extents;
+
+  return Qnil;
+}
+
+static VALUE
 cr_font_extents_ascent (VALUE self)
 {
   return rb_float_new (_SELF(self)->ascent);
 }
 
-static    VALUE
+static VALUE
+cr_font_extents_set_ascent (VALUE self, VALUE ascent)
+{
+  _SELF(self)->ascent = NUM2DBL (ascent);
+  return self;
+}
+
+static VALUE
 cr_font_extents_descent (VALUE self)
 {
   return rb_float_new (_SELF(self)->descent);
 }
 
-static    VALUE
+static VALUE
+cr_font_extents_set_descent (VALUE self, VALUE descent)
+{
+  _SELF(self)->descent = NUM2DBL (descent);
+  return self;
+}
+
+static VALUE
 cr_font_extents_height (VALUE self)
 {
   return rb_float_new (_SELF(self)->height);
 }
 
-static    VALUE
+static VALUE
+cr_font_extents_set_height (VALUE self, VALUE height)
+{
+  _SELF(self)->height = NUM2DBL (height);
+  return self;
+}
+
+static VALUE
 cr_font_extents_max_x_advance (VALUE self)
 {
   return rb_float_new (_SELF(self)->max_x_advance);
 }
 
-static    VALUE
+static VALUE
+cr_font_extents_set_max_x_advance (VALUE self, VALUE max_x_advance)
+{
+  _SELF(self)->max_x_advance = NUM2DBL (max_x_advance);
+  return self;
+}
+
+static VALUE
 cr_font_extents_max_y_advance (VALUE self)
 {
   return rb_float_new (_SELF(self)->max_y_advance);
 }
 
 static VALUE
+cr_font_extents_set_max_y_advance (VALUE self, VALUE max_y_advance)
+{
+  _SELF(self)->max_y_advance = NUM2DBL (max_y_advance);
+  return self;
+}
+
+static VALUE
 cr_font_extents_to_s (VALUE self)
 {
   VALUE ret;
@@ -110,16 +168,33 @@
   rb_cCairo_FontExtents =
     rb_define_class_under (rb_mCairo, "FontExtents", rb_cObject);
 
+  rb_define_alloc_func (rb_cCairo_FontExtents, cr_font_extents_allocate);
+
+  rb_define_method (rb_cCairo_FontExtents, "initialize",
+                    cr_font_extents_initialize, 0);
+
   rb_define_method (rb_cCairo_FontExtents, "ascent",
                     cr_font_extents_ascent, 0);
+  rb_define_method (rb_cCairo_FontExtents, "set_ascent",
+                    cr_font_extents_set_ascent, 1);
   rb_define_method (rb_cCairo_FontExtents, "descent",
                     cr_font_extents_descent, 0);
+  rb_define_method (rb_cCairo_FontExtents, "set_descent",
+                    cr_font_extents_set_descent, 1);
   rb_define_method (rb_cCairo_FontExtents, "height",
                     cr_font_extents_height, 0);
+  rb_define_method (rb_cCairo_FontExtents, "set_height",
+                    cr_font_extents_set_height, 1);
   rb_define_method (rb_cCairo_FontExtents, "max_x_advance",
                     cr_font_extents_max_x_advance, 0);
+  rb_define_method (rb_cCairo_FontExtents, "set_max_x_advance",
+                    cr_font_extents_set_max_x_advance, 1);
   rb_define_method (rb_cCairo_FontExtents, "max_y_advance",
                     cr_font_extents_max_y_advance, 0);
+  rb_define_method (rb_cCairo_FontExtents, "set_max_y_advance",
+                    cr_font_extents_set_max_y_advance, 1);
 
   rb_define_method (rb_cCairo_FontExtents, "to_s", cr_font_extents_to_s, 0);
+
+  RB_CAIRO_DEF_SETTERS (rb_cCairo_FontExtents);
 }



More information about the cairo-commit mailing list