1 /**
2  ** font2txt.c ---- make an ASCII dump of a font
3  **
4  ** Copyright (c) 1995 Csaba Biegl, 820 Stirrup Dr, Nashville, TN 37221
5  ** [e-mail: csaba@vuse.vanderbilt.edu]
6  **
7  ** This is a test/demo file of the GRX graphics library.
8  ** You can use GRX test/demo files as you want.
9  **
10  ** The GRX graphics library is free software; you can redistribute it
11  ** and/or modify it under some conditions; see the "copying.grx" file
12  ** for details.
13  **
14  ** This library is distributed in the hope that it will be useful,
15  ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16  ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17  **
18  **/
19 
20 #include <stdio.h>
21 #include "grx20.h"
22 
dumpf(GrFont * f)23 void dumpf(GrFont *f)
24 {
25 	int  chr,wdt,hgt,xpos,ypos;
26 	char far *bmp;
27 	hgt = f->h.height;
28 	for(chr = f->h.minchar; chr < (f->h.minchar + f->h.numchars); chr++) {
29 	    wdt = GrFontCharWidth(f,chr);
30 	    bmp = GrFontCharBitmap(f,chr);
31 	    printf("char '%c', code = 0x%04x\n",chr,chr);
32 	    for(ypos = 0; ypos < hgt; ypos++) {
33 		for(xpos = 0; xpos < wdt; xpos++) {
34 		    putchar((bmp[xpos >> 3] & (0x80 >> (xpos & 7))) ? '#' : '.');
35 		}
36 		putchar('\n');
37 		bmp += ((wdt + 7) >> 3);
38 	    }
39 	    putchar('\n');
40 	}
41 }
42 
main()43 int main()
44 {
45 	dumpf(GrLoadFont("pc8x16"));
46 	dumpf(GrBuildConvertedFont(
47 	    &GrDefaultFont,
48 	    (GR_FONTCVT_SKIPCHARS | GR_FONTCVT_RESIZE | GR_FONTCVT_PROPORTION),
49 	    10,
50 	    20,
51 	    ' ',
52 	    'z'
53 	));
54 	return(0);
55 }
56 
57