diff --git a/src/Font.cc b/src/Font.cc index 74ef8d3..e46c486 100644 --- a/src/Font.cc +++ b/src/Font.cc @@ -1,6 +1,5 @@ #include "Font.h" #include "GLTexture.h" -#include #include #include #include FT_FREETYPE_H @@ -116,7 +115,7 @@ static VALUE Font_new(VALUE klass, VALUE fname, VALUE size) } int line_height = round_up_26_6(font->face->size->metrics.height); - int baseline_offset = (line_height - (max_top - min_bottom)) / 2; + int baseline_offset = (line_height - (max_top - min_bottom)) / 2 - min_bottom; VALUE rv = Data_Wrap_Struct(klass, NULL, Font_free, font); rb_iv_set(rv, "@advance", INT2FIX(get_glyph(font, 'x')->get_advance())); @@ -131,6 +130,7 @@ void Font_Init() rb_define_singleton_method(ruby_class, "new", (VALUE(*)(...))Font_new, 2); rb_define_attr(ruby_class, "advance", 1, 0); rb_define_attr(ruby_class, "line_height", 1, 0); + rb_define_attr(ruby_class, "baseline_offset", 1, 0); } Glyph::Glyph()