From: Ben Harris Date: Sat, 22 Jul 2017 23:24:38 +0000 (+0100) Subject: Further improvements to the glyph complement PDF. X-Git-Tag: bedstead-002.000~122 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=02c7c14618aa78aec7aab68830325bcec9e60b44;p=bedstead.git Further improvements to the glyph complement PDF. Now has multiple pages and draws character cell. --- diff --git a/bedstead.c b/bedstead.c index e14cb52..56ed868 100644 --- a/bedstead.c +++ b/bedstead.c @@ -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"); }