Beginnings of mechanisms for generating a glyph complement PDF.

This commit is contained in:
Ben Harris 2017-07-22 21:44:12 +01:00
parent 0ad411932d
commit 2e8a4e90c9
2 changed files with 46 additions and 1 deletions

View File

@ -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

View File

@ -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");
}