added ttf support to ruby module
authorMatthias Kramm <kramm@quiss.org>
Thu, 25 Feb 2010 19:27:56 +0000 (11:27 -0800)
committerMatthias Kramm <kramm@quiss.org>
Thu, 25 Feb 2010 19:27:56 +0000 (11:27 -0800)
lib/ruby/gfx.c

index 648e902..d392ed0 100644 (file)
@@ -3,6 +3,7 @@
 #include "../gfxsource.h"
 #include "../gfxtools.h"
 #include "../gfximage.h"
 #include "../gfxsource.h"
 #include "../gfxtools.h"
 #include "../gfximage.h"
+#include "../gfxfont.h"
 #include "../devices/pdf.h"
 #include "../readers/swf.h"
 #include "../readers/image.h"
 #include "../devices/pdf.h"
 #include "../readers/swf.h"
 #include "../readers/image.h"
@@ -363,6 +364,15 @@ static VALUE font_glyphs(VALUE cls)
     return font->glyph_array;
 }
 
     return font->glyph_array;
 }
 
+static VALUE font_save_ttf(VALUE cls, VALUE _filename)
+{
+    Get_Font(font,cls);
+    Check_Type(_filename, T_STRING);
+    const char*filename = StringValuePtr(_filename);
+    gfxfont_save(font->font, filename);
+    return Qnil;
+}
+
 static VALUE font_kerning(VALUE cls)
 {
     Get_Font(font,cls);
 static VALUE font_kerning(VALUE cls)
 {
     Get_Font(font,cls);
@@ -736,6 +746,7 @@ void Init_gfx()
     rb_define_method(Font, "glyphs", font_glyphs, 0);
     rb_define_method(Font, "kerning", font_kerning, 0);
     rb_define_method(Font, "get_kerning_table", font_kerning, 0);
     rb_define_method(Font, "glyphs", font_glyphs, 0);
     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);
     
     Device = rb_define_class_under(GFX, "Device", rb_cObject);
     rb_define_method(Device, "startpage", noop, -1);
     
     Device = rb_define_class_under(GFX, "Device", rb_cObject);
     rb_define_method(Device, "startpage", noop, -1);