-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfontconvert.c
75 lines (64 loc) · 1.33 KB
/
fontconvert.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
68
69
70
71
72
73
74
75
/**
@brief FontConvert
Convert the mpf (Mini-Pixel-Font) file into a c-header file.
@author Stephan Ruloff
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <linux/limits.h>
#include <ctype.h>
#include "font.h"
int main(int argc, char **argv)
{
char *fontname = 0;
char *headername = 0;
FontMaster *m;
int ret;
char font[PATH_MAX] = "";
char *lastDot = 0;
char *lastSlash = 0;
int i;
if (argc == 3) {
fontname = argv[1];
headername = argv[2];
} else {
printf("fontconvert <fontname> <headername>\n");
return 1;
}
m = FontCreate();
if (!m) {
printf("Out of memory\n");
exit(1);
}
ret = FontLoad(m, fontname);
if (ret) {
lastDot = strrchr(fontname, '.');
lastSlash = strrchr(fontname, '/');
if (lastSlash == 0) {
lastSlash = fontname;
} else {
lastSlash++;
}
if (lastDot == 0) {
lastDot = fontname + strlen(fontname);
}
for (i = 0; lastSlash < lastDot; lastSlash++) {
font[i] = toupper(*lastSlash);
i++;
}
font[i] = 0;
printf("Font %s\n", font);
ret = FontConvertToHeader(m, font, headername);
if (ret) {
printf("Error %i\n", ret);
} else {
printf("Ok\n");
}
} else {
printf("No Character in FontFile!\n");
}
return 0;
}