chiark / gitweb /
Add row and column headings to glyph complement.
authorBen Harris <bjh21@bjh21.me.uk>
Mon, 31 Jul 2017 22:48:00 +0000 (23:48 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Mon, 31 Jul 2017 22:48:00 +0000 (23:48 +0100)
bedstead.c

index 25c3d4c4f4495659f95527c9b5a781453e680d31..e0ff03e04c79d91e52fb0d73bfbf32dfcdfc1607 100644 (file)
@@ -2143,6 +2143,7 @@ glyph_complement()
        int i, unicol = 32/nrow, col = -1, row = 0;
        int const nglyphs = sizeof(glyphs) / sizeof(glyphs[0]);
        int npages = 0;
+       bool newcol = false;
        struct glyph const *sorted[nglyphs], *g;
 
        for (i = 0; i < nglyphs; i++)
@@ -2153,12 +2154,15 @@ glyph_complement()
        printf("%%%%Title: Bedstead Glyph Complement\n");
        printf("%%%%LanguageLevel: 2\n");
        printf("/xfont /Bedstead findfont 20 scalefont def\n");
+       printf("/nfont /Bedstead findfont 10 scalefont def\n");
        printf("/lfont /Bedstead findfont 4 scalefont def\n");
        printf("/str 50 string def\n");
-       printf("/label {\n");
-       printf(" lfont setfont\n");
+       printf("/centre {\n");
        printf(" dup stringwidth pop 2 div neg 0 rmoveto show\n");
        printf("} def\n");
+       printf("/label {\n");
+       printf(" lfont setfont centre\n");
+       printf("} def\n");
        /* unicode glyphname  exemplify -- */
        printf("/exemplify {\n");
        printf(" xfont setfont dup 14 14 moveto glyphshow\n");
@@ -2170,6 +2174,15 @@ glyph_complement()
        printf(" 0 0 moveto 0 40 lineto 40 40 lineto 40 0 lineto closepath\n");
        printf("  1 setlinewidth stroke\n");
        printf("} def\n");
+       printf("/colnum {\n");
+       printf(" nfont setfont 20 42 moveto centre\n");
+       printf("} def\n");
+       printf("/rownums {\n");
+       printf(" nfont setfont 0 1 15 {\n");
+       printf("  dup -40 mul 16.5 add -10 exch moveto\n");
+       printf("  16 1 string cvrs show\n");
+       printf(" } for\n");
+       printf("} def\n");
        printf("/setdistillerparams where\n");
        printf("{ pop << /SubsetFonts false >> setdistillerparams } if\n");
        printf("%%%%EndProlog\n");
@@ -2183,12 +2196,19 @@ glyph_complement()
                        }
                        unicol = g->unicode / nrow;
                        row = 0;
+                       newcol = true;
                }
                if (col == -1) {
                        ++npages;
                        printf("%%%%Page: %d %d\n", npages, npages);
-                       printf("gsave 20 800 translate\n");
+                       printf("gsave 20 700 translate rownums\n");
                        col = 0;
+                       newcol = true;
+               }
+               if (newcol && g->unicode != -1) {
+                       printf("gsave %d 0 translate (%03X) colnum grestore\n",
+                              col * 40, unicol);
+                       newcol = false;
                }
                printf("gsave %d %d translate ",
                       (col * 40),