chiark / gitweb /
Lay complement out more in keeping with Unicode values.
authorBen Harris <bjh21@bjh21.me.uk>
Mon, 31 Jul 2017 22:22:48 +0000 (23:22 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Mon, 31 Jul 2017 22:22:48 +0000 (23:22 +0100)
Now each column represents one column in the Unicode code charts, with
entirely empty columns suppressed.  Unencoded characters are packed in
at the end.

bedstead.c

index 698a49cf24447bf95e19a35043fedb994cf4d8e0..25c3d4c4f4495659f95527c9b5a781453e680d31 100644 (file)
@@ -2139,8 +2139,8 @@ byunicode(const void *va, const void *vb)
 static void
 glyph_complement()
 {
-       int i;
-       int const nrow = 20, ncol=12;
+       int const nrow = 16, ncol=12;
+       int i, unicol = 32/nrow, col = -1, row = 0;
        int const nglyphs = sizeof(glyphs) / sizeof(glyphs[0]);
        int npages = 0;
        struct glyph const *sorted[nglyphs], *g;
@@ -2174,14 +2174,25 @@ glyph_complement()
        printf("{ pop << /SubsetFonts false >> setdistillerparams } if\n");
        printf("%%%%EndProlog\n");
        for (i = 0; i < nglyphs; i++) {
-               if (i % (nrow*ncol) == 0) {
+               g = sorted[i];
+               if (g->unicode / nrow != unicol ||
+                   (g->unicode == -1 && row == nrow)) {
+                       if (++col == ncol) {
+                               printf("grestore showpage\n");
+                               col = -1;
+                       }
+                       unicol = g->unicode / nrow;
+                       row = 0;
+               }
+               if (col == -1) {
                        ++npages;
                        printf("%%%%Page: %d %d\n", npages, npages);
+                       printf("gsave 20 800 translate\n");
+                       col = 0;
                }
-               g = sorted[i];
                printf("gsave %d %d translate ",
-                      20 + (((i%(nrow*ncol)/nrow) * 40)),
-                      800 - ((i%nrow) * 40));
+                      (col * 40),
+                      -((g->unicode == -1 ? row++ : g->unicode%nrow) * 40));
                if (g->unicode != -1)
                        printf("(U+%04X)", g->unicode);
                else
@@ -2191,8 +2202,6 @@ glyph_complement()
                else
                        printf("/uni%04X ", g->unicode);
                printf("exemplify grestore\n");
-               if (i % (nrow*ncol) == (nrow*ncol)-1)
-                              printf("showpage\n");
        }
        printf("showpage\n");
        printf("%%%%EOF\n");