From 807e61dc8a0cb3bf272a6e61cb5fdde37fa20b1d Mon Sep 17 00:00:00 2001 From: Josh Holtrop Date: Thu, 7 Aug 2014 21:05:13 -0400 Subject: [PATCH] Font: fix baseline_offset calculation --- src/Font.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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()