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;
|
||||
}
|
||||
|
||||
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) {
|
||||
if(m_feng.load_font(font_filename, 0, agg::glyph_ren_outline)) {
|
||||
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);
|
||||
fprintf(stderr, "Font metrics ascender: %d descender: %d\n", ascender, descender);
|
||||
|
||||
// FIXME: figure out correct calculation for font->height with
|
||||
// ascent, descent and linegap.
|
||||
font->height = size;
|
||||
float scale = font->renderer->scale_for_em_to_pixels(size);
|
||||
font->height = (ascender - descender) * scale + 0.5;
|
||||
|
||||
fprintf(stderr, "Font height: %d\n", font->height);
|
||||
|
||||
return font;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue