chiark / gitweb /
Reverse (almost) all the paths
authorBen Harris <bjh21@bjh21.me.uk>
Sun, 17 Nov 2024 09:32:14 +0000 (09:32 +0000)
committerBen Harris <bjh21@bjh21.me.uk>
Sun, 17 Nov 2024 09:36:54 +0000 (09:36 +0000)
Type 1 fonts (and by extension CFF fonts) are required to have their
outer contours go counter-clockwise.  Bedstead has always generated
outlines clockwise and depended on FontForge to correct them.  Now
they're generated counter-clockwise as is proper, which will be fine
until I decide I want TrueType outlines instead.

This makes no difference to FreeType's rendering at either 20 ppem or
10.5 ppem

bedstead.c
editor

index 20f048c820f4100ec42cf9a1c7f003ed2486df7d..2b791775b63390ccc47ae9f5f2e7efa395f3dd77 100644 (file)
@@ -3957,14 +3957,14 @@ blackpixel(int x, int y, bool bl, bool br, bool tr, bool tl)
        x *= XPIX_S; y *= YPIX_S;
 
        if (bl) moveto(x, y);
-       else { moveto(x+XQTR_S, y); lineto(x, y+YQTR_S); }
-       if (tl) lineto(x, y+YPIX_S);
-       else { lineto(x, y+YPIX_S-YQTR_S); lineto(x+XQTR_S, y+YPIX_S); }
-       if (tr) lineto(x+XPIX_S, y+YPIX_S);
-       else { lineto(x+XPIX_S-XQTR_S, y+YPIX_S);
-              lineto(x+XPIX_S, y+YPIX_S-YQTR_S); }
+       else { moveto(x, y+YQTR_S); lineto(x+XQTR_S, y); }
        if (br) lineto(x+XPIX_S, y);
-       else { lineto(x+XPIX_S, y+YQTR_S); lineto(x+XPIX_S-XQTR_S, y); }
+       else { lineto(x+XPIX_S-XQTR_S, y); lineto(x+XPIX_S, y+YQTR_S); }
+       if (tr) lineto(x+XPIX_S, y+YPIX_S);
+       else { lineto(x+XPIX_S, y+YPIX_S-YQTR_S);
+              lineto(x+XPIX_S-XQTR_S, y+YPIX_S); }
+       if (tl) lineto(x, y+YPIX_S);
+       else { lineto(x+XQTR_S, y+YPIX_S); lineto(x, y+YPIX_S-YQTR_S); }
        closepath();
 }
 
@@ -3974,32 +3974,32 @@ whitepixel(int x, int y, bool bl, bool br, bool tr, bool tl)
        x *= XPIX_S; y *= YPIX_S;
 
        if (bl) {
-               moveto(x, y); lineto(x, y+YPIX_S-YQTR_S);
-               if (br) { lineto(x+XPIX_S/2, y+YPIX_S/2-YQTR_S);
-                         lineto(x+XQTR_S, y); }
+               moveto(x, y);
+               if (br) { lineto(x+XQTR_S, y);
+                         lineto(x+XPIX_S/2, y+YPIX_S/2-YQTR_S); }
                else lineto(x+XPIX_S-XQTR_S, y);
-               closepath();
+               lineto(x, y+YPIX_S-YQTR_S); closepath();
        }
-       if (tl) {
-               moveto(x, y+YPIX_S); lineto(x+XPIX_S-XQTR_S, y+YPIX_S);
-               if (bl) { lineto(x+XPIX_S/2-XQTR_S, y+YPIX_S/2);
-                       lineto(x, y+YPIX_S-YQTR_S); }
-               else lineto(x, y+YQTR_S);
-               closepath();
+       if (br) {
+               moveto(x+XPIX_S, y);
+               if (tr) { lineto(x+XPIX_S, y+YQTR_S);
+                         lineto(x+XPIX_S/2+XQTR_S, y+YPIX_S/2); }
+               else lineto(x+XPIX_S, y+YPIX_S-YQTR_S);
+               lineto(x+XQTR_S, y); closepath();
        }
        if (tr) {
-               moveto(x+XPIX_S, y+YPIX_S); lineto(x+XPIX_S, y+YQTR_S);
-               if (tl) { lineto(x+XPIX_S/2, y+YPIX_S/2+YQTR_S);
-                       lineto(x+XPIX_S-XQTR_S, y+YPIX_S); }
+               moveto(x+XPIX_S, y+YPIX_S);
+               if (tl) { lineto(x+XPIX_S-XQTR_S, y+YPIX_S);
+                         lineto(x+XPIX_S/2, y+YPIX_S/2+YQTR_S); }
                else lineto(x+XQTR_S, y+YPIX_S);
-               closepath();
+               lineto(x+XPIX_S, y+YQTR_S); closepath();
        }
-       if (br) {
-               moveto(x+XPIX_S, y); lineto(x+XQTR_S, y);
-               if (tr) { lineto(x+XPIX_S/2+XQTR_S, y+YPIX_S/2);
-                       lineto(x+XPIX_S, y+YQTR_S); }
-               else lineto(x+XPIX_S, y+YPIX_S-YQTR_S);
-               closepath();
+       if (tl) {
+               moveto(x, y+YPIX_S);
+               if (bl) { lineto(x, y+YPIX_S-YQTR_S);
+                         lineto(x+XPIX_S/2-XQTR_S, y+YPIX_S/2); }
+               else lineto(x, y+YQTR_S);
+               lineto(x+XPIX_S-XQTR_S, y+YPIX_S); closepath();
        }
 }
 
@@ -4212,7 +4212,7 @@ tile(int x0, int y0, int x1, int y1)
 {
        x0 *= XPIX_S; y0 *= YPIX_S;
        x1 *= XPIX_S; y1 *= YPIX_S;
-       moveto(x0, y0); lineto(x0, y1); lineto(x1, y1); lineto(x1, y0);
+       moveto(x0, y0);  lineto(x1, y0); lineto(x1, y1); lineto(x0, y1);
        closepath();
 }
 
diff --git a/editor b/editor
index 5674b577c7756bc74bdb591f34327e0f9c411a5a..88db3b8a1e40026f5fce786324fcccc9add8870c 100755 (executable)
--- a/editor
+++ b/editor
@@ -167,7 +167,7 @@ class EditorGui:
                 x1, y1 = path[i]
                 area += (y1-y0) * (x0+x1)/2
             pathswithmetadata.append([abs(area),
-                                     ('black' if area>0 else 'white'),
+                                     ('black' if area<0 else 'white'),
                                       path])
         pathswithmetadata.sort(reverse=True)