From 530a41fab60cde1e1b77053da96d963f1eaed54b Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 31 Jul 2017 23:48:00 +0100 Subject: [PATCH] Add row and column headings to glyph complement. --- bedstead.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/bedstead.c b/bedstead.c index 25c3d4c..e0ff03e 100644 --- a/bedstead.c +++ b/bedstead.c @@ -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), -- 2.30.2