My TrueTypeFonts Get More Glitchy With Every Size!

Here is what it looks like at sizes 60, 65, and 80. In case you did not see, it gets VERY bad at 80.

Is this normal for .TTF, or am I coding it wrong?

If not, then continue…

I have modelled this nearly word for word from slick2d’s amazing implementation (I took out extra chars).

I do not know why this is happening! I seriously have no leads here. So I hate throwing the source code out at you guys, but I commented it out for you guys though, so you can point out any errors in the code.

Thanks in advance!

What is the value of fmetrics.getHeight() returning? For both correct and bugged chars.

Internally Slick’s TrueTypeFont basically just creates a bitmap font from an AWT Font.

When it comes to basic bitmap fonts you must regenerate the font for each size, you can’t just generate it once and scale the bitmap without loosing quality and/or the font becoming blurry. However a little bit of blur here and there on the fonts is mostly fine for game usage but do have a go with the opengl filters GL_LINEAR and GL_NEAREST to see if it helps.

Are you sure it’s the bitmap that’s going wrong and not the rendering code? Have you dumped the texture to a file and checked that it looks sensible?

I think you have two options: either alter your library to support using multiple textures when necessary, or alter it to detect when the texture is too small and increase its size. I would favour the second option, and I would split the texture generation into two phases: one which runs through doing the layout, with a “double texture dimensions and go to start” if it overflows y, and a second phase which does the actual rendering of the characters onto the texture.