chiark / gitweb /
Beginnings of mechanisms for generating a glyph complement PDF.
authorBen Harris <bjh21@bjh21.me.uk>
Sat, 22 Jul 2017 20:44:12 +0000 (21:44 +0100)
committerBen Harris <bjh21@bjh21.me.uk>
Sat, 22 Jul 2017 20:44:12 +0000 (21:44 +0100)
Makefile
bedstead.c

index f89376d0ecedab59d626db9d7e204bd292fc40c4..3c8039ecba3bfda38386dfcd16b10b0167c0b0f0 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -50,6 +50,12 @@ bedstead-ultracondensed.sfd: bedstead
 bedstead-%-df.png: df.ps bedstead.pfa
        gs -q -dSAFER -dsize=$* -sDEVICE=png16m -o $@ bedstead.pfa $<
 
+complement.ps: bedstead
+       ./bedstead --glyph-complement > complement.ps
+
+complement.pdf: complement.ps bedstead.pfa
+       gs -q -dSAFER -sDEVICE=pdfwrite -o $@ bedstead.pfa $<
+
 .PHONY: clean
 clean:
        rm -f bedstead *.sfd *.otf *.bdf *.pfa *.png
index 3948a20d8167e3b4fe19fbb9e3b1081d68fc81db..e14cb52a27f0d05b2d9e21c60b2faec587d55052 100644 (file)
@@ -191,7 +191,8 @@ void doprologue(void);
 void dochar(char const data[YSIZE], unsigned flags);
 static void dochar_plotter(char const data[YSIZE], unsigned flags);
 static void domosaic(unsigned code, bool sep);
-static void dopanose();
+static void dopanose(void);
+static void glyph_complement(void);
 
 struct glyph {
        char data[YSIZE];
@@ -1264,6 +1265,12 @@ main(int argc, char **argv)
        int extraglyphs = 0;
        char *endptr;
 
+       if (argc == 2 && strcmp(argv[1], "--complement")) {
+               glyph_complement();
+               return 0;
+       }
+             
+       
        while (argc > 1) {
                for (i = 0; i < nparams; i++)
                        if (strcmp(argv[1], params[i].option) == 0) {
@@ -2048,3 +2055,35 @@ domosaic(unsigned code, bool sep)
        clean_path();
        emit_path();
 }
+
+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");
+       /* 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(" 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("showpage\n");
+}