refactor - ploot - simple plotting tools HTML git clone git://bitreich.org/ploot git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/ploot DIR Log DIR Files DIR Refs DIR Tags DIR README DIR LICENSE --- DIR commit a07960fb4acccb2f1cc7d5dab19e3ec4ffc89684 DIR parent a2f50e1cb8af6ef5571c142b93b8ade388e0bfa5 HTML Author: Josuah Demangeon <me@josuah.net> Date: Sat, 22 Feb 2020 16:54:07 +0100 refactor Diffstat: M .gitignore | 5 +---- M Makefile | 31 ++++++++++++++++++------------- D arg.h | 18 ------------------ A config.mk | 3 +++ D csv.c | 95 ------------------------------ D def.h | 68 ------------------------------- D drawille.c | 221 ------------------------------- D font.c | 20 -------------------- D font13.c | 1576 ------------------------------- D font7.c | 743 ------------------------------- D font8.c | 743 ------------------------------- M ploot-braille.c | 114 +++++++++++++++++++++----------- M ploot-farbfeld.c | 369 ++++++++++--------------------- M ploot-feed.c | 133 +++++++++++++++++-------------- A proto.sh | 73 +++++++++++++++++++++++++++++++ D scale.c | 139 ------------------------------ A src/csv.c | 109 +++++++++++++++++++++++++++++++ A src/csv.h | 22 ++++++++++++++++++++++ A src/drawille.c | 193 +++++++++++++++++++++++++++++++ A src/drawille.h | 28 ++++++++++++++++++++++++++++ A src/ffplot.c | 147 +++++++++++++++++++++++++++++++ A src/ffplot.h | 34 +++++++++++++++++++++++++++++++ A src/font.c | 20 ++++++++++++++++++++ A src/font.h | 22 ++++++++++++++++++++++ A src/font13.c | 1576 +++++++++++++++++++++++++++++++ A src/font7.c | 743 +++++++++++++++++++++++++++++++ A src/font8.c | 743 +++++++++++++++++++++++++++++++ A src/log.c | 99 +++++++++++++++++++++++++++++++ A src/log.h | 15 +++++++++++++++ A src/scale.c | 141 +++++++++++++++++++++++++++++++ A src/scale.h | 18 ++++++++++++++++++ A src/tool.c | 103 +++++++++++++++++++++++++++++++ A src/tool.h | 20 ++++++++++++++++++++ D util.c | 103 ------------------------------- 34 files changed, 4388 insertions(+), 4099 deletions(-) --- DIR diff --git a/.gitignore b/.gitignore @@ -1,5 +1,2 @@ *.o -*.core -ploot-braille -ploot-farbfeld -ploot-feed +/ploot-*[!.]? DIR diff --git a/Makefile b/Makefile @@ -1,22 +1,27 @@ -CFLAGS = -Wall -Wextra -std=c99 -pedantic -fPIC -LFLAGS = -static -BIN = ploot-farbfeld ploot-feed ploot-braille -LIB = -lm -MANDIR = $(PREFIX)/share/man +include config.mk -SRC = csv.c drawille.c font.c font7.c font8.c font13.c util.c scale.c +src = src/csv.c src/drawille.c src/ffplot.c src/font.c src/font13.c \ + src/font7.c src/font8.c src/log.c src/scale.c src/tool.c +inc = src/csv.h src/drawille.h src/ffplot.h src/font.h src/log.h \ + src/scale.h src/tool.h +bin = ploot-farbfeld ploot-feed ploot-braille +obj = ${src:.c=.o} +lib = -lm -all: $(BIN) +all: $(bin) -${SRC:.c=.o} ${BIN:=.o}: arg.h def.h Makefile -${BIN}: ${SRC:.c=.o} ${BIN:=.o} - ${CC} $(LFLAGS) -o $@ $@.o ${SRC:.c=.o} $(LIB) +.c.o: + ${CC} -c ${CFLAGS} -o $@ $< -install: $(BIN) +${obj} ${bin:=.o}: ${inc} Makefile +${bin}: ${obj} ${bin:=.o} + ${CC} $(LFLAGS) -o $@ $@.o ${obj} $(lib) + +install: $(bin) mkdir -p ${PREFIX}/bin $(MANDIR)/man1 $(MANDIR)/man7 - cp $(BIN) ${PREFIX}/bin + cp $(bin) ${PREFIX}/bin cp ploot-farbfeld.1 ploot-feed.1 $(MANDIR)/man1 cp ploot-csv.7 $(MANDIR)/man7 clean: - rm -f *.o + rm -f *.o */*.o ${bin} DIR diff --git a/arg.h b/arg.h @@ -1,18 +0,0 @@ -#ifndef ARG_H -#define ARG_H - -#define ARG_SWITCH(argc, argv) \ - arg0 = *argv; \ - while (++argv && --argc && **argv == '-' && (*argv)[1]) \ - if ((*argv)[1] == '-' && (*argv)[2] == '\0') { \ - ++argv; break; \ - } else for (int stop = 0; !stop && *++*argv != '\0' ;) \ - switch (**argv) - -#define ARG ((*++*argv != '\0' || *++argv != NULL) \ - ? ((stop = 1), argc--, *argv) \ - : (usage(), NULL)) - -extern char const *arg0; - -#endif DIR diff --git a/config.mk b/config.mk @@ -0,0 +1,3 @@ +CFLAGS = -Wall -Wextra -std=c99 -pedantic -fPIC -I"src" -D_POSIX_C_SOURCE=200811L +LFLAGS = -static +MANDIR = $(PREFIX)/share/man DIR diff --git a/csv.c b/csv.c @@ -1,95 +0,0 @@ -/* - * Read CSV data onto a set of (struct vlist). - */ - -#include <string.h> -#include <time.h> -#include <stdlib.h> - -#include "def.h" - -static void -csv_addtime(struct vlist *vl, time_t epoch) -{ - if ((vl->t = realloc(vl->t, (vl->n + 1) * sizeof(*vl->t))) == NULL) - err(1, "reallocating values buffer"); - vl->t[vl->n] = epoch; -} - -static void -csv_addval(struct vlist *vl, double field) -{ - if ((vl->v = realloc(vl->v, (vl->n + 1) * sizeof(*vl->v))) == NULL) - err(1, "reallocating values buffer"); - vl->v[vl->n] = field; -} - -/* - * Add to each column the value on the current row. - */ -void -csv_addrow(struct vlist *vl, size_t ncol, char *line) -{ - char *field; - - if ((field = strsep(&line, ",")) == NULL) - err(1, "missing epoch at row %zu", vl->n); - - csv_addtime(vl, eatol(field)); - for (; (field = strsep(&line, ",")) != NULL; ncol--, vl->n++, vl++) { - if (ncol == 0) - err(1, "too many fields at line %zu", vl->n); - csv_addval(vl, eatof(field)); - } - if (ncol > 0) - err(1, "too few fields at line %zu", vl->n); -} - -/* - * < *ncol > - * epoch,label1,label2,label3 - */ -void -csv_labels(FILE *fp, char *buf, struct vlist **vl, size_t *ncol) -{ - char *field; - size_t sz; - - if (esfgets(buf, LINE_MAX, fp) == NULL) - err(1, "missing label line"); - - if (strcmp(strsep(&buf, ","), "epoch") != 0) - err(1, "first label must be \"epoch\""); - - *vl = NULL; - for (*ncol = 0; (field = strsep(&buf, ",")) != NULL; ++*ncol) { - sz = (*ncol + 1) * sizeof **vl; - if ((*vl = realloc(*vl, sz)) == NULL) - err(1, "realloc"); - (*vl)[*ncol].label = field; - } -} - -/* - * < ncol > - * epoch,a1,b1,c1 ^ - * epoch,a2,b2,c2 vl->n - * epoch,a3,b3,c3 v - */ -void -csv_values(FILE *fp, struct vlist *vl, size_t ncol) -{ - char line[LINE_MAX]; - time_t *tbuf; - - while (esfgets(line, sizeof(line), fp) != NULL) - csv_addrow(vl, ncol, line); - if (vl->n == 0) - err(1, "no value could be read"); - if (vl->n == 1) - err(1, "only one value could be read"); - - /* The same time buffer can be used for all. */ - for (tbuf = vl->t; ncol > 0; ncol--, vl++) - vl->t = tbuf; -} DIR diff --git a/def.h b/def.h @@ -1,68 +0,0 @@ -#include <limits.h> -#include <stdarg.h> -#include <stdint.h> -#include <stdio.h> - -#define LEN(x) (sizeof(x) / sizeof(*x)) -#define MAX(x, y) ((x) > (y) ? (x) : (y)) -#define MIN(x, y) ((x) < (y) ? (x) : (y)) -#define ABS(x) ((x) < 0 ? -(x) : (x)) - -/* - * Canvas to draw on with braille characters. - */ -struct drawille { - int col, row; /* number of dots in total */ - uint8_t buf[]; /* buffer of size (col * row) */ -}; - -/* - * Bitmapped font saved as a '_' and 'X' pattern in a C source file. - */ -struct font { - int height; /* The width is variable. */ - char *glyph[128]; /* 0: end, 1: off, 2: on. */ -}; - -/* - * List of values and timestamps. Both have their dedicated buffer - * so that the timestamp buffer can be shared across vlist objects. - */ -struct vlist { - time_t *t; /* array of timestamps */ - double *v; /* array of values */ - size_t n; /* number of values */ - char *label; /* for the legend */ -}; - -/**/ -void csv_addrow (struct vlist *, size_t, char *); -void csv_labels (FILE *, char *, struct vlist **, size_t *); -void csv_values (FILE *, struct vlist *, size_t); -size_t drawille_put_row (struct drawille *, FILE *, int); -void drawille_dot (struct drawille *, int, int); -struct drawille *drawille_new (int, int); -void drawille_line (struct drawille *, int, int, int, int); -void drawille_histogram_dot (struct drawille *, int, int, int); -void drawille_histogram_line (struct drawille *, int, int, int, int, int); -int drawille_histogram (struct vlist *, struct drawille *, time_t, time_t, double, double); -char * drawille_text (struct drawille *, int, int, struct font *, char *); -size_t font_width (struct font *, int); -size_t font_strlen (struct font *, char *); -struct font font13; -struct font font7; -struct font font8; -char const *arg0; -int scale_ypos (double, double, double, int); -int scale_xpos (time_t, time_t, time_t, int); -void scale_vminmax (double *, double *, int); -void scale (struct vlist *, int, time_t *, time_t *, time_t *, double *, double *, double *); -size_t strlcpy (char *, const char *, size_t); -void put3utf (long); -char * strsep (char **, const char *); -void estriplf (char *); -double eatof (char *); -long eatol (char *); -int humanize (char *, double); - -#endif DIR diff --git a/drawille.c b/drawille.c @@ -1,221 +0,0 @@ -/* - * Terminal-based plotting using drawille character, aka drawille. - */ - -#include <stdint.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <math.h> - -#include "def.h" - -/* parameters used to draw a line */ -struct line { - int x0, y0, x1, y1; /* point of the line */ - int dx, dy, sx, sy, err; /* parameters for the algorythm */ -}; - -/* - * Turn on the bit at position (row, col) of a single cell. The - * pattern is not linear (1-4-2-5-3-6-7-8), because it matches the - * drawille pattern. - */ -static void -drawille_cell_dot(uint8_t *cell, int row, int col) -{ - uint8_t flags[4][2] = { - { 0x01, 0x08 }, - { 0x02, 0x10 }, - { 0x04, 0x20 }, - { 0x40, 0x80 }, - }; - - *cell |= flags[row][col]; -} - -static size_t -drawille_cell_utf(uint8_t cell, char *utf) -{ - long rune; - - rune = 10240 + cell; - utf[0] = (char)(0xe0 | (0x0f & (rune >> 12))); /* 1110xxxx */ - utf[1] = (char)(0x80 | (0x3f & (rune >> 6))); /* 10xxxxxx */ - utf[2] = (char)(0x80 | (0x3f & (rune))); /* 10xxxxxx */ - return 3; -} - -static uint8_t -drawille_get(struct drawille *drw, int row, int col) -{ - return drw->buf[row * drw->col + col]; -} - -size_t -drawille_put_row(struct drawille *drw, FILE *fp, int row) -{ - char txt[] = "xxx"; - size_t n; - - n = 0; - for (int col = 0; col < drw->col; col++) { - drawille_cell_utf(drawille_get(drw, row, col), txt); - n += fputs(txt, fp); - } - return n; -} - -/* - * Coordinates are passed as (x, y), but the canvas stores bits as - * (row, col). Conversion is made by this function. - */ -void -drawille_dot(struct drawille *drw, int x, int y) -{ - if (x < 0 || x / 2 >= drw->col || y < 0 || y / 4 >= drw->row) - return; - drawille_cell_dot(drw->buf + (drw->row - y / 4 - 1) * drw->col + (x / 2), - 3 - y % 4, - x % 2); -} - -struct drawille * -drawille_new(int row, int col) -{ - struct drawille *drw; - - if ((drw = calloc(sizeof(struct drawille) + row * col, 1)) == NULL) - return NULL; - drw->row = row; - drw->col = col; - return drw; -} - -static void -drawille_line_init(struct line *l, int x0, int y0, int x1, int y1) -{ - l->x0 = x0; - l->y0 = y0; - l->x1 = x1; - l->y1 = y1; - l->sx = x0 < x1 ? 1 : -1; - l->sy = y0 < y1 ? 1 : -1; - l->dx = abs(x1 - x0); - l->dy = abs(y1 - y0); - l->err = (l->dx > l->dy ? l->dx : -l->dy) / 2; -} - -static int -drawille_line_next(struct line *l) -{ - int e; - - if (l->x0 == l->x1 && l->y0 == l->y1) - return 0; - - e = l->err; - if (e > -l->dx) { - l->x0 += l->sx; - l->err -= l->dy; - } - if (e < l->dy) { - l->y0 += l->sy; - l->err += l->dx; - } - return 1; -} - -void -drawille_line(struct drawille *drw, int x0, int y0, int x1, int y1) -{ - struct line l; - - drawille_line_init(&l, x0, y0, x1, y1); - do { - drawille_dot(drw, l.x0, l.y0); - } while (drawille_line_next(&l)); -} - -void -drawille_histogram_dot(struct drawille *drw, int x, int y, int zero) -{ - int sign; - - sign = (y > zero) ? (+1) : (-1); - for (; y != zero + sign; y -= sign) - drawille_dot(drw, x, y); -} - -void -drawille_histogram_line(struct drawille *drw, int x0, int y0, int x1, int y1, int zero) -{ - struct line l; - - drawille_line_init(&l, x0, y0, x1, y1); - do { - drawille_histogram_dot(drw, l.x0, l.y0, zero); - } while (drawille_line_next(&l)); -} - -/* - * Plot the body as an histogram interpolating the gaps and include - * a vertical and horizontal axis. - */ -int -drawille_histogram(struct vlist *vl, struct drawille *drw, - time_t tmin, time_t tmax, double vmin, double vmax) -{ - int x, xprev, y, yprev, zero; - double *v; - time_t *t; - size_t n; - - zero = scale_ypos(0, vmin, vmax, drw->row*4); - v = vl->v; - t = vl->t; - n = vl->n; - for (; n > 0; n--, t++, v++) { - if (isnan(*v)) /* XXX: better handling? */ - continue; - y = scale_ypos(*v, vmin, vmax, drw->row * 4); - x = scale_xpos(*t, tmin, tmax, drw->col * 2); - if (n < vl->n) - drawille_histogram_line(drw, xprev, yprev, x, y, zero); - xprev = x; - yprev = y; - } - return 0; -} - -static int -drawille_text_glyph(struct drawille *drw, int x, int y, struct font *font, char c) -{ - int width; - char *glyph; - - if ((unsigned)c > 127) - glyph = font->glyph[0]; - else - glyph = font->glyph[(unsigned)c]; - - width = strlen(glyph) / font->height; - - for (int ix = 0; ix < width; ix++) - for (int iy = 0; iy < font->height; iy++) { - if (glyph[ix + (font->height - 1) * width - iy * width] == 3) - drawille_dot(drw, x + ix, y + iy); - } - - return width; -} - -char * -drawille_text(struct drawille *drw, int x, int y, struct font *font, char *s) -{ - if (drw->row*4 < font->height) - return NULL; - for (; *s != '\0' && x < drw->col/2; s++, x++) - x += drawille_text_glyph(drw, x, y, font, *s); - return s; -} DIR diff --git a/font.c b/font.c @@ -1,20 +0,0 @@ -#include <string.h> - -#include "def.h" - -size_t -font_width(struct font *ft, int c) -{ - return strlen(ft->glyph[c]) / ft->height; -} - -size_t -font_strlen(struct font *ft, char *s) -{ - size_t len; - - len = 0; - for (; *s != '\0'; s++) - len += font_width(ft, *s); - return len; -} DIR diff --git a/font13.c b/font13.c @@ -1,1576 +0,0 @@ -#include "def.h" - -#define C(x) static char glyph_##x[] -#define _ 2 -#define X 3 - -C(error) = { - _,_,_,_,_, - X,X,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,X, - _,_,_,_,_, -0}; - -C(space) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(bang) = { - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(double) = { - _,_,_,_,_, - _,X,_,X,_, - _,X,_,X,_, - _,X,_,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(hash) = { - _,_,_,_,_, - _,X,_,X,_, - _,X,_,X,_, - X,X,X,X,X, - _,X,_,X,_, - _,X,_,X,_, - _,X,_,X,_, - X,X,X,X,X, - _,X,_,X,_, - _,X,_,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(dollar) = { - _,_,X,_,_, - _,X,X,X,_, - X,_,X,_,X, - X,_,X,_,_, - X,_,X,_,_, - _,X,X,X,_, - _,_,X,_,X, - _,_,X,_,X, - X,_,X,_,X, - _,X,X,X,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(percent) = { - _,_,_,_,_, - X,X,_,_,X, - X,X,_,_,X, - _,_,_,X,_, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - _,X,_,_,_, - X,_,_,X,X, - X,_,_,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(amp) = { - _,_,_,_,_, - _,_,X,_,_, - _,X,_,X,_, - _,X,_,X,_, - _,_,X,_,_, - _,X,X,_,X, - X,_,_,X,_, - X,_,_,X,_, - X,_,_,X,_, - _,X,X,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(single) = { - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(l_round) = { - _,_,_,_,_, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,_,X,_,_, - _,_,_,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(r_round) = { - _,_,_,_,_, - _,X,_,_,_, - _,_,X,_,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(asterisk) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - X,_,X,_,X, - _,X,X,X,_, - _,_,X,_,_, - _,X,X,X,_, - X,_,X,_,X, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(plus) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - X,X,X,X,X, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(coma) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,_,_,_, - _,_,_,_,_, -0}; - -C(minus) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(dot) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(slash) = { - _,_,_,_,_, - _,_,_,_,X, - _,_,_,_,X, - _,_,_,X,_, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - _,X,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(0) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,X,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(1) = { - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(2) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,X, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - X,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(3) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - _,_,_,_,X, - _,_,_,_,X, - _,X,X,X,_, - _,_,_,_,X, - _,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(4) = { - _,_,_,_,_, - _,_,_,_,X, - _,_,_,X,X, - _,_,X,_,X, - _,X,_,_,X, - X,_,_,_,X, - X,X,X,X,X, - _,_,_,_,X, - _,_,_,_,X, - _,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(5) = { - _,_,_,_,_, - X,X,X,X,X, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,_, - _,_,_,_,X, - _,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(6) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(7) = { - _,_,_,_,_, - X,X,X,X,X, - _,_,_,_,X, - _,_,_,_,X, - _,_,_,X,_, - _,_,_,X,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(8) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(9) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,X, - _,_,_,_,X, - _,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(column) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(semicolumn) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,_,_,_, - _,_,_,_,_, -0}; - -C(l_angle) = { - _,_,_,_,_, - _,_,_,_,X, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - X,_,_,_,_, - _,X,_,_,_, - _,_,X,_,_, - _,_,_,X,_, - _,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(equal) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(r_angle) = { - _,_,_,_,_, - X,_,_,_,_, - _,X,_,_,_, - _,_,X,_,_, - _,_,_,X,_, - _,_,_,_,X, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - X,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(question) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,X, - _,_,_,X,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(at) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,X,X,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,X,X, - X,_,_,_,_, - _,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(A) = { - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,_,X,_, - _,X,_,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(B) = { - _,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(C) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(D) = { - _,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(E) = { - _,_,_,_,_, - X,X,X,X,X, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(F) = { - _,_,_,_,_, - X,X,X,X,X, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(G) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(H) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(I) = { - _,_,_,_,_, - _,X,X,X,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(J) = { - _,_,_,_,_, - _,X,X,X,X, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - X,_,_,X,_, - _,X,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(K) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,X,_, - X,_,X,_,_, - X,X,_,_,_, - X,_,X,_,_, - X,_,_,X,_, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(L) = { - _,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(M) = { - _,_,_,_,_, - X,_,_,_,X, - X,X,_,X,X, - X,X,_,X,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(N) = { - _,_,_,_,_, - X,_,_,_,X, - X,X,_,_,X, - X,X,_,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,_,X,X, - X,_,_,X,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(O) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(P) = { - _,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(Q) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,X,_,X, - _,X,X,X,_, - _,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(R) = { - _,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,_, - X,_,X,_,_, - X,_,_,X,_, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(S) = { - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,_, - X,_,_,_,_, - _,X,X,X,_, - _,_,_,_,X, - _,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(T) = { - _,_,_,_,_, - X,X,X,X,X, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(U) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(V) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,_,X,_, - _,X,_,X,_, - _,X,_,X,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(W) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,X,_,X,X, - X,X,_,X,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(X) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - _,X,_,X,_, - _,X,_,X,_, - _,_,X,_,_, - _,X,_,X,_, - _,X,_,X,_, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(Y) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - _,X,_,X,_, - _,X,_,X,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(Z) = { - _,_,_,_,_, - X,X,X,X,X, - _,_,_,_,X, - _,_,_,X,_, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - _,X,_,_,_, - X,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(l_square) = { - _,_,_,_,_, - _,X,X,X,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(backsl) = { - _,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,_,X,_,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,_,X, - _,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(r_square) = { - _,_,_,_,_, - _,X,X,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(hat) = { - _,_,_,_,_, - _,_,X,_,_, - _,X,_,X,_, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(underscore) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -X ,X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(backtilt) = { - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(a) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,X,X,_, - _,_,_,_,X, - _,_,_,_,X, - _,X,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(b) = { - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(c) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(d) = { - _,_,_,_,X, - _,_,_,_,X, - _,_,_,_,X, - _,X,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(e) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,X, - X,_,_,_,_, - X,_,_,_,_, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(f) = { - _,_,X,X,X, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - X,X,X,X,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(g) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,X, - _,_,_,_,X, - _,_,_,_,X, - X,X,X,X,_, -0}; - -C(h) = { - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(i) = { - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,X,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(j) = { - _,_,_,X,_, - _,_,_,X,_, - _,_,_,_,_, - _,_,X,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - X,_,_,X,_, - _,X,X,_,_, -0}; - -C(k) = { - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,X, - X,_,_,X,_, - X,_,X,_,_, - X,X,_,_,_, - X,_,X,_,_, - X,_,_,X,_, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(l) = { - _,X,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(m) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,_, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(n) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(o) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(p) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,X,X,X,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, -0}; - -C(q) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,X,X,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,X, - _,_,_,_,X, - _,_,_,_,X, - _,_,_,_,X, -0}; - -C(r) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,_,X,X,X, - X,X,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - X,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(s) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,X,X,X, - X,_,_,_,_, - X,_,_,_,_, - _,X,X,X,_, - _,_,_,_,X, - _,_,_,_,X, - X,X,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(t) = { - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - X,X,X,X,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,_,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(u) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(v) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,_,X,_, - _,X,_,X,_, - _,X,_,X,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(w) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,X,_,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(x) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - _,X,_,X,_, - _,_,X,_,_, - _,X,_,X,_, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(y) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,X,X,X,X, - _,_,_,_,X, - _,_,_,_,X, - X,X,X,X,_, -0}; - -C(z) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,X, - _,_,_,_,X, - _,_,_,X,_, - _,_,X,_,_, - _,X,_,_,_, - X,_,_,_,_, - X,X,X,X,X, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(l_curly) = { - _,_,_,_,_, - _,_,X,X,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - X,_,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,X,_,_,_, - _,_,X,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(pipe) = { - _,_,_,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(r_curly) = { - _,_,_,_,_, - _,X,X,_,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,_,X, - _,_,_,X,_, - _,_,_,X,_, - _,_,_,X,_, - _,X,X,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(tilde) = { - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,X,_,_,X, - X,_,X,_,X, - X,_,_,X,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -struct font font13 = { 13, { - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_space, glyph_bang, glyph_double, glyph_hash, - glyph_dollar, glyph_percent, glyph_amp, glyph_single, - glyph_l_round, glyph_r_round, glyph_asterisk, glyph_plus, - glyph_coma, glyph_minus, glyph_dot, glyph_slash, - glyph_0, glyph_1, glyph_2, glyph_3, - glyph_4, glyph_5, glyph_6, glyph_7, - glyph_8, glyph_9, glyph_column, glyph_semicolumn, - glyph_l_angle, glyph_equal, glyph_r_angle, glyph_question, - glyph_at, glyph_A, glyph_B, glyph_C, - glyph_D, glyph_E, glyph_F, glyph_G, - glyph_H, glyph_I, glyph_J, glyph_K, - glyph_L, glyph_M, glyph_N, glyph_O, - glyph_P, glyph_Q, glyph_R, glyph_S, - glyph_T, glyph_U, glyph_V, glyph_W, - glyph_X, glyph_Y, glyph_Z, glyph_l_square, - glyph_backsl, glyph_r_square, glyph_hat, glyph_underscore, - glyph_backtilt, glyph_a, glyph_b, glyph_c, - glyph_d, glyph_e, glyph_f, glyph_g, - glyph_h, glyph_i, glyph_j, glyph_k, - glyph_l, glyph_m, glyph_n, glyph_o, - glyph_p, glyph_q, glyph_r, glyph_s, - glyph_t, glyph_u, glyph_v, glyph_w, - glyph_x, glyph_y, glyph_z, glyph_l_curly, - glyph_pipe, glyph_r_curly, glyph_tilde, glyph_error -} }; DIR diff --git a/font7.c b/font7.c @@ -1,743 +0,0 @@ -#include "def.h" - -#define C(x) static char glyph_##x[] -#define _ 2 -#define X 3 - -C(err) = { - X,X,X,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,X,X,X, -0}; - -C(A) = { - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - X,X,X,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(B) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,X,X,_, - X,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(C) = { - _,_,_,_, - _,X,X,X, - X,_,_,_, - X,_,_,_, - X,_,_,_, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(D) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(E) = { - _,_,_,_, - X,X,X,X, - X,_,_,_, - X,X,X,_, - X,_,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(F) = { - _,_,_,_, - X,X,X,X, - X,_,_,_, - X,X,X,_, - X,_,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(G) = { - _,_,_,_, - _,X,X,X, - X,_,_,_, - X,_,X,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(H) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,X,X,X, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(I) = { - _,_,_, - X,X,X, - _,X,_, - _,X,_, - _,X,_, - X,X,X, - _,_,_, - _,_,_, -0}; - -C(J) = { - _,_,_,_, - _,X,X,X, - _,_,X,_, - _,_,X,_, - _,_,X,_, - X,X,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(K) = { - _,_,_,_, - X,_,_,X, - X,_,X,_, - X,X,_,_, - X,_,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(L) = { - _,_,_,_, - X,_,_,_, - X,_,_,_, - X,_,_,_, - X,_,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(M) = { - _,_,_,_,_, - X,_,_,_,X, - X,X,_,X,X, - X,_,X,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(N) = { - _,_,_,_, - X,_,_,X, - X,X,_,X, - X,X,X,X, - X,_,X,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(O) = { - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(P) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,X,X,_, - X,_,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(Q) = { - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,X,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(R) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,X,X,_, - X,_,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(S) = { - _,_,_,_, - _,X,X,X, - X,_,_,_, - _,X,X,_, - _,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(T) = { - _,_,_,_, - X,X,X,X, - _,X,X,_, - _,X,X,_, - _,X,X,_, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(U) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(V) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,X,_, - X,_,X,_, - X,X,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(W) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,X,_,X,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(X) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(Y) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,X,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(Z) = { - _,_,_,_, - X,X,X,X, - _,_,_,X, - _,X,X,_, - X,_,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(a) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(b) = { - X,_,_,_, - X,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(c) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,_, - X,_,_,_, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(d) = { - _,_,_,X, - _,_,_,X, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(e) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,X,X,X, - X,_,_,_, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(f) = { - _,X,X, - X,_,_, - X,_,_, - X,X,_, - X,_,_, - X,_,_, - _,_,_, - _,_,_, -0}; - -C(g) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,X,X,_, -0}; - -C(h) = { - X,_,_,_, - X,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(i) = { - _,X,_, - _,_,_, - X,X,_, - _,X,_, - _,X,_, - _,X,X, - _,_,_, - _,_,_, -0}; - -C(j) = { - _,X,_, - _,_,_, - X,X,_, - _,X,_, - _,X,_, - _,X,_, - _,X,_, - X,_,_, -0}; - -C(k) = { - X,_,_,_, - X,_,_,_, - X,_,_,X, - X,_,X,_, - X,X,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(l) = { - X,X,_, - _,X,_, - _,X,_, - _,X,_, - _,X,_, - X,X,X, - _,_,_, - _,_,_, -0}; - -C(m) = { - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,_, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(n) = { - _,_,_,_, - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(o) = { - _,_,_,_, - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(p) = { - _,_,_,_, - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,X,X,_, - X,_,_,_, - X,_,_,_, -0}; - -C(q) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,_,_,X, -0}; - -C(r) = { - _,_,_,_, - _,_,_,_, - X,_,X,X, - X,X,_,_, - X,_,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(s) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,X,_,_, - _,_,X,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(t) = { - X,_,_, - X,_,_, - X,X,X, - X,_,_, - X,_,_, - _,X,X, - _,_,_, - _,_,_, -0}; - -C(u) = { - _,_,_,_, - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(v) = { - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - _,X,_,X,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(w) = { - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,X,_,X,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(x) = { - _,_,_,_, - _,_,_,_, - X,_,_,X, - _,X,X,_, - _,X,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(y) = { - _,_,_,_, - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,X,X,_, -0}; - -C(z) = { - _,_,_,_, - _,_,_,_, - X,X,X,X, - _,_,X,_, - _,X,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(0) = { - _,X,X,_, - X,_,_,X, - X,_,X,X, - X,X,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(1) = { - _,X,_, - X,X,_, - _,X,_, - _,X,_, - _,X,_, - X,X,X, - _,_,_, - _,_,_, -0}; - -C(2) = { - _,X,X,_, - X,_,_,X, - _,_,_,X, - _,_,X,_, - _,X,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(3) = { - X,X,X,_, - _,_,_,X, - _,X,X,X, - _,_,_,X, - _,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(4) = { - _,_,X,X, - _,X,_,X, - X,_,_,X, - X,X,X,X, - _,_,_,X, - _,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(5) = { - X,X,X,X, - X,_,_,_, - X,X,X,_, - _,_,_,X, - _,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(6) = { - _,X,X,_, - X,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(7) = { - X,X,X,X, - _,_,_,X, - _,_,X,_, - _,_,X,_, - _,X,_,_, - _,X,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(8) = { - _,X,X,_, - X,_,_,X, - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(9) = { - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(space) = { - _,_,_, - _,_,_, - _,_,_, - _,_,_, - _,_,_, - _,_,_, - _,_,_, -0}; - -struct font font7 = { 8, { - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_space, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_0, glyph_1, glyph_2, glyph_3, - glyph_4, glyph_5, glyph_6, glyph_7, - glyph_8, glyph_9, glyph_err, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_A, glyph_B, glyph_C, - glyph_D, glyph_E, glyph_F, glyph_G, - glyph_H, glyph_I, glyph_J, glyph_K, - glyph_L, glyph_M, glyph_N, glyph_O, - glyph_P, glyph_Q, glyph_R, glyph_S, - glyph_T, glyph_U, glyph_V, glyph_W, - glyph_X, glyph_Y, glyph_Z, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err, - glyph_err, glyph_a, glyph_b, glyph_c, - glyph_d, glyph_e, glyph_f, glyph_g, - glyph_h, glyph_i, glyph_j, glyph_k, - glyph_l, glyph_m, glyph_n, glyph_o, - glyph_p, glyph_q, glyph_r, glyph_s, - glyph_t, glyph_u, glyph_v, glyph_w, - glyph_x, glyph_y, glyph_z, glyph_err, - glyph_err, glyph_err, glyph_err, glyph_err -} }; DIR diff --git a/font8.c b/font8.c @@ -1,743 +0,0 @@ -#include "def.h" - -#define C(x) static char glyph_##x[] -#define _ 2 -#define X 3 - -C(error) = { - X,X,X,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,X,X,X, -0}; - -C(A) = { - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - X,X,X,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(B) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,X,X,_, - X,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(C) = { - _,_,_,_, - _,X,X,X, - X,_,_,_, - X,_,_,_, - X,_,_,_, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(D) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(E) = { - _,_,_,_, - X,X,X,X, - X,_,_,_, - X,X,X,_, - X,_,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(F) = { - _,_,_,_, - X,X,X,X, - X,_,_,_, - X,X,X,_, - X,_,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(G) = { - _,_,_,_, - _,X,X,X, - X,_,_,_, - X,_,X,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(H) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,X,X,X, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(I) = { - _,_,_, - X,X,X, - _,X,_, - _,X,_, - _,X,_, - X,X,X, - _,_,_, - _,_,_, -0}; - -C(J) = { - _,_,_,_, - _,X,X,X, - _,_,X,_, - _,_,X,_, - _,_,X,_, - X,X,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(K) = { - _,_,_,_, - X,_,_,X, - X,_,X,_, - X,X,_,_, - X,_,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(L) = { - _,_,_,_, - X,_,_,_, - X,_,_,_, - X,_,_,_, - X,_,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(M) = { - _,_,_,_,_, - X,_,_,_,X, - X,X,_,X,X, - X,_,X,_,X, - X,_,_,_,X, - X,_,_,_,X, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(N) = { - _,_,_,_, - X,_,_,X, - X,X,_,X, - X,X,X,X, - X,_,X,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(O) = { - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(P) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,X,X,_, - X,_,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(Q) = { - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,X,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(R) = { - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,X,X,_, - X,_,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(S) = { - _,_,_,_, - _,X,X,X, - X,_,_,_, - _,X,X,_, - _,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(T) = { - _,_,_,_, - X,X,X,X, - _,X,X,_, - _,X,X,_, - _,X,X,_, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(U) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(V) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,X,_, - X,_,X,_, - X,X,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(W) = { - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,X,_,X,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(X) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(Y) = { - _,_,_,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,X,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(Z) = { - _,_,_,_, - X,X,X,X, - _,_,_,X, - _,X,X,_, - X,_,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(a) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(b) = { - X,_,_,_, - X,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(c) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,_, - X,_,_,_, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(d) = { - _,_,_,X, - _,_,_,X, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(e) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,X,X,X, - X,_,_,_, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(f) = { - _,X,X, - X,_,_, - X,_,_, - X,X,_, - X,_,_, - X,_,_, - _,_,_, - _,_,_, -0}; - -C(g) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,X,X,_, -0}; - -C(h) = { - X,_,_,_, - X,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(i) = { - _,X,_, - _,_,_, - X,X,_, - _,X,_, - _,X,_, - _,X,X, - _,_,_, - _,_,_, -0}; - -C(j) = { - _,X,_, - _,_,_, - X,X,_, - _,X,_, - _,X,_, - _,X,_, - _,X,_, - X,_,_, -0}; - -C(k) = { - X,_,_,_, - X,_,_,_, - X,_,_,X, - X,_,X,_, - X,X,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(l) = { - X,X,_, - _,X,_, - _,X,_, - _,X,_, - _,X,_, - X,X,X, - _,_,_, - _,_,_, -0}; - -C(m) = { - _,_,_,_,_, - _,_,_,_,_, - X,X,X,X,_, - X,_,X,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(n) = { - _,_,_,_, - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(o) = { - _,_,_,_, - _,_,_,_, - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(p) = { - _,_,_,_, - _,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - X,X,X,_, - X,_,_,_, - X,_,_,_, -0}; - -C(q) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,_,_,X, -0}; - -C(r) = { - _,_,_,_, - _,_,_,_, - X,_,X,X, - X,X,_,_, - X,_,_,_, - X,_,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(s) = { - _,_,_,_, - _,_,_,_, - _,X,X,X, - X,X,_,_, - _,_,X,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(t) = { - X,_,_, - X,_,_, - X,X,X, - X,_,_, - X,_,_, - _,X,X, - _,_,_, - _,_,_, -0}; - -C(u) = { - _,_,_,_, - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(v) = { - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,_,_,X, - _,X,_,X,_, - _,_,X,_,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(w) = { - _,_,_,_,_, - _,_,_,_,_, - X,_,_,_,X, - X,_,X,_,X, - X,_,X,_,X, - _,X,_,X,_, - _,_,_,_,_, - _,_,_,_,_, -0}; - -C(x) = { - _,_,_,_, - _,_,_,_, - X,_,_,X, - _,X,X,_, - _,X,X,_, - X,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(y) = { - _,_,_,_, - _,_,_,_, - X,_,_,X, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,X,X,_, -0}; - -C(z) = { - _,_,_,_, - _,_,_,_, - X,X,X,X, - _,_,X,_, - _,X,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(0) = { - _,X,X,_, - X,_,_,X, - X,_,X,X, - X,X,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(1) = { - _,X,_, - X,X,_, - _,X,_, - _,X,_, - _,X,_, - X,X,X, - _,_,_, - _,_,_, -0}; - -C(2) = { - _,X,X,_, - X,_,_,X, - _,_,_,X, - _,_,X,_, - _,X,_,_, - X,X,X,X, - _,_,_,_, - _,_,_,_, -0}; - -C(3) = { - X,X,X,_, - _,_,_,X, - _,X,X,X, - _,_,_,X, - _,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(4) = { - _,_,X,X, - _,X,_,X, - X,_,_,X, - X,X,X,X, - _,_,_,X, - _,_,_,X, - _,_,_,_, - _,_,_,_, -0}; - -C(5) = { - X,X,X,X, - X,_,_,_, - X,X,X,_, - _,_,_,X, - _,_,_,X, - X,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(6) = { - _,X,X,_, - X,_,_,_, - X,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(7) = { - X,X,X,X, - _,_,_,X, - _,_,X,_, - _,_,X,_, - _,X,_,_, - _,X,_,_, - _,_,_,_, - _,_,_,_, -0}; - -C(8) = { - _,X,X,_, - X,_,_,X, - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(9) = { - _,X,X,_, - X,_,_,X, - X,_,_,X, - _,X,X,X, - _,_,_,X, - _,X,X,_, - _,_,_,_, - _,_,_,_, -0}; - -C(space) = { - _,_,_, - _,_,_, - _,_,_, - _,_,_, - _,_,_, - _,_,_, - _,_,_, -0}; - -struct font font8 = { 8, { - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_space, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_0, glyph_1, glyph_2, glyph_3, - glyph_4, glyph_5, glyph_6, glyph_7, - glyph_8, glyph_9, glyph_error, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_A, glyph_B, glyph_C, - glyph_D, glyph_E, glyph_F, glyph_G, - glyph_H, glyph_I, glyph_J, glyph_K, - glyph_L, glyph_M, glyph_N, glyph_O, - glyph_P, glyph_Q, glyph_R, glyph_S, - glyph_T, glyph_U, glyph_V, glyph_W, - glyph_X, glyph_Y, glyph_Z, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error, - glyph_error, glyph_a, glyph_b, glyph_c, - glyph_d, glyph_e, glyph_f, glyph_g, - glyph_h, glyph_i, glyph_j, glyph_k, - glyph_l, glyph_m, glyph_n, glyph_o, - glyph_p, glyph_q, glyph_r, glyph_s, - glyph_t, glyph_u, glyph_v, glyph_w, - glyph_x, glyph_y, glyph_z, glyph_error, - glyph_error, glyph_error, glyph_error, glyph_error -} }; DIR diff --git a/ploot-braille.c b/ploot-braille.c @@ -6,27 +6,60 @@ #include <string.h> #include <time.h> #include <math.h> +#include <unistd.h> -#include "def.h" -#include "arg.h" +#include "drawille.h" +#include "scale.h" +#include "tool.h" +#include "log.h" -char const *arg0 = NULL; +char const *arg0 = NULL; -static int -braille_axis_x(FILE *fp, time_t tmin, time_t tmax, time_t tstep, int col) +/* + * Plot the body as an histogram interpolating the gaps and include + * a vertical and horizontal axis. + */ +int +braille_histogram(struct vlist *vl, struct drawille *drw, + time_t tmin, time_t tmax, double vmin, double vmax) { - int x, o, prec; - char tmp[sizeof("MM/DD HH:MM")], *fmt; + int x, xprev, y, yprev, zero; + double *v; + time_t *t; size_t n; - time_t t; - fmt = (tstep < 3600 * 12) ? "^%H:%M:%S" : - (tstep < 3600 * 24) ? "^%m/%d %H:%M" : - "^%Y/%m/%d"; + zero = scale_ypos(0, vmin, vmax, drw->row*4); + v = vl->v; + t = vl->t; + n = vl->n; + for (; n > 0; n--, t++, v++) { + if (isnan(*v)) /* XXX: better handling? */ + continue; + y = scale_ypos(*v, vmin, vmax, drw->row * 4); + x = scale_xpos(*t, tmin, tmax, drw->col * 2); + if (n < vl->n) + drawille_histogram_line(drw, xprev, yprev, x, y, zero); + xprev = x; + yprev = y; + } + return 0; +} + +static int +braille_axis_x(FILE *fp, time_t tmin, time_t tmax, time_t tstep, int col) +{ + int x, o, prec; + char tmp[sizeof("MM/DD HH:MM")], *fmt; + size_t n; + time_t t; + + fmt = + (tstep < 3600 * 12) ? "^%H:%M:%S" : + (tstep < 3600 * 24) ? "^%m/%d %H:%M" : + "^%Y/%m/%d"; n = x = 0; - t = tmin; - t += tstep - t % tstep; + t = tmin + tstep - tmin % tstep; for (; t < tmax; t += tstep) { x = (t - tmin) * col / (tmax - tmin); strftime(tmp, sizeof tmp, fmt, localtime(&t)); @@ -35,7 +68,7 @@ braille_axis_x(FILE *fp, time_t tmin, time_t tmax, time_t tstep, int col) return -1; n += o; } - fputc('\n', fp); + fprintf(fp, "\n"); return 0; } @@ -45,25 +78,25 @@ braille_axis_x(FILE *fp, time_t tmin, time_t tmax, time_t tstep, int col) static void braille_axis_y(FILE *fp, double vmin, double vmax, int r, int rows) { - char tmp[10] = "", *s; - double val; + char tmp[10] = "", *s; + double val; val = (rows - r) * (vmax - vmin) / rows; humanize(tmp, val); - s = (r == 0) ? "┌" : - (r == rows - 1) ? "└" : - "├"; + s = + (r == 0) ? "┌" : + (r == rows - 1) ? "└" : + "├"; fprintf(fp, "%s%-6s ", s, tmp); } static int braille_render(struct drawille *drw, FILE *fp, double vmin, double vmax) { - /* Render the plot line by line. */ for (int row = 0; row < drw->row; row++) { drawille_put_row(drw, fp, row); braille_axis_y(fp, vmin, vmax, row, drw->row); - fputc('\n', fp); + fprintf(fp, "\n"); } return 0; } @@ -71,10 +104,10 @@ braille_render(struct drawille *drw, FILE *fp, double vmin, double vmax) static void plot(struct vlist *vl, FILE *fp, size_t ncol, int row, int col) { - size_t len; - double vmin, vmax, vstep; - time_t tmin, tmax, tstep; - struct drawille *drw; + size_t len; + double vmin, vmax, vstep; + time_t tmin, tmax, tstep; + struct drawille *drw; len = 500; col -= 8; @@ -83,13 +116,13 @@ plot(struct vlist *vl, FILE *fp, size_t ncol, int row, int col) warn("vstep=%lf vstep=%ld", vstep, tstep); if ((drw = drawille_new(row, col)) == NULL) - err(1, "allocating drawille canvas"); - if (drawille_histogram(vl, drw, tmin, tmax, vmin, vmax) == -1) - err(1, "allocating drawille canvas"); + fatal(1, "allocating drawille canvas"); + if (braille_histogram(vl, drw, tmin, tmax, vmin, vmax) == -1) + fatal(1, "allocating drawille canvas"); if (braille_render(drw, fp, vmin, vmax) == -1) - err(1, "rendering braille canvas"); + fatal(1, "rendering braille canvas"); if (braille_axis_x(fp, tmin, tmax, tstep, col) == -1) - err(1, "printing x axis");; + fatal(1, "printing x axis");; free(drw); } @@ -103,19 +136,24 @@ usage(void) int main(int argc, char **argv) { - struct vlist *vl; - char labels[LINE_MAX]; - size_t ncol; - - ARG_SWITCH(argc, argv) { - default: - usage(); + struct vlist *vl; + size_t ncol; + int c; + + optind = 0; + while ((c = getopt(argc, argv, "")) > -1) { + switch (c) { + default: + usage(); + } } + argc -= optind; + argv += optind; if (argc > 0) usage(); - csv_labels(stdin, labels, &vl, &ncol); + csv_labels(stdin, &vl, &ncol); csv_values(stdin, vl, ncol); plot(vl, stdout, ncol, 20, 80); DIR diff --git a/ploot-farbfeld.c b/ploot-farbfeld.c @@ -1,19 +1,22 @@ +#include <arpa/inet.h> #include <assert.h> #include <ctype.h> #include <fcntl.h> #include <limits.h> +#include <math.h> #include <stdint.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <time.h> +#include <unistd.h> -#include <arpa/inet.h> - -#include <math.h> - -#include "arg.h" -#include "def.h" +#include "csv.h" +#include "ffplot.h" +#include "font.h" +#include "log.h" +#include "tool.h" +#include "scale.h" #define MARGIN 4 @@ -45,32 +48,17 @@ #define LEGEND_W (100) #define LEGEND_H (PLOT_H) -struct color { - uint16_t red; - uint16_t green; - uint16_t blue; - uint16_t alpha; -}; - -struct cname { - char *name; - struct color color; +struct colorname { + char *name; + struct ffcolor color; }; -struct canvas { - int w; /* width */ - int h; /* height */ - int x; /* x offset */ - int y; /* y offset */ - struct color *buf; -}; - -char const *arg0 = NULL; -static char *tflag = ""; -static char *uflag = ""; +char const *arg0 = NULL; +static char *tflag = ""; +static char *uflag = ""; static struct font *font = &font13; -static struct cname cname[] = { +static struct colorname colorname[] = { /* name red green blue alpha */ { "red", { 0xffff, 0x4444, 0x4444, 0xffff } }, { "orange", { 0xffff, 0x9999, 0x4444, 0xffff } }, @@ -81,146 +69,8 @@ static struct cname cname[] = { { NULL, { 0, 0, 0, 0 } } }; -/* - * Convert (x,y) coordinates to (row,col) for printing into the buffer. - * The buffer only contain one number, so the coordinate is a single integer: - * width * y + y. - * The coordinates are shifted by offx and offy to permit relative coordinates. - * - * The convention used: y - * - (0,0) is at the lower left corner of the canvas. | - * - (0,1) is above it. +--x - */ -static void -ff_pixel(struct canvas *can, struct color *color, - int x, int y) -{ - x += can->x; - y += can->y; - if (x < 0 || x >= can->w || y < 0 || y >= can->h) - return; - memcpy(can->buf + can->w * (can->h - 1 - y) + x, color, sizeof(*can->buf)); -} - -static void -ff_rectangle(struct canvas *can, struct color *color, - int y1, int x1, - int y2, int x2) -{ - int x, y, ymin, xmin, ymax, xmax; - - ymin = MIN(y1, y2); ymax = MAX(y1, y2); - xmin = MIN(x1, x2); xmax = MAX(x1, x2); - - for (y = ymin; y <= ymax; y++) - for (x = xmin; x <= xmax; x++) - ff_pixel(can, color, x, y); -} - -/* - * From Bresenham's line algorithm and dcat's tplot. - */ -static void -ff_line(struct canvas *can, struct color *color, - int x0, int y0, - int x1, int y1) -{ - int dy, dx, sy, sx, err, e; - - sx = x0 < x1 ? 1 : -1; - sy = y0 < y1 ? 1 : -1; - dx = abs(x1 - x0); - dy = abs(y1 - y0); - err = (dy > dx ? dy : -dx) / 2; - - for (;;) { - ff_pixel(can, color, x0, y0); - - if (y0 == y1 && x0 == x1) - break; - - e = err; - if (e > -dy) { - y0 += sy; - err -= dx; - } - if (e < dx) { - x0 += sx; - err += dy; - } - } -} - -/* - * Draw a coloured glyph from font f centered on y. - */ -static int -ff_char(struct canvas *can, struct color *color, char c, - int x, int y) -{ - int yf, xf, wf; - - if (c & 0x80) - c = '\0'; - y -= font->height / 2; - wf = font_width(font, c); - for (xf = 0; xf < wf; xf++) - for (yf = 0; yf < font->height; yf++) - if (font->glyph[(int)c][wf * (font->height - yf) + xf] == 3) - ff_pixel(can, color, x + xf, y + yf); - return wf + 1; -} - -/* - * Draw a left aligned string without wrapping it. - */ -static size_t -ff_text_left(struct canvas *can, struct color *color, char *s, - int x, int y) -{ - for (; *s != '\0'; s++) - x += ff_char(can, color, *s, x, y); - return x; -} - -/* - * Draw a center aligned string without wrapping it. - */ -static size_t -ff_text_center(struct canvas *can, struct color *color, char *s, - int x, int y) -{ - x -= font_strlen(font, s) / 2; - return ff_text_left(can, color, s, x, y); -} - -/* - * Draw a right aligned string without wrapping it. - */ -static size_t -ff_text_right(struct canvas *can, struct color *color, char *s, - int x, int y) -{ - x -= font_strlen(font, s); - return ff_text_left(can, color, s, x, y); -} - -static void -ff_print(struct canvas *can) -{ - uint32_t w, h; - - w = htonl(can->w); - h = htonl(can->h); - - fputs("farbfeld", stdout); - fwrite(&w, sizeof(w), 1, stdout); - fwrite(&h, sizeof(h), 1, stdout); - fwrite(can->buf, can->w * can->h, sizeof(*can->buf), stdout); -} - static int -ff_t2x(time_t t, time_t tmin, time_t tmax) +farbfeld_t2x(time_t t, time_t tmin, time_t tmax) { if (tmin == tmax) return PLOT_W; @@ -228,7 +78,7 @@ ff_t2x(time_t t, time_t tmin, time_t tmax) } static int -ff_v2y(double v, double vmin, double vmax) +farbfeld_v2y(double v, double vmin, double vmax) { if (vmin == vmax) return PLOT_H; @@ -236,12 +86,12 @@ ff_v2y(double v, double vmin, double vmax) } static void -ff_xaxis(struct canvas *can, struct color *label, struct color *grid, +farbfeld_xaxis(struct ffplot *plot, struct ffcolor *label, struct ffcolor *grid, time_t tmin, time_t tmax, time_t tstep) { - time_t t; - int x; - char str[sizeof("MM/DD HH/MM")], *fmt; + time_t t; + int x; + char str[sizeof("MM/DD HH/MM")], *fmt; if (tstep < 3600 * 12) fmt = "%H:%M:%S"; @@ -251,64 +101,64 @@ ff_xaxis(struct canvas *can, struct color *label, struct color *grid, fmt = "%X/%m/%d"; for (t = tmax - tmax % tstep; t >= tmin; t -= tstep) { - x = ff_t2x(t, tmin, tmax); + x = farbfeld_t2x(t, tmin, tmax); - ff_line(can, grid, + ffplot_line(plot, grid, x, XLABEL_H, x, XLABEL_H + PLOT_H); strftime(str, sizeof(str), fmt, localtime(&t)); - ff_text_center(can, label, str, + ffplot_text_center(plot, label, font, str, x, XLABEL_H / 2); } } static void -ff_yaxis(struct canvas *can, struct color *label, struct color *grid, +farbfeld_yaxis(struct ffplot *plot, struct ffcolor *label, struct ffcolor *grid, double vmin, double vmax, double vstep) { - double v; - int y; - char str[8 + 1]; + double v; + int y; + char str[8 + 1]; for (v = vmax - fmod(vmax, vstep); v >= vmin; v -= vstep) { - y = ff_v2y(v, vmin, vmax); + y = farbfeld_v2y(v, vmin, vmax); - ff_line(can, grid, + ffplot_line(plot, grid, YLABEL_W, y, YLABEL_W + PLOT_W, y); humanize(str, v); - ff_text_right(can, label, str, + ffplot_text_right(plot, label, font, str, YLABEL_W - MARGIN, y); } } static void -ff_title(struct canvas *can, - struct color *ct, char *title, - struct color *cu, char *unit) +farbfeld_title(struct ffplot *plot, + struct ffcolor *ct, char *title, + struct ffcolor *cu, char *unit) { - ff_text_left(can, ct, title, TITLE_H / 2, 0); - ff_text_right(can, cu, unit, TITLE_H / 2, TITLE_W); + ffplot_text_left(plot, ct, font, title, TITLE_H / 2, 0); + ffplot_text_right(plot, cu, font, unit, TITLE_H / 2, TITLE_W); } static void -ff_plot(struct canvas *can, struct vlist *vl, struct color *color, +farbfeld_plot(struct ffplot *plot, struct vlist *vl, struct ffcolor *color, double vmin, double vmax, time_t tmin, time_t tmax) { - time_t *tp; - double *vp; - int x, y, n, ylast, xlast, first; + time_t *tp; + double *vp; + int x, y, n, ylast, xlast, first; first = 1; for (tp = vl->t, vp = vl->v, n = vl->n; n > 0; n--, vp++, tp++) { - y = ff_v2y(*vp, vmin, vmax); - x = ff_t2x(*tp, tmin, tmax); + y = farbfeld_v2y(*vp, vmin, vmax); + x = farbfeld_t2x(*tp, tmin, tmax); if (!first) - ff_line(can, color, xlast, ylast, x, y); + ffplot_line(plot, color, xlast, ylast, x, y); ylast = y; xlast = x; @@ -317,24 +167,24 @@ ff_plot(struct canvas *can, struct vlist *vl, struct color *color, } static void -ff_values(struct canvas *can, struct vlist *vl, struct color **cl, size_t ncol, +farbfeld_values(struct ffplot *plot, struct vlist *vl, struct ffcolor **cl, size_t ncol, time_t tmin, time_t tmax, double vmin, double vmax) { for (; ncol > 0; ncol--, vl++, cl++) - ff_plot(can, vl, *cl, vmin, vmax, tmin, tmax); + farbfeld_plot(plot, vl, *cl, vmin, vmax, tmin, tmax); } static void -ff_legend(struct canvas *can, struct color *fg, struct vlist *vl, struct color **cl, size_t ncol) +farbfeld_legend(struct ffplot *plot, struct ffcolor *fg, struct vlist *vl, struct ffcolor **cl, size_t ncol) { - size_t x, y; + size_t x, y; for (; ncol > 0; ncol--, vl++, cl++) { y = -(ncol - 1) * (font->height + MARGIN); x = MARGIN * 2; - x = ff_text_left(can, *cl, "-", x, y) + MARGIN; - x = ff_text_left(can, fg, vl->label, x, y); + x = ffplot_text_left(plot, *cl, font, "-", x, y) + MARGIN; + x = ffplot_text_left(plot, fg, font, vl->label, x, y); } } @@ -350,77 +200,77 @@ ff_legend(struct canvas *can, struct color *fg, struct vlist *vl, struct color * * x label here */ static void -ff(struct vlist *vl, struct color **cl, size_t ncol, char *name, char *units) +plot(struct vlist *vl, struct ffcolor **cl, size_t ncol, char *name, char *units) { - struct canvas can = { IMAGE_W, IMAGE_H, 0, 0, NULL }; - struct color plot_bg = { 0x2222, 0x2222, 0x2222, 0xffff }; - struct color grid_bg = { 0x2929, 0x2929, 0x2929, 0xffff }; - struct color grid_fg = { 0x3737, 0x3737, 0x3737, 0xffff }; - struct color label_fg = { 0x8888, 0x8888, 0x8888, 0xffff }; - struct color title_fg = { 0xdddd, 0xdddd, 0xdddd, 0xffff }; - double vmin, vmax, vstep; - time_t tmin, tmax, tstep; + struct ffplot plot = { IMAGE_W, IMAGE_H, 0, 0, NULL }; + struct ffcolor plot_bg = { 0x2222, 0x2222, 0x2222, 0xffff }; + struct ffcolor grid_bg = { 0x2929, 0x2929, 0x2929, 0xffff }; + struct ffcolor grid_fg = { 0x3737, 0x3737, 0x3737, 0xffff }; + struct ffcolor label_fg = { 0x8888, 0x8888, 0x8888, 0xffff }; + struct ffcolor title_fg = { 0xdddd, 0xdddd, 0xdddd, 0xffff }; + double vmin, vmax, vstep; + time_t tmin, tmax, tstep; scale(vl, ncol, &tmin, &tmax, &tstep, &vmin, &vmax, &vstep); - assert(can.buf = calloc(IMAGE_H * IMAGE_W, sizeof *can.buf)); + assert(plot.buf = calloc(IMAGE_H * IMAGE_W, sizeof *plot.buf)); - can.y = 0; - can.x = 0; - ff_rectangle(&can, &plot_bg, 0, 0, IMAGE_H - 1, IMAGE_W - 1); + plot.y = 0; + plot.x = 0; + ffplot_rectangle(&plot, &plot_bg, 0, 0, IMAGE_H - 1, IMAGE_W - 1); - can.x = PLOT_X; - can.y = PLOT_Y; - ff_rectangle(&can, &grid_bg, 0, 0, PLOT_H, PLOT_W); + plot.x = PLOT_X; + plot.y = PLOT_Y; + ffplot_rectangle(&plot, &grid_bg, 0, 0, PLOT_H, PLOT_W); - can.x = XLABEL_X; - can.y = XLABEL_Y; - ff_xaxis(&can, &label_fg, &grid_fg, tmin, tmax, tstep); + plot.x = XLABEL_X; + plot.y = XLABEL_Y; + farbfeld_xaxis(&plot, &label_fg, &grid_fg, tmin, tmax, tstep); - can.x = YLABEL_X; - can.y = YLABEL_Y; - ff_yaxis(&can, &label_fg, &grid_fg, vmin, vmax, vstep); + plot.x = YLABEL_X; + plot.y = YLABEL_Y; + farbfeld_yaxis(&plot, &label_fg, &grid_fg, vmin, vmax, vstep); - can.x = TITLE_X; - can.y = TITLE_Y; - ff_title(&can, &title_fg, name, &label_fg, units); + plot.x = TITLE_X; + plot.y = TITLE_Y; + farbfeld_title(&plot, &title_fg, name, &label_fg, units); - can.x = PLOT_X; - can.y = PLOT_Y; - ff_values(&can, vl, cl, ncol, tmin, tmax, vmin, vmax); + plot.x = PLOT_X; + plot.y = PLOT_Y; + farbfeld_values(&plot, vl, cl, ncol, tmin, tmax, vmin, vmax); - can.x = LEGEND_X; - can.y = LEGEND_Y; - ff_legend(&can, &label_fg, vl, cl, ncol); + plot.x = LEGEND_X; + plot.y = LEGEND_Y; + farbfeld_legend(&plot, &label_fg, vl, cl, ncol); - ff_print(&can); + ffplot_print(stdout, &plot); } -static struct color * +static struct ffcolor * name_to_color(char *name) { - struct cname *cn; + struct colorname *cn; - for (cn = cname; cn->name != NULL; cn++) + for (cn = colorname; cn->name != NULL; cn++) if (strcmp(name, cn->name) == 0) return &cn->color; return NULL; } static void -argv_to_color(struct color **cl, char **argv) +argv_to_color(struct ffcolor **cl, char **argv) { for (; *argv != NULL; cl++, argv++) if ((*cl = name_to_color(*argv)) == NULL) - err(1, "unknown color name: %s", *argv); + fatal(1, "unknown color name: %s", *argv); } static void usage(void) { fprintf(stderr, "usage: %s [-t title] [-u unit] {", arg0); - fputs(cname->name, stderr); - for (struct cname *cn = cname + 1; cn->name != NULL; cn++) + fputs(colorname->name, stderr); + for (struct colorname *cn = colorname + 1; cn->name != NULL; cn++) fprintf(stderr, ",%s", cn->name); fputs("}...\n", stderr); exit(1); @@ -429,36 +279,41 @@ usage(void) int main(int argc, char **argv) { - struct vlist *vl; - struct color **cl; - char labels[LINE_MAX]; - size_t ncol; - - ARG_SWITCH(argc, argv) { - case 't': - tflag = ARG; - break; - case 'u': - uflag = ARG; - break; - default: - usage(); + struct vlist *vl; + struct ffcolor **cl; + size_t ncol; + int c; + + optind = 0; + while ((c = getopt(argc, argv, "")) > -1) { + switch (c) { + case 't': + tflag = optarg; + break; + case 'u': + uflag = optarg; + break; + default: + usage(); + } } + argc -= optind; + argv += optind; if (argc == 0) usage(); assert(cl = calloc(argc, sizeof(*cl))); - csv_labels(stdin, labels, &vl, &ncol); + csv_labels(stdin, &vl, &ncol); if (ncol > (size_t)argc) - err(1, "too many columns or not enough arguments"); + fatal(1, "too many columns or not enough arguments"); else if (ncol < (size_t)argc) - err(1, "too many arguments or not enough columns"); + fatal(1, "too many arguments or not enough columns"); csv_values(stdin, vl, ncol); argv_to_color(cl, argv); - ff(vl, cl, argc, tflag, uflag); + plot(vl, cl, argc, tflag, uflag); free(vl); free(cl); DIR diff --git a/ploot-feed.c b/ploot-feed.c @@ -6,16 +6,17 @@ #include <string.h> #include <ctype.h> #include <stdint.h> +#include <unistd.h> -#include "arg.h" -#include "def.h" +#include "tool.h" +#include "log.h" #define WIDTH_MAX 1024 #define BRAILLE_START 10240 -char const *arg0 = NULL; -static int wflag = 80; -static int width = 0; +char const *arg0 = NULL; +static int wflag = 80; +static int width = 0; /* * Turn the bit at position (row, col) on in the . @@ -36,7 +37,7 @@ plot_dot(long *out, int row, int col) static void plot_val(long *out, double val, double max, int row) { - int col, c; + int col, c; val = MIN(max, val); col = (int)(val * (double)(width - 1) / max * 2); @@ -51,23 +52,23 @@ plot_val(long *out, double val, double max, int row) static time_t plot_row(long *out, char *line, double *max, int nrow, int ncol) { - time_t epoch; - double val; - int n; - char *tok; + time_t epoch; + double val; + int n; + char *tok; if ((tok = strsep(&line, ",")) == NULL) - fputs("*** missing epoch value\n", stderr), exit(1); + fatal(100, "*** missing epoch value"); epoch = eatol(tok); for (n = 0; (tok = strsep(&line, ",")) != NULL; n++) { if (n >= ncol) - fputs("too many values\n", stderr), exit(1); + fatal(100, "too many values"); val = atof(tok); plot_val(out + n * width, val, max[n], nrow); } if (n < ncol) - fputs("not enough values\n", stderr), exit(1); + fatal(100, "not enough values"); return epoch; } @@ -78,10 +79,11 @@ plot_row(long *out, char *line, double *max, int nrow, int ncol) static time_t plot_line(long *out, double *max, int ncol) { - time_t epoch; - int n, nrow; - long *o, rune; - char line[LINE_MAX]; + time_t epoch; + int n, nrow; + long *o, rune; + char *line; + size_t sz; for (rune = BRAILLE_START, o = out, n = ncol * width; n > 0; o++, n--) memcpy(o, &rune, sizeof(rune)); @@ -90,19 +92,24 @@ plot_line(long *out, double *max, int ncol) memcpy(o, &rune, sizeof(rune)); out++; + sz = 0; for (nrow = 0; nrow < 4; nrow++) { - if ((esfgets(line, LINE_MAX, stdin)) == NULL) + if (getline(&line, &sz, stdin) == -1) { + if (ferror(stdin)) + fatal(111, "reading row from stdin"); exit(0); + } epoch = plot_row(out, line, max, nrow, ncol); } + free(line); return epoch; } static void put_time(time_t epoch, time_t last, int nline) { - char *out, buf[sizeof("XXxXXxXX ")]; + char *out, buf[sizeof("XXxXXxXX ")]; switch (nline % 3) { case 0: @@ -130,11 +137,11 @@ put_line(long *out) } static void -plot(char labels[LINE_MAX], double *max, int ncol) +plot(char labels[4069], double *max, int ncol) { - time_t epoch, last_epoch; - long out[WIDTH_MAX + 1]; - int n; + time_t epoch, last_epoch; + long out[WIDTH_MAX + 1]; + int n; last_epoch = epoch = 0; @@ -159,34 +166,40 @@ plot(char labels[LINE_MAX], double *max, int ncol) * offer: sizeof(*buf / 2). */ static int -read_labels(char *labv[LINE_MAX]) +read_labels(char **labv) { - int ncol; - char *l, line[LINE_MAX], *tok; - - if ((l = esfgets(line, LINE_MAX, stdin)) == NULL) - fputs("missing label line\n", stderr), exit(1); + int ncol; + char *cp, *line, *tok; + size_t sz; + + sz = 0; + if (getline(&line, &sz, stdin) == -1) { + if (ferror(stdin)) + fatal(111, "reading labels from stdin"); + fatal(100, "missing label line", stderr); + } + cp = line; - if (strcmp(strsep(&l, ","), "epoch") != 0) - fputs("first label must be \"epoch\"\n", stderr), exit(1); + if (strcmp(strsep(&cp, ","), "epoch") != 0) + fatal(100, "first label must be 'epoch'"); - for (ncol = 0; (tok = strsep(&l, ",")) != NULL; ncol++, labv++) + for (ncol = 0; (tok = strsep(&cp, ",")) != NULL; ncol++, labv++) *labv = tok; *labv = NULL; if (ncol < 1) - fputs("no label found\n", stderr), exit(1); - + fatal(100, "no label found"); + free(line); return ncol; } static void -fmt_labels(char out[LINE_MAX], int ncol, char *labels[LINE_MAX / 2]) +fmt_labels(char out[4069], int ncol, char *labels[4069 / 2]) { - int i, n; + int i, n; for (i = 0; i < ncol; labels++, i++) { - n = LINE_MAX - (width + sizeof("│")) * i; + n = 4069 - (width + sizeof("│")) * i; out += snprintf(out, n, "│%-*s", width - 1, *labels); } } @@ -198,41 +211,39 @@ usage(void) exit(1); } -static int -parse_args(int argc, char **argv, double *max) +int +main(int argc, char **argv) { - int n; - - ARG_SWITCH(argc, argv) { - case 'w': - wflag = atoi(ARG); - break; - default: - usage(); + double max[4069 / 2], *m; + int ncol, nmax; + char *labv[4069 / 2], labels[4069]; + int c; + + optind = 0; + while ((c = getopt(argc, argv, "w:")) > -1) { + switch (c) { + case 'w': + wflag = atoi(optarg); + break; + default: + usage(); + } } + argc -= optind; + argv += optind; if (argc == 0) usage(); - for (n = argc; n > 0; n--, argv++, max++) - *max = eatof(*argv); - - return argc; -} - -int -main(int argc, char **argv) -{ - double max[LINE_MAX / 2]; - int ncol, nmax; - char *labv[LINE_MAX / 2], labels[LINE_MAX]; + nmax = argc; + for (m = max; argc > 0; argc--, argv++, m++) + *m = eatof(*argv); - nmax = parse_args(argc, argv, max); ncol = read_labels(labv); width = (wflag - sizeof("XXxXXxXX _")) / ncol - sizeof("|"); fmt_labels(labels, ncol, labv); if (ncol != nmax) - fputs("not as many labels and arguments\n", stderr), exit(1); + fatal(100, "not as many labels and arguments"); plot(labels, max, ncol); return 0; DIR diff --git a/proto.sh b/proto.sh @@ -0,0 +1,73 @@ +#!/bin/sh +awk=' +BEGIN { + tab = "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t" + print "/**/" +} + +END { + print "" + print "#endif" +} + +# functions + +args { + sub(/^[ \t]*/, " ") + args = args $0 +} + +/^[a-zA-Z0-9_]+\([][)(a-z_A-Z0-9*,. \t]*$/ { + if (match(type, "static") || match($0, ";$")) + next + + symbol = $0 + sub(/\(.*/, "", symbol) + sub(/[a-zA-Z0-9_]*\(/, "", $0) + if (symbol == "main") + next + + args = $0 + sub(/^[a-z]*\(/, "", args) +} + +args && /\)$/ { + gsub(/[\n \t]+/, " ", args) + + sub(/\)$/, "", args) + + gsub(/[a-zA-Z0-9_]+\[[^]]*\]/, "[]", args) + gsub(/[*][a-zA-Z0-9_]+/, "*", args) + gsub(/[ ][a-zA-Z0-9_]+,/, ",", args) + gsub(/[ ][a-zA-Z0-9_]+$/, "", args) + gsub(/[ ][a-zA-Z0-9_]+\*/, "*", args) + gsub(/\.\.\.\$/, "...", args) + gsub(/void\)$/, "void", args) + + printf("%s%s%s%s(%s);\n", + type, substr(tab, 1, 20 / 8 - (length(type) - 3) / 8), + symbol, substr(tab, 1, 30 / 8 - (length(symbol) - 1) / 8), + args) + + args = "" +} + +!args { + type = $0 +} + +# variables + +/^[a-zA-Z][][ \t*a-z_A-Z0-9]*=.*[;{]$/ && $1 != "static" && $1 != "enum" { + sub(/ *=.*/, ";") + sub(/[ \t]*;$/, ";"); + print +} +' + +for file in src/*.c; do file=${file%.c} + grep -Fq '/**/' "$file.h" 2>/dev/null || continue + header=$(awk '$0 == "/**/" { exit(0) } 1' "$file.h" + awk "$awk" "$file.c") + printf '%s\n' "$header" >"$file.h" +done DIR diff --git a/scale.c b/scale.c @@ -1,139 +0,0 @@ -#include "def.h" -#include "err.h" - -#define XDENSITY 7 /* nb of values on x axis */ -#define YDENSITY 7 /* nb of values on y axis */ - -/* - * - <max ^ - * - | Translate the coordinates between double values - * - <val szy and height in the plot of <row> rows. - * - | - * - <min v - */ -int -scale_ypos(double val, double min, double max, int szy) -{ - return szy * (val - min) / (max - min); -} - -/* - * <---- szx ----> Translate the coordinates between the time - * range and position in the plot of <col> cols. - * t1 t t2 - * | . . | . . | - */ -int -scale_xpos(time_t t, time_t t1, time_t t2, int szx) -{ - return szx * (t - t1) / (t2 - t1); -} - -static void -scale_minmax(struct vlist *vl, int ncol, - time_t *tmin, time_t *tmax, - double *vmin, double *vmax) -{ - double *v; - time_t *t; - size_t n; - - *vmin = *vmax = 0; - *tmin = *tmax = *vl->t; - - for (; ncol > 0; ncol--, vl++) { - for (t = vl->t, v = vl->v, n = vl->n; n > 0; t++, v++, n--) { - if (*v < *vmin) *vmin = *v; - if (*v > *vmax) *vmax = *v; - if (*t < *tmin) *tmin = *t; - if (*t > *tmax) *tmax = *t; - } - } - - if (*tmin == *tmax) - err(1, "invalid time scale: min=%lld max=%lld", *tmin, *tmax); -} - -static time_t -scale_tstep(time_t min, time_t max, int density) -{ - time_t dt, *s, scale[] = { - 1, 5, 2, 10, 20, 30, 60, 60*2, 60*5, 60*10, 60*20, 60*30, 3600, - 3600*2, 3600*5, 3600*10, 3600*18, 3600*24, 3600*24*2, - 3600*24*5, 3600*24*10, 3600*24*20, 3600*24*30, 3600*24*50, - 3600*24*100, 3600*24*365, 0 - }; - - dt = max - min; - for (s = scale; s < scale + LEN(scale); s++) - if (dt < *s * density) - return *s; - return 0; -} - -static double -scale_vstep(double min, double max, int density) -{ - double dv, d, *s, scale[] = { 1, 2, 3, 5 }; - - dv = max - min; - - if (dv > 1) - for (d = 1; d != 0; d *= 10) - for (s = scale; s < scale + LEN(scale); s++) - if (dv < *s * d * density) - return *s * d; - if (dv < 1) - for (d = 1; d != 0; d *= 10) - for (s = scale + LEN(scale) - 1; s >= scale; s--) - if (dv > *s / d * density / 2) - return *s / d; - return 0; -} - -/* - * Adjust the vertical scale so that everything fits, with nice - * scale values. - */ -void -scale_vminmax(double *min, double *max, int row) -{ - double unit, range, mi; - - range = *max - *min; - unit = 1; - - /* Zoom until it fills the canvas. */ - for (; (row - 1) * unit > range; unit /= 10) - continue; - - /* Dezoom until it fits the canvas. */ - for (; (row - 1) * unit < range; unit *= 10) - continue; - - /* Fine tune. */ - if ((row - 1) * unit / 5 > range) - unit /= 5; - if ((row - 1) * unit / 4 > range) - unit /= 4; - if ((row - 1) * unit / 2 > range) - unit /= 2; - - /* Align the minimum (and the zero). */ - for (mi = 0; mi > *min - unit; mi -= unit) - continue; - - /* Update the displayed minimal and maximal. */ - *min = mi; - *max = mi + unit * row; -} - -void -scale(struct vlist *vl, int ncol, - time_t *tmin, time_t *tmax, time_t *tstep, - double *vmin, double *vmax, double *vstep) -{ - scale_minmax(vl, ncol, tmin, tmax, vmin, vmax); - *tstep = scale_tstep(*tmin, *tmax, XDENSITY); - *vstep = scale_vstep(*vmin, *vmax, YDENSITY); -} DIR diff --git a/src/csv.c b/src/csv.c @@ -0,0 +1,109 @@ +#include "csv.h" + +#include <assert.h> +#include <string.h> +#include <time.h> +#include <stdlib.h> + +#include "log.h" +#include "tool.h" + +/* + * Read CSV data onto a set of (struct vlist). + */ + +static void +csv_addtime(struct vlist *vl, time_t epoch) +{ + assert(vl->t = realloc(vl->t, (vl->n + 1) * sizeof(*vl->t))); + vl->t[vl->n] = epoch; +} + +static void +csv_addval(struct vlist *vl, double field) +{ + assert(vl->v = realloc(vl->v, (vl->n + 1) * sizeof(*vl->v))); + vl->v[vl->n] = field; +} + +/* + * Add to each column the value on the current row. The time_t + * buffer is shared among all fields. + */ +void +csv_addrow(struct vlist *vl, size_t ncol, char *line) +{ + char *field; + time_t *tbuf; + + if ((field = strsep(&line, ",")) == NULL) + fatal(1, "missing epoch at row %zu", vl->n); + + csv_addtime(vl, eatol(field)); + for (; (field = strsep(&line, ",")) != NULL; ncol--, vl->n++, vl++) { + if (ncol == 0) + fatal(1, "too many fields at line %zu", vl->n); + csv_addval(vl, eatof(field)); + } + if (ncol > 0) + fatal(1, "too few fields at line %zu", vl->n); + + /* the same time buffer can be used for all columns */ + for (tbuf = vl->t; ncol > 0; ncol--, vl++) + vl->t = tbuf; +} + +/* + * < *ncol > + * epoch,label1,label2,label3 + */ +void +csv_labels(FILE *fp, struct vlist **vl, size_t *ncol) +{ + char *field, *line, *cp, *label; + size_t sz; + ssize_t r; + + r = getline(&line, &sz, fp); + if (ferror(fp)) + fatal(111, "error while reading from file"); + if (r == -1) + fatal(100, "missing label line"); + + cp = line; + if (strcmp(strsep(&cp, ","), "epoch") != 0) + fatal(1, "first label must be 'epoch'"); + + *vl = NULL; + *ncol = 0; + while ((field = strsep(&cp, ","))) { + assert(*vl = realloc(*vl, sz += sizeof(**vl))); + label = (*vl)[(*ncol)++].label; + strlcpy(label, field, sizeof(label)); + } + + free(line); +} + +/* + * < ncol > + * epoch,a1,b1,c1 ^ + * epoch,a2,b2,c2 vl->n + * epoch,a3,b3,c3 v + */ +void +csv_values(FILE *fp, struct vlist *vl, size_t ncol) +{ + char *line; + size_t sz; + + sz = 0; + while (getline(&line, &sz, fp) > -1) + csv_addrow(vl, ncol, line); + if (vl->n == 0) + fatal(1, "no value could be read"); + if (vl->n == 1) + fatal(1, "only one value could be read"); + + free(line); +} DIR diff --git a/src/csv.h b/src/csv.h @@ -0,0 +1,22 @@ +#ifndef CSV_H +#define CSV_H + +#include <stdio.h> + +/* + * List of values and timestamps. Both have their dedicated buffer + * so that the timestamp buffer can be shared across vlist objects. + */ +struct vlist { + time_t *t; /* array of timestamps */ + double *v; /* array of values */ + size_t n; /* number of values */ + char label[64]; /* for the legend */ +}; + +/**/ +void csv_addrow (struct vlist *, size_t, char *); +void csv_labels (FILE *, struct vlist **, size_t *); +void csv_values (FILE *, struct vlist *, size_t); + +#endif DIR diff --git a/src/drawille.c b/src/drawille.c @@ -0,0 +1,193 @@ +#include "drawille.h" + +#include <stdint.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <math.h> + +#include "font.h" + +/* + * Terminal-based plotting using drawille character, aka drawille. + */ + +/* parameters used to draw a line */ +struct line { + int x0, y0, x1, y1; /* point of the line */ + int dx, dy, sx, sy, err; /* parameters for the algorythm */ +}; + +/* + * Turn on the bit at position (row, col) of a single cell. The + * pattern is not linear (1-4-2-5-3-6-7-8), because it matches the + * drawille pattern. + */ +static void +drawille_cell_dot(uint8_t *cell, int row, int col) +{ + uint8_t flags[4][2] = { + { 0x01, 0x08 }, + { 0x02, 0x10 }, + { 0x04, 0x20 }, + { 0x40, 0x80 }, + }; + + *cell |= flags[row][col]; +} + +static size_t +drawille_cell_utf(uint8_t cell, char *utf) +{ + long rune; + + rune = 10240 + cell; + utf[0] = (char)(0xe0 | (0x0f & (rune >> 12))); /* 1110xxxx */ + utf[1] = (char)(0x80 | (0x3f & (rune >> 6))); /* 10xxxxxx */ + utf[2] = (char)(0x80 | (0x3f & (rune))); /* 10xxxxxx */ + return 3; +} + +static uint8_t +drawille_get(struct drawille *drw, int row, int col) +{ + return drw->buf[row * drw->col + col]; +} + +size_t +drawille_put_row(struct drawille *drw, FILE *fp, int row) +{ + char txt[] = "xxx"; + size_t n; + + n = 0; + for (int col = 0; col < drw->col; col++) { + drawille_cell_utf(drawille_get(drw, row, col), txt); + n += fputs(txt, fp); + } + return n; +} + +/* + * Coordinates are passed as (x, y), but the canvas stores bits as + * (row, col). Conversion is made by this function. + */ +void +drawille_dot(struct drawille *drw, int x, int y) +{ + if (x < 0 || x / 2 >= drw->col || y < 0 || y / 4 >= drw->row) + return; + drawille_cell_dot(drw->buf + (drw->row - y / 4 - 1) * drw->col + (x / 2), + 3 - y % 4, + x % 2); +} + +struct drawille * +drawille_new(int row, int col) +{ + struct drawille *drw; + + if ((drw = calloc(sizeof(struct drawille) + row * col, 1)) == NULL) + return NULL; + drw->row = row; + drw->col = col; + return drw; +} + +static void +drawille_line_init(struct line *l, int x0, int y0, int x1, int y1) +{ + l->x0 = x0; + l->y0 = y0; + l->x1 = x1; + l->y1 = y1; + l->sx = x0 < x1 ? 1 : -1; + l->sy = y0 < y1 ? 1 : -1; + l->dx = abs(x1 - x0); + l->dy = abs(y1 - y0); + l->err = (l->dx > l->dy ? l->dx : -l->dy) / 2; +} + +static int +drawille_line_next(struct line *l) +{ + int e; + + if (l->x0 == l->x1 && l->y0 == l->y1) + return 0; + + e = l->err; + if (e > -l->dx) { + l->x0 += l->sx; + l->err -= l->dy; + } + if (e < l->dy) { + l->y0 += l->sy; + l->err += l->dx; + } + return 1; +} + +void +drawille_line(struct drawille *drw, int x0, int y0, int x1, int y1) +{ + struct line l; + + drawille_line_init(&l, x0, y0, x1, y1); + do { + drawille_dot(drw, l.x0, l.y0); + } while (drawille_line_next(&l)); +} + +void +drawille_histogram_dot(struct drawille *drw, int x, int y, int zero) +{ + int sign; + + sign = (y > zero) ? (+1) : (-1); + for (; y != zero + sign; y -= sign) + drawille_dot(drw, x, y); +} + +void +drawille_histogram_line(struct drawille *drw, int x0, int y0, int x1, int y1, int zero) +{ + struct line l; + + drawille_line_init(&l, x0, y0, x1, y1); + do { + drawille_histogram_dot(drw, l.x0, l.y0, zero); + } while (drawille_line_next(&l)); +} + +static int +drawille_text_glyph(struct drawille *drw, int x, int y, struct font *font, char c) +{ + int width; + char *glyph; + + if ((unsigned)c > 127) + glyph = font->glyph[0]; + else + glyph = font->glyph[(unsigned)c]; + + width = strlen(glyph) / font->height; + + for (int ix = 0; ix < width; ix++) + for (int iy = 0; iy < font->height; iy++) { + if (glyph[ix + (font->height - 1) * width - iy * width] == 3) + drawille_dot(drw, x + ix, y + iy); + } + + return width; +} + +char * +drawille_text(struct drawille *drw, int x, int y, struct font *font, char *s) +{ + if (drw->row*4 < font->height) + return NULL; + for (; *s != '\0' && x < drw->col/2; s++, x++) + x += drawille_text_glyph(drw, x, y, font, *s); + return s; +} DIR diff --git a/src/drawille.h b/src/drawille.h @@ -0,0 +1,28 @@ +#ifndef DRAWILLE_H +#define DRAWILLE_H + +#include <stddef.h> +#include <stdint.h> +#include <stdio.h> + +#include "csv.h" +#include "font.h" + +/* + * Canvas to draw on with braille characters. + */ +struct drawille { + int col, row; /* number of dots in total */ + uint8_t buf[]; /* buffer of size (col * row) */ +}; + +/**/ +size_t drawille_put_row (struct drawille *, FILE *, int); +void drawille_dot (struct drawille *, int, int); +struct drawille *drawille_new (int, int); +void drawille_line (struct drawille *, int, int, int, int); +void drawille_histogram_dot (struct drawille *, int, int, int); +void drawille_histogram_line (struct drawille *, int, int, int, int, int); +char * drawille_text (struct drawille *, int, int, struct font *, char *); + +#endif DIR diff --git a/src/ffplot.c b/src/ffplot.c @@ -0,0 +1,147 @@ +#include "ffplot.h" + +#include <arpa/inet.h> +#include <stddef.h> +#include <string.h> +#include <stdio.h> + +#include "font.h" +#include "tool.h" + +/* + * Convert (x,y) coordinates to (row,col) for printing into the buffer. + * The buffer only contain one number, so the coordinate is a single integer: + * width * y + y. + * The coordinates are shifted by offx and offy to permit relative coordinates. + * + * The convention used: y + * - (0,0) is at the lower left corner of the plotvas. | + * - (0,1) is above it. +--x + */ +void +ffplot_pixel(struct ffplot *plot, struct ffcolor *color, + int x, int y) +{ + x += plot->x; + y += plot->y; + if (x < 0 || x >= plot->w || y < 0 || y >= plot->h) + return; + memcpy(plot->buf + plot->w * (plot->h - 1 - y) + x, color, sizeof(*plot->buf)); +} + +void +ffplot_rectangle(struct ffplot *plot, struct ffcolor *color, + int y1, int x1, + int y2, int x2) +{ + int x, y, ymin, xmin, ymax, xmax; + + ymin = MIN(y1, y2); ymax = MAX(y1, y2); + xmin = MIN(x1, x2); xmax = MAX(x1, x2); + + for (y = ymin; y <= ymax; y++) + for (x = xmin; x <= xmax; x++) + ffplot_pixel(plot, color, x, y); +} + +/* + * From Bresenham's line algorithm and dcat's tplot. + */ +void +ffplot_line(struct ffplot *plot, struct ffcolor *color, + int x0, int y0, + int x1, int y1) +{ + int dy, dx, sy, sx, err, e; + + sx = x0 < x1 ? 1 : -1; + sy = y0 < y1 ? 1 : -1; + dx = ABS(x1 - x0); + dy = ABS(y1 - y0); + err = (dy > dx ? dy : -dx) / 2; + + for (;;) { + ffplot_pixel(plot, color, x0, y0); + + if (y0 == y1 && x0 == x1) + break; + + e = err; + if (e > -dy) { + y0 += sy; + err -= dx; + } + if (e < dx) { + x0 += sx; + err += dy; + } + } +} + +/* + * Draw a coloured glyph from font f centered on y. + */ +int +ffplot_char(struct ffplot *plot, struct ffcolor *color, struct font *ft, char c, + int x, int y) +{ + int yf, xf, wf; + + if (c & 0x80) + c = '\0'; + y -= ft->height / 2; + wf = font_width(ft, c); + for (xf = 0; xf < wf; xf++) + for (yf = 0; yf < ft->height; yf++) + if (ft->glyph[(int)c][wf * (ft->height - yf) + xf] == 3) + ffplot_pixel(plot, color, x + xf, y + yf); + return wf + 1; +} + +/* + * Draw a left aligned string without wrapping it. + */ +size_t +ffplot_text_left(struct ffplot *plot, struct ffcolor *color, struct font *ft, + char *s, int x, int y) +{ + for (; *s != '\0'; s++) + x += ffplot_char(plot, color, ft, *s, x, y); + return x; +} + +/* + * Draw a center aligned string without wrapping it. + */ +size_t +ffplot_text_center(struct ffplot *plot, struct ffcolor *color, struct font *ft, + char *s, int x, int y) +{ + x -= font_strlen(ft, s) / 2; + return ffplot_text_left(plot, color, ft, s, x, y); +} + +/* + * Draw a right aligned string without wrapping it. + */ +size_t +ffplot_text_right(struct ffplot *plot, struct ffcolor *color, struct font *ft, + char *s, int x, int y) +{ + x -= font_strlen(ft, s); + return ffplot_text_left(plot, color, ft, s, x, y); +} + +void +ffplot_print(FILE *fp, struct ffplot *plot) +{ + uint32_t w, h; + + w = htonl(plot->w); + h = htonl(plot->h); + + fputs("ffplot", stdout); + fwrite(&w, sizeof(w), 1, fp); + fwrite(&h, sizeof(h), 1, fp); + fwrite(plot->buf, plot->w * plot->h, sizeof(*plot->buf), fp); +} DIR diff --git a/src/ffplot.h b/src/ffplot.h @@ -0,0 +1,34 @@ +#ifndef FFPLOT_H +#define FFPLOT_H + +#include <stdio.h> +#include <stddef.h> + +#include "font.h" + +struct ffcolor { + uint16_t red; + uint16_t green; + uint16_t blue; + uint16_t alpha; +}; + +struct ffplot { + int w; /* width */ + int h; /* height */ + int x; /* x offset */ + int y; /* y offset */ + struct ffcolor *buf; +}; + +/**/ +void ffplot_pixel (struct ffplot *, struct ffcolor *, int, int); +void ffplot_rectangle (struct ffplot *, struct ffcolor *, int, int, int, int); +void ffplot_line (struct ffplot *, struct ffcolor *, int, int, int, int); +int ffplot_char (struct ffplot *, struct ffcolor *, struct font *, char, int, int); +size_t ffplot_text_left (struct ffplot *, struct ffcolor *, struct font *, char *, int, int); +size_t ffplot_text_center (struct ffplot *, struct ffcolor *, struct font *, char *, int, int); +size_t ffplot_text_right (struct ffplot *, struct ffcolor *, struct font *, char *, int, int); +void ffplot_print (FILE *, struct ffplot *); + +#endif DIR diff --git a/src/font.c b/src/font.c @@ -0,0 +1,20 @@ +#include "font.h" + +#include <string.h> + +size_t +font_width(struct font *ft, int c) +{ + return strlen(ft->glyph[c]) / ft->height; +} + +size_t +font_strlen(struct font *ft, char *s) +{ + size_t len; + + len = 0; + for (; *s != '\0'; s++) + len += font_width(ft, *s); + return len; +} DIR diff --git a/src/font.h b/src/font.h @@ -0,0 +1,22 @@ +#ifndef FONT_H +#define FONT_H + +#include <stddef.h> + +/* + * Bitmapped font saved as a '_' and 'X' pattern in a C source file. + */ +struct font { + int height; /* The width is variable. */ + char *glyph[128]; /* 0: end, 1: off, 2: on. */ +}; + +struct font font13; +struct font font7; +struct font font8; + +/**/ +size_t font_width (struct font *, int); +size_t font_strlen (struct font *, char *); + +#endif DIR diff --git a/src/font13.c b/src/font13.c @@ -0,0 +1,1576 @@ +#include "font.h" + +#define C(x) static char glyph_##x[] +#define _ 2 +#define X 3 + +C(error) = { + _,_,_,_,_, + X,X,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,X, + _,_,_,_,_, +0}; + +C(space) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(bang) = { + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(double) = { + _,_,_,_,_, + _,X,_,X,_, + _,X,_,X,_, + _,X,_,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(hash) = { + _,_,_,_,_, + _,X,_,X,_, + _,X,_,X,_, + X,X,X,X,X, + _,X,_,X,_, + _,X,_,X,_, + _,X,_,X,_, + X,X,X,X,X, + _,X,_,X,_, + _,X,_,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(dollar) = { + _,_,X,_,_, + _,X,X,X,_, + X,_,X,_,X, + X,_,X,_,_, + X,_,X,_,_, + _,X,X,X,_, + _,_,X,_,X, + _,_,X,_,X, + X,_,X,_,X, + _,X,X,X,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(percent) = { + _,_,_,_,_, + X,X,_,_,X, + X,X,_,_,X, + _,_,_,X,_, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + _,X,_,_,_, + X,_,_,X,X, + X,_,_,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(amp) = { + _,_,_,_,_, + _,_,X,_,_, + _,X,_,X,_, + _,X,_,X,_, + _,_,X,_,_, + _,X,X,_,X, + X,_,_,X,_, + X,_,_,X,_, + X,_,_,X,_, + _,X,X,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(single) = { + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(l_round) = { + _,_,_,_,_, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,_,X,_,_, + _,_,_,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(r_round) = { + _,_,_,_,_, + _,X,_,_,_, + _,_,X,_,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(asterisk) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + X,_,X,_,X, + _,X,X,X,_, + _,_,X,_,_, + _,X,X,X,_, + X,_,X,_,X, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(plus) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + X,X,X,X,X, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(coma) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,_,_,_, + _,_,_,_,_, +0}; + +C(minus) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(dot) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(slash) = { + _,_,_,_,_, + _,_,_,_,X, + _,_,_,_,X, + _,_,_,X,_, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + _,X,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(0) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,X,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(1) = { + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(2) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,X, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + X,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(3) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + _,_,_,_,X, + _,_,_,_,X, + _,X,X,X,_, + _,_,_,_,X, + _,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(4) = { + _,_,_,_,_, + _,_,_,_,X, + _,_,_,X,X, + _,_,X,_,X, + _,X,_,_,X, + X,_,_,_,X, + X,X,X,X,X, + _,_,_,_,X, + _,_,_,_,X, + _,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(5) = { + _,_,_,_,_, + X,X,X,X,X, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,_, + _,_,_,_,X, + _,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(6) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(7) = { + _,_,_,_,_, + X,X,X,X,X, + _,_,_,_,X, + _,_,_,_,X, + _,_,_,X,_, + _,_,_,X,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(8) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(9) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,X, + _,_,_,_,X, + _,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(column) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(semicolumn) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,_,_,_, + _,_,_,_,_, +0}; + +C(l_angle) = { + _,_,_,_,_, + _,_,_,_,X, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + X,_,_,_,_, + _,X,_,_,_, + _,_,X,_,_, + _,_,_,X,_, + _,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(equal) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(r_angle) = { + _,_,_,_,_, + X,_,_,_,_, + _,X,_,_,_, + _,_,X,_,_, + _,_,_,X,_, + _,_,_,_,X, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + X,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(question) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,X, + _,_,_,X,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(at) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,X,X,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,X,X, + X,_,_,_,_, + _,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(A) = { + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,_,X,_, + _,X,_,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(B) = { + _,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(C) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(D) = { + _,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(E) = { + _,_,_,_,_, + X,X,X,X,X, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(F) = { + _,_,_,_,_, + X,X,X,X,X, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(G) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(H) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(I) = { + _,_,_,_,_, + _,X,X,X,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(J) = { + _,_,_,_,_, + _,X,X,X,X, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + X,_,_,X,_, + _,X,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(K) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,X,_, + X,_,X,_,_, + X,X,_,_,_, + X,_,X,_,_, + X,_,_,X,_, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(L) = { + _,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(M) = { + _,_,_,_,_, + X,_,_,_,X, + X,X,_,X,X, + X,X,_,X,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(N) = { + _,_,_,_,_, + X,_,_,_,X, + X,X,_,_,X, + X,X,_,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,_,X,X, + X,_,_,X,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(O) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(P) = { + _,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(Q) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,X,_,X, + _,X,X,X,_, + _,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(R) = { + _,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,_, + X,_,X,_,_, + X,_,_,X,_, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(S) = { + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,_, + X,_,_,_,_, + _,X,X,X,_, + _,_,_,_,X, + _,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(T) = { + _,_,_,_,_, + X,X,X,X,X, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(U) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(V) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,_,X,_, + _,X,_,X,_, + _,X,_,X,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(W) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,X,_,X,X, + X,X,_,X,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(X) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + _,X,_,X,_, + _,X,_,X,_, + _,_,X,_,_, + _,X,_,X,_, + _,X,_,X,_, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(Y) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + _,X,_,X,_, + _,X,_,X,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(Z) = { + _,_,_,_,_, + X,X,X,X,X, + _,_,_,_,X, + _,_,_,X,_, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + _,X,_,_,_, + X,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(l_square) = { + _,_,_,_,_, + _,X,X,X,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(backsl) = { + _,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,_,X,_,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,_,X, + _,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(r_square) = { + _,_,_,_,_, + _,X,X,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(hat) = { + _,_,_,_,_, + _,_,X,_,_, + _,X,_,X,_, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(underscore) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +X ,X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(backtilt) = { + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(a) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,_, + _,_,_,_,X, + _,_,_,_,X, + _,X,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(b) = { + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(c) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(d) = { + _,_,_,_,X, + _,_,_,_,X, + _,_,_,_,X, + _,X,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(e) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,X, + X,_,_,_,_, + X,_,_,_,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(f) = { + _,_,X,X,X, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + X,X,X,X,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(g) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,X, + _,_,_,_,X, + _,_,_,_,X, + X,X,X,X,_, +0}; + +C(h) = { + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(i) = { + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,X,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(j) = { + _,_,_,X,_, + _,_,_,X,_, + _,_,_,_,_, + _,_,X,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + X,_,_,X,_, + _,X,X,_,_, +0}; + +C(k) = { + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,X, + X,_,_,X,_, + X,_,X,_,_, + X,X,_,_,_, + X,_,X,_,_, + X,_,_,X,_, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(l) = { + _,X,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(m) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,_, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(n) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(o) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(p) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,X,X,X,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, +0}; + +C(q) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,X, + _,_,_,_,X, + _,_,_,_,X, + _,_,_,_,X, +0}; + +C(r) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,_,X,X,X, + X,X,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + X,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(s) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,X,X,X, + X,_,_,_,_, + X,_,_,_,_, + _,X,X,X,_, + _,_,_,_,X, + _,_,_,_,X, + X,X,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(t) = { + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + X,X,X,X,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,_,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(u) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(v) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,_,X,_, + _,X,_,X,_, + _,X,_,X,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(w) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,X,_,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(x) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + _,X,_,X,_, + _,_,X,_,_, + _,X,_,X,_, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(y) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,X,X,X,X, + _,_,_,_,X, + _,_,_,_,X, + X,X,X,X,_, +0}; + +C(z) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,X, + _,_,_,_,X, + _,_,_,X,_, + _,_,X,_,_, + _,X,_,_,_, + X,_,_,_,_, + X,X,X,X,X, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(l_curly) = { + _,_,_,_,_, + _,_,X,X,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + X,_,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,X,_,_,_, + _,_,X,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(pipe) = { + _,_,_,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(r_curly) = { + _,_,_,_,_, + _,X,X,_,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,_,X, + _,_,_,X,_, + _,_,_,X,_, + _,_,_,X,_, + _,X,X,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(tilde) = { + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,X,_,_,X, + X,_,X,_,X, + X,_,_,X,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +struct font font13 = { 13, { + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_space, glyph_bang, glyph_double, glyph_hash, + glyph_dollar, glyph_percent, glyph_amp, glyph_single, + glyph_l_round, glyph_r_round, glyph_asterisk, glyph_plus, + glyph_coma, glyph_minus, glyph_dot, glyph_slash, + glyph_0, glyph_1, glyph_2, glyph_3, + glyph_4, glyph_5, glyph_6, glyph_7, + glyph_8, glyph_9, glyph_column, glyph_semicolumn, + glyph_l_angle, glyph_equal, glyph_r_angle, glyph_question, + glyph_at, glyph_A, glyph_B, glyph_C, + glyph_D, glyph_E, glyph_F, glyph_G, + glyph_H, glyph_I, glyph_J, glyph_K, + glyph_L, glyph_M, glyph_N, glyph_O, + glyph_P, glyph_Q, glyph_R, glyph_S, + glyph_T, glyph_U, glyph_V, glyph_W, + glyph_X, glyph_Y, glyph_Z, glyph_l_square, + glyph_backsl, glyph_r_square, glyph_hat, glyph_underscore, + glyph_backtilt, glyph_a, glyph_b, glyph_c, + glyph_d, glyph_e, glyph_f, glyph_g, + glyph_h, glyph_i, glyph_j, glyph_k, + glyph_l, glyph_m, glyph_n, glyph_o, + glyph_p, glyph_q, glyph_r, glyph_s, + glyph_t, glyph_u, glyph_v, glyph_w, + glyph_x, glyph_y, glyph_z, glyph_l_curly, + glyph_pipe, glyph_r_curly, glyph_tilde, glyph_error +} }; DIR diff --git a/src/font7.c b/src/font7.c @@ -0,0 +1,743 @@ +#include "font.h" + +#define C(x) static char glyph_##x[] +#define _ 2 +#define X 3 + +C(err) = { + X,X,X,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,X,X,X, +0}; + +C(A) = { + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + X,X,X,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(B) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,X,X,_, + X,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(C) = { + _,_,_,_, + _,X,X,X, + X,_,_,_, + X,_,_,_, + X,_,_,_, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(D) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(E) = { + _,_,_,_, + X,X,X,X, + X,_,_,_, + X,X,X,_, + X,_,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(F) = { + _,_,_,_, + X,X,X,X, + X,_,_,_, + X,X,X,_, + X,_,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(G) = { + _,_,_,_, + _,X,X,X, + X,_,_,_, + X,_,X,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(H) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,X,X,X, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(I) = { + _,_,_, + X,X,X, + _,X,_, + _,X,_, + _,X,_, + X,X,X, + _,_,_, + _,_,_, +0}; + +C(J) = { + _,_,_,_, + _,X,X,X, + _,_,X,_, + _,_,X,_, + _,_,X,_, + X,X,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(K) = { + _,_,_,_, + X,_,_,X, + X,_,X,_, + X,X,_,_, + X,_,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(L) = { + _,_,_,_, + X,_,_,_, + X,_,_,_, + X,_,_,_, + X,_,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(M) = { + _,_,_,_,_, + X,_,_,_,X, + X,X,_,X,X, + X,_,X,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(N) = { + _,_,_,_, + X,_,_,X, + X,X,_,X, + X,X,X,X, + X,_,X,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(O) = { + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(P) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,X,X,_, + X,_,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(Q) = { + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,X,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(R) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,X,X,_, + X,_,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(S) = { + _,_,_,_, + _,X,X,X, + X,_,_,_, + _,X,X,_, + _,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(T) = { + _,_,_,_, + X,X,X,X, + _,X,X,_, + _,X,X,_, + _,X,X,_, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(U) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(V) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,X,_, + X,_,X,_, + X,X,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(W) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,X,_,X,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(X) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(Y) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,X,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(Z) = { + _,_,_,_, + X,X,X,X, + _,_,_,X, + _,X,X,_, + X,_,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(a) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(b) = { + X,_,_,_, + X,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(c) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,_, + X,_,_,_, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(d) = { + _,_,_,X, + _,_,_,X, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(e) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,X,X,X, + X,_,_,_, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(f) = { + _,X,X, + X,_,_, + X,_,_, + X,X,_, + X,_,_, + X,_,_, + _,_,_, + _,_,_, +0}; + +C(g) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,X,X,_, +0}; + +C(h) = { + X,_,_,_, + X,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(i) = { + _,X,_, + _,_,_, + X,X,_, + _,X,_, + _,X,_, + _,X,X, + _,_,_, + _,_,_, +0}; + +C(j) = { + _,X,_, + _,_,_, + X,X,_, + _,X,_, + _,X,_, + _,X,_, + _,X,_, + X,_,_, +0}; + +C(k) = { + X,_,_,_, + X,_,_,_, + X,_,_,X, + X,_,X,_, + X,X,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(l) = { + X,X,_, + _,X,_, + _,X,_, + _,X,_, + _,X,_, + X,X,X, + _,_,_, + _,_,_, +0}; + +C(m) = { + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,_, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(n) = { + _,_,_,_, + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(o) = { + _,_,_,_, + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(p) = { + _,_,_,_, + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,X,X,_, + X,_,_,_, + X,_,_,_, +0}; + +C(q) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,_,_,X, +0}; + +C(r) = { + _,_,_,_, + _,_,_,_, + X,_,X,X, + X,X,_,_, + X,_,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(s) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,X,_,_, + _,_,X,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(t) = { + X,_,_, + X,_,_, + X,X,X, + X,_,_, + X,_,_, + _,X,X, + _,_,_, + _,_,_, +0}; + +C(u) = { + _,_,_,_, + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(v) = { + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + _,X,_,X,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(w) = { + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,X,_,X,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(x) = { + _,_,_,_, + _,_,_,_, + X,_,_,X, + _,X,X,_, + _,X,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(y) = { + _,_,_,_, + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,X,X,_, +0}; + +C(z) = { + _,_,_,_, + _,_,_,_, + X,X,X,X, + _,_,X,_, + _,X,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(0) = { + _,X,X,_, + X,_,_,X, + X,_,X,X, + X,X,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(1) = { + _,X,_, + X,X,_, + _,X,_, + _,X,_, + _,X,_, + X,X,X, + _,_,_, + _,_,_, +0}; + +C(2) = { + _,X,X,_, + X,_,_,X, + _,_,_,X, + _,_,X,_, + _,X,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(3) = { + X,X,X,_, + _,_,_,X, + _,X,X,X, + _,_,_,X, + _,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(4) = { + _,_,X,X, + _,X,_,X, + X,_,_,X, + X,X,X,X, + _,_,_,X, + _,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(5) = { + X,X,X,X, + X,_,_,_, + X,X,X,_, + _,_,_,X, + _,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(6) = { + _,X,X,_, + X,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(7) = { + X,X,X,X, + _,_,_,X, + _,_,X,_, + _,_,X,_, + _,X,_,_, + _,X,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(8) = { + _,X,X,_, + X,_,_,X, + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(9) = { + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(space) = { + _,_,_, + _,_,_, + _,_,_, + _,_,_, + _,_,_, + _,_,_, + _,_,_, +0}; + +struct font font7 = { 8, { + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_space, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_0, glyph_1, glyph_2, glyph_3, + glyph_4, glyph_5, glyph_6, glyph_7, + glyph_8, glyph_9, glyph_err, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_A, glyph_B, glyph_C, + glyph_D, glyph_E, glyph_F, glyph_G, + glyph_H, glyph_I, glyph_J, glyph_K, + glyph_L, glyph_M, glyph_N, glyph_O, + glyph_P, glyph_Q, glyph_R, glyph_S, + glyph_T, glyph_U, glyph_V, glyph_W, + glyph_X, glyph_Y, glyph_Z, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err, + glyph_err, glyph_a, glyph_b, glyph_c, + glyph_d, glyph_e, glyph_f, glyph_g, + glyph_h, glyph_i, glyph_j, glyph_k, + glyph_l, glyph_m, glyph_n, glyph_o, + glyph_p, glyph_q, glyph_r, glyph_s, + glyph_t, glyph_u, glyph_v, glyph_w, + glyph_x, glyph_y, glyph_z, glyph_err, + glyph_err, glyph_err, glyph_err, glyph_err +} }; DIR diff --git a/src/font8.c b/src/font8.c @@ -0,0 +1,743 @@ +#include "font.h" + +#define C(x) static char glyph_##x[] +#define _ 2 +#define X 3 + +C(error) = { + X,X,X,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,X,X,X, +0}; + +C(A) = { + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + X,X,X,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(B) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,X,X,_, + X,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(C) = { + _,_,_,_, + _,X,X,X, + X,_,_,_, + X,_,_,_, + X,_,_,_, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(D) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(E) = { + _,_,_,_, + X,X,X,X, + X,_,_,_, + X,X,X,_, + X,_,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(F) = { + _,_,_,_, + X,X,X,X, + X,_,_,_, + X,X,X,_, + X,_,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(G) = { + _,_,_,_, + _,X,X,X, + X,_,_,_, + X,_,X,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(H) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,X,X,X, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(I) = { + _,_,_, + X,X,X, + _,X,_, + _,X,_, + _,X,_, + X,X,X, + _,_,_, + _,_,_, +0}; + +C(J) = { + _,_,_,_, + _,X,X,X, + _,_,X,_, + _,_,X,_, + _,_,X,_, + X,X,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(K) = { + _,_,_,_, + X,_,_,X, + X,_,X,_, + X,X,_,_, + X,_,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(L) = { + _,_,_,_, + X,_,_,_, + X,_,_,_, + X,_,_,_, + X,_,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(M) = { + _,_,_,_,_, + X,_,_,_,X, + X,X,_,X,X, + X,_,X,_,X, + X,_,_,_,X, + X,_,_,_,X, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(N) = { + _,_,_,_, + X,_,_,X, + X,X,_,X, + X,X,X,X, + X,_,X,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(O) = { + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(P) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,X,X,_, + X,_,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(Q) = { + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,X,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(R) = { + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,X,X,_, + X,_,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(S) = { + _,_,_,_, + _,X,X,X, + X,_,_,_, + _,X,X,_, + _,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(T) = { + _,_,_,_, + X,X,X,X, + _,X,X,_, + _,X,X,_, + _,X,X,_, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(U) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(V) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,X,_, + X,_,X,_, + X,X,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(W) = { + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,X,_,X,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(X) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(Y) = { + _,_,_,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,X,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(Z) = { + _,_,_,_, + X,X,X,X, + _,_,_,X, + _,X,X,_, + X,_,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(a) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(b) = { + X,_,_,_, + X,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(c) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,_, + X,_,_,_, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(d) = { + _,_,_,X, + _,_,_,X, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(e) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,X,X,X, + X,_,_,_, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(f) = { + _,X,X, + X,_,_, + X,_,_, + X,X,_, + X,_,_, + X,_,_, + _,_,_, + _,_,_, +0}; + +C(g) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,X,X,_, +0}; + +C(h) = { + X,_,_,_, + X,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(i) = { + _,X,_, + _,_,_, + X,X,_, + _,X,_, + _,X,_, + _,X,X, + _,_,_, + _,_,_, +0}; + +C(j) = { + _,X,_, + _,_,_, + X,X,_, + _,X,_, + _,X,_, + _,X,_, + _,X,_, + X,_,_, +0}; + +C(k) = { + X,_,_,_, + X,_,_,_, + X,_,_,X, + X,_,X,_, + X,X,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(l) = { + X,X,_, + _,X,_, + _,X,_, + _,X,_, + _,X,_, + X,X,X, + _,_,_, + _,_,_, +0}; + +C(m) = { + _,_,_,_,_, + _,_,_,_,_, + X,X,X,X,_, + X,_,X,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(n) = { + _,_,_,_, + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(o) = { + _,_,_,_, + _,_,_,_, + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(p) = { + _,_,_,_, + _,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + X,X,X,_, + X,_,_,_, + X,_,_,_, +0}; + +C(q) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,_,_,X, +0}; + +C(r) = { + _,_,_,_, + _,_,_,_, + X,_,X,X, + X,X,_,_, + X,_,_,_, + X,_,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(s) = { + _,_,_,_, + _,_,_,_, + _,X,X,X, + X,X,_,_, + _,_,X,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(t) = { + X,_,_, + X,_,_, + X,X,X, + X,_,_, + X,_,_, + _,X,X, + _,_,_, + _,_,_, +0}; + +C(u) = { + _,_,_,_, + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(v) = { + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,_,_,X, + _,X,_,X,_, + _,_,X,_,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(w) = { + _,_,_,_,_, + _,_,_,_,_, + X,_,_,_,X, + X,_,X,_,X, + X,_,X,_,X, + _,X,_,X,_, + _,_,_,_,_, + _,_,_,_,_, +0}; + +C(x) = { + _,_,_,_, + _,_,_,_, + X,_,_,X, + _,X,X,_, + _,X,X,_, + X,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(y) = { + _,_,_,_, + _,_,_,_, + X,_,_,X, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,X,X,_, +0}; + +C(z) = { + _,_,_,_, + _,_,_,_, + X,X,X,X, + _,_,X,_, + _,X,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(0) = { + _,X,X,_, + X,_,_,X, + X,_,X,X, + X,X,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(1) = { + _,X,_, + X,X,_, + _,X,_, + _,X,_, + _,X,_, + X,X,X, + _,_,_, + _,_,_, +0}; + +C(2) = { + _,X,X,_, + X,_,_,X, + _,_,_,X, + _,_,X,_, + _,X,_,_, + X,X,X,X, + _,_,_,_, + _,_,_,_, +0}; + +C(3) = { + X,X,X,_, + _,_,_,X, + _,X,X,X, + _,_,_,X, + _,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(4) = { + _,_,X,X, + _,X,_,X, + X,_,_,X, + X,X,X,X, + _,_,_,X, + _,_,_,X, + _,_,_,_, + _,_,_,_, +0}; + +C(5) = { + X,X,X,X, + X,_,_,_, + X,X,X,_, + _,_,_,X, + _,_,_,X, + X,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(6) = { + _,X,X,_, + X,_,_,_, + X,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(7) = { + X,X,X,X, + _,_,_,X, + _,_,X,_, + _,_,X,_, + _,X,_,_, + _,X,_,_, + _,_,_,_, + _,_,_,_, +0}; + +C(8) = { + _,X,X,_, + X,_,_,X, + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(9) = { + _,X,X,_, + X,_,_,X, + X,_,_,X, + _,X,X,X, + _,_,_,X, + _,X,X,_, + _,_,_,_, + _,_,_,_, +0}; + +C(space) = { + _,_,_, + _,_,_, + _,_,_, + _,_,_, + _,_,_, + _,_,_, + _,_,_, +0}; + +struct font font8 = { 8, { + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_space, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_0, glyph_1, glyph_2, glyph_3, + glyph_4, glyph_5, glyph_6, glyph_7, + glyph_8, glyph_9, glyph_error, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_A, glyph_B, glyph_C, + glyph_D, glyph_E, glyph_F, glyph_G, + glyph_H, glyph_I, glyph_J, glyph_K, + glyph_L, glyph_M, glyph_N, glyph_O, + glyph_P, glyph_Q, glyph_R, glyph_S, + glyph_T, glyph_U, glyph_V, glyph_W, + glyph_X, glyph_Y, glyph_Z, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error, + glyph_error, glyph_a, glyph_b, glyph_c, + glyph_d, glyph_e, glyph_f, glyph_g, + glyph_h, glyph_i, glyph_j, glyph_k, + glyph_l, glyph_m, glyph_n, glyph_o, + glyph_p, glyph_q, glyph_r, glyph_s, + glyph_t, glyph_u, glyph_v, glyph_w, + glyph_x, glyph_y, glyph_z, glyph_error, + glyph_error, glyph_error, glyph_error, glyph_error +} }; DIR diff --git a/src/log.c b/src/log.c @@ -0,0 +1,99 @@ +#include "log.h" + +#include <string.h> + +/* + * log.c - log to standard error according to the log level + * + * Instead of logging to syslog, delegate logging to a separate + * tool, such as FreeBSD's daemon(8), POSIX's logger(1). + * + * log_init() sets the log level to the "LOG" environment variable + * if set, or to 4 (log down to info included) otherwise. + */ + +#include <errno.h> +#include <stdlib.h> +#include <stdio.h> + +#define LOG_DEFAULT 3 + +int log_level = -1; + +void +vlogf(int exitcode, int level, char const *flag, char const *fmt, va_list va) +{ + char *env; + + if (log_level == -1) { + env = getenv("LOG"); + log_level = env ? atoi(env) : 0; + log_level = log_level > 0 ? log_level : LOG_DEFAULT; + } + + if (log_level < level) + goto end; + + fprintf(stderr, "%s: ", flag); + vfprintf(stderr, fmt, va); + + if (errno) + fprintf(stderr, ": %s", strerror(errno)); + errno = 0; + + fprintf(stderr, "\n"); + fflush(stderr); +end: + if (exitcode) + exit(exitcode); +} + +void +fatal(int exitcode, char const *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vlogf(exitcode, 0, "fatal", fmt, va); + va_end(va); +} + +void +error(char const *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vlogf(0, 1, "error", fmt, va); + va_end(va); +} + +void +warn(char const *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vlogf(0, 2, "warn", fmt, va); + va_end(va); +} + +void +info(char const *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vlogf(0, 3, "info", fmt, va); + va_end(va); +} + +void +debug(char const *fmt, ...) +{ + va_list va; + + va_start(va, fmt); + vlogf(0, 4, "debug", fmt, va); + va_end(va); +} DIR diff --git a/src/log.h b/src/log.h @@ -0,0 +1,15 @@ +#ifndef LOG_H +#define LOG_H + +#include <stdarg.h> + +/**/ +int log_level; +void vlogf (int, int, char const *, char const *, va_list); +void fatal (int, char const *, ...); +void error (char const *, ...); +void warn (char const *, ...); +void info (char const *, ...); +void debug (char const *, ...); + +#endif DIR diff --git a/src/scale.c b/src/scale.c @@ -0,0 +1,141 @@ +#include "scale.h" + +#include <stddef.h> +#include <time.h> + +#include "tool.h" +#include "log.h" + +/* + * - <max ^ + * - | Translate the coordinates between double values + * - <val szy and height in the plot of <row> rows. + * - | + * - <min v + */ +int +scale_ypos(double val, double min, double max, int szy) +{ + return szy * (val - min) / (max - min); +} + +/* + * <---- szx ----> Translate the coordinates between the time + * range and position in the plot of <col> cols. + * t1 t t2 + * | . . | . . | + */ +int +scale_xpos(time_t t, time_t t1, time_t t2, int szx) +{ + return szx * (t - t1) / (t2 - t1); +} + +static void +scale_minmax(struct vlist *vl, int ncol, + time_t *tmin, time_t *tmax, + double *vmin, double *vmax) +{ + double *v; + time_t *t; + size_t n; + + *vmin = *vmax = 0; + *tmin = *tmax = *vl->t; + + for (; ncol > 0; ncol--, vl++) { + for (t = vl->t, v = vl->v, n = vl->n; n > 0; t++, v++, n--) { + if (*v < *vmin) *vmin = *v; + if (*v > *vmax) *vmax = *v; + if (*t < *tmin) *tmin = *t; + if (*t > *tmax) *tmax = *t; + } + } + + if (*tmin == *tmax) + fatal(1, "invalid time scale: min=%lld max=%lld", *tmin, *tmax); +} + +static time_t +scale_tstep(time_t min, time_t max, int density) +{ + time_t dt, *s, scale[] = { + 1, 5, 2, 10, 20, 30, 60, 60*2, 60*5, 60*10, 60*20, 60*30, 3600, + 3600*2, 3600*5, 3600*10, 3600*18, 3600*24, 3600*24*2, + 3600*24*5, 3600*24*10, 3600*24*20, 3600*24*30, 3600*24*50, + 3600*24*100, 3600*24*365, 0 + }; + + dt = max - min; + for (s = scale; s < scale + LEN(scale); s++) + if (dt < *s * density) + return *s; + return 0; +} + +static double +scale_vstep(double min, double max, int density) +{ + double dv, d, *s, scale[] = { 1, 2, 3, 5 }; + + dv = max - min; + + if (dv > 1) + for (d = 1; d != 0; d *= 10) + for (s = scale; s < scale + LEN(scale); s++) + if (dv < *s * d * density) + return *s * d; + if (dv < 1) + for (d = 1; d != 0; d *= 10) + for (s = scale + LEN(scale) - 1; s >= scale; s--) + if (dv > *s / d * density / 2) + return *s / d; + return 0; +} + +/* + * Adjust the vertical scale so that everything fits, with nice + * scale values. + */ +void +scale_vminmax(double *min, double *max, int row) +{ + double unit, range, mi; + + range = *max - *min; + unit = 1; + + /* Zoom until it fills the canvas. */ + for (; (row - 1) * unit > range; unit /= 10) + continue; + + /* Dezoom until it fits the canvas. */ + for (; (row - 1) * unit < range; unit *= 10) + continue; + + /* Fine tune. */ + if ((row - 1) * unit / 5 > range) + unit /= 5; + if ((row - 1) * unit / 4 > range) + unit /= 4; + if ((row - 1) * unit / 2 > range) + unit /= 2; + + /* Align the minimum (and the zero). */ + for (mi = 0; mi > *min - unit; mi -= unit) + continue; + + /* Update the displayed minimal and maximal. */ + *min = mi; + *max = mi + unit * row; +} + +void +scale(struct vlist *vl, int ncol, + time_t *tmin, time_t *tmax, time_t *tstep, + double *vmin, double *vmax, double *vstep) +{ + scale_minmax(vl, ncol, tmin, tmax, vmin, vmax); + *tstep = scale_tstep(*tmin, *tmax, SCALE_X); + *vstep = scale_vstep(*vmin, *vmax, SCALE_Y); +} DIR diff --git a/src/scale.h b/src/scale.h @@ -0,0 +1,18 @@ +#ifndef SCALE_H +#define SCALE_H + +#include <stddef.h> +#include <time.h> + +#include "csv.h" + +#define SCALE_X 7 /* nb of values on x axis */ +#define SCALE_Y 7 /* nb of values on y axis */ + +/**/ +int scale_ypos (double, double, double, int); +int scale_xpos (time_t, time_t, time_t, int); +void scale_vminmax (double *, double *, int); +void scale (struct vlist *, int, time_t *, time_t *, time_t *, double *, double *, double *); + +#endif DIR diff --git a/src/tool.c b/src/tool.c @@ -0,0 +1,103 @@ +#include "tool.h" + +#include <ctype.h> +#include <errno.h> +#include <limits.h> +#include <stdarg.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +size_t +strlcpy(char *buf, const char *str, size_t sz) +{ + size_t len, cpy; + + cpy = ((len = strlen(str)) > sz) ? (sz) : (len); + memcpy(buf, str, cpy); + buf[sz - 1] = '\0'; + return len; +} + +void +put3utf(long rune) +{ + putchar((char)(0xe0 | (0x0f & (rune >> 12)))); /* 1110xxxx */ + putchar((char)(0x80 | (0x3f & (rune >> 6)))); /* 10xxxxxx */ + putchar((char)(0x80 | (0x3f & (rune)))); /* 10xxxxxx */ +} + +char * +strsep(char **strp, const char *sep) +{ + char *s, *prev; + + if (*strp == NULL) + return NULL; + for (s = prev = *strp; strchr(sep, *s) == NULL; s++); + if (*s == '\0') { + *strp = NULL; + return prev; + } + *s = '\0'; + *strp = s + 1; + + return prev; +} + +void +estriplf(char *line) +{ + char *lf; + + if ((lf = strchr(line, '\n')) == NULL || lf[1] != '\0') + fputs("invalid input\n", stderr), exit(1); + *lf = '\0'; +} + +double +eatof(char *str) +{ + char *s; + + for (s = str; *s != '\0'; s++) + if (!isdigit(*s) && *s != '-' && *s != '.') + fputs("invalid float format\n", stderr), exit(1); + return atof(str); +} + +long +eatol(char *str) +{ + char *s; + + for (s = str; *s != '\0'; s++) + if (!isdigit(*s) && *s != '-') + fputs("invalid number format\n", stderr), exit(1); + return atol(str); +} + +/* + * Set 'str' to a human-readable form of 'num' with always a width of 8 (+1 for + * the '\0' terminator). Buffer overflow is ensured not to happen due to the + * max size of a double. Return the exponent. + */ +int +humanize(char *str, double val) +{ + int exp, precision; + char label[] = { '\0', 'M', 'G', 'T', 'E' }; + + for (exp = 0; ABS(val) > 1000; exp++) + val /= 1000; + + precision = (ABS(val) < 10) ? 2 : (ABS(val) < 100) ? 1 : 0; + precision += (exp == 0); + + snprintf(str, 9, "%+.*f %c", precision, val, label[exp]); + str[8] = '\0'; + if (val >= 0) + str[0] = ' '; + + return exp * 3; +} DIR diff --git a/src/tool.h b/src/tool.h @@ -0,0 +1,20 @@ +#ifndef TOOL_H +#define TOOL_H + +#include <stddef.h> + +#define LEN(x) (sizeof(x) / sizeof(*x)) +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +#define MIN(x, y) ((x) < (y) ? (x) : (y)) +#define ABS(x) ((x) < 0 ? -(x) : (x)) + +/**/ +size_t strlcpy (char *, const char *, size_t); +void put3utf (long); +char * strsep (char **, const char *); +void estriplf (char *); +double eatof (char *); +long eatol (char *); +int humanize (char *, double); + +#endif DIR diff --git a/util.c b/util.c @@ -1,103 +0,0 @@ -#include <ctype.h> -#include <errno.h> -#include <limits.h> -#include <stdarg.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> - -#include "def.h" - -size_t -strlcpy(char *buf, const char *str, size_t sz) -{ - size_t len, cpy; - - cpy = ((len = strlen(str)) > sz) ? (sz) : (len); - memcpy(buf, str, cpy); - buf[sz - 1] = '\0'; - return len; -} - -void -put3utf(long rune) -{ - putchar((char)(0xe0 | (0x0f & (rune >> 12)))); /* 1110xxxx */ - putchar((char)(0x80 | (0x3f & (rune >> 6)))); /* 10xxxxxx */ - putchar((char)(0x80 | (0x3f & (rune)))); /* 10xxxxxx */ -} - -char * -strsep(char **strp, const char *sep) -{ - char *s, *prev; - - if (*strp == NULL) - return NULL; - for (s = prev = *strp; strchr(sep, *s) == NULL; s++); - if (*s == '\0') { - *strp = NULL; - return prev; - } - *s = '\0'; - *strp = s + 1; - - return prev; -} - -void -estriplf(char *line) -{ - char *lf; - - if ((lf = strchr(line, '\n')) == NULL || lf[1] != '\0') - fputs("invalid input\n", stderr), exit(1); - *lf = '\0'; -} - -double -eatof(char *str) -{ - char *s; - - for (s = str; *s != '\0'; s++) - if (!isdigit(*s) && *s != '-' && *s != '.') - fputs("invalid float format\n", stderr), exit(1); - return atof(str); -} - -long -eatol(char *str) -{ - char *s; - - for (s = str; *s != '\0'; s++) - if (!isdigit(*s) && *s != '-') - fputs("invalid number format\n", stderr), exit(1); - return atol(str); -} - -/* - * Set 'str' to a human-readable form of 'num' with always a width of 8 (+1 for - * the '\0' terminator). Buffer overflow is ensured not to happen due to the - * max size of a double. Return the exponent. - */ -int -humanize(char *str, double val) -{ - int exp, precision; - char label[] = { '\0', 'M', 'G', 'T', 'E' }; - - for (exp = 0; ABS(val) > 1000; exp++) - val /= 1000; - - precision = (ABS(val) < 10) ? 2 : (ABS(val) < 100) ? 1 : 0; - precision += (exp == 0); - - snprintf(str, 9, "%+.*f %c", precision, val, label[exp]); - str[8] = '\0'; - if (val >= 0) - str[0] = ' '; - - return exp * 3; -}