From 0153fbc05916bf3565faddd5978dbd299a3ca66b Mon Sep 17 00:00:00 2001 From: Ben Harris Date: Mon, 31 Jul 2017 23:22:48 +0100 Subject: [PATCH] Lay complement out more in keeping with Unicode values. Now each column represents one column in the Unicode code charts, with entirely empty columns suppressed. Unencoded characters are packed in at the end. --- bedstead.c | 25 +++++++++++++++++-------- 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/bedstead.c b/bedstead.c index 698a49c..25c3d4c 100644 --- a/bedstead.c +++ b/bedstead.c @@ -2139,8 +2139,8 @@ byunicode(const void *va, const void *vb) static void glyph_complement() { - int i; - int const nrow = 20, ncol=12; + int const nrow = 16, ncol=12; + int i, unicol = 32/nrow, col = -1, row = 0; int const nglyphs = sizeof(glyphs) / sizeof(glyphs[0]); int npages = 0; struct glyph const *sorted[nglyphs], *g; @@ -2174,14 +2174,25 @@ glyph_complement() printf("{ pop << /SubsetFonts false >> setdistillerparams } if\n"); printf("%%%%EndProlog\n"); for (i = 0; i < nglyphs; i++) { - if (i % (nrow*ncol) == 0) { + g = sorted[i]; + if (g->unicode / nrow != unicol || + (g->unicode == -1 && row == nrow)) { + if (++col == ncol) { + printf("grestore showpage\n"); + col = -1; + } + unicol = g->unicode / nrow; + row = 0; + } + if (col == -1) { ++npages; printf("%%%%Page: %d %d\n", npages, npages); + printf("gsave 20 800 translate\n"); + col = 0; } - g = sorted[i]; printf("gsave %d %d translate ", - 20 + (((i%(nrow*ncol)/nrow) * 40)), - 800 - ((i%nrow) * 40)); + (col * 40), + -((g->unicode == -1 ? row++ : g->unicode%nrow) * 40)); if (g->unicode != -1) printf("(U+%04X)", g->unicode); else @@ -2191,8 +2202,6 @@ glyph_complement() else printf("/uni%04X ", g->unicode); printf("exemplify grestore\n"); - if (i % (nrow*ncol) == (nrow*ncol)-1) - printf("showpage\n"); } printf("showpage\n"); printf("%%%%EOF\n"); -- 2.30.2