[cairo-commit] rcairo/src rb_cairo_context.c, 1.28, 1.29 rb_cairo_font_face.c, 1.6, 1.7
Kouhei Sutou
commit at pdx.freedesktop.org
Sat Aug 16 20:00:43 PDT 2008
Committed by: kou
Update of /cvs/cairo/rcairo/src
In directory kemper:/tmp/cvs-serv14819/src
Modified Files:
rb_cairo_context.c rb_cairo_font_face.c
Log Message:
* test/test_font_face.rb
(FontFaceTest#test_toy_font_face_new_with_invalid_family_name):
add a test for creating Cairo::ToyFontFace with invalid family
name.
(FontFaceTest#test_toy_font_face_new): add a test for creating
Cairo::ToyFontFace with nil family name.
* src/rb_cairo_font_face.c (cr_toy_font_face_initialize): accept nil.
* src/rb_cairo_context.c (cr_select_font_face): make family optional.
* test/test_context.rb
(ContextTest#test_select_font_face),
(ContextTest#test_select_font_face_with_invalid_family_name): add
a test for Cairo::Context#select_font_face.
Index: rb_cairo_context.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_context.c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- rb_cairo_context.c 16 Aug 2008 12:52:16 -0000 1.28
+++ rb_cairo_context.c 17 Aug 2008 03:00:41 -0000 1.29
@@ -1071,11 +1071,31 @@
static VALUE
cr_select_font_face (int argc, VALUE *argv, VALUE self)
{
- VALUE family, rb_slant, rb_weight;
+ VALUE rb_family, rb_slant, rb_weight;
+ const char *family;
cairo_font_slant_t slant;
cairo_font_weight_t weight;
- rb_scan_args(argc, argv, "12", &family, &rb_slant, &rb_weight);
+ rb_scan_args(argc, argv, "03", &rb_family, &rb_slant, &rb_weight);
+
+ if (NIL_P (rb_family))
+ {
+ family = "";
+ }
+ else if (rb_cairo__is_kind_of (rb_family, rb_cString))
+ {
+ family = RSTRING_PTR (rb_family);
+ }
+ else if (rb_cairo__is_kind_of (rb_family, rb_cSymbol))
+ {
+ family = rb_id2name (SYM2ID (rb_family));
+ }
+ else
+ {
+ rb_raise (rb_eArgError,
+ "family name should be nil, String or Symbol: %s",
+ rb_cairo__inspect (rb_family));
+ }
if (NIL_P (rb_slant))
slant = CAIRO_FONT_SLANT_NORMAL;
@@ -1087,7 +1107,7 @@
else
weight = RVAL2CRFONTWEIGHT (rb_weight);
- cairo_select_font_face (_SELF, RVAL2CSTR (family), slant, weight);
+ cairo_select_font_face (_SELF, family, slant, weight);
cr_check_status (_SELF);
return self;
}
Index: rb_cairo_font_face.c
===================================================================
RCS file: /cvs/cairo/rcairo/src/rb_cairo_font_face.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- rb_cairo_font_face.c 16 Aug 2008 12:52:16 -0000 1.6
+++ rb_cairo_font_face.c 17 Aug 2008 03:00:41 -0000 1.7
@@ -120,9 +120,13 @@
cairo_font_slant_t slant;
cairo_font_weight_t weight;
- rb_scan_args (argc, argv, "12", &rb_family, &rb_slant, &rb_weight);
+ rb_scan_args (argc, argv, "03", &rb_family, &rb_slant, &rb_weight);
- if (rb_cairo__is_kind_of (rb_family, rb_cString))
+ if (NIL_P (rb_family))
+ {
+ family = "";
+ }
+ else if (rb_cairo__is_kind_of (rb_family, rb_cString))
{
family = RSTRING_PTR (rb_family);
}
@@ -133,7 +137,7 @@
else
{
rb_raise (rb_eArgError,
- "family name should be String or Symbol: %s",
+ "family name should be nil, String or Symbol: %s",
rb_cairo__inspect (rb_family));
}
More information about the cairo-commit
mailing list