Browse code

Add support for writing to file

Robert Cranston authored on 08/03/2026 06:21:18
Showing 1 changed files
... ...
@@ -16,6 +16,12 @@ To build, run `make`. You need the following dependencies on your system:
16 16
 -   [GLEW][]
17 17
 -   [GLFW][]
18 18
 
19
+If you're having trouble building or running this and just want to see the
20
+result, some output is saved in [`windings.ppm`](windings.ppm) and
21
+[`resolve.ppm`](resolve.ppm). If you want to compare them with [Figure 7][] you
22
+can run `make FE6.gif` (sic) to download it to the repository root (with
23
+`wget`).
24
+
19 25
 The code prioritizes conciseness and takes a number of shortcuts:
20 26
 
21 27
 -   We don't actually generate the SDFs and winding numbers from contours, we
Browse code

Add implementation

Robert Cranston authored on 08/03/2026 03:36:49
Showing 1 changed files
... ...
@@ -16,6 +16,18 @@ To build, run `make`. You need the following dependencies on your system:
16 16
 -   [GLEW][]
17 17
 -   [GLFW][]
18 18
 
19
+The code prioritizes conciseness and takes a number of shortcuts:
20
+
21
+-   We don't actually generate the SDFs and winding numbers from contours, we
22
+    just hard code simple circle SDFs with given winding numbers.
23
+-   We don't always take care to explicitly bind OpenGL state at the point of
24
+    use if we happen to know that the currently bound thing is correct or
25
+    harmless, which we often do for this simple program.
26
+-   We abuse the blend mode to add winding numbers, to avoid juggling multiple
27
+    textures. If you're using clever geometry tricks to generate the SDFs this
28
+    might be a problem. You might be able to use some overdraw reducing
29
+    technique, like a depth pre-pass, to mitigate that.
30
+
19 31
 [`sdf-winding`]:  https://git.rcrnstn.net/rcrnstn/sdf-winding
20 32
 [glyph]:          https://en.wikipedia.org/wiki/Glyph
21 33
 [winding number]: https://en.wikipedia.org/wiki/Winding_number
Browse code

Add OpenGL boilerplate

Robert Cranston authored on 08/03/2026 00:46:06
Showing 1 changed files
... ...
@@ -10,12 +10,20 @@ the inside from the outside of a glyph][TrueType]:
10 10
 
11 11
 I have not read a single word of that reference manual, proceed accordingly.
12 12
 
13
+To build, run `make`. You need the following dependencies on your system:
14
+
15
+-   OpenGL
16
+-   [GLEW][]
17
+-   [GLFW][]
18
+
13 19
 [`sdf-winding`]:  https://git.rcrnstn.net/rcrnstn/sdf-winding
14 20
 [glyph]:          https://en.wikipedia.org/wiki/Glyph
15 21
 [winding number]: https://en.wikipedia.org/wiki/Winding_number
16 22
 [SDF]:            https://en.wikipedia.org/wiki/Signed_distance_function
17 23
 [Figure 7]:       https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/FE6.gif
18 24
 [TrueType]:       https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#distinguishing
25
+[GLEW]:           https://glew.sourceforge.net
26
+[GLFW]:           https://www.glfw.org
19 27
 
20 28
 ## License
21 29
 
Browse code

Expand on the purpose in the readme

Robert Cranston authored on 08/03/2026 00:14:33
Showing 1 changed files
... ...
@@ -2,10 +2,20 @@
2 2
 
3 3
 [Glyph][] contour [winding number][] and [SDF][] OpenGL experiment.
4 4
 
5
+This repository has a singular purpose: to roughly reproduce [Figure 7][] from
6
+the [Apple TrueType Reference Manual - Chapter 2: Font Engine - Distinguishing
7
+the inside from the outside of a glyph][TrueType]:
8
+
9
+![Figure 7][]
10
+
11
+I have not read a single word of that reference manual, proceed accordingly.
12
+
5 13
 [`sdf-winding`]:  https://git.rcrnstn.net/rcrnstn/sdf-winding
6 14
 [glyph]:          https://en.wikipedia.org/wiki/Glyph
7 15
 [winding number]: https://en.wikipedia.org/wiki/Winding_number
8 16
 [SDF]:            https://en.wikipedia.org/wiki/Signed_distance_function
17
+[Figure 7]:       https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/FE6.gif
18
+[TrueType]:       https://developer.apple.com/fonts/TrueType-Reference-Manual/RM02/Chap2.html#distinguishing
9 19
 
10 20
 ## License
11 21
 
Browse code

Add license

Robert Cranston authored on 08/03/2026 00:09:06
Showing 1 changed files
... ...
@@ -6,3 +6,11 @@
6 6
 [glyph]:          https://en.wikipedia.org/wiki/Glyph
7 7
 [winding number]: https://en.wikipedia.org/wiki/Winding_number
8 8
 [SDF]:            https://en.wikipedia.org/wiki/Signed_distance_function
9
+
10
+## License
11
+
12
+Licensed under the [ISC License][] unless otherwise noted, see the
13
+[`LICENSE`][] file.
14
+
15
+[ISC License]: https://choosealicense.com/licenses/isc
16
+[`LICENSE`]: LICENSE
Browse code

Add readme

Robert Cranston authored on 08/03/2026 00:09:00
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,8 @@
1
+# [`sdf-winding`][]
2
+
3
+[Glyph][] contour [winding number][] and [SDF][] OpenGL experiment.
4
+
5
+[`sdf-winding`]:  https://git.rcrnstn.net/rcrnstn/sdf-winding
6
+[glyph]:          https://en.wikipedia.org/wiki/Glyph
7
+[winding number]: https://en.wikipedia.org/wiki/Winding_number
8
+[SDF]:            https://en.wikipedia.org/wiki/Signed_distance_function