/*
** Display the character set represented by a font file on the level 1
** graphics screen.                                   FDC, 6/5/84
**
** Example of use of the routines readfont and gputc.
*/

#include <stdio.h>
#include <graph.h>

unsigned short fontbuf[FONTSIZE];	/* buffer for largest expected font */
char *fontname = "fmacs:font.visual";

main(argc, argv)
int argc;
char *argv[];
{
	int h, w, l, x, y;
	char *c = "The quick brown fox jumps over the lazy dog";

	if (argc > 2) {
		printf("usage: showfont fontfile\n");
		exit(1);
	}
	if (argc == 2) fontname = argv[1];
/*
** readfont returns the actual number of shorts read in to the buffer.
** h and w are set to the maximum character height and width respectively.
*/
	l = readfont(fontname, fontbuf, FONTSIZE, &h, &w);
	printf("Length = %d, maxheight = %d, maxwidth = %d\n", l, h, w);
	clear();			/* clear screen */
	colour(WHITE);			/* set colour to white */
	enable(ALL);			/* enable all planes */
	offset(0, 0);			/* origin at bottom left */
	h += 3; w += 3;			/* character cells size */
	for (y = 0; y < 16; y++)	/* 16 rows */
		for (x = 0; x < 16; x++) {	/* 16 columns */
			setpos((x+3)*w, (20-y)*h);	/* pixel pos of char */
			gputc(16*y+x);	/* graphics putc */
		}
	setpos(3*w, 24*h);
	while(*fontname) gputc(*fontname++);	/* display filename */
	setpos(0,0);
	while(*c) gputc(*c++);			/* display sample text */
}
