summaryrefslogtreecommitdiff
path: root/tools/loadrbf.c
diff options
context:
space:
mode:
Diffstat (limited to 'tools/loadrbf.c')
-rw-r--r--tools/loadrbf.c95
1 files changed, 95 insertions, 0 deletions
diff --git a/tools/loadrbf.c b/tools/loadrbf.c
new file mode 100644
index 0000000000..769195ea99
--- /dev/null
+++ b/tools/loadrbf.c
@@ -0,0 +1,95 @@
1/*
2 * Load an rbf font, store in incore format and display - or -
3 * Read an incore font and display it.
4 *
5 * If FONT defined, just link in FONT and display it
6 * otherwise, load av[1] and display it
7 *
8 * Copyright (c) 2002 by Greg Haerr <greg@censoft.com>
9 */
10#include <stdio.h>
11
12/* this should go in a library...*/
13#define DEBUGF printf
14#include "../firmware/loadfont.c"
15
16#ifdef FONT
17extern MWCFONT FONT;
18PMWCFONT pf = &FONT;
19#endif
20
21/* printf display an incore font*/
22void
23dispfont(PMWCFONT pf)
24{
25 int i;
26
27 printf("Font: '%s' %dx%d ", pf->name, pf->maxwidth, pf->height);
28 printf("0x%02x-0x%02x (size %d)\n", pf->firstchar,
29 pf->firstchar+pf->size, pf->size);
30 printf("\tDefault char 0x%02x ", pf->defaultchar);
31 printf("(%s width)\n", pf->width? "proportional": "fixed");
32
33 for (i=0; i<pf->size; ++i) {
34 int width = pf->width ? pf->width[i] : pf->maxwidth;
35 int height = pf->height;
36 int x;
37 int bitcount = 0;
38 MWIMAGEBITS *bits = pf->bits + (pf->offset? pf->offset[i]: (height * i));
39 MWIMAGEBITS bitvalue;
40
41 printf("\nCharacter 0x%02x (width %d)\n", i+pf->firstchar, width);
42 printf("+");
43 for (x=0; x<width; ++x) printf("-");
44 printf("+\n");
45
46 x = 0;
47 while (height > 0) {
48 if (x == 0) printf("|");
49
50 if (bitcount <= 0) {
51 bitcount = MWIMAGE_BITSPERIMAGE;
52 bitvalue = *bits++;
53 }
54
55 printf( MWIMAGE_TESTBIT(bitvalue)? "*": " ");
56
57 bitvalue = MWIMAGE_SHIFTBIT(bitvalue);
58 --bitcount;
59 if (++x == width) {
60 printf("|\n");
61 --height;
62 x = 0;
63 bitcount = 0;
64 }
65 }
66 printf("+");
67 for (x=0; x<width; ++x) printf("-");
68 printf("+\n");
69 }
70}
71
72int
73main(int ac, char **av)
74{
75 PMWCFONT pf;
76 MWCFONT font;
77#ifdef FONT
78 /* if FONT defined, just display linked-in font*/
79 extern MWCFONT FONT;
80 pf = &FONT;
81#else
82 if (ac != 2) {
83 printf("usage: loadrbf font.rbf\n");
84 exit(1);
85 }
86
87 pf = rbf_load_font(av[1], &font);
88 if (!pf) {
89 printf("loadrbf: read error: %s\n", av[1]);
90 exit(1);
91 }
92#endif
93 dispfont(pf);
94 return 0;
95}