From: Ben Harris Date: Mon, 17 Jul 2017 20:19:03 +0000 (+0100) Subject: Very rough code for a single-line skeleton font. X-Git-Tag: bedstead-002.000~129 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~bjharris/git?a=commitdiff_plain;h=66885289f0c7b0ada5dd843d9ede3e1c5b5a96da;p=bedstead-debian.git Very rough code for a single-line skeleton font. This uses a different dochar() function which currently emits a lot of little path fragments in roughly the right places. --- diff --git a/bedstead.c b/bedstead.c index fff2d67..45fc759 100644 --- a/bedstead.c +++ b/bedstead.c @@ -189,6 +189,7 @@ struct param const *param = ¶ms[0]; 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(); @@ -1238,6 +1239,8 @@ getpix(char const data[YSIZE], int x, int y, unsigned flags) return (data[y] >> (XSIZE - x - 1)) & 1; } +static bool plottermode = false; + int main(int argc, char **argv) { @@ -1254,7 +1257,10 @@ main(int argc, char **argv) argv++; argc--; goto next; } - if (strcmp(argv[1], "--") == 0) { + if (strcmp(argv[1], "--plotter") == 0) { + plottermode = true; + argv++; argc--; + } else if (strcmp(argv[1], "--") == 0) { argv++; argc--; break; } else if (argv[1][0] == '-') { @@ -1331,6 +1337,10 @@ main(int argc, char **argv) printf("DisplaySize: -24\n"); printf("AntiAlias: 1\n"); printf("FitToEm: 1\n"); + if (plottermode) { + printf("StrokedFont: 1\n"); + printf("StrokeWidth: 50\n"); + } printf("BeginPrivate: 2\n"); printf(" StdHW 5 [%d]\n", YPIX); printf(" StdVW 5 [%d]\n", XPIX); @@ -1374,8 +1384,12 @@ main(int argc, char **argv) if (glyphs[i].flags & MOS) domosaic(glyphs[i].data[0], (glyphs[i].data[0] & 0x20) != 0); - else - dochar(glyphs[i].data, glyphs[i].flags); + else { + if (plottermode) + dochar_plotter(glyphs[i].data, glyphs[i].flags); + else + dochar(glyphs[i].data, glyphs[i].flags); + } printf("EndChar\n"); } printf("EndChars\n"); @@ -1884,6 +1898,30 @@ dochar(char const data[YSIZE], unsigned flags) emit_path(); } +static void +dochar_plotter(char const data[YSIZE], unsigned flags) +{ + int x, y; + +#define CONNECT(dx, dy) do { \ + moveto(x * XPIX_S, (YSIZE-y-1) * YPIX_S); \ + lineto((x+dx) * XPIX_S, (YSIZE-y-1+dy) * YPIX_S); \ + } while (0) + + clearpath(); + for (x = 0; x < XSIZE; x++) { + for (y = 0; y < YSIZE; y++) { + if (GETPIX(x, y)) { + if (R) CONNECT(1, 0); + if (D) CONNECT(0, -1); + if (DR && !D && !R) CONNECT(1, -1); + if (DL && !D && !L) CONNECT(-1, -1); + } + } + } + emit_path(); +} + static void tile(int x0, int y0, int x1, int y1) {