/*
 *	Checkfont: display all chars offset by their horizontal offsets.
 *	Check visually that the left hand edges line up.
 *
 *	If a char is too far to the right, it will not be in contact with the
 *	reference line.  If it is too far to the left, the reference line will
 *	be broken because it is xor-ed in.
 */

#include <stdio.h>
#include "term_font.h"

main()
{
	register int i, j;
	register struct term_font *f;
	int ch;


	for (i=0; term_font[i].tf_name != NULL; i++) {

		f = &term_font[i];

		/* select the font */
		printf("\033[%dm", f->tf_select);

		/* text cursor off */
		printf("\033[?31h");

		/* clear the screen */
		putchar('\f');
		
		for (j=33; j<=127; j++) {
			printf("\033[?32h");		/* bitmap mode on */
			printf("\033[%d;%dH",
				/* row */ 1 + (j&15)*f->tf_height,
				/* col */ 16 * (j>>4) - f->tf_hoffset[j-33]);
			printf("\033[?32l");		/* bitmap mode off */
			putchar(j);			/* the char */
		}

		/* draw reference lines (eor) */
		printf("\033[?32;7h");		/* bitmap mode on */
		for (j=16 * f->tf_height; j>0; j--) {
			printf("\033[%d;31H", j);
			/* word with MSB set, repeat 6 times */
			printf("%c00q5", '0' + (32768>>10));
		}
		printf("\033[?32l");		/* bitmap mode off */

		/* text cursor on */
		printf("\033[?31l");

		fflush(stdout);
		read(1, &ch, 1);	/* wait for keypress */
	}

	exit(0);
}
