FreeType Merges New "SDF" Renderer For High Quality Text Rendering In Games, Etc

Written by Michael Larabel in Desktop on 24 December 2020 at 06:56 AM EST. 10 Comments
DESKTOP
As a Christmas gift to font enthusiasts, the FreeType font rasterization engine today merged its SDF renderer.

The new SDF code was merged today across the span of many commits. The FreeType Signed Distance Field (SDF) rasterizer generates SDF directly from outlines unlike the existing "BSDF" rasterizer in FreeType that first goes through bitmaps.

The FreeType SDF code was written by Anuj Verma and its approach based on a master's thesis written in 2015 by a Viktor Chlumsky, "Shape Decomposition for Multi-channel Distance Fields." Anuj Verma wrote the FreeType SDF code as part of Google Summer of Code 2020. Here is the GSoC 2020 summary that also goes into more details for the motivation and benefits of this code:
Distance fields looks similar to rasterized images but are very different from them. In the context of fonts, each pixel in a distance field image (or bitmap) is a shortest value from that pixel's position to the nearest edge of the outline of the corresponding glyph. Distance field is also known as distance transform and have various applications such as image processing, path-finding etc, but the main motive behind this project is to support high quality text rendering in real-time graphics applications (such as games). So, while rendering distance fields in such applications, the renderer can simply check the pixel's value and discard ones that are greater than a specific range. This makes distance fields almost infinity scalable without losing quality, this means you can use a 128x128 resolution distance transform and it will provide better quality than a 4k resolution image and will also require much less space. Moreover they can also be used to add many types of cool effects, like halos, drop shadows, bluring etc. So, the goal of this project is to add support for generating signed distance fields from font files in FreeType.

The FreeType SDF code is now in the project's Git codebase.

FreeType has already been used for text rendering in some games like Dawn of War, Company of Heroes, Ace Combat, and others. With this new SDF renderer it will be interesting to see if FreeType becomes more widely used now by games and other real-time graphics programs.
Related News
About The Author
Michael Larabel

Michael Larabel is the principal author of Phoronix.com and founded the site in 2004 with a focus on enriching the Linux hardware experience. Michael has written more than 20,000 articles covering the state of Linux hardware support, Linux performance, graphics drivers, and other topics. Michael is also the lead developer of the Phoronix Test Suite, Phoromatic, and OpenBenchmarking.org automated benchmarking software. He can be followed via Twitter, LinkedIn, or contacted via MichaelLarabel.com.

Popular News This Week