Jump to content
  • Advertisement
Sign in to follow this  
gfxCahd

Rendering Sub-pixel Positioned Glyphs

This topic is 915 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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.

Edited by gfxCahd

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Edited by gfxCahd

Share this post


Link to post
Share on other sites

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?

Edited by gfxCahd

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!