Hacker News new | ask | show | jobs
by kragen 2 days ago
Yes, and in particular the piecewise-planar approximation I'm using to the SDF, which is discontinuous, giving rise to a bit of spikiness in the level sets of the approximation. I have four attacks to try on this problem in vriffle:

1. Enjoy it. It slightly improves readability, and it's an aesthetically interesting effect that can be exaggerated if desired.

2. Sample the SDF at higher resolution. If I increase TPE_X (texels per em in X) from 24 to 96 and TPE_Y from 12 to 48, there are no longer any visible font rendering artifacts either at normal text sizes or at very large text sizes, and, despite the larger working set, the frame time with an animated procedural background and no inter-frame glyph caching increases from about 4.3 milliseconds to 4.7 milliseconds. Of course, it doesn't affect the size of the antialiased rasterized glyphs, so if I cache those between frames by pressing 'c' it's just as fast, 2.9–3.0ms. But it takes 1.1 seconds at startup to precompute the SDFs for all of the several thousand glyphs in DejaVu Serif, so I'd have to do that lazily. And there's some kind of bug in the SDF sampling which gives badly distressed rasterizations at extremely small font sizes with the higher-resolution SDF, when it should only improve the rendering.

3. Improve the SDF approximation by changing the piecewise-planar approximation, for example, rotating the gradient angle to a better angle. These spikes typically happen near sharp corners, where the gradient of the actual SDF rotates dramatically over a short distance, and a better approximation might be possible at the same resolution.

4. Use a different representation entirely.

I don't know which one will work best.