Generate callgraph

This commit is contained in:
Michael Hayes
2011-08-27 01:46:08 +00:00
commit 513810e138
233 changed files with 22993 additions and 0 deletions
+18
View File
@@ -0,0 +1,18 @@
CC = gcc
CFLAGS = -O2 -Wall -W -g
FONTDEFS = $(wildcard *.txt)
FONTS = $(FONTDEFS:.txt=.h)
all: fontgen $(FONTS)
%.h: %.txt fontgen
./fontgen $(@:.h=) < $^ > $@
fontgen: fontgen.c
$(CC) $(CFLAGS) $< -o $@
clean:
-rm *.o fontgen
+123
View File
@@ -0,0 +1,123 @@
To create a new font, edit a font definition file with text editor.
Then run make. This will run fontgen to create a corresponding .h
file that can be included in a program.
Here's an example format for a font definition file. The first line
is a comment, the second line defines the width of each font
character, and the third light defines the height of each font
character. The following lines describe the font characters. The
. characters indicate an off pixel and other characters (such as @ or
#) indicate an on pixel. The first character is the corresponding
ASCII symbol.
The font does not need to be contiguous. Empty entries will be
displayed as blanks. However, they will take up memory.
# This is a demo font with only 3 characters.
width=5
height=7
.....
.....
.....
.....
.....
.....
.....
!
.@@..
.@@..
.@@..
.@@..
.@@..
.....
.@@..
"
.@.@.
.@.@.
.@.@.
.....
.....
.....
.....
The font entries with indices below 32 can be specified using \nnn
where nnn is the octal representation for the desired index. For
example, here are three faces assigned to indices 1, 2, 3. Note,
index 0 cannot be used since this marks the end of a string.
# Here's a demo font of three faces.
width=5
height=7
\001
.@.@.
.@.@.
.@.@.
.....
.....
@...@
.@@@.
\002
.....
@@.@@
@@.@@
.....
..@..
@...@
.@@@.
\003
.....
@@.@@
@@.@@
.....
..@..
.@@@.
@...@
The tricky bit is representing these codes in C. You have to do
something like tinygl_text ("\001\002\003"); An alternative, is to
assign these to printable characters. For example,
# Here's a demo font of three faces.
width=5
height=7
A
.@.@.
.@.@.
.@.@.
.....
.....
@...@
.@@@.
B
.....
@@.@@
@@.@@
.....
..@..
@...@
.@@@.
C
.....
@@.@@
@@.@@
.....
..@..
.@@@.
@...@
Then you can display them with tinygl_text ("ABC"); Unfortunately, the
font cannot display ABC as well. One solution is to load multiple
fonts and switch between them.
#include "faces5x7.h"
#include "font5x7_1.h"
tinygl_font_set (&faces5x7);
tinygl_text ("ABC");
tinygl_font_set (&font5x7_1);
tinygl_text ("ABC");
However, only one font can be active at a time.
+162
View File
@@ -0,0 +1,162 @@
/** @file font3x5_1.h
@author fontgen
@date 28 Sep 2010
@defgroup font3x5_1 This is a tiny 3x5 font with uppercase, digits, and symbols only.
M.P. Hayes 2 Sep 2010
*/
#ifndef FONT3X5_1_H_
#define FONT3X5_1_H_
#define FONT3X5_1_WIDTH 3
#define FONT3X5_1_HEIGHT 5
#define FONT3X5_1_OFFSET 32
#define FONT3X5_1_SIZE 59
#ifndef FONT_WIDTH
#define FONT_WIDTH 3
#endif
#ifndef FONT_HEIGHT
#define FONT_HEIGHT 5
#endif
#ifndef FONT_OFFSET
#define FONT_OFFSET 32
#endif
#ifndef FONT_SIZE_MAX
#define FONT_SIZE_MAX 59
#endif
#include "font.h"
static font_t font3x5_1 =
{
.flags = 1, /* (packed) */
.width = 3,
.height = 5,
.offset = 32,
.size = 59,
.bytes = 2,
.data =
{
/* */
0x00, 0x00,
/* ! */
0x92, 0x20,
/* " */
0xeb, 0x73,
/* # */
0x7d, 0x5f,
/* $ */
0xde, 0x3d,
/* % */
0xa5, 0x52,
/* & */
0xea, 0x7a,
/* ' */
0x14, 0x00,
/* ( */
0x4a, 0x22,
/* ) */
0x22, 0x29,
/* * */
0xba, 0x2e,
/* + */
0xd0, 0x05,
/* , */
0x00, 0x14,
/* - */
0xc0, 0x01,
/* . */
0x00, 0x20,
/* / */
0xa4, 0x12,
/* 0 */
0x6a, 0x2b,
/* 1 */
0x9a, 0x74,
/* 2 */
0xa3, 0x72,
/* 3 */
0xa3, 0x38,
/* 4 */
0xed, 0x49,
/* 5 */
0x8f, 0x38,
/* 6 */
0xce, 0x2a,
/* 7 */
0xa7, 0x12,
/* 8 */
0xaa, 0x2a,
/* 9 */
0xae, 0x49,
/* : */
0x10, 0x04,
/* ; */
0x10, 0x14,
/* < */
0x54, 0x44,
/* = */
0x38, 0x0e,
/* > */
0x11, 0x15,
/* ? */
0x2a, 0x25,
/* @ */
0x00, 0x00,
/* A */
0xea, 0x5b,
/* B */
0xeb, 0x3a,
/* C */
0x4f, 0x72,
/* D */
0x6b, 0x3b,
/* E */
0xcf, 0x73,
/* F */
0xcf, 0x13,
/* G */
0x4f, 0x7a,
/* H */
0xed, 0x5b,
/* I */
0x97, 0x74,
/* J */
0x24, 0x7b,
/* K */
0x5d, 0x56,
/* L */
0x49, 0x72,
/* M */
0xfd, 0x5b,
/* N */
0x6f, 0x5b,
/* O */
0x6f, 0x7b,
/* P */
0xef, 0x13,
/* Q */
0x6f, 0x7f,
/* R */
0xef, 0x57,
/* S */
0xce, 0x38,
/* T */
0x97, 0x24,
/* U */
0x6d, 0x7b,
/* V */
0x6d, 0x2b,
/* W */
0xed, 0x5f,
/* X */
0xad, 0x5a,
/* Y */
0xad, 0x24,
/* Z */
0xa7, 0x72,
}
};
#endif /* FONT3X5_1_H_ */
+358
View File
@@ -0,0 +1,358 @@
# This is a tiny 3x5 font with uppercase, digits, and symbols only.
# M.P. Hayes 2 Sep 2010
width=3
height=5
...
...
...
...
...
!
.@.
.@.
.@.
...
.@.
"
@@.
@.@
@@@
@..
@@@
#
@.@
@@@
@.@
@@@
@.@
$
.@@
@@.
@@@
.@@
@@.
%
@.@
..@
.@.
@..
@.@
&
.@.
@.@
@@.
@.@
@@@
'
..@
.@.
...
...
...
(
.@.
@..
@..
@..
.@.
)
.@.
..@
..@
..@
.@.
*
.@.
@@@
.@.
@@@
.@.
+
...
.@.
@@@
.@.
...
,
...
...
...
.@.
@..
-
...
...
@@@
...
...
.
...
...
...
...
.@.
/
..@
..@
.@.
@..
@..
0
.@.
@.@
@.@
@.@
.@.
1
.@.
@@.
.@.
.@.
@@@
2
@@.
..@
.@.
@..
@@@
3
@@.
..@
.@.
..@
@@.
4
@.@
@.@
@@@
..@
..@
5
@@@
@..
.@.
..@
@@.
6
.@@
@..
@@.
@.@
.@.
7
@@@
..@
.@.
@..
@..
8
.@.
@.@
.@.
@.@
.@.
9
.@@
@.@
.@@
..@
..@
:
...
.@.
...
.@.
...
;
...
.@.
...
.@.
@..
<
..@
.@.
@..
.@.
..@
=
...
@@@
...
@@@
...
>
@..
.@.
..@
.@.
@..
?
.@.
@.@
..@
.@.
.@.
.
...
...
...
...
.@.
A
.@.
@.@
@@@
@.@
@.@
B
@@.
@.@
@@.
@.@
@@.
C
@@@
@..
@..
@..
@@@
D
@@.
@.@
@.@
@.@
@@.
E
@@@
@..
@@@
@..
@@@
F
@@@
@..
@@@
@..
@..
G
@@@
@..
@..
@.@
@@@
H
@.@
@.@
@@@
@.@
@.@
I
@@@
.@.
.@.
.@.
@@@
J
..@
..@
..@
@.@
@@@
K
@.@
@@.
@..
@@.
@.@
L
@..
@..
@..
@..
@@@
M
@.@
@@@
@@@
@.@
@.@
N
@@@
@.@
@.@
@.@
@.@
O
@@@
@.@
@.@
@.@
@@@
P
@@@
@.@
@@@
@..
@..
Q
@@@
@.@
@.@
@@@
@@@
R
@@@
@.@
@@@
@@.
@.@
S
.@@
@..
@@.
..@
@@.
T
@@@
.@.
.@.
.@.
.@.
U
@.@
@.@
@.@
@.@
@@@
V
@.@
@.@
@.@
@.@
.@.
W
@.@
@.@
@@@
@@@
@.@
X
@.@
@.@
.@.
@.@
@.@
Y
@.@
@.@
.@.
.@.
.@.
Z
@@@
..@
.@.
@..
@@@
+234
View File
@@ -0,0 +1,234 @@
/** @file font5x7_1.h
@author fontgen
@date 28 Sep 2010
@defgroup font5x7_1 This is a 5x7 font with uppercase, lowercase, digits, and symbols.
M.P. Hayes 2 Sep 2010
*/
#ifndef FONT5X7_1_H_
#define FONT5X7_1_H_
#define FONT5X7_1_WIDTH 5
#define FONT5X7_1_HEIGHT 7
#define FONT5X7_1_OFFSET 32
#define FONT5X7_1_SIZE 95
#ifndef FONT_WIDTH
#define FONT_WIDTH 5
#endif
#ifndef FONT_HEIGHT
#define FONT_HEIGHT 7
#endif
#ifndef FONT_OFFSET
#define FONT_OFFSET 32
#endif
#ifndef FONT_SIZE_MAX
#define FONT_SIZE_MAX 95
#endif
#include "font.h"
static const font_t font5x7_1 =
{
.flags = 1, /* (packed) */
.width = 5,
.height = 7,
.offset = 32,
.size = 95,
.bytes = 5,
.data =
{
/* */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ! */
0xc6, 0x18, 0x63, 0x80, 0x01,
/* " */
0x4a, 0x29, 0x00, 0x00, 0x00,
/* # */
0x4a, 0x7d, 0xf5, 0x95, 0x02,
/* $ */
0xc4, 0x17, 0x47, 0x1f, 0x01,
/* % */
0x63, 0x22, 0x22, 0x32, 0x06,
/* & */
0x26, 0x15, 0x51, 0x93, 0x05,
/* ' */
0x86, 0x08, 0x00, 0x00, 0x00,
/* ( */
0x88, 0x08, 0x21, 0x08, 0x02,
/* ) */
0x82, 0x20, 0x84, 0x88, 0x00,
/* * */
0x80, 0x54, 0x57, 0x09, 0x00,
/* + */
0x80, 0x90, 0x4f, 0x08, 0x00,
/* , */
0x00, 0x00, 0x60, 0x88, 0x00,
/* - */
0x00, 0x80, 0x0f, 0x00, 0x00,
/* . */
0x00, 0x00, 0x00, 0x8c, 0x01,
/* / */
0x00, 0x22, 0x22, 0x02, 0x00,
/* 0 */
0x2e, 0xe6, 0x3a, 0xa3, 0x03,
/* 1 */
0xc4, 0x10, 0x42, 0x88, 0x03,
/* 2 */
0x2e, 0x42, 0x44, 0xc4, 0x07,
/* 3 */
0x2e, 0x42, 0x07, 0xa3, 0x03,
/* 4 */
0x88, 0xa9, 0xf4, 0x11, 0x02,
/* 5 */
0x3f, 0x84, 0x07, 0xa3, 0x03,
/* 6 */
0x2e, 0x86, 0x17, 0xa3, 0x03,
/* 7 */
0x3f, 0x42, 0x44, 0x08, 0x01,
/* 8 */
0x2e, 0x46, 0x17, 0xa3, 0x03,
/* 9 */
0x2e, 0x46, 0x0f, 0xa3, 0x03,
/* : */
0xc0, 0x18, 0x60, 0x0c, 0x00,
/* ; */
0xc0, 0x18, 0x60, 0x88, 0x00,
/* < */
0x88, 0x88, 0x20, 0x08, 0x02,
/* = */
0x00, 0x7c, 0xf0, 0x01, 0x00,
/* > */
0x82, 0x20, 0x88, 0x88, 0x00,
/* ? */
0x2e, 0x42, 0x44, 0x00, 0x01,
/* @ */
0x2e, 0x42, 0x5b, 0xab, 0x03,
/* A */
0x44, 0xc5, 0x1f, 0x63, 0x04,
/* B */
0x2f, 0xc6, 0x17, 0xe3, 0x03,
/* C */
0x2e, 0x86, 0x10, 0xa2, 0x03,
/* D */
0x2f, 0xc6, 0x18, 0xe3, 0x03,
/* E */
0x3f, 0x84, 0x17, 0xc2, 0x07,
/* F */
0x3f, 0x84, 0x17, 0x42, 0x00,
/* G */
0x2e, 0x86, 0x1e, 0xa3, 0x07,
/* H */
0x31, 0xc6, 0x1f, 0x63, 0x04,
/* I */
0x8e, 0x10, 0x42, 0x88, 0x03,
/* J */
0x10, 0x42, 0x18, 0xa3, 0x03,
/* K */
0x31, 0x95, 0x51, 0x52, 0x04,
/* L */
0x21, 0x84, 0x10, 0xc2, 0x07,
/* M */
0x71, 0xd7, 0x1a, 0x63, 0x04,
/* N */
0x71, 0xd6, 0x1c, 0x63, 0x04,
/* O */
0x2e, 0xc6, 0x18, 0xa3, 0x03,
/* P */
0x2f, 0xc6, 0x17, 0x42, 0x00,
/* Q */
0x2e, 0xc6, 0x58, 0x93, 0x05,
/* R */
0x2f, 0xc6, 0x17, 0x63, 0x04,
/* S */
0x2e, 0x06, 0x07, 0xa3, 0x03,
/* T */
0x9f, 0x10, 0x42, 0x08, 0x01,
/* U */
0x31, 0xc6, 0x18, 0xa3, 0x03,
/* V */
0x31, 0xc6, 0x18, 0x15, 0x01,
/* W */
0x31, 0xc6, 0x5a, 0xab, 0x02,
/* X */
0x31, 0x2a, 0xa2, 0x62, 0x04,
/* Y */
0x31, 0x2a, 0x42, 0x08, 0x01,
/* Z */
0x1f, 0x22, 0x22, 0xc2, 0x07,
/* [ */
0x27, 0x84, 0x10, 0xc2, 0x01,
/* \ */
0x20, 0x08, 0x82, 0x20, 0x00,
/* ] */
0x0e, 0x21, 0x84, 0x90, 0x03,
/* ^ */
0x44, 0x45, 0x00, 0x00, 0x00,
/* _ */
0x00, 0x00, 0x00, 0xc0, 0x07,
/* ` */
0x82, 0x20, 0x00, 0x00, 0x00,
/* a */
0x00, 0x38, 0xe8, 0xa3, 0x07,
/* b */
0x21, 0xb4, 0x19, 0xe3, 0x03,
/* c */
0x00, 0xb8, 0x10, 0xa2, 0x03,
/* d */
0x10, 0xda, 0x1c, 0xa3, 0x07,
/* e */
0x00, 0xb8, 0xf8, 0x83, 0x03,
/* f */
0x4c, 0x8a, 0x23, 0x84, 0x00,
/* g */
0xc0, 0xc7, 0xe8, 0xa1, 0x03,
/* h */
0x21, 0xb4, 0x19, 0x63, 0x04,
/* i */
0x04, 0x18, 0x42, 0x88, 0x03,
/* j */
0x08, 0x30, 0x84, 0x92, 0x01,
/* k */
0x21, 0xa4, 0x32, 0x4a, 0x02,
/* l */
0x86, 0x10, 0x42, 0x88, 0x03,
/* m */
0x00, 0xac, 0x5a, 0x63, 0x04,
/* n */
0x00, 0xb4, 0x19, 0x63, 0x04,
/* o */
0x00, 0xb8, 0x18, 0xa3, 0x03,
/* p */
0x00, 0xbc, 0xf8, 0x42, 0x00,
/* q */
0x00, 0xd8, 0xec, 0x21, 0x04,
/* r */
0x00, 0xb4, 0x19, 0x42, 0x00,
/* s */
0x00, 0xb8, 0xe0, 0xe0, 0x03,
/* t */
0x42, 0x1c, 0x21, 0x24, 0x03,
/* u */
0x00, 0xc4, 0x18, 0xb3, 0x05,
/* v */
0x00, 0xc4, 0x18, 0x15, 0x01,
/* w */
0x00, 0xc4, 0x5a, 0xab, 0x02,
/* x */
0x00, 0x44, 0x45, 0x54, 0x04,
/* y */
0x00, 0xc4, 0xe8, 0xa1, 0x03,
/* z */
0x00, 0x7c, 0x44, 0xc4, 0x07,
/* { */
0x88, 0x10, 0x41, 0x08, 0x02,
/* | */
0x84, 0x10, 0x42, 0x08, 0x01,
/* } */
0x82, 0x10, 0x44, 0x88, 0x00,
/* ~ */
0x00, 0x88, 0x8a, 0x00, 0x00,
}
};
#endif /* FONT5X7_1_H_ */
+764
View File
@@ -0,0 +1,764 @@
# This is a 5x7 font with uppercase, lowercase, digits, and symbols.
# M.P. Hayes 2 Sep 2010
width=5
height=7
.....
.....
.....
.....
.....
.....
.....
!
.@@..
.@@..
.@@..
.@@..
.@@..
.....
.@@..
"
.@.@.
.@.@.
.@.@.
.....
.....
.....
.....
#
.@.@.
.@.@.
@@@@@
.@.@.
@@@@@
.@.@.
.@.@.
$
..@..
.@@@@
@.@..
.@@@.
..@.@
@@@@.
..@..
%
@@...
@@..@
...@.
..@..
.@...
@..@@
...@@
&
.@@..
@..@.
@.@..
.@...
@.@.@
@..@.
.@@.@
'
.@@..
..@..
.@...
.....
.....
.....
.....
(
...@.
..@..
.@...
.@...
.@...
..@..
...@.
)
.@...
..@..
...@.
...@.
...@.
..@..
.@...
*
.....
..@..
@.@.@
.@@@.
@.@.@
..@..
.....
+
.....
..@..
..@..
@@@@@
..@..
..@..
.....
,
.....
.....
.....
.....
.@@..
..@..
.@...
-
.....
.....
.....
@@@@@
.....
.....
.....
.
.....
.....
.....
.....
.....
.@@..
.@@..
/
.....
....@
...@.
..@..
.@...
@....
.....
0
.@@@.
@...@
@..@@
@.@.@
@@..@
@...@
.@@@.
1
..@..
.@@..
..@..
..@..
..@..
..@..
.@@@.
2
.@@@.
@...@
....@
...@.
..@..
.@...
@@@@@
3
.@@@.
@...@
....@
.@@@.
....@
@...@
.@@@.
4
...@.
..@@.
.@.@.
@..@.
@@@@@
...@.
...@.
5
@@@@@
@....
@....
@@@@.
....@
@...@
.@@@.
6
.@@@.
@...@
@....
@@@@.
@...@
@...@
.@@@.
7
@@@@@
@...@
....@
...@.
..@..
..@..
..@..
8
.@@@.
@...@
@...@
.@@@.
@...@
@...@
.@@@.
9
.@@@.
@...@
@...@
.@@@@
....@
@...@
.@@@.
:
.....
.@@..
.@@..
.....
.@@..
.@@..
.....
;
.....
.@@..
.@@..
.....
.@@..
..@..
.@...
<
...@.
..@..
.@...
@....
.@...
..@..
...@.
=
.....
.....
@@@@@
.....
@@@@@
.....
.....
>
.@...
..@..
...@.
....@
...@.
..@..
.@...
?
.@@@.
@...@
....@
...@.
..@..
.....
..@..
@
.@@@.
@...@
....@
.@@.@
@.@.@
@.@.@
.@@@.
A
..@..
.@.@.
@...@
@@@@@
@...@
@...@
@...@
B
@@@@.
@...@
@...@
@@@@.
@...@
@...@
@@@@.
C
.@@@.
@...@
@....
@....
@....
@...@
.@@@.
D
@@@@.
@...@
@...@
@...@
@...@
@...@
@@@@.
E
@@@@@
@....
@....
@@@@.
@....
@....
@@@@@
F
@@@@@
@....
@....
@@@@.
@....
@....
@....
G
.@@@.
@...@
@....
@.@@@
@...@
@...@
.@@@@
H
@...@
@...@
@...@
@@@@@
@...@
@...@
@...@
I
.@@@.
..@..
..@..
..@..
..@..
..@..
.@@@.
J
....@
....@
....@
....@
@...@
@...@
.@@@.
K
@...@
@..@.
@.@..
@@...
@.@..
@..@.
@...@
L
@....
@....
@....
@....
@....
@....
@@@@@
M
@...@
@@.@@
@.@.@
@.@.@
@...@
@...@
@...@
N
@...@
@@..@
@.@.@
@..@@
@...@
@...@
@...@
O
.@@@.
@...@
@...@
@...@
@...@
@...@
.@@@.
P
@@@@.
@...@
@...@
@@@@.
@....
@....
@....
Q
.@@@.
@...@
@...@
@...@
@.@.@
@..@.
.@@.@
R
@@@@.
@...@
@...@
@@@@.
@...@
@...@
@...@
S
.@@@.
@...@
@....
.@@@.
....@
@...@
.@@@.
T
@@@@@
..@..
..@..
..@..
..@..
..@..
..@..
U
@...@
@...@
@...@
@...@
@...@
@...@
.@@@.
V
@...@
@...@
@...@
@...@
@...@
.@.@.
..@..
W
@...@
@...@
@...@
@.@.@
@.@.@
@.@.@
.@.@.
X
@...@
@...@
.@.@.
..@..
.@.@.
@...@
@...@
Y
@...@
@...@
.@.@.
..@..
..@..
..@..
..@..
Z
@@@@@
....@
...@.
..@..
.@...
@....
@@@@@
[
@@@..
@....
@....
@....
@....
@....
@@@..
\
.....
@....
.@...
..@..
...@.
....@
.....
]
.@@@.
...@.
...@.
...@.
...@.
...@.
.@@@.
^
..@..
.@.@.
@...@
.....
.....
.....
.....
_
.....
.....
.....
.....
.....
.....
@@@@@
`
.@...
..@..
...@.
.....
.....
.....
.....
a
.....
.....
.@@@.
....@
.@@@@
@...@
.@@@@
b
@....
@....
@.@@.
@@..@
@...@
@...@
@@@@.
c
.....
.....
.@@@.
@....
@....
@...@
.@@@.
d
....@
....@
.@@.@
@..@@
@...@
@...@
.@@@@
e
.....
.....
.@@@.
@...@
@@@@@
@....
.@@@.
f
..@@.
.@..@
.@...
@@@..
.@...
.@...
.@...
g
.....
.@@@@
@...@
@...@
.@@@@
....@
.@@@.
h
@....
@....
@.@@.
@@..@
@...@
@...@
@...@
i
..@..
.....
.@@..
..@..
..@..
..@..
.@@@.
j
...@.
.....
..@@.
...@.
...@.
@..@.
.@@..
k
@....
@....
@..@.
@.@..
@@...
@.@..
@..@.
l
.@@..
..@..
..@..
..@..
..@..
..@..
.@@@.
m
.....
.....
@@.@.
@.@.@
@.@.@
@...@
@...@
n
.....
.....
@.@@.
@@..@
@...@
@...@
@...@
o
.....
.....
.@@@.
@...@
@...@
@...@
.@@@.
p
.....
.....
@@@@.
@...@
@@@@.
@....
@....
q
.....
.....
.@@.@
@..@@
.@@@@
....@
....@
r
.....
.....
@.@@.
@@..@
@....
@....
@....
s
.....
.....
.@@@.
@....
.@@@.
....@
@@@@.
t
.@...
.@...
@@@..
.@...
.@...
.@..@
..@@.
u
.....
.....
@...@
@...@
@...@
@..@@
.@@.@
v
.....
.....
@...@
@...@
@...@
.@.@.
..@..
w
.....
.....
@...@
@.@.@
@.@.@
@.@.@
.@.@.
x
.....
.....
@...@
.@.@.
..@..
.@.@.
@...@
y
.....
.....
@...@
@...@
.@@@@
....@
.@@@.
z
.....
.....
@@@@@
...@.
..@..
.@...
@@@@@
{
...@.
..@..
..@..
.@...
..@..
..@..
...@.
|
..@..
..@..
..@..
..@..
..@..
..@..
..@..
}
.@...
..@..
..@..
...@.
..@..
..@..
.@...
~
.....
.....
.@...
@.@.@
...@.
.....
.....
+186
View File
@@ -0,0 +1,186 @@
/** @file font5x7_2.h
@author fontgen
@date 28 Sep 2010
@defgroup font5x7_2 This is a 5x7 font with uppercase, digits, and some symbols.
M.P. Hayes 2 Sep 2010
*/
#ifndef FONT5X7_2_H_
#define FONT5X7_2_H_
#define FONT5X7_2_WIDTH 5
#define FONT5X7_2_HEIGHT 7
#define FONT5X7_2_OFFSET 32
#define FONT5X7_2_SIZE 71
#ifndef FONT_WIDTH
#define FONT_WIDTH 5
#endif
#ifndef FONT_HEIGHT
#define FONT_HEIGHT 7
#endif
#ifndef FONT_OFFSET
#define FONT_OFFSET 32
#endif
#ifndef FONT_SIZE_MAX
#define FONT_SIZE_MAX 71
#endif
#include "font.h"
static font_t font5x7_2 =
{
.flags = 1, /* (packed) */
.width = 5,
.height = 7,
.offset = 32,
.size = 71,
.bytes = 5,
.data =
{
/* */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ! */
0x00, 0x00, 0x00, 0x00, 0x00,
/* " */
0x00, 0x00, 0x00, 0x00, 0x00,
/* # */
0x00, 0x00, 0x00, 0x00, 0x00,
/* $ */
0x00, 0x00, 0x00, 0x00, 0x00,
/* % */
0x00, 0x00, 0x00, 0x00, 0x00,
/* & */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ' */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ( */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ) */
0x00, 0x00, 0x00, 0x00, 0x00,
/* * */
0x00, 0x00, 0x00, 0x00, 0x00,
/* + */
0x00, 0x00, 0x00, 0x00, 0x00,
/* , */
0x00, 0x00, 0x00, 0x00, 0x00,
/* - */
0x00, 0x00, 0x00, 0x00, 0x00,
/* . */
0x00, 0x00, 0x02, 0x00, 0x00,
/* / */
0x00, 0x00, 0x00, 0x00, 0x00,
/* 0 */
0x2e, 0xe6, 0x3a, 0xa3, 0x03,
/* 1 */
0xc4, 0x10, 0x42, 0x88, 0x03,
/* 2 */
0x2e, 0x42, 0x44, 0xc4, 0x07,
/* 3 */
0x1f, 0x11, 0x04, 0xa3, 0x03,
/* 4 */
0x88, 0xa9, 0xf4, 0x11, 0x02,
/* 5 */
0x3f, 0x3c, 0x08, 0xa3, 0x03,
/* 6 */
0x4c, 0x84, 0x17, 0xa3, 0x03,
/* 7 */
0x1f, 0x22, 0x42, 0x08, 0x01,
/* 8 */
0x2f, 0x46, 0x17, 0xa3, 0x03,
/* 9 */
0x2e, 0x46, 0x0f, 0x91, 0x01,
/* : */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ; */
0x00, 0x00, 0x00, 0x00, 0x00,
/* < */
0x00, 0x00, 0x00, 0x00, 0x00,
/* = */
0x00, 0x00, 0x00, 0x00, 0x00,
/* > */
0x41, 0x10, 0x44, 0x44, 0x00,
/* ? */
0x2e, 0x42, 0x44, 0x00, 0x01,
/* @ */
0x00, 0x00, 0x00, 0x00, 0x00,
/* A */
0x2e, 0xc6, 0xf8, 0x63, 0x04,
/* B */
0x4f, 0x4a, 0x27, 0xe5, 0x03,
/* C */
0x2e, 0x86, 0x10, 0xa2, 0x03,
/* D */
0x4f, 0x4a, 0x29, 0xe5, 0x03,
/* E */
0x3f, 0x84, 0x1f, 0xc2, 0x07,
/* F */
0x3f, 0x84, 0x17, 0x42, 0x00,
/* G */
0x2e, 0x86, 0x1c, 0xa3, 0x07,
/* H */
0x31, 0xc6, 0x1f, 0x63, 0x04,
/* I */
0x8e, 0x10, 0x42, 0x88, 0x03,
/* J */
0x1c, 0x21, 0x84, 0x92, 0x01,
/* K */
0x31, 0x95, 0x51, 0x52, 0x04,
/* L */
0x21, 0x84, 0x10, 0xc2, 0x07,
/* M */
0x71, 0xd7, 0x1a, 0x63, 0x04,
/* N */
0x71, 0xce, 0x9a, 0x73, 0x04,
/* O */
0x2e, 0xc6, 0x18, 0xa3, 0x03,
/* P */
0x2f, 0xc6, 0x17, 0x42, 0x00,
/* Q */
0x2e, 0xc6, 0x58, 0xd3, 0x05,
/* R */
0x2f, 0xc6, 0x57, 0x52, 0x04,
/* S */
0x2e, 0x06, 0x07, 0xa3, 0x03,
/* T */
0x9f, 0x10, 0x42, 0x08, 0x01,
/* U */
0x31, 0xc6, 0x18, 0xa3, 0x03,
/* V */
0x31, 0xc6, 0x18, 0x15, 0x01,
/* W */
0x31, 0xc6, 0x5a, 0x77, 0x04,
/* X */
0x31, 0x2a, 0xa2, 0x62, 0x04,
/* Y */
0x31, 0x46, 0x45, 0x08, 0x01,
/* Z */
0x1f, 0x22, 0x22, 0xc2, 0x07,
/* [ */
0x00, 0x00, 0x00, 0x00, 0x00,
/* \ */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ] */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ^ */
0x00, 0x00, 0x00, 0x00, 0x00,
/* _ */
0x00, 0x00, 0x00, 0x00, 0x00,
/* ` */
0x00, 0x00, 0x00, 0x00, 0x00,
/* a */
0x00, 0x00, 0x00, 0x00, 0x00,
/* b */
0x00, 0x00, 0x00, 0x00, 0x00,
/* c */
0x00, 0x00, 0x00, 0x00, 0x00,
/* d */
0x00, 0x00, 0x00, 0x00, 0x00,
/* e */
0x00, 0x00, 0x00, 0x00, 0x00,
/* f */
0x2e, 0x86, 0xf0, 0x43, 0x00,
}
};
#endif /* FONT5X7_2_H_ */
+332
View File
@@ -0,0 +1,332 @@
# This is a 5x7 font with uppercase, digits, and some symbols.
# M.P. Hayes 2 Sep 2010
width=5
height=7
.....
.....
.....
.....
.....
.....
.....
.
.....
.....
.....
..@..
.....
.....
.....
>
@....
.@...
..@..
...@.
..@..
.@...
@....
?
.@@@.
@...@
....@
...@.
..@..
.....
..@..
0
.@@@.
@...@
@..@@
@.@.@
@@..@
@...@
.@@@.
1
..@..
.@@..
..@..
..@..
..@..
..@..
.@@@.
2
.@@@.
@...@
....@
...@.
..@..
.@...
@@@@@
3
@@@@@
...@.
..@..
...@.
....@
@...@
.@@@.
4
...@.
..@@.
.@.@.
@..@.
@@@@@
...@.
...@.
5
@@@@@
@....
@@@@.
....@
....@
@...@
.@@@.
6
..@@.
.@...
@....
@@@@.
@...@
@...@
.@@@.
7
@@@@@
....@
...@.
..@..
..@..
..@..
..@..
8
@@@@.
@...@
@...@
.@@@.
@...@
@...@
.@@@.
9
.@@@.
@...@
@...@
.@@@@
....@
...@.
.@@..
A
.@@@.
@...@
@...@
@...@
@@@@@
@...@
@...@
B
@@@@.
.@..@
.@..@
.@@@.
.@..@
.@..@
@@@@.
C
.@@@.
@...@
@....
@....
@....
@...@
.@@@.
D
@@@@.
.@..@
.@..@
.@..@
.@..@
.@..@
@@@@.
E
@@@@@
@....
@....
@@@@@
@....
@....
@@@@@
F
@@@@@
@....
@....
@@@@.
@....
@....
@....
f
.@@@.
@...@
@....
@....
@@@@@
@....
@....
G
.@@@.
@...@
@....
@..@@
@...@
@...@
.@@@@
H
@...@
@...@
@...@
@@@@@
@...@
@...@
@...@
I
.@@@.
..@..
..@..
..@..
..@..
..@..
.@@@.
J
..@@@
...@.
...@.
...@.
...@.
@..@.
.@@..
K
@...@
@..@.
@.@..
@@...
@.@..
@..@.
@...@
L
@....
@....
@....
@....
@....
@....
@@@@@
M
@...@
@@.@@
@.@.@
@.@.@
@...@
@...@
@...@
N
@...@
@@..@
@@..@
@.@.@
@..@@
@..@@
@...@
O
.@@@.
@...@
@...@
@...@
@...@
@...@
.@@@.
P
@@@@.
@...@
@...@
@@@@.
@....
@....
@....
Q
.@@@.
@...@
@...@
@...@
@.@.@
@..@.
@@@.@
R
@@@@.
@...@
@...@
@@@@.
@.@..
@..@.
@...@
S
.@@@.
@...@
@....
.@@@.
....@
@...@
.@@@.
T
@@@@@
..@..
..@..
..@..
..@..
..@..
..@..
U
@...@
@...@
@...@
@...@
@...@
@...@
.@@@.
V
@...@
@...@
@...@
@...@
@...@
.@.@.
..@..
W
@...@
@...@
@...@
@.@.@
@.@.@
@@.@@
@...@
X
@...@
@...@
.@.@.
..@..
.@.@.
@...@
@...@
Y
@...@
@...@
@...@
.@.@.
..@..
..@..
..@..
Z
@@@@@
....@
...@.
..@..
.@...
@....
@@@@@
+462
View File
@@ -0,0 +1,462 @@
/** @file fontgen.c
@author M. P. Hayes, UCECE
@date 15 May 2007
@brief
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <limits.h>
#include <stdint.h>
#include <ctype.h>
#include <time.h>
/* FIXME. This is not robust. */
typedef struct
{
char name[64];
char *comment;
uint8_t width;
uint8_t height;
uint8_t offset;
uint8_t size;
uint8_t bytes;
uint8_t interlaced;
uint8_t *data;
} font_t;
#define FONT_SIZE_MAX 255
int font_zoom (font_t *font, font_t *zoom_font, int zoom_x, int zoom_y)
{
int i;
uint8_t *image;
uint8_t *zoom_image;
int bits;
*zoom_font = *font;
zoom_font->width = font->width * zoom_x;
zoom_font->height = font->height * zoom_y;
zoom_font->bytes = font->bytes * zoom_x * zoom_y;
zoom_font->data = calloc (FONT_SIZE_MAX, zoom_font->bytes);
bits = zoom_font->width * zoom_font->height;
if (zoom_font->interlaced)
bits = (bits + 1) / 2;
zoom_font->bytes = (bits + CHAR_BIT - 1) / CHAR_BIT;
image = malloc (font->width * font->height);
zoom_image = malloc (font->width * zoom_x * font->height * zoom_y);
for (i = font->offset; i < font->size + font->offset; i++)
{
int k;
int x;
int y;
uint8_t font_byte;
uint8_t *font_elt;
font_elt = &font->data[i * font->bytes];
k = 0;
font_byte = *font_elt++;
for (y = 0; y < font->height; y++)
{
for (x = 0; x < font->width; x++)
{
image[y * font->width + x] = (font_byte & 1) * 255;
font_byte >>= 1;
k++;
if (k >= CHAR_BIT)
{
k = 0;
font_byte = *font_elt++;
}
}
}
for (y = 0; y < zoom_font->height; y++)
{
for (x = 0; x < zoom_font->width; x++)
zoom_image[y * zoom_font->width + x]
= image[(y / zoom_y) * font->width + (x / zoom_x)];
}
font_elt = &zoom_font->data[i * zoom_font->bytes];
k = 0;
*font_elt = 0;
for (y = 0; y < zoom_font->height; y++)
{
for (x = 0; x < zoom_font->width; x++)
{
if (zoom_image[y * zoom_font->width + x])
*font_elt |= (1 << k);
k++;
if (k >= CHAR_BIT)
{
k = 0;
font_elt++;
*font_elt = 0;
}
}
}
}
free (image);
free (zoom_image);
return 1;
}
int font_scan (font_t *font)
{
char buffer[132];
int line;
int symcnt;
int symline;
uint8_t symbol;
uint8_t symbol_min;
uint8_t symbol_max;
int tmp;
int bits;
unsigned int i;
font->comment = 0;
/* FIXME, use more robust key-value pair parsing. */
while (1)
{
int c;
c = fgetc (stdin);
if (c == EOF)
return 0;
ungetc (c, stdin);
if (!strchr ("#whi", c))
break;
if (!fgets (buffer, sizeof (buffer), stdin))
return 0;
if (c == 'w')
{
if (sscanf (buffer, "width=%d", &tmp) != 1)
fprintf (stderr, "Width parse error: %s\n", buffer);
font->width = tmp;
}
else if (c == 'h')
{
if (sscanf (buffer, "height=%d", &tmp) != 1)
fprintf (stderr, "Height parse error: %s\n", buffer);
font->height = tmp;
}
else if (c == 'i')
{
if (sscanf (buffer, "interlaced=%d", &tmp) != 1)
fprintf (stderr, "Interlaced parse error: %s\n", buffer);
font->interlaced = tmp;
}
else if (c == '#')
{
if (!font->comment)
font->comment = calloc (1, strlen (buffer) + 1);
else
font->comment = realloc (font->comment,
strlen (font->comment)
+ strlen (buffer) + 1);
strcat (font->comment, buffer + 1);
}
}
if (!font->width)
{
fprintf (stderr, "Missing width specifier\n");
return 1;
}
if (!font->height)
{
fprintf (stderr, "Missing height specifier\n");
return 1;
}
bits = font->width * font->height;
if (font->interlaced)
bits = (bits + 1) / 2;
font->bytes = (bits + CHAR_BIT - 1) / CHAR_BIT;
font->offset = 0;
font->size = ~0;
symbol_min = ~0;
symbol_max = 0;
font->data = calloc (FONT_SIZE_MAX, font->bytes);
symbol = 0;
line = 4;
for (symcnt = 1; ; symcnt++)
{
int bit = 0;
for (symline = 1; symline <= font->height + 1; symline++)
{
unsigned int num;
if (!fgets (buffer, sizeof (buffer), stdin))
{
/* Have reached end of file. */
font->offset = symbol_min;
font->size = symbol_max - symbol_min + 1;
return 0;
}
/* Remove newline. */
buffer[strlen (buffer) - 1] = '\0';
if (symline != 1)
{
char *p;
if (strlen (buffer) != font->width)
{
fprintf (stderr, "Parse error at line %d: %s\n", line, buffer);
return 1;
}
p = buffer;
if (font->interlaced)
{
num = symline & 1 ? font->width / 2 : (font->width + 1) / 2;
if (symline & 1)
p++;
}
else
num = font->width;
for (i = 0; i < num; i++)
{
if (*p != '.')
{
font->data[symbol * font->bytes + bit / CHAR_BIT]
|= (1 << (bit % CHAR_BIT));
}
else if (*p != '.')
{
fprintf (stderr, "Parse error at line %d: %c\n", line, *p);
return 1;
}
bit++;
if (font->interlaced)
p += 2;
else
p++;
}
}
else
{
if (buffer[0] == '\\' && buffer[1] != '\0')
{
if (sscanf (buffer + 1, "%o", &tmp) != 1)
{
fprintf (stderr, "Parse error (octal num) at line %d: %s\n", line, buffer);
return 2;
}
symbol = tmp;
}
else
{
char sym;
if (sscanf (buffer, "%c", &sym) != 1)
{
fprintf (stderr, "Parse error (char) at line %d: %s\n", line, buffer);
return 2;
}
symbol = sym;
}
if (symbol < symbol_min)
symbol_min = symbol;
if (symbol > symbol_max)
symbol_max = symbol;
}
line++;
}
}
}
static void font_print_1 (font_t *font, uint8_t symbol)
{
int i;
for (i = 0; i < font->bytes; i++)
printf ("0x%02x, ", font->data[symbol * font->bytes + i]);
fputs ("\n", stdout);
}
static void font_print (font_t *font)
{
int i;
uint8_t bytes_per_char;
time_t now;
char name_upper[128];
char timestr[32];
bytes_per_char = (font->width * font->height + 8 - 1) >> 3;
for (i= 0; font->name[i]; i++)
name_upper[i] = toupper (font->name[i]);
name_upper[i] = '\0';
time (&now);
strftime (timestr, sizeof (timestr), "%d %b %Y", localtime (&now));
printf ("/** @file %s.h\n", font->name);
printf (" @author fontgen\n");
printf (" @date %s\n\n", timestr);
printf (" @defgroup %s %s\n", font->name, font->comment);
printf ("*/\n\n");
printf ("#ifndef %s_H_\n", name_upper);
printf ("#define %s_H_\n\n", name_upper);
printf ("#define %s_WIDTH %d\n", name_upper, font->width);
printf ("#define %s_HEIGHT %d\n", name_upper, font->height);
printf ("#define %s_OFFSET %d\n", name_upper, font->offset);
printf ("#define %s_SIZE %d\n\n", name_upper, font->size);
printf ("#ifndef FONT_WIDTH\n#define FONT_WIDTH %d\n#endif\n",
font->width);
printf ("#ifndef FONT_HEIGHT\n#define FONT_HEIGHT %d\n#endif\n",
font->height);
printf ("#ifndef FONT_OFFSET\n#define FONT_OFFSET %d\n#endif\n",
font->offset);
printf ("#ifndef FONT_SIZE_MAX\n#define FONT_SIZE_MAX %d\n#endif\n",
font->size);
printf ("#include \"font.h\"\n\n");
printf ("static font_t %s =\n{\n", font->name);
printf (" .flags = 1, /* (packed) */\n");
printf (" .width = %d,\n", font->width);
printf (" .height = %d,\n", font->height);
printf (" .offset = %d,\n", font->offset);
printf (" .size = %d,\n", font->size);
printf (" .bytes = %d,\n", bytes_per_char);
printf (" .data =\n {\n");
for (i = font->offset; i < font->size + font->offset; i++)
{
if (i < 32)
printf (" /* \\%o */\n ", i);
else
printf (" /* %c */\n ", i);
font_print_1 (font, i);
}
printf (" }\n};\n#endif /* %s_H_ */\n", name_upper);
}
static void font_draw_1 (font_t *font, uint8_t symbol)
{
int i;
int j;
int bit;
char ch;
uint8_t *data;
data = &font->data[symbol * font->bytes];
bit = 0;
ch = *data++;
for (i = 0; i < font->height; i++)
{
for (j = 0; j < font->width; j++)
{
if (font->interlaced && ((i & 1) ^ (j & 1)))
{
fputc (' ', stdout);
continue;
}
fputc (ch & 1 ? '@' : '.', stdout);
ch >>= 1;
bit++;
if ((bit % CHAR_BIT) == 0)
ch = *data++;
}
fputc ('\n', stdout);
}
}
static void font_draw (font_t *font)
{
int i;
printf ("width=%d\n", font->width);
printf ("height=%d\n", font->height);
printf ("interlaced=%d\n", font->interlaced);
for (i = 0; i < 32; i++)
{
printf ("\\%o\n", i);
font_draw_1 (font, i);
}
for (; i < FONT_SIZE_MAX; i++)
{
printf ("%c\n", i);
font_draw_1 (font, i);
}
}
int main (int argc, char **argv)
{
int ret;
font_t font;
ret = font_scan (&font);
if (ret)
return ret;
if (argc < 2)
{
fprintf (stderr, "Usage: fontgen fontname\n");
return 1;
}
strcpy (font.name, argv[1]);
argc--;
argv++;
if (argc > 2 && !strcmp (argv[1], "-zoom"))
{
int zoom;
font_t zoom_font;
zoom = atoi (argv[2]);
argc -= 2;
argv += 2;
font_zoom (&font, &zoom_font, zoom, zoom);
font = zoom_font;
}
if (argc > 1 && !strcmp (argv[1], "-ascii"))
font_draw (&font);
else
font_print (&font);
return 0;
}