X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=lib%2Fruby%2Fgfx.c;h=661d8efbcce7d5e31274514f638a1d8c4f1263c5;hb=9bcdd3d1665c7f85d2fc7472e45ebfbf89c65783;hp=687e38ab6c8ad98d1aeecf78dee490de0fbc8ca5;hpb=8f67c24d3250b417099a27525c3ef14ab1c7b3db;p=swftools.git diff --git a/lib/ruby/gfx.c b/lib/ruby/gfx.c index 687e38a..661d8ef 100644 --- a/lib/ruby/gfx.c +++ b/lib/ruby/gfx.c @@ -281,6 +281,16 @@ static VALUE glyph_advance(VALUE cls) return rb_float_new(glyph->font->font->glyphs[glyph->nr].advance); } +static VALUE glyph_bbox(VALUE cls) +{ + Get_Glyph(glyph,cls); + gfxbbox_t bbox = gfxline_getbbox(glyph->font->font->glyphs[glyph->nr].line); + return rb_ary_new3(4, rb_float_new(bbox.xmin), + rb_float_new(bbox.ymin), + rb_float_new(bbox.xmax), + rb_float_new(bbox.ymax)); +} + static VALUE glyph_unicode(VALUE cls) { Get_Glyph(glyph,cls); @@ -310,6 +320,18 @@ static VALUE font_allocate(VALUE cls) return v; } +static VALUE font_ascent(VALUE cls) +{ + Get_Font(font,cls); + return rb_float_new(font->font->ascent); +} + +static VALUE font_descent(VALUE cls) +{ + Get_Font(font,cls); + return rb_float_new(font->font->descent); +} + static VALUE font_name(VALUE cls) { Get_Font(font,cls); @@ -634,9 +656,12 @@ void Init_gfx() rb_define_method(Glyph, "polygon", glyph_polygon, 0); rb_define_method(Glyph, "unicode", glyph_unicode, 0); rb_define_method(Glyph, "advance", glyph_advance, 0); + rb_define_method(Glyph, "bbox", glyph_bbox, 0); Font = rb_define_class_under(GFX, "Font", rb_cObject); rb_define_method(Font, "name", font_name, 0); + rb_define_method(Font, "ascent", font_ascent, 0); + rb_define_method(Font, "descent", font_descent, 0); rb_define_method(Font, "glyphs", font_glyphs, 0); Device = rb_define_class_under(GFX, "Device", rb_cObject);