Distance font rendering

Source: Internet
Author: User
Tags libgdx

One drawback to using bitmap font is that it shows significant aliasing when the font is scaled. Therefore, fonts such as small, normal, big, and so on will usually be created for a particular font to cope with different scaling intervals.

This can create a huge memory overhead. The article Http://www.valvesoftware.com/publications/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf of value refers to a

Scale friendly method, the result of the implementation is as follows.

Implementation method:

1. Use FreeType, or Windows GDI to create a bitmap of characters. The super-sample is used here. For fonts with a base 20 height, use a font of X Supersamplescale to create bitmaps. It is created in the X 4来.

2. For each character of the bitmap, convert and down the scale to signed distance field. It is important to note that in Bitmap-font we always store and render characters in the smallest bounding box of a character bitmap. But for distance field, you must

Large expansion of the perimeter of the bounding box of the character. For example, the bitmap size of ' A ' is 16x20, so for the creation of distance field, we have to expand to (16+paddingx*2) * (+paddingy*2), and then put the character bitmap in the middle position after the

Distance calculation. Otherwise, in texture sampling, linear filtering should cause the edges of the characters to cross over adjacent characters.

3. Convert the distance after the down scale to a bitmap and pack the storage.

Basically now the article that the Google comes out is to deal with a whole package of bitmap, for example:

Https://github.com/libgdx/libgdx/wiki/Distance-field-fonts

https://crimild.wordpress.com/2013/09/01/improving-text-rendering-with-signed-distance-fields/

https://www.mapbox.com/blog/text-signed-distance-fields/

This way I feel a problem, it requires that the characters are very sparse in Atlas, and carefully specify a sweep radius to ensure that the distance is not affected by other characters in the area of a character.

, due to the problem of arranging and scanning radii, the pixels that surround the a character, the Red line mark area, and the nearest edge computed by its distance may be located on the G character. There will be incorrect results when rendering.

Adjusts the scan radius and the processing results after padding.

    • . The singed distance field font has a good effect when zoomed in, but it is very ugly when the font shrinks.
    • About Smoothstep.
Smoothstep (0.5-smoothbais, 0.5 + Smoothbais, Distance);

The value of Smoothbais can severely affect the final rendering quality. I finally chose the fontheight/texturesize. Smoothbais is a data that follows the texture size and is more sensitive to sampling patterns, and may be better with DDX Ddy.

Wip:

    • Render quality.
    • Glow & Shadow.

Distance font rendering

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.