# [`sdf-winding`][] [Glyph][] contour [winding number][] and [SDF][] OpenGL experiment. This repository has a singular purpose: to roughly reproduce [Figure 7][] from the [Apple TrueType Reference Manual - Chapter 2: Font Engine - Distinguishing the inside from the outside of a glyph][TrueType]: ![Figure 7][] I have not read a single word of that reference manual, proceed accordingly. To build, run `make`. You need the following dependencies on your system: - OpenGL - [GLEW][] - [GLFW][] If you're having trouble building or running this and just want to see the result, some output is saved in [`windings.ppm`](windings.ppm) and [`resolve.ppm`](resolve.ppm). If you want to compare them with [Figure 7][] you can run `make FE6.gif` (sic) to download it to the repository root (with `wget`). The code prioritizes conciseness and takes a number of shortcuts: - We don't actually generate the SDFs and winding numbers from contours, we just hard code simple circle SDFs with given winding numbers. - We don't always take care to explicitly bind OpenGL state at the point of use if we happen to know that the currently bound thing is correct or harmless, which we often do for this simple program. - We abuse the blend mode to add winding numbers, to avoid juggling multiple textures. If you're using clever geometry tricks to generate the SDFs this might be a problem. You might be able to use some overdraw reducing technique, like a depth pre-pass, to mitigate that. [`sdf-winding`]: https://git.rcrnstn.net/rcrnstn/sdf-winding [glyph]: https://en.wikipedia.org/wiki/Glyph [winding number]: https://en.wikipedia.org/wiki/Winding_number [SDF]: https://en.wikipedia.org/wiki/Signed_distance_function [Figure 7]: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/FE6.gif [TrueType]: https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#distinguishing [GLEW]: https://glew.sourceforge.net [GLFW]: https://www.glfw.org ## License Licensed under the [ISC License][] unless otherwise noted, see the [`LICENSE`][] file. [ISC License]: https://choosealicense.com/licenses/isc [`LICENSE`]: LICENSE