forked from jonasjj/font8x8-vhdl-package
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrender.c
67 lines (57 loc) · 1.33 KB
/
render.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include "font8x8_basic.h"
void usage(char *exec) {
printf("Usage: %s <char_code>\n", exec);
printf(" <char_code> Decimal character code between 0 and 127\n");
}
void render(char *bitmap, int ord) {
int x,y;
int set;
int mask;
printf(" (");
if(isprint(ord)) {
printf(" -- '%c'", ord);
}
printf("\n");
for (x=0; x < 8; x++) {
printf(" (");
for (y=0; y < 8; y++) {
set = bitmap[x] & 1 << y;
printf("%s", set ? "'1'" : "'0'");
if (y < 8 - 1) {
printf(", ");
}
}
if (x < 8 - 1) {
printf("),\n");
} else {
printf(")\n");
}
}
printf(" )");
}
int main(int argc, char **argv) {
printf("-- Auto generated file.\n"
"-- See https://github.com/bberrevoets/font8x8-vhdl-package\n\n"
"library ieee;\n"
"use ieee.std_logic_1164.all;\n\n"
"library dot_matrix;\n"
"use dot_matrix.types.all;\n\n"
"package charmap is\n"
" constant charmap : charmap_type := (\n");
int ord;
for (ord = 0; ord < 128; ord++) {
char *bitmap = font8x8_basic[ord];
render(bitmap, ord);
if (ord < 128 -1) {
printf(",\n");
} else {
printf("\n");
}
}
printf(" );\n");
printf("end package;\n");
return 0;
}