2 #include "../../config.h"
3 #include "../gfxdevice.h"
4 #include "../gfxsource.h"
5 #include "../gfxtools.h"
6 #include "../gfximage.h"
7 #include "../gfxfont.h"
8 #include "../gfxfilter.h"
9 #include "../devices/pdf.h"
10 #include "../readers/swf.h"
11 #include "../readers/image.h"
12 #include "../pdf/pdf.h"
18 #define RUBY_GFX_VERSION "0.9.0"
21 static VALUE Font, Glyph, Bitmap, Document, DocumentPage, PDFClass, SWFClass, ImageClass, Device;
24 typedef struct doc_internal {
26 gfxsource_t*driver; // filled by alloc
28 gfxfontlist_t*fontlist;
31 typedef struct page_internal {
36 typedef struct image_internal {
41 typedef struct font_internal {
47 typedef struct glyph_internal {
52 static gfxsource_t* pdfdriver = 0;
53 static gfxsource_t* imagedriver = 0;
54 static gfxsource_t* swfdriver = 0;
56 #define Get_Doc(doc,cls) doc_internal_t*doc=0;Data_Get_Struct(cls, doc_internal_t, doc);
57 #define Get_Page(page,cls) page_internal_t*page=0;Data_Get_Struct(cls, page_internal_t, page);
59 static VALUE doc_allocate(VALUE cls, gfxsource_t*driver);
60 static VALUE page_allocate(VALUE cls);
62 // ------------------------ documents ---------------------------------------
64 static VALUE doc_initialize(VALUE cls, VALUE _filename)
66 Check_Type(_filename, T_STRING);
68 const char*filename = StringValuePtr(_filename);
69 doc->fontlist = gfxfontlist_create();
70 doc->doc = pdfdriver->open(pdfdriver, filename);
72 rb_raise(rb_eIOError, "couldn't open %s", filename);
77 static VALUE doc_num_pages(VALUE cls)
80 return INT2FIX(doc->doc->num_pages);
83 static VALUE doc_get_page(VALUE cls, VALUE _nr)
85 Check_Type(_nr, T_FIXNUM);
86 int nr = FIX2INT(_nr);
89 VALUE v = page_allocate(DocumentPage);
91 page->page = doc->doc->getpage(doc->doc, nr);
94 rb_raise(rb_eArgError, "No page %d in document", nr);
100 static VALUE doc_each_page(VALUE cls)
104 for(t=1;t<=doc->doc->num_pages;t++) {
105 VALUE v = page_allocate(DocumentPage);
107 page->page = doc->doc->getpage(doc->doc, t);
114 static void doc_mark(doc_internal_t*doc)
116 gfxfontlist_t*l = doc->fontlist;
119 rb_gc_mark((VALUE)l->user);
124 static void doc_free(doc_internal_t*doc)
126 gfxfontlist_free(doc->fontlist, 0);
128 doc->doc->destroy(doc->doc);
134 static VALUE doc_allocate(VALUE cls, gfxsource_t*driver)
136 doc_internal_t*doc = 0;
137 VALUE v = Data_Make_Struct(cls, doc_internal_t, doc_mark, doc_free, doc);
139 memset(doc, 0, sizeof(doc_internal_t));
140 doc->driver = driver;
144 static VALUE pdf_allocate(VALUE cls) {return doc_allocate(cls, pdfdriver);}
145 static VALUE swf_allocate(VALUE cls) {return doc_allocate(cls, swfdriver);}
146 static VALUE imgdrv_allocate(VALUE cls) {return doc_allocate(cls, imagedriver);}
148 // ------------------------ doc pages ---------------------------------------
150 static void page_free(page_internal_t*page)
154 page->page->destroy(page->page);
159 static void page_mark(page_internal_t*page)
161 rb_gc_mark(page->doc->self);
163 static VALUE page_allocate(VALUE cls)
165 page_internal_t*page = 0;
166 VALUE v = Data_Make_Struct(cls, page_internal_t, page_mark, page_free, page);
167 memset(page, 0, sizeof(page_internal_t));
170 static VALUE page_nr(VALUE cls)
173 return INT2FIX(page->page->nr);
175 static VALUE page_width(VALUE cls)
178 return INT2FIX(page->page->width);
180 static VALUE page_height(VALUE cls)
183 return INT2FIX(page->page->height);
186 // ------------------------ image -------------------------------------------
188 #define Get_Image(image,cls) image_internal_t*image=0;Data_Get_Struct(cls, image_internal_t, image);
190 static void image_free(image_internal_t*image)
194 static void image_mark(image_internal_t*image)
196 rb_gc_mark(image->doc->self);
198 static VALUE image_allocate(VALUE cls)
200 image_internal_t*image = 0;
201 VALUE v = Data_Make_Struct(cls, image_internal_t, image_mark, image_free, image);
202 memset(image, 0, sizeof(image_internal_t));
205 static VALUE image_width(VALUE cls)
208 return INT2FIX(image->image->width);
210 static VALUE image_height(VALUE cls)
213 return INT2FIX(image->image->height);
215 static VALUE image_rescale(VALUE cls, VALUE _width, VALUE _height)
218 Check_Type(_width, T_FIXNUM);
219 Check_Type(_height, T_FIXNUM);
220 int width = FIX2INT(_width);
221 int height = FIX2INT(_height);
222 volatile VALUE v_image2 = image_allocate(Bitmap);
223 Get_Image(image2,v_image2)
224 image2->doc = image->doc;
225 image2->image = gfximage_rescale(image->image, width, height);
227 rb_raise(rb_eArgError, "Can't rescale to size %dx%d", width, height);
231 static VALUE image_has_alpha(VALUE cls)
234 int size = image->image->width * image->image->height;
235 gfxcolor_t*data = image->image->data;
237 for(t=0;t<size;t++) {
243 static VALUE image_save_jpeg(VALUE cls, VALUE _filename, VALUE quality)
246 Check_Type(_filename, T_STRING);
247 Check_Type(quality, T_FIXNUM);
248 const char*filename = StringValuePtr(_filename);
249 gfximage_save_jpeg(image->image, filename, FIX2INT(quality));
252 static VALUE image_save_png(VALUE cls, VALUE _filename)
255 Check_Type(_filename, T_STRING);
256 const char*filename = StringValuePtr(_filename);
257 gfximage_save_png(image->image, filename);
260 VALUE convert_image(doc_internal_t*doc,gfximage_t*_image)
262 VALUE v = image_allocate(Bitmap);
264 image->image = _image;
268 void invalidate_image(VALUE v)
274 // ------------------------ glyphs ------------------------------------------
276 static VALUE convert_line(gfxline_t*line);
278 #define Get_Glyph(glyph,cls) glyph_internal_t*glyph=0;Data_Get_Struct(cls, glyph_internal_t, glyph);
280 static void glyph_free(glyph_internal_t*glyph)
285 static void glyph_mark(glyph_internal_t*glyph)
287 rb_gc_mark(glyph->font->self);
290 static VALUE glyph_allocate(VALUE cls)
292 glyph_internal_t*glyph = 0;
293 VALUE v = Data_Make_Struct(cls, glyph_internal_t, glyph_mark, glyph_free, glyph);
294 memset(glyph, 0, sizeof(glyph_internal_t));
298 static VALUE glyph_polygon(VALUE cls)
300 Get_Glyph(glyph,cls);
301 return convert_line(glyph->font->font->glyphs[glyph->nr].line);
304 static VALUE glyph_advance(VALUE cls)
306 Get_Glyph(glyph,cls);
307 return rb_float_new(glyph->font->font->glyphs[glyph->nr].advance);
310 static VALUE glyph_bbox(VALUE cls)
312 Get_Glyph(glyph,cls);
313 gfxbbox_t bbox = gfxline_getbbox(glyph->font->font->glyphs[glyph->nr].line);
314 return rb_ary_new3(4, rb_float_new(bbox.xmin),
315 rb_float_new(bbox.ymin),
316 rb_float_new(bbox.xmax),
317 rb_float_new(bbox.ymax));
320 static VALUE glyph_unicode(VALUE cls)
322 Get_Glyph(glyph,cls);
323 return INT2FIX(glyph->font->font->glyphs[glyph->nr].unicode);
326 // ------------------------ font --------------------------------------------
328 #define Get_Font(font,cls) font_internal_t*font=0;Data_Get_Struct(cls, font_internal_t, font);
330 static void font_mark(font_internal_t*font)
332 rb_gc_mark(font->glyph_array);
335 static void font_free(font_internal_t*font)
340 static VALUE font_allocate(VALUE cls)
342 font_internal_t*font = 0;
343 VALUE v = Data_Make_Struct(cls, font_internal_t, font_mark, font_free, font);
344 memset(font, 0, sizeof(font_internal_t));
349 static VALUE font_ascent(VALUE cls)
352 return rb_float_new(font->font->ascent);
355 static VALUE font_descent(VALUE cls)
358 return rb_float_new(font->font->descent);
361 static VALUE font_name(VALUE cls)
364 return rb_tainted_str_new2(font->font->id);
367 static VALUE font_glyphs(VALUE cls)
370 return font->glyph_array;
373 static VALUE font_save_ttf(VALUE cls, VALUE _filename)
376 Check_Type(_filename, T_STRING);
377 const char*filename = StringValuePtr(_filename);
378 gfxfont_save(font->font, filename);
382 static VALUE font_save_eot(VALUE cls, VALUE _filename)
385 Check_Type(_filename, T_STRING);
386 const char*filename = StringValuePtr(_filename);
387 gfxfont_save_eot(font->font, filename);
391 static VALUE font_kerning(VALUE cls)
394 gfxkerning_t*kerning = font->font->kerning;
395 int kerning_size = font->font->kerning_size;
396 volatile VALUE a = rb_ary_new2(kerning_size);
398 for(t=0;t<kerning_size;t++) {
399 volatile VALUE tuple = rb_ary_new2(3);
400 rb_ary_store(tuple, 0, INT2FIX(kerning[t].c1));
401 rb_ary_store(tuple, 1, INT2FIX(kerning[t].c2));
402 rb_ary_store(tuple, 2, INT2FIX(kerning[t].advance));
403 rb_ary_store(a, t, tuple);
408 // ------------------------ gfx device --------------------------------------
410 typedef struct device_internal {
415 static ID id_setparameter = 0;
416 static ID id_startpage = 0;
417 static ID id_startclip = 0;
418 static ID id_endclip = 0;
419 static ID id_stroke = 0;
420 static ID id_fill = 0;
421 static ID id_fillbitmap = 0;
422 static ID id_fillgradient = 0;
423 static ID id_addfont = 0;
424 static ID id_drawchar = 0;
425 static ID id_drawlink = 0;
426 static ID id_endpage = 0;
427 static ID id_geterror = 0;
428 static ID id_finish = 0;
429 static ID id_butt = 0;
430 static ID id_round = 0;
431 static ID id_square = 0;
432 static ID id_bevel = 0;
433 static ID id_miter = 0;
434 static ID id_move = 0;
435 static ID id_line = 0;
436 static ID id_spline = 0;
437 static ID id_radial = 0;
438 static ID id_linear = 0;
439 static ID id_remove_font_transforms = 0;
440 static ID id_maketransparent = 0;
441 static ID id_vectors_to_glyphs = 0;
443 static VALUE noop(int argc, VALUE *argv, VALUE obj) {return obj;}
445 #define forward(v,id,args...) rb_respond_to((v), (id))?rb_funcall((v), (id), args):0
447 VALUE convert_line(gfxline_t*line)
451 while(l) {l=l->next;len++;}
453 volatile VALUE array = rb_ary_new2(len);
459 if(l->type == gfx_moveTo) {
460 e = rb_ary_new3(3, ID2SYM(id_move), Qfalse, Qfalse);
461 rb_ary_store(array, pos, e);
462 rb_ary_store(e, 1, rb_float_new(l->x));
463 rb_ary_store(e, 2, rb_float_new(l->y));
464 } else if(l->type == gfx_lineTo) {
465 e = rb_ary_new3(3, ID2SYM(id_line), Qfalse, Qfalse);
466 rb_ary_store(array, pos, e);
467 rb_ary_store(e, 1, rb_float_new(l->x));
468 rb_ary_store(e, 2, rb_float_new(l->y));
470 e = rb_ary_new3(5, ID2SYM(id_spline), Qfalse, Qfalse, Qfalse, Qfalse);
471 rb_ary_store(array, pos, e);
472 rb_ary_store(e, 1, rb_float_new(l->x));
473 rb_ary_store(e, 2, rb_float_new(l->y));
474 rb_ary_store(e, 3, rb_float_new(l->sx));
475 rb_ary_store(e, 4, rb_float_new(l->sy));
482 VALUE convert_color(gfxcolor_t*color)
484 return rb_ary_new3(4, INT2FIX(color->a), INT2FIX(color->r), INT2FIX(color->g), INT2FIX(color->b));
486 VALUE convert_matrix(gfxmatrix_t*matrix)
488 volatile VALUE array = rb_ary_new2(3);
489 volatile VALUE a = rb_ary_new2(2);
490 rb_ary_store(array, 0, a);
491 rb_ary_store(a, 0, rb_float_new(matrix->m00));
492 rb_ary_store(a, 1, rb_float_new(matrix->m01));
494 rb_ary_store(array, 1, a);
495 rb_ary_store(a, 0, rb_float_new(matrix->m10));
496 rb_ary_store(a, 1, rb_float_new(matrix->m11));
498 rb_ary_store(array, 2, a);
499 rb_ary_store(a, 0, rb_float_new(matrix->tx));
500 rb_ary_store(a, 1, rb_float_new(matrix->ty));
503 static VALUE font_is_cached(device_internal_t*i, gfxfont_t*font)
505 return (VALUE)gfxfontlist_getuserdata(i->doc->fontlist, font->id);
507 static void cache_font(device_internal_t*i, gfxfont_t*font, VALUE v)
509 i->doc->fontlist = gfxfontlist_addfont2(i->doc->fontlist, font, (void*)v);
511 static VALUE convert_font(gfxfont_t*font)
513 volatile VALUE v2 = font_allocate(Font);
516 f->glyph_array = rb_ary_new2(font->num_glyphs);
519 for(t=0;t<font->num_glyphs;t++) {
520 volatile VALUE a = glyph_allocate(Glyph);
521 rb_ary_store(f->glyph_array, t, a);
528 static VALUE convert_gradient(gfxgradient_t*gradient)
533 device_internal_t*i = (device_internal_t*)dev->internal; \
535 int rb_setparameter(gfxdevice_t*dev, const char*key, const char*value)
538 volatile VALUE v_key = rb_tainted_str_new2(key);
539 volatile VALUE v_value = rb_tainted_str_new2(value);
540 VALUE ret = forward(v,id_setparameter,2,v_key,v_value);
543 void rb_startpage(gfxdevice_t*dev, int width, int height)
546 VALUE ret = forward(v,id_startpage,2,INT2FIX(width),INT2FIX(height));
548 void rb_startclip(gfxdevice_t*dev, gfxline_t*line)
551 volatile VALUE v_line = convert_line(line);
552 VALUE ret = forward(v,id_startclip,1,v_line);
554 void rb_endclip(gfxdevice_t*dev)
557 VALUE ret = forward(v,id_endclip,0);
559 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)
564 if(cap_style == gfx_capButt) cap = id_butt;
565 else if(cap_style == gfx_capRound) cap = id_round;
566 else if(cap_style == gfx_capSquare) cap = id_square;
569 if(joint_style == gfx_joinRound) joint = id_round;
570 else if(joint_style == gfx_joinMiter) joint = id_miter;
571 else if(joint_style == gfx_joinBevel) joint = id_bevel;
573 volatile VALUE v_line = convert_line(line);
574 volatile VALUE v_width = rb_float_new(width);
575 volatile VALUE v_color = convert_color(color);
576 volatile VALUE v_miter = rb_float_new(miterLimit);
577 forward(v, id_stroke, 6, v_line, v_width, v_color, ID2SYM(cap), ID2SYM(joint), v_miter);
579 void rb_fill(gfxdevice_t*dev, gfxline_t*line, gfxcolor_t*color)
583 volatile VALUE v_line = convert_line(line);
584 volatile VALUE v_color = convert_color(color);
585 forward(v, id_fill, 2, v_line, v_color);
587 void rb_fillbitmap(gfxdevice_t*dev, gfxline_t*line, gfximage_t*img, gfxmatrix_t*matrix, gfxcxform_t*cxform)
590 volatile VALUE v_image = convert_image(i->doc, img);
591 volatile VALUE v_line = convert_line(line);
592 volatile VALUE v_matrix = convert_matrix(matrix);
593 forward(v, id_fillbitmap, 4, v_line, v_image, v_matrix, Qnil);
594 invalidate_image(v_image);
596 void rb_fillgradient(gfxdevice_t*dev, gfxline_t*line, gfxgradient_t*gradient, gfxgradienttype_t type, gfxmatrix_t*matrix)
599 ID typeid = (type == gfxgradient_linear)? id_linear : id_radial;
601 volatile VALUE v_line = convert_line(line);
602 volatile VALUE v_matrix = convert_matrix(matrix);
603 volatile VALUE v_gradient = convert_gradient(gradient);
604 forward(v, id_fillgradient, 4, v_line, v_gradient, ID2SYM(typeid), v_matrix);
606 void rb_addfont(gfxdevice_t*dev, gfxfont_t*font)
610 volatile VALUE f = font_is_cached(i, font);
611 if(!f) {f=convert_font(font);cache_font(i,font,f);}
613 forward(v, id_addfont, 1, f);
615 void rb_drawchar(gfxdevice_t*dev, gfxfont_t*font, int glyphnr, gfxcolor_t*color, gfxmatrix_t*matrix)
618 volatile VALUE f = font_is_cached(i, font);
619 if(!f) {f=convert_font(font);cache_font(i,font,f);}
621 volatile VALUE v_color = convert_color(color);
622 volatile VALUE v_matrix = convert_matrix(matrix);
623 forward(v, id_drawchar, 4, f, INT2FIX(glyphnr), v_color, v_matrix);
625 void rb_drawlink(gfxdevice_t*dev, gfxline_t*line, const char*action)
628 volatile VALUE v_line = convert_line(line);
629 volatile VALUE v_action = rb_tainted_str_new2(action);
631 forward(v, id_drawlink, 2, v_line, v_action);
633 void rb_endpage(gfxdevice_t*dev)
636 forward(v, id_endpage, 0);
638 void gfxresult_rb_destroy(gfxresult_t*r)
642 gfxresult_t* rb_finish(gfxdevice_t*dev)
645 VALUE ret = forward(v, id_finish, 0);
646 gfxresult_t*r = (gfxresult_t*)rfx_calloc(sizeof(gfxresult_t));
647 r->destroy = gfxresult_rb_destroy;
648 r->internal = (void*)(ptroff_t)ret;
652 #define make_device(dev, idoc, device) \
654 device_internal_t i; \
658 dev.setparameter = rb_setparameter; \
659 dev.startpage = rb_startpage; \
660 dev.startclip = rb_startclip; \
661 dev.endclip = rb_endclip; \
662 dev.stroke = rb_stroke; \
663 dev.fill = rb_fill; \
664 dev.fillbitmap = rb_fillbitmap; \
665 dev.fillgradient = rb_fillgradient; \
666 dev.addfont = rb_addfont; \
667 dev.drawchar = rb_drawchar; \
668 dev.drawlink = rb_drawlink; \
669 dev.endpage = rb_endpage; \
670 dev.finish = rb_finish;
672 static VALUE page_render(VALUE cls, VALUE device)
674 Check_Type(device, T_OBJECT);
677 make_device(dev, page->doc, device);
679 dev.startpage(&dev, page->page->width, page->page->height);
680 page->page->render(page->page, &dev);
686 static VALUE doc_render(VALUE cls, VALUE device, VALUE _range, VALUE filters)
688 const char*range = 0;
690 Check_Type(_range, T_STRING);
691 range = StringValuePtr(_range);
695 make_device(_dev, doc, device);
696 gfxdevice_t*dev = &_dev;
698 if(!NIL_P(filters)) {
699 if(TYPE(filters) != T_ARRAY)
700 rb_raise(rb_eArgError, "third argument of doc->render must be an array of symbols");
702 int len = RARRAY(filters)->len;
705 VALUE filter = RARRAY(filters)->ptr[t++];
706 Check_Type(filter, T_SYMBOL);
707 ID id = SYM2ID(filter);
708 # define PARAM(x) VALUE x;if(t==len) rb_raise(rb_eArgError, "End of array while parsing arguments for filter %s", rb_id2name(id)); \
709 else x = RARRAY(filters)->ptr[t++];
710 if(id == id_remove_font_transforms) {
711 wrap_filter2(dev, remove_font_transforms);
712 } else if(id == id_vectors_to_glyphs) {
713 wrap_filter2(dev, vectors_to_glyphs);
714 } else if(id == id_maketransparent) {
716 wrap_filter(dev, maketransparent, FIX2INT(alpha));
718 rb_raise(rb_eArgError, "unknown filter %s", rb_id2name(id));
724 for(pagenr=1;pagenr<=doc->doc->num_pages;pagenr++) {
725 if(is_in_range(pagenr, (char*)range)) {
726 gfxpage_t*page = doc->doc->getpage(doc->doc, pagenr);
727 dev->startpage(dev, page->width, page->height);
728 page->render(page, dev);
735 gfxresult_t*r = dev->finish(dev);
741 static VALUE doc_prepare(VALUE cls, VALUE device)
744 make_device(dev, doc, device);
745 doc->doc->prepare(doc->doc, &dev);
750 // ---------------------- global functions ----------------------------------
752 VALUE gfx_setparameter(VALUE module, VALUE _key, VALUE _value)
754 Check_Type(_key, T_STRING);
755 Check_Type(_value, T_STRING);
756 const char*key = StringValuePtr(_key);
757 const char*value = StringValuePtr(_value);
758 pdfdriver->setparameter(pdfdriver, key, value);
759 swfdriver->setparameter(swfdriver, key, value);
760 imagedriver->setparameter(imagedriver, key, value);
764 // --------------------------------------------------------------------------
768 initLog(0,0,0,0,0,2);
777 pdfdriver = gfxsource_pdf_create();
778 swfdriver = gfxsource_swf_create();
779 imagedriver = gfxsource_image_create();
781 GFX = rb_define_module("GFX");
782 rb_define_const(GFX, "VERSION", INT2FIX(20100309));
784 rb_define_module_function(GFX, "setparameter", gfx_setparameter, 2);
786 DocumentPage = rb_define_class_under(GFX, "DocumentPage", rb_cObject);
787 rb_define_method(DocumentPage, "width", page_width, 0);
788 rb_define_method(DocumentPage, "height", page_height, 0);
789 rb_define_method(DocumentPage, "nr", page_nr, 0);
790 rb_define_method(DocumentPage, "render", page_render, 1);
792 Document = rb_define_class_under(GFX, "Document", rb_cObject);
793 rb_define_method(Document, "initialize", doc_initialize, 1);
794 rb_define_method(Document, "page", doc_get_page, 1);
795 rb_define_method(Document, "each_page", doc_each_page, 0);
796 rb_define_method(Document, "prepare", doc_prepare, 1);
797 rb_define_method(Document, "render", doc_render, 3);
799 Bitmap = rb_define_class_under(GFX, "Bitmap", rb_cObject);
800 rb_define_method(Bitmap, "save_jpeg", image_save_jpeg, 2);
801 rb_define_method(Bitmap, "save_png", image_save_png, 1);
802 rb_define_method(Bitmap, "width", image_width, 0);
803 rb_define_method(Bitmap, "height", image_height, 0);
804 rb_define_method(Bitmap, "rescale", image_rescale, 2);
805 rb_define_method(Bitmap, "has_alpha", image_has_alpha, 0);
807 Glyph = rb_define_class_under(GFX, "Glyph", rb_cObject);
808 rb_define_method(Glyph, "polygon", glyph_polygon, 0);
809 rb_define_method(Glyph, "unicode", glyph_unicode, 0);
810 rb_define_method(Glyph, "advance", glyph_advance, 0);
811 rb_define_method(Glyph, "bbox", glyph_bbox, 0);
813 Font = rb_define_class_under(GFX, "Font", rb_cObject);
814 rb_define_method(Font, "name", font_name, 0);
815 rb_define_method(Font, "ascent", font_ascent, 0);
816 rb_define_method(Font, "descent", font_descent, 0);
817 rb_define_method(Font, "glyphs", font_glyphs, 0);
818 rb_define_method(Font, "kerning", font_kerning, 0);
819 rb_define_method(Font, "get_kerning_table", font_kerning, 0);
820 rb_define_method(Font, "save_ttf", font_save_ttf, 1);
821 rb_define_method(Font, "save_eot", font_save_eot, 1);
823 Device = rb_define_class_under(GFX, "Device", rb_cObject);
824 rb_define_method(Device, "startpage", noop, -1);
825 rb_define_method(Device, "endpage", noop, -1);
826 rb_define_method(Device, "startclip", noop, -1);
827 rb_define_method(Device, "endclip", noop, -1);
828 rb_define_method(Device, "stroke", noop, -1);
829 rb_define_method(Device, "fill", noop, -1);
830 rb_define_method(Device, "fillbitmap", noop, -1);
831 rb_define_method(Device, "fillgradient", noop, -1);
832 rb_define_method(Device, "addfont", noop, -1);
833 rb_define_method(Device, "drawchar", noop, -1);
834 rb_define_method(Device, "drawlink", noop, -1);
836 PDFClass = rb_define_class_under(GFX, "PDF", Document);
837 rb_define_alloc_func(PDFClass, pdf_allocate);
839 SWFClass = rb_define_class_under(GFX, "SWF", Document);
840 rb_define_alloc_func(SWFClass, swf_allocate);
842 ImageClass = rb_define_class_under(GFX, "ImageRead", Document);
843 rb_define_alloc_func(ImageClass, imgdrv_allocate);
845 id_setparameter = rb_intern("setparameter");
846 id_startpage = rb_intern("startpage") ;
847 id_startclip = rb_intern("startclip") ;
848 id_endclip = rb_intern("endclip") ;
849 id_stroke = rb_intern("stroke") ;
850 id_fill = rb_intern("fill") ;
851 id_fillbitmap = rb_intern("fillbitmap") ;
852 id_fillgradient = rb_intern("fillgradient") ;
853 id_addfont = rb_intern("addfont") ;
854 id_drawchar = rb_intern("drawchar") ;
855 id_drawlink = rb_intern("drawlink") ;
856 id_endpage = rb_intern("endpage") ;
857 id_geterror = rb_intern("geterror") ;
858 id_finish = rb_intern("finish") ;
859 id_butt = rb_intern("butt");
860 id_round = rb_intern("round");
861 id_square = rb_intern("square");
862 id_miter = rb_intern("miter");
863 id_bevel = rb_intern("bevel");
864 id_move = rb_intern("move");
865 id_line = rb_intern("line");
866 id_spline = rb_intern("spline");
867 id_radial = rb_intern("radial");
868 id_linear = rb_intern("linear");
869 id_remove_font_transforms = rb_intern("remove_font_transforms");
870 id_maketransparent = rb_intern("maketransparent");
871 id_vectors_to_glyphs = rb_intern("vectors_to_glyphs");