diff options
author | Matthias Kramm <kramm@quiss.org> | 2009-12-21 17:57:05 -0800 |
---|---|---|
committer | Matthias Kramm <kramm@quiss.org> | 2009-12-21 17:58:09 -0800 |
commit | 6c8f037f0f76ce4b28b80a2133e4150d93012ef7 (patch) | |
tree | 87bc4572f202751a638e1ae7cc1d92296cd75fef /lib/ruby | |
parent | b174b88412be23f82cb844d1d99f9c6761c94cbb (diff) |
more parameter refactoring
Diffstat (limited to 'lib/ruby')
-rw-r--r-- | lib/ruby/gfx.c | 21 | ||||
-rw-r--r-- | lib/ruby/test.rb | 3 |
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/ruby/gfx.c b/lib/ruby/gfx.c index ae4b6d8f..6a47da74 100644 --- a/lib/ruby/gfx.c +++ b/lib/ruby/gfx.c @@ -501,7 +501,7 @@ void rb_addfont(gfxdevice_t*dev, gfxfont_t*font) HEAD volatile VALUE f = font_is_cached(i, font); - if(!f) {f=convert_font(font);cache_font(i,font,v);} + if(!f) {f=convert_font(font);cache_font(i,font,f);} forward(v, id_addfont, 1, f); } @@ -509,7 +509,7 @@ void rb_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, { HEAD volatile VALUE f = font_is_cached(i, font); - if(!f) {f=convert_font(font);cache_font(i,font,v);} + if(!f) {f=convert_font(font);cache_font(i,font,f);} volatile VALUE v_color = convert_color(color); volatile VALUE v_matrix = convert_matrix(matrix); @@ -561,11 +561,26 @@ static VALUE page_render(VALUE cls, VALUE device) dev.endpage = rb_endpage; dev.finish = rb_finish; + dev.startpage(&dev, page->page->width, page->page->height); page->page->render(page->page, &dev); + dev.endpage(&dev); return cls; } +// ---------------------- global functions ---------------------------------- + +VALUE gfx_setparameter(VALUE module, VALUE _key, VALUE _value) +{ + Check_Type(_key, T_STRING); + Check_Type(_value, T_STRING); + const char*key = StringValuePtr(_key); + const char*value = StringValuePtr(_value); + pdfdriver->setparameter(pdfdriver, key, value); + swfdriver->setparameter(swfdriver, key, value); + imagedriver->setparameter(imagedriver, key, value); + return GFX; +} // -------------------------------------------------------------------------- @@ -578,6 +593,8 @@ void Init_gfx() GFX = rb_define_module("GFX"); + rb_define_module_function(GFX, "setparameter", gfx_setparameter, 2); + DocumentPage = rb_define_class_under(GFX, "DocumentPage", rb_cObject); rb_define_method(DocumentPage, "width", page_width, 0); rb_define_method(DocumentPage, "height", page_height, 0); diff --git a/lib/ruby/test.rb b/lib/ruby/test.rb index 5e6b6887..1c0418e1 100644 --- a/lib/ruby/test.rb +++ b/lib/ruby/test.rb @@ -1,7 +1,6 @@ require 'gfx' -#pdf = GFX::PDF.new('test.pdf') -pdf = GFX::PDF.new('/home/kramm/paper5.pdf') +pdf = GFX::PDF.new('file.pdf') class TestRender < GFX::Device def startpage(width,height) |