X-Git-Url: http://git.asbjorn.biz/?p=swftools.git;a=blobdiff_plain;f=lib%2Fruby%2Fgfx.c;h=7c48a093069844683ac67f9a3bd0f08065bdaede;hp=ce11f02983bdba7fcdae11b219027cde59af8811;hb=df99e9de2273822d54a2efa8d02a08e90181ede1;hpb=a725c3e28bafaf52cc45bdacf730b80edd83756d diff --git a/lib/ruby/gfx.c b/lib/ruby/gfx.c index ce11f02..7c48a09 100644 --- a/lib/ruby/gfx.c +++ b/lib/ruby/gfx.c @@ -1,4 +1,5 @@ #include +#include "../../config.h" #include "../gfxdevice.h" #include "../gfxsource.h" #include "../gfxtools.h" @@ -234,7 +235,7 @@ static VALUE image_has_alpha(VALUE cls) gfxcolor_t*data = image->image->data; int t; for(t=0;ta!=255) + if(data[t].a!=255) return Qtrue; } return Qfalse; @@ -378,6 +379,15 @@ static VALUE font_save_ttf(VALUE cls, VALUE _filename) return Qnil; } +static VALUE font_save_eot(VALUE cls, VALUE _filename) +{ + Get_Font(font,cls); + Check_Type(_filename, T_STRING); + const char*filename = StringValuePtr(_filename); + gfxfont_save_eot(font->font, filename); + return Qnil; +} + static VALUE font_kerning(VALUE cls) { Get_Font(font,cls); @@ -428,6 +438,7 @@ static ID id_radial = 0; static ID id_linear = 0; static ID id_remove_font_transforms = 0; static ID id_maketransparent = 0; +static ID id_vectors_to_glyphs = 0; static VALUE noop(int argc, VALUE *argv, VALUE obj) {return obj;} @@ -616,7 +627,8 @@ void rb_drawlink(gfxdevice_t*dev, gfxline_t*line, const char*action) HEAD volatile VALUE v_line = convert_line(line); volatile VALUE v_action = rb_tainted_str_new2(action); - forward(v, id_drawlink, v_line, v_action); + + forward(v, id_drawlink, 2, v_line, v_action); } void rb_endpage(gfxdevice_t*dev) { @@ -697,6 +709,8 @@ static VALUE doc_render(VALUE cls, VALUE device, VALUE _range, VALUE filters) else x = RARRAY(filters)->ptr[t++]; if(id == id_remove_font_transforms) { wrap_filter2(dev, remove_font_transforms); + } else if(id == id_vectors_to_glyphs) { + wrap_filter2(dev, vectors_to_glyphs); } else if(id == id_maketransparent) { PARAM(alpha); wrap_filter(dev, maketransparent, FIX2INT(alpha)); @@ -752,11 +766,20 @@ VALUE gfx_setparameter(VALUE module, VALUE _key, VALUE _value) void Init_gfx() { initLog(0,0,0,0,0,2); +#ifdef HAVE_SRAND48 + srand48(time(0)); +#else +#ifdef HAVE_SRAND + srand(time(0)); +#endif +#endif + pdfdriver = gfxsource_pdf_create(); swfdriver = gfxsource_swf_create(); imagedriver = gfxsource_image_create(); GFX = rb_define_module("GFX"); + rb_define_const(GFX, "VERSION", INT2FIX(20100309)); rb_define_module_function(GFX, "setparameter", gfx_setparameter, 2); @@ -795,6 +818,7 @@ void Init_gfx() rb_define_method(Font, "kerning", font_kerning, 0); rb_define_method(Font, "get_kerning_table", font_kerning, 0); rb_define_method(Font, "save_ttf", font_save_ttf, 1); + rb_define_method(Font, "save_eot", font_save_eot, 1); Device = rb_define_class_under(GFX, "Device", rb_cObject); rb_define_method(Device, "startpage", noop, -1); @@ -844,5 +868,6 @@ void Init_gfx() id_linear = rb_intern("linear"); id_remove_font_transforms = rb_intern("remove_font_transforms"); id_maketransparent = rb_intern("maketransparent"); + id_vectors_to_glyphs = rb_intern("vectors_to_glyphs"); }