+ return INT2FIX(glyph->font->font->glyphs[glyph->nr].unicode);
+}
+
+// ------------------------ font --------------------------------------------
+
+#define Get_Font(font,cls) font_internal_t*font=0;Data_Get_Struct(cls, font_internal_t, font);
+
+static void font_mark(font_internal_t*font)
+{
+ rb_gc_mark(font->glyph_array);
+}
+
+static void font_free(font_internal_t*font)
+{
+ free(font);
+}
+
+static VALUE font_allocate(VALUE cls)
+{
+ font_internal_t*font = 0;
+ VALUE v = Data_Make_Struct(cls, font_internal_t, font_mark, font_free, font);
+ memset(font, 0, sizeof(font_internal_t));
+ font->self = v;
+ return v;
+}
+
+static VALUE font_ascent(VALUE cls)
+{
+ Get_Font(font,cls);
+ return rb_float_new(font->font->ascent);
+}
+
+static VALUE font_descent(VALUE cls)
+{
+ Get_Font(font,cls);
+ return rb_float_new(font->font->descent);
+}
+
+static VALUE font_name(VALUE cls)
+{
+ Get_Font(font,cls);
+ return rb_tainted_str_new2(font->font->id);
+}
+
+static VALUE font_glyphs(VALUE cls)
+{
+ Get_Font(font,cls);
+ return font->glyph_array;
+}
+
+static VALUE font_kerning(VALUE cls)
+{
+ Get_Font(font,cls);
+ gfxkerning_t*kerning = font->font->kerning;
+ int kerning_size = font->font->kerning_size;
+ volatile VALUE a = rb_ary_new2(kerning_size);
+ int t;
+ for(t=0;t<kerning_size;t++) {
+ volatile VALUE tuple = rb_ary_new2(3);
+ rb_ary_store(tuple, 0, INT2FIX(kerning[t].c1));
+ rb_ary_store(tuple, 1, INT2FIX(kerning[t].c2));
+ rb_ary_store(tuple, 2, INT2FIX(kerning[t].advance));
+ rb_ary_store(a, t, tuple);
+ }
+ return a;