X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fruby%2Fgfx.c;h=9384d1904be9731026911339652c1fc64a8a62ad;hp=11addd21e04658489517bdb63c61ce918e3a7836;hb=2ddfa640af28b592ecf4295f0b1b7b43c923f707;hpb=1503f016b8d04b374c0e2290d37a4f2f91e63688 diff --git a/lib/ruby/gfx.c b/lib/ruby/gfx.c index 11addd2..9384d19 100644 --- a/lib/ruby/gfx.c +++ b/lib/ruby/gfx.c @@ -63,6 +63,9 @@ static VALUE doc_initialize(VALUE cls, VALUE _filename) const char*filename = StringValuePtr(_filename); doc->fontlist = gfxfontlist_create(); doc->doc = pdfdriver->open(pdfdriver, filename); + if(!doc->doc) { + rb_raise(rb_eIOError, "couldn't open %s", filename); + } return cls; } @@ -281,6 +284,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); @@ -334,6 +347,23 @@ static VALUE font_glyphs(VALUE cls) return font->glyph_array; } +static VALUE font_kerning(VALUE cls) +{ + Get_Font(font,cls); + gfxkerning_t*kerning = font->font->kerning; + int kerning_size = font->font->kerning_size; + volatile VALUE a = rb_ary_new2(kerning_size); + int t; + for(t=0;t