I want to render font glyphs with FreeType. But for some fonts (e.g. bahnschrift.ttf) the rendered bitmaps have negative y positions. Negative coordinates won't work on the system I want to integrate FreeType into.
Is there any way to avoid these negative positions? I could obviously move all characters down by some pixels, but this option is far too expensive. Or is this due to the metrics of this particular font?
This problem occurs for example with the font bahnschrift.ttf and capital letters like umlauts Ä or Ö.
I load and render the glyph with the default flags:
FT_Set_Pixel_Sizes(m_Face, 0, 32);
FT_UInt glyph_index = (FT_UInt)c;
if (m_Face->charmap) {
glyph_index = FT_Get_Char_Index(m_Face, c);
}
if (glyph_index) {
err = FT_Load_Glyph(m_Face, glyph_index, FT_LOAD_DEFAULT);
return (err) ? false : true;
}
if (FT_Render_Glyph(m_Face->glyph, FT_RENDER_MODE_NORMAL) != FT_Err_Ok) {
return false;
}
I then retrieve the baseline from the font:
int baseline = m_Face->size->metrics.ascender >> 6;
And the y0 position of the glyph bitmap is calculated like so:
glyph.y0 = -m_Face->glyph->bitmap_top + baseline;
Is my calculation of the glyph metrics wrong?