emit_path();
}
+static int
+byunicode(const void *va, const void *vb)
+{
+ struct glyph const *a = *(struct glyph const **)va,
+ *b = *(struct glyph const **)vb;
+
+ /* Cast to unsigned so -1 sorts last. */
+ if ((unsigned)a->unicode < (unsigned)b->unicode) return -1;
+ if ((unsigned)a->unicode > (unsigned)b->unicode) return +1;
+ return strcmp(a->name, b->name);
+}
+
static void
glyph_complement()
{
int i;
+ int const nrow = 20, ncol=12;
int const nglyphs = sizeof(glyphs) / sizeof(glyphs[0]);
-
+ struct glyph const *sorted[nglyphs], *g;
+
+ for (i = 0; i < nglyphs; i++)
+ sorted[i] = &glyphs[i];
+ qsort(sorted, nglyphs, sizeof(sorted[0]), &byunicode);
printf("%%!\n");
printf("/xfont /Bedstead findfont 20 scalefont def\n");
printf("/lfont /Bedstead findfont 4 scalefont def\n");
printf(" 1 setlinewidth stroke\n");
printf("} def\n");
for (i = 0; i < nglyphs; i++) {
+ g = sorted[i];
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);
+ 20 + (((i%(nrow*ncol)/nrow) * 40)),
+ 800 - ((i%nrow) * 40));
+ if (g->unicode != -1)
+ printf("(U+%04X)", g->unicode);
else
printf("()");
- if (glyphs[i].name != NULL)
- printf("/%s ", glyphs[i].name);
+ if (g->name != NULL)
+ printf("/%s ", g->name);
else
- printf("/uni%04X ", glyphs[i].unicode);
+ printf("/uni%04X ", g->unicode);
printf("exemplify grestore\n");
- if (i % 240 == 239) printf("showpage\n");
+ if (i % (nrow*ncol) == (nrow*ncol)-1)
+ printf("showpage\n");
}
printf("showpage\n");
}