From: Ben Harris Date: Sat, 22 Jul 2017 20:44:12 +0000 (+0100) Subject: Beginnings of mechanisms for generating a glyph complement PDF. X-Git-Tag: bedstead-002.000~123 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=2e8a4e90c909b36383e8434ec821822ba2c0e1bc;p=bedstead.git Beginnings of mechanisms for generating a glyph complement PDF. --- diff --git a/Makefile b/Makefile index f89376d..3c8039e 100644 --- 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 diff --git a/bedstead.c b/bedstead.c index 3948a20..e14cb52 100644 --- a/bedstead.c +++ b/bedstead.c @@ -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"); +}