chiark / gitweb /
Further improvements to the glyph complement PDF.
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 22 Jul 2017 23:24:38 +0000 (00:24 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 22 Jul 2017 23:24:38 +0000 (00:24 +0100)
Now has multiple pages and draws character cell.

bedstead.c

index e14cb52a27f0d05b2d9e21c60b2faec587d55052..56ed86858d2d9cf698d9f612924b61ebacb5532d 100644 (file)
@@ -2060,30 +2060,40 @@ static void
 glyph_complement()
 {
        int i;
-       char uni[10];
        int const nglyphs = sizeof(glyphs) / sizeof(glyphs[0]);
        
        printf("%%!\n");
        printf("/xfont /Bedstead findfont 20 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(" dup stringwidth pop 2 div neg 0 rmoveto show\n");
+       printf("} def\n");
        /* unicode glyphname  exemplify -- */
        printf("/exemplify {\n");
-       printf(" xfont setfont dup 10 14 moveto glyphshow\n");
-       printf(" lfont setfont 10 36 moveto str cvs show\n");
-       printf(" dup -1 eq { pop } { 10 2 moveto (U+) show 16 str cvrs\n");
-       printf("  dup length 1 3 { pop (0) show } for show } ifelse\n");
+       printf(" xfont setfont dup 14 14 moveto glyphshow\n");
+       printf(" 0.1 setlinewidth\n");
+       printf("  14 10 moveto 14 30 lineto 26 30 lineto 26 10 lineto\n");
+       printf("  closepath stroke\n");
+       printf(" 20 36 moveto str cvs label\n");
+       printf(" 20 2 moveto label\n");
        printf(" 0 0 moveto 0 40 lineto 40 40 lineto 40 0 lineto closepath\n");
        printf("  1 setlinewidth stroke\n");
        printf("} def\n");
        for (i = 0; i < nglyphs; i++) {
-               if (glyphs[i].name == NULL)
-                       sprintf(uni, "uni%04X", glyphs[i].unicode);
-               printf("gsave %d %d translate 0 0 moveto "
-                      "%d /%s exemplify grestore\n",
-                      20 + ((i/20) * 40),
-                      800 - ((i%20) * 40), glyphs[i].unicode,
-                      glyphs[i].name ? glyphs[i].name : uni);
+               printf("gsave %d %d translate 0 0 moveto ",
+                      20 + (((i%240)/20) * 40), 800 - ((i%20) * 40));
+               if (glyphs[i].unicode != -1)
+                       printf("(U+%04X)", glyphs[i].unicode);
+               else
+                       printf("()");
+               if (glyphs[i].name != NULL)
+                       printf("/%s ", glyphs[i].name);
+               else
+                       printf("/uni%04X ", glyphs[i].unicode);
+               printf("exemplify grestore\n");
+               if (i % 240 == 239) printf("showpage\n");
        }
        printf("showpage\n");
 }