#4 Buffer fonts often miss a row of pixel

closed-fixed
Sam Hocevar
None
5
2010-05-22
2008-07-21
Benlitz
No

I have this bug both on Windows and Linux, both with my program that uses FTGL and with FTGL demo application.

The last row (or the last column) of pixels, which corresponds to a part of the antialiasing around letters, is croped due to some rounding error in texture coords calculation.

I fixed that bug myself on my local copy of FTGL (I use 2.1.3-rc5) by doing this :

in function FTBufferFontImpl::RenderI() in FTBufferFont.cpp, around line 311, I changed the code this way :

FTPoint low = position + bbox.Lower() - FTPoint(padding, padding);
FTPoint up = position + bbox.Upper() + FTPoint(padding, padding);

glBegin(GL_QUADS);
glNormal3f(0.0f, 0.0f, 1.0f);
glTexCoord2f(0.0f,
float(texHeight - height) / texHeight);
glVertex2f(low.Xf(), up.Yf());
glTexCoord2f(0.0f,
1.0f);
glVertex2f(low.Xf(), low.Yf());
glTexCoord2f(float(width) / texWidth,
1.0f);
glVertex2f(up.Xf(), low.Yf());
glTexCoord2f(float(width) / texWidth,
float(texHeight - height) / texHeight);
glVertex2f(up.Xf(), up.Yf());
glEnd();

The difference between my code and the previous one is that instead of removing the padding in TextCoord, I remove it by drawing a larger polygon. There's a little bit more texel to manage with my method, but fonts are well rendered.

Discussion

  • The changes described above improve buffer font rendering for me as well.

     
  • Been bitten by this one too ...
    Patch above works for me.

     
  • Sam Hocevar
    Sam Hocevar
    2010-05-22

    Thanks. Patch applied upstream.

     
  • Sam Hocevar
    Sam Hocevar
    2010-05-22

    • assigned_to: nobody --> sammy
    • status: open --> closed-fixed