SDF Fonts

 from Red Blob Games
8 Jan 2026
A signed distance field for the letter “A”, using SDFs from msdfgen, tiny-sdf, and stb_truetype

 1  Source#

I picked one glyph to render for the illustrations. For some reason I couldn’t get anything but “A” to work in my stb code. Probably a buffer overflow in my C code?

I generated the msdfgen distance field with:

~/Projects/src/msdfgen/msdfgen sdf -yflip -range 3 -size 31 31 -autoframe -font fonts/FiraSans-Regular.otf $glyph -format bin -o build/illustration-sdf.bin

I generated the stb distance field with a C program, stb_export.c:

clang -D CODEPOINT=$glyph stb_export.c -o build/stb_export.exe && build/stb_export.exe

And then I rendered with compare-sdf-libraries.js.

I don’t understand why the outputs don’t match! I guess there are a lot of parameters to tweak.

Email me , or comment here: