2 #include "../gfxdevice.h"
3 #include "../gfxsource.h"
4 #include "../gfxtools.h"
5 #include "../gfximage.h"
6 #include "../gfxfont.h"
7 #include "../gfxfilter.h"
8 #include "../devices/pdf.h"
9 #include "../readers/swf.h"
10 #include "../readers/image.h"
11 #include "../pdf/pdf.h"
17 #define RUBY_GFX_VERSION "0.9.0"
20 static VALUE Font, Glyph, Bitmap, Document, DocumentPage, PDFClass, SWFClass, ImageClass, Device;
23 typedef struct doc_internal {
25 gfxsource_t*driver; // filled by alloc
27 gfxfontlist_t*fontlist;
30 typedef struct page_internal {
35 typedef struct image_internal {
40 typedef struct font_internal {
46 typedef struct glyph_internal {
51 static gfxsource_t* pdfdriver = 0;
52 static gfxsource_t* imagedriver = 0;
53 static gfxsource_t* swfdriver = 0;
55 #define Get_Doc(doc,cls) doc_internal_t*doc=0;Data_Get_Struct(cls, doc_internal_t, doc);
56 #define Get_Page(page,cls) page_internal_t*page=0;Data_Get_Struct(cls, page_internal_t, page);
58 static VALUE doc_allocate(VALUE cls, gfxsource_t*driver);
59 static VALUE page_allocate(VALUE cls);
61 // ------------------------ documents ---------------------------------------
63 static VALUE doc_initialize(VALUE cls, VALUE _filename)
65 Check_Type(_filename, T_STRING);
67 const char*filename = StringValuePtr(_filename);
68 doc->fontlist = gfxfontlist_create();
69 doc->doc = pdfdriver->open(pdfdriver, filename);
71 rb_raise(rb_eIOError, "couldn't open %s", filename);
76 static VALUE doc_num_pages(VALUE cls)
79 return INT2FIX(doc->doc->num_pages);
82 static VALUE doc_get_page(VALUE cls, VALUE _nr)
84 Check_Type(_nr, T_FIXNUM);
85 int nr = FIX2INT(_nr);
88 VALUE v = page_allocate(DocumentPage);
90 page->page = doc->doc->getpage(doc->doc, nr);
93 rb_raise(rb_eArgError, "No page %d in document", nr);
99 static VALUE doc_each_page(VALUE cls)
103 for(t=1;t<=doc->doc->num_pages;t++) {
104 VALUE v = page_allocate(DocumentPage);
106 page->page = doc->doc->getpage(doc->doc, t);
113 static void doc_mark(doc_internal_t*doc)
115 gfxfontlist_t*l = doc->fontlist;
118 rb_gc_mark((VALUE)l->user);
123 static void doc_free(doc_internal_t*doc)
125 gfxfontlist_free(doc->fontlist, 0);
127 doc->doc->destroy(doc->doc);
133 static VALUE doc_allocate(VALUE cls, gfxsource_t*driver)
135 doc_internal_t*doc = 0;
136 VALUE v = Data_Make_Struct(cls, doc_internal_t, doc_mark, doc_free, doc);
138 memset(doc, 0, sizeof(doc_internal_t));
139 doc->driver = driver;
143 static VALUE pdf_allocate(VALUE cls) {return doc_allocate(cls, pdfdriver);}
144 static VALUE swf_allocate(VALUE cls) {return doc_allocate(cls, swfdriver);}
145 static VALUE imgdrv_allocate(VALUE cls) {return doc_allocate(cls, imagedriver);}
147 // ------------------------ doc pages ---------------------------------------
149 static void page_free(page_internal_t*page)
153 page->page->destroy(page->page);
158 static void page_mark(page_internal_t*page)
160 rb_gc_mark(page->doc->self);
162 static VALUE page_allocate(VALUE cls)
164 page_internal_t*page = 0;
165 VALUE v = Data_Make_Struct(cls, page_internal_t, page_mark, page_free, page);
166 memset(page, 0, sizeof(page_internal_t));
169 static VALUE page_nr(VALUE cls)
172 return INT2FIX(page->page->nr);
174 static VALUE page_width(VALUE cls)
177 return INT2FIX(page->page->width);
179 static VALUE page_height(VALUE cls)
182 return INT2FIX(page->page->height);
185 // ------------------------ image -------------------------------------------
187 #define Get_Image(image,cls) image_internal_t*image=0;Data_Get_Struct(cls, image_internal_t, image);
189 static void image_free(image_internal_t*image)
193 static void image_mark(image_internal_t*image)
195 rb_gc_mark(image->doc->self);
197 static VALUE image_allocate(VALUE cls)
199 image_internal_t*image = 0;
200 VALUE v = Data_Make_Struct(cls, image_internal_t, image_mark, image_free, image);
201 memset(image, 0, sizeof(image_internal_t));
204 static VALUE image_width(VALUE cls)
207 return INT2FIX(image->image->width);
209 static VALUE image_height(VALUE cls)
212 return INT2FIX(image->image->height);
214 static VALUE image_rescale(VALUE cls, VALUE _width, VALUE _height)
217 Check_Type(_width, T_FIXNUM);
218 Check_Type(_height, T_FIXNUM);
219 int width = FIX2INT(_width);
220 int height = FIX2INT(_height);
221 volatile VALUE v_image2 = image_allocate(Bitmap);
222 Get_Image(image2,v_image2)
223 image2->doc = image->doc;
224 image2->image = gfximage_rescale(image->image, width, height);
226 rb_raise(rb_eArgError, "Can't rescale to size %dx%d", width, height);
230 static VALUE image_has_alpha(VALUE cls)
233 int size = image->image->width * image->image->height;
234 gfxcolor_t*data = image->image->data;
236 for(t=0;t<size;t++) {
242 static VALUE image_save_jpeg(VALUE cls, VALUE _filename, VALUE quality)
245 Check_Type(_filename, T_STRING);
246 Check_Type(quality, T_FIXNUM);
247 const char*filename = StringValuePtr(_filename);
248 gfximage_save_jpeg(image->image, filename, FIX2INT(quality));
251 static VALUE image_save_png(VALUE cls, VALUE _filename)
254 Check_Type(_filename, T_STRING);
255 const char*filename = StringValuePtr(_filename);
256 gfximage_save_png(image->image, filename);
259 VALUE convert_image(doc_internal_t*doc,gfximage_t*_image)
261 VALUE v = image_allocate(Bitmap);
263 image->image = _image;
267 void invalidate_image(VALUE v)
273 // ------------------------ glyphs ------------------------------------------
275 static VALUE convert_line(gfxline_t*line);
277 #define Get_Glyph(glyph,cls) glyph_internal_t*glyph=0;Data_Get_Struct(cls, glyph_internal_t, glyph);
279 static void glyph_free(glyph_internal_t*glyph)
284 static void glyph_mark(glyph_internal_t*glyph)
286 rb_gc_mark(glyph->font->self);
289 static VALUE glyph_allocate(VALUE cls)
291 glyph_internal_t*glyph = 0;
292 VALUE v = Data_Make_Struct(cls, glyph_internal_t, glyph_mark, glyph_free, glyph);
293 memset(glyph, 0, sizeof(glyph_internal_t));
297 static VALUE glyph_polygon(VALUE cls)
299 Get_Glyph(glyph,cls);
300 return convert_line(glyph->font->font->glyphs[glyph->nr].line);
303 static VALUE glyph_advance(VALUE cls)
305 Get_Glyph(glyph,cls);
306 return rb_float_new(glyph->font->font->glyphs[glyph->nr].advance);
309 static VALUE glyph_bbox(VALUE cls)
311 Get_Glyph(glyph,cls);
312 gfxbbox_t bbox = gfxline_getbbox(glyph->font->font->glyphs[glyph->nr].line);
313 return rb_ary_new3(4, rb_float_new(bbox.xmin),
314 rb_float_new(bbox.ymin),
315 rb_float_new(bbox.xmax),
316 rb_float_new(bbox.ymax));
319 static VALUE glyph_unicode(VALUE cls)
321 Get_Glyph(glyph,cls);
322 return INT2FIX(glyph->font->font->glyphs[glyph->nr].unicode);
325 // ------------------------ font --------------------------------------------
327 #define Get_Font(font,cls) font_internal_t*font=0;Data_Get_Struct(cls, font_internal_t, font);
329 static void font_mark(font_internal_t*font)
331 rb_gc_mark(font->glyph_array);
334 static void font_free(font_internal_t*font)
339 static VALUE font_allocate(VALUE cls)
341 font_internal_t*font = 0;
342 VALUE v = Data_Make_Struct(cls, font_internal_t, font_mark, font_free, font);
343 memset(font, 0, sizeof(font_internal_t));
348 static VALUE font_ascent(VALUE cls)
351 return rb_float_new(font->font->ascent);
354 static VALUE font_descent(VALUE cls)
357 return rb_float_new(font->font->descent);
360 static VALUE font_name(VALUE cls)
363 return rb_tainted_str_new2(font->font->id);
366 static VALUE font_glyphs(VALUE cls)
369 return font->glyph_array;
372 static VALUE font_save_ttf(VALUE cls, VALUE _filename)
375 Check_Type(_filename, T_STRING);
376 const char*filename = StringValuePtr(_filename);
377 gfxfont_save(font->font, filename);
381 static VALUE font_save_eot(VALUE cls, VALUE _filename)
384 Check_Type(_filename, T_STRING);
385 const char*filename = StringValuePtr(_filename);
386 gfxfont_save_eot(font->font, filename);
390 static VALUE font_kerning(VALUE cls)
393 gfxkerning_t*kerning = font->font->kerning;
394 int kerning_size = font->font->kerning_size;
395 volatile VALUE a = rb_ary_new2(kerning_size);
397 for(t=0;t<kerning_size;t++) {
398 volatile VALUE tuple = rb_ary_new2(3);
399 rb_ary_store(tuple, 0, INT2FIX(kerning[t].c1));
400 rb_ary_store(tuple, 1, INT2FIX(kerning[t].c2));
401 rb_ary_store(tuple, 2, INT2FIX(kerning[t].advance));
402 rb_ary_store(a, t, tuple);
407 // ------------------------ gfx device --------------------------------------
409 typedef struct device_internal {
414 static ID id_setparameter = 0;
415 static ID id_startpage = 0;
416 static ID id_startclip = 0;
417 static ID id_endclip = 0;
418 static ID id_stroke = 0;
419 static ID id_fill = 0;
420 static ID id_fillbitmap = 0;
421 static ID id_fillgradient = 0;
422 static ID id_addfont = 0;
423 static ID id_drawchar = 0;
424 static ID id_drawlink = 0;
425 static ID id_endpage = 0;
426 static ID id_geterror = 0;
427 static ID id_finish = 0;
428 static ID id_butt = 0;
429 static ID id_round = 0;
430 static ID id_square = 0;
431 static ID id_bevel = 0;
432 static ID id_miter = 0;
433 static ID id_move = 0;
434 static ID id_line = 0;
435 static ID id_spline = 0;
436 static ID id_radial = 0;
437 static ID id_linear = 0;
438 static ID id_remove_font_transforms = 0;
439 static ID id_maketransparent = 0;
441 static VALUE noop(int argc, VALUE *argv, VALUE obj) {return obj;}
443 #define forward(v,id,args...) rb_respond_to((v), (id))?rb_funcall((v), (id), args):0
445 VALUE convert_line(gfxline_t*line)
449 while(l) {l=l->next;len++;}
451 volatile VALUE array = rb_ary_new2(len);
457 if(l->type == gfx_moveTo) {
458 e = rb_ary_new3(3, ID2SYM(id_move), Qfalse, Qfalse);
459 rb_ary_store(array, pos, e);
460 rb_ary_store(e, 1, rb_float_new(l->x));
461 rb_ary_store(e, 2, rb_float_new(l->y));
462 } else if(l->type == gfx_lineTo) {
463 e = rb_ary_new3(3, ID2SYM(id_line), Qfalse, Qfalse);
464 rb_ary_store(array, pos, e);
465 rb_ary_store(e, 1, rb_float_new(l->x));
466 rb_ary_store(e, 2, rb_float_new(l->y));
468 e = rb_ary_new3(5, ID2SYM(id_spline), Qfalse, Qfalse, Qfalse, Qfalse);
469 rb_ary_store(array, pos, e);
470 rb_ary_store(e, 1, rb_float_new(l->x));
471 rb_ary_store(e, 2, rb_float_new(l->y));
472 rb_ary_store(e, 3, rb_float_new(l->sx));
473 rb_ary_store(e, 4, rb_float_new(l->sy));
480 VALUE convert_color(gfxcolor_t*color)
482 return rb_ary_new3(4, INT2FIX(color->a), INT2FIX(color->r), INT2FIX(color->g), INT2FIX(color->b));
484 VALUE convert_matrix(gfxmatrix_t*matrix)
486 volatile VALUE array = rb_ary_new2(3);
487 volatile VALUE a = rb_ary_new2(2);
488 rb_ary_store(array, 0, a);
489 rb_ary_store(a, 0, rb_float_new(matrix->m00));
490 rb_ary_store(a, 1, rb_float_new(matrix->m01));
492 rb_ary_store(array, 1, a);
493 rb_ary_store(a, 0, rb_float_new(matrix->m10));
494 rb_ary_store(a, 1, rb_float_new(matrix->m11));
496 rb_ary_store(array, 2, a);
497 rb_ary_store(a, 0, rb_float_new(matrix->tx));
498 rb_ary_store(a, 1, rb_float_new(matrix->ty));
501 static VALUE font_is_cached(device_internal_t*i, gfxfont_t*font)
503 return (VALUE)gfxfontlist_getuserdata(i->doc->fontlist, font->id);
505 static void cache_font(device_internal_t*i, gfxfont_t*font, VALUE v)
507 i->doc->fontlist = gfxfontlist_addfont2(i->doc->fontlist, font, (void*)v);
509 static VALUE convert_font(gfxfont_t*font)
511 volatile VALUE v2 = font_allocate(Font);
514 f->glyph_array = rb_ary_new2(font->num_glyphs);
517 for(t=0;t<font->num_glyphs;t++) {
518 volatile VALUE a = glyph_allocate(Glyph);
519 rb_ary_store(f->glyph_array, t, a);
526 static VALUE convert_gradient(gfxgradient_t*gradient)
531 device_internal_t*i = (device_internal_t*)dev->internal; \
533 int rb_setparameter(gfxdevice_t*dev, const char*key, const char*value)
536 volatile VALUE v_key = rb_tainted_str_new2(key);
537 volatile VALUE v_value = rb_tainted_str_new2(value);
538 VALUE ret = forward(v,id_setparameter,2,v_key,v_value);
541 void rb_startpage(gfxdevice_t*dev, int width, int height)
544 VALUE ret = forward(v,id_startpage,2,INT2FIX(width),INT2FIX(height));
546 void rb_startclip(gfxdevice_t*dev, gfxline_t*line)
549 volatile VALUE v_line = convert_line(line);
550 VALUE ret = forward(v,id_startclip,1,v_line);
552 void rb_endclip(gfxdevice_t*dev)
555 VALUE ret = forward(v,id_endclip,0);
557 void rb_stroke(gfxdevice_t*dev, gfxline_t*line, gfxcoord_t width, gfxcolor_t*color, gfx_capType cap_style, gfx_joinType joint_style, gfxcoord_t miterLimit)
562 if(cap_style == gfx_capButt) cap = id_butt;
563 else if(cap_style == gfx_capRound) cap = id_round;
564 else if(cap_style == gfx_capSquare) cap = id_square;
567 if(joint_style == gfx_joinRound) joint = id_round;
568 else if(joint_style == gfx_joinMiter) joint = id_miter;
569 else if(joint_style == gfx_joinBevel) joint = id_bevel;
571 volatile VALUE v_line = convert_line(line);
572 volatile VALUE v_width = rb_float_new(width);
573 volatile VALUE v_color = convert_color(color);
574 volatile VALUE v_miter = rb_float_new(miterLimit);
575 forward(v, id_stroke, 6, v_line, v_width, v_color, ID2SYM(cap), ID2SYM(joint), v_miter);
577 void rb_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
581 volatile VALUE v_line = convert_line(line);
582 volatile VALUE v_color = convert_color(color);
583 forward(v, id_fill, 2, v_line, v_color);
585 void rb_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
588 volatile VALUE v_image = convert_image(i->doc, img);
589 volatile VALUE v_line = convert_line(line);
590 volatile VALUE v_matrix = convert_matrix(matrix);
591 forward(v, id_fillbitmap, 4, v_line, v_image, v_matrix, Qnil);
592 invalidate_image(v_image);
594 void rb_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
597 ID typeid = (type == gfxgradient_linear)? id_linear : id_radial;
599 volatile VALUE v_line = convert_line(line);
600 volatile VALUE v_matrix = convert_matrix(matrix);
601 volatile VALUE v_gradient = convert_gradient(gradient);
602 forward(v, id_fillgradient, 4, v_line, v_gradient, ID2SYM(typeid), v_matrix);
604 void rb_addfont(gfxdevice_t*dev, gfxfont_t*font)
608 volatile VALUE f = font_is_cached(i, font);
609 if(!f) {f=convert_font(font);cache_font(i,font,f);}
611 forward(v, id_addfont, 1, f);
613 void rb_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
616 volatile VALUE f = font_is_cached(i, font);
617 if(!f) {f=convert_font(font);cache_font(i,font,f);}
619 volatile VALUE v_color = convert_color(color);
620 volatile VALUE v_matrix = convert_matrix(matrix);
621 forward(v, id_drawchar, 4, f, INT2FIX(glyphnr), v_color, v_matrix);
623 void rb_drawlink(gfxdevice_t*dev, gfxline_t*line, const char*action)
626 volatile VALUE v_line = convert_line(line);
627 volatile VALUE v_action = rb_tainted_str_new2(action);
629 forward(v, id_drawlink, 2, v_line, v_action);
631 void rb_endpage(gfxdevice_t*dev)
634 forward(v, id_endpage, 0);
636 void gfxresult_rb_destroy(gfxresult_t*r)
640 gfxresult_t* rb_finish(gfxdevice_t*dev)
643 VALUE ret = forward(v, id_finish, 0);
644 gfxresult_t*r = (gfxresult_t*)rfx_calloc(sizeof(gfxresult_t));
645 r->destroy = gfxresult_rb_destroy;
646 r->internal = (void*)(ptroff_t)ret;
650 #define make_device(dev, idoc, device) \
652 device_internal_t i; \
656 dev.setparameter = rb_setparameter; \
657 dev.startpage = rb_startpage; \
658 dev.startclip = rb_startclip; \
659 dev.endclip = rb_endclip; \
660 dev.stroke = rb_stroke; \
661 dev.fill = rb_fill; \
662 dev.fillbitmap = rb_fillbitmap; \
663 dev.fillgradient = rb_fillgradient; \
664 dev.addfont = rb_addfont; \
665 dev.drawchar = rb_drawchar; \
666 dev.drawlink = rb_drawlink; \
667 dev.endpage = rb_endpage; \
668 dev.finish = rb_finish;
670 static VALUE page_render(VALUE cls, VALUE device)
672 Check_Type(device, T_OBJECT);
675 make_device(dev, page->doc, device);
677 dev.startpage(&dev, page->page->width, page->page->height);
678 page->page->render(page->page, &dev);
684 static VALUE doc_render(VALUE cls, VALUE device, VALUE _range, VALUE filters)
686 const char*range = 0;
688 Check_Type(_range, T_STRING);
689 range = StringValuePtr(_range);
693 make_device(_dev, doc, device);
694 gfxdevice_t*dev = &_dev;
696 if(!NIL_P(filters)) {
697 if(TYPE(filters) != T_ARRAY)
698 rb_raise(rb_eArgError, "third argument of doc->render must be an array of symbols");
700 int len = RARRAY(filters)->len;
703 VALUE filter = RARRAY(filters)->ptr[t++];
704 Check_Type(filter, T_SYMBOL);
705 ID id = SYM2ID(filter);
706 # define PARAM(x) VALUE x;if(t==len) rb_raise(rb_eArgError, "End of array while parsing arguments for filter %s", rb_id2name(id)); \
707 else x = RARRAY(filters)->ptr[t++];
708 if(id == id_remove_font_transforms) {
709 wrap_filter2(dev, remove_font_transforms);
710 } else if(id == id_maketransparent) {
712 wrap_filter(dev, maketransparent, FIX2INT(alpha));
714 rb_raise(rb_eArgError, "unknown filter %s", rb_id2name(id));
720 for(pagenr=1;pagenr<=doc->doc->num_pages;pagenr++) {
721 if(is_in_range(pagenr, (char*)range)) {
722 gfxpage_t*page = doc->doc->getpage(doc->doc, pagenr);
723 dev->startpage(dev, page->width, page->height);
724 page->render(page, dev);
731 gfxresult_t*r = dev->finish(dev);
737 static VALUE doc_prepare(VALUE cls, VALUE device)
740 make_device(dev, doc, device);
741 doc->doc->prepare(doc->doc, &dev);
746 // ---------------------- global functions ----------------------------------
748 VALUE gfx_setparameter(VALUE module, VALUE _key, VALUE _value)
750 Check_Type(_key, T_STRING);
751 Check_Type(_value, T_STRING);
752 const char*key = StringValuePtr(_key);
753 const char*value = StringValuePtr(_value);
754 pdfdriver->setparameter(pdfdriver, key, value);
755 swfdriver->setparameter(swfdriver, key, value);
756 imagedriver->setparameter(imagedriver, key, value);
760 // --------------------------------------------------------------------------
764 initLog(0,0,0,0,0,2);
765 pdfdriver = gfxsource_pdf_create();
766 swfdriver = gfxsource_swf_create();
767 imagedriver = gfxsource_image_create();
769 GFX = rb_define_module("GFX");
770 rb_define_const(GFX, "VERSION", INT2FIX(20100309));
772 rb_define_module_function(GFX, "setparameter", gfx_setparameter, 2);
774 DocumentPage = rb_define_class_under(GFX, "DocumentPage", rb_cObject);
775 rb_define_method(DocumentPage, "width", page_width, 0);
776 rb_define_method(DocumentPage, "height", page_height, 0);
777 rb_define_method(DocumentPage, "nr", page_nr, 0);
778 rb_define_method(DocumentPage, "render", page_render, 1);
780 Document = rb_define_class_under(GFX, "Document", rb_cObject);
781 rb_define_method(Document, "initialize", doc_initialize, 1);
782 rb_define_method(Document, "page", doc_get_page, 1);
783 rb_define_method(Document, "each_page", doc_each_page, 0);
784 rb_define_method(Document, "prepare", doc_prepare, 1);
785 rb_define_method(Document, "render", doc_render, 3);
787 Bitmap = rb_define_class_under(GFX, "Bitmap", rb_cObject);
788 rb_define_method(Bitmap, "save_jpeg", image_save_jpeg, 2);
789 rb_define_method(Bitmap, "save_png", image_save_png, 1);
790 rb_define_method(Bitmap, "width", image_width, 0);
791 rb_define_method(Bitmap, "height", image_height, 0);
792 rb_define_method(Bitmap, "rescale", image_rescale, 2);
793 rb_define_method(Bitmap, "has_alpha", image_has_alpha, 0);
795 Glyph = rb_define_class_under(GFX, "Glyph", rb_cObject);
796 rb_define_method(Glyph, "polygon", glyph_polygon, 0);
797 rb_define_method(Glyph, "unicode", glyph_unicode, 0);
798 rb_define_method(Glyph, "advance", glyph_advance, 0);
799 rb_define_method(Glyph, "bbox", glyph_bbox, 0);
801 Font = rb_define_class_under(GFX, "Font", rb_cObject);
802 rb_define_method(Font, "name", font_name, 0);
803 rb_define_method(Font, "ascent", font_ascent, 0);
804 rb_define_method(Font, "descent", font_descent, 0);
805 rb_define_method(Font, "glyphs", font_glyphs, 0);
806 rb_define_method(Font, "kerning", font_kerning, 0);
807 rb_define_method(Font, "get_kerning_table", font_kerning, 0);
808 rb_define_method(Font, "save_ttf", font_save_ttf, 1);
809 rb_define_method(Font, "save_eot", font_save_eot, 1);
811 Device = rb_define_class_under(GFX, "Device", rb_cObject);
812 rb_define_method(Device, "startpage", noop, -1);
813 rb_define_method(Device, "endpage", noop, -1);
814 rb_define_method(Device, "startclip", noop, -1);
815 rb_define_method(Device, "endclip", noop, -1);
816 rb_define_method(Device, "stroke", noop, -1);
817 rb_define_method(Device, "fill", noop, -1);
818 rb_define_method(Device, "fillbitmap", noop, -1);
819 rb_define_method(Device, "fillgradient", noop, -1);
820 rb_define_method(Device, "addfont", noop, -1);
821 rb_define_method(Device, "drawchar", noop, -1);
822 rb_define_method(Device, "drawlink", noop, -1);
824 PDFClass = rb_define_class_under(GFX, "PDF", Document);
825 rb_define_alloc_func(PDFClass, pdf_allocate);
827 SWFClass = rb_define_class_under(GFX, "SWF", Document);
828 rb_define_alloc_func(SWFClass, swf_allocate);
830 ImageClass = rb_define_class_under(GFX, "ImageRead", Document);
831 rb_define_alloc_func(ImageClass, imgdrv_allocate);
833 id_setparameter = rb_intern("setparameter");
834 id_startpage = rb_intern("startpage") ;
835 id_startclip = rb_intern("startclip") ;
836 id_endclip = rb_intern("endclip") ;
837 id_stroke = rb_intern("stroke") ;
838 id_fill = rb_intern("fill") ;
839 id_fillbitmap = rb_intern("fillbitmap") ;
840 id_fillgradient = rb_intern("fillgradient") ;
841 id_addfont = rb_intern("addfont") ;
842 id_drawchar = rb_intern("drawchar") ;
843 id_drawlink = rb_intern("drawlink") ;
844 id_endpage = rb_intern("endpage") ;
845 id_geterror = rb_intern("geterror") ;
846 id_finish = rb_intern("finish") ;
847 id_butt = rb_intern("butt");
848 id_round = rb_intern("round");
849 id_square = rb_intern("square");
850 id_miter = rb_intern("miter");
851 id_bevel = rb_intern("bevel");
852 id_move = rb_intern("move");
853 id_line = rb_intern("line");
854 id_spline = rb_intern("spline");
855 id_radial = rb_intern("radial");
856 id_linear = rb_intern("linear");
857 id_remove_font_transforms = rb_intern("remove_font_transforms");
858 id_maketransparent = rb_intern("maketransparent");