Rendering Sub-pixel Positioned Glyphs

Started by
3 comments, last by gfxCahd 8 years, 1 month ago

I am rendering text letter by letter as textured quads (my glyphs are in a texture atlas).

Though my glyphs' positions and dimensions in their texture atlas are integers (in texel space), their rendered screen size and coordinates will be float, mainly due to scalling. This results in text that does not have a consistent appearance. I know that any degree of scalling will deteriorate the quality of each letter, that's expected. What I am trying to solve is the case where (apparently due to sub-pixel positioning) the same letters in a line of text are rendered differently (e.g. some a's are blurry, while others sharper). Forcing their screen coordinates to be integers solves the consistency issue, but ruins their overall positioning (I go to the trouble of calculating kerning, and forcing integer possitioning renders this pointless).

Is there a solution to this? This problem exists with any rendered quad, it's just that more obvious when what is rendered is text.

Advertisement

Font files often contain hand-drawn bitmap characters for small font sizes and vector characters for big font sizes. Libraries like FreeType will give you integer offsets and kerning values for those.

Having multiple sizes of a font in a texture atlas will make it a little bit bigger, especially for huge fonts, which can be drawn with signed distance fields instead: http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf

I second the use of signed-distance-field fonts. Because of how the texture sampling works, they end up looking crisp with any transformation.

Font files often contain hand-drawn bitmap characters for small font sizes and vector characters for big font sizes. Libraries like FreeType will give you integer offsets and kerning values for those.

Having multiple sizes of a font in a texture atlas will make it a little bit bigger, especially for huge fonts, which can be drawn with signed distance fields instead: http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf

Yeah, I know about signed distance fields. But my issue is with small font sizes. As I understand, the best method for small fonts is still textured quads.

So, no ideas? I was wondering whether rendering my text at its native scale to a texture, and then I shrink that in order to render it to the screen.

Efficiency-wise it shouldn't be much of a problem if I store and reuse the text-texture, recreating it only when the text is modified. Code-wise it wouldn't be a clean as my current set-up (rendering each glyph at run-time). Is that what most games use in order to get nice small text?

This topic is closed to new replies.

Advertisement