Font: fix baseline_offset calculation
This commit is contained in:
parent
cdb22f3ff2
commit
807e61dc8a
@ -1,6 +1,5 @@
|
|||||||
#include "Font.h"
|
#include "Font.h"
|
||||||
#include "GLTexture.h"
|
#include "GLTexture.h"
|
||||||
#include <iostream>
|
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <ft2build.h>
|
#include <ft2build.h>
|
||||||
#include FT_FREETYPE_H
|
#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 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);
|
VALUE rv = Data_Wrap_Struct(klass, NULL, Font_free, font);
|
||||||
rb_iv_set(rv, "@advance", INT2FIX(get_glyph(font, 'x')->get_advance()));
|
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_singleton_method(ruby_class, "new", (VALUE(*)(...))Font_new, 2);
|
||||||
rb_define_attr(ruby_class, "advance", 1, 0);
|
rb_define_attr(ruby_class, "advance", 1, 0);
|
||||||
rb_define_attr(ruby_class, "line_height", 1, 0);
|
rb_define_attr(ruby_class, "line_height", 1, 0);
|
||||||
|
rb_define_attr(ruby_class, "baseline_offset", 1, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
Glyph::Glyph()
|
Glyph::Glyph()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user