Add correct font's height calculation using AGG
Compute the height like in renderer.c
This commit is contained in:
parent
0fea5d9d25
commit
010966d60d
|
@ -68,6 +68,14 @@ public:
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
float scale_for_em_to_pixels(float size) {
|
||||||
|
int units_per_em = m_feng.face_units_em();
|
||||||
|
if (units_per_em > 0) {
|
||||||
|
return size / units_per_em;
|
||||||
|
}
|
||||||
|
return 0.0;
|
||||||
|
}
|
||||||
|
|
||||||
bool load_font(const char *font_filename) {
|
bool load_font(const char *font_filename) {
|
||||||
if(m_feng.load_font(font_filename, 0, agg::glyph_ren_outline)) {
|
if(m_feng.load_font(font_filename, 0, agg::glyph_ren_outline)) {
|
||||||
m_font_loaded = true;
|
m_font_loaded = true;
|
||||||
|
|
|
@ -66,9 +66,11 @@ RenFontA* ren_load_font_agg(const char *filename, float size) {
|
||||||
font->renderer->get_font_vmetrics(ascender, descender);
|
font->renderer->get_font_vmetrics(ascender, descender);
|
||||||
fprintf(stderr, "Font metrics ascender: %d descender: %d\n", ascender, descender);
|
fprintf(stderr, "Font metrics ascender: %d descender: %d\n", ascender, descender);
|
||||||
|
|
||||||
// FIXME: figure out correct calculation for font->height with
|
float scale = font->renderer->scale_for_em_to_pixels(size);
|
||||||
// ascent, descent and linegap.
|
font->height = (ascender - descender) * scale + 0.5;
|
||||||
font->height = size;
|
|
||||||
|
fprintf(stderr, "Font height: %d\n", font->height);
|
||||||
|
|
||||||
return font;
|
return font;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue