Add font vmetrics in AGG font renderer test
This commit is contained in:
parent
4701c2899c
commit
155e76df5f
|
@ -55,6 +55,19 @@ public:
|
||||||
m_gamma_lut.gamma(m_gamma);
|
m_gamma_lut.gamma(m_gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool get_font_vmetrics(int& ascender, int& descender) {
|
||||||
|
int face_height = m_feng.face_height();
|
||||||
|
if (face_height > 0) {
|
||||||
|
double current_height = m_feng.height();
|
||||||
|
m_feng.height(1.0);
|
||||||
|
ascender = m_feng.ascender() * face_height;
|
||||||
|
descender = m_feng.descender() * face_height;
|
||||||
|
m_feng.height(current_height);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
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;
|
||||||
|
|
|
@ -62,6 +62,10 @@ RenFontA* ren_load_font_agg(const char *filename, float size) {
|
||||||
font->renderer = new font_renderer_lcd(true, false, false, 1.8);
|
font->renderer = new font_renderer_lcd(true, false, false, 1.8);
|
||||||
font->renderer->load_font(filename);
|
font->renderer->load_font(filename);
|
||||||
|
|
||||||
|
int ascender, descender;
|
||||||
|
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
|
// FIXME: figure out correct calculation for font->height with
|
||||||
// ascent, descent and linegap.
|
// ascent, descent and linegap.
|
||||||
font->height = size;
|
font->height = size;
|
||||||
|
|
Loading…
Reference in New Issue