-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbmpfont_create_main.c
58 lines (54 loc) · 1.37 KB
/
bmpfont_create_main.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
#include <windows.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "bmpfont_create.h"
// For debugging
//#define LATIN_ONLY
int options(void *bmpfont, int ac, char **av)
{
// --exe defaults to bmpfont. I think it's a good value for libraries,
// so I don't think I need to document it.
// Create an issue or send a pull request if you don't agree.
bmpfont_add_option(bmpfont, "--exe", av[0]);
for (int i = 1; i < ac; i += 2)
{
if (strcmp(av[i], "--help") == 0)
{
bmpfont_add_option(bmpfont, "--help", NULL);
return 0;
}
if (av[i][0] != '-' || av[i][1] != '-')
{
fprintf(stderr, "%s: unrecognized option '%s'\n"
"Try '%s --help' for more information.",
av[0], av[i], av[0]);
return 0;
}
if (i + 1 >= ac)
{
fprintf(stderr, "%s: option '%s' requires an argument\n"
"Try '%s --help' for more information.",
av[0], av[i], av[0]);
return 0;
}
if (bmpfont_add_option(bmpfont, av[i], av[i + 1]) == 0)
return 0;
}
return 1;
}
int main(int ac, char **av)
{
void *bmpfont = bmpfont_init();
if (!options(bmpfont, ac, av))
return 1;
#ifdef LATIN_ONLY
// Debug - generate only 256 characters.
char chars_list[256];
memset(chars_list, 1, 256);
bmpfont_add_option_binary(bmpfont, "--chars-list", chars_list, 256);
#endif
bmpfont_run(bmpfont);
bmpfont_free(bmpfont);
return 0;
}