Move knowledge of different widths out of main().

It's now contained in on place in bedstead.c (and in the Makefile).
This commit is contained in:
Ben Harris 2017-07-08 21:04:18 +01:00
parent 2d120df252
commit 065de73643

View File

@ -126,37 +126,41 @@
*/
struct param {
char const * option;
char const * fontname;
char const * fullname;
int xpix;
int ttfwidth;
};
struct param default_param = {
"Bedstead", "Bedstead",
100, /* xpix */
5, /* ttfwidth */
struct param const params[] = {
{
"--normal",
"Bedstead", "Bedstead",
100, /* xpix */
5, /* ttfwidth */
},
{
"--extended",
"Bedstead-Extended", "Bedstead Extended",
124, /* xpix */
7, /* ttfwidth */
},
{
"--condensed",
"Bedstead-Condensed", "Bedstead Condensed",
50, /* xpix */
1, /* ttfwidth */
},
{
"--semicondensed",
"Bedstead-Semicondensed", "Bedstead Semicondensed",
62, /* xpix */
2, /* ttfwidth */
},
};
struct param extended_param = {
"Bedstead-Extended", "Bedstead Extended",
124, /* xpix */
7, /* ttfwidth */
};
struct param condensed_param = {
"Bedstead-Condensed", "Bedstead Condensed",
50, /* xpix */
1, /* ttfwidth */
};
struct param semicondensed_param = {
"Bedstead-Semicondensed", "Bedstead Semicondensed",
62, /* xpix */
2, /* ttfwidth */
};
struct param *param = &default_param;
struct param const *param = &params[0];
/* Size of pixels in font design units (usually 1000/em) */
#define XPIX (param->xpix)
@ -1228,20 +1232,18 @@ main(int argc, char **argv)
{
int i;
int const nglyphs = sizeof(glyphs) / sizeof(glyphs[0]);
int const nparams = sizeof(params) / sizeof(params[0]);
int extraglyphs = 0;
char *endptr;
while (argc > 1) {
if (strcmp(argv[1], "--extended") == 0) {
param = &extended_param;
argv++; argc--;
} else if (strcmp(argv[1], "--condensed") == 0) {
param = &condensed_param;
argv++; argc--;
} else if (strcmp(argv[1], "--semicondensed") == 0) {
param = &semicondensed_param;
argv++; argc--;
} else if (strcmp(argv[1], "--") == 0) {
for (i = 0; i < nparams; i++)
if (strcmp(argv[1], params[i].option) == 0) {
param = &params[i];
argv++; argc--;
goto next;
}
if (strcmp(argv[1], "--") == 0) {
argv++; argc--;
break;
} else if (argv[1][0] == '-') {
@ -1249,6 +1251,7 @@ main(int argc, char **argv)
return 1;
} else break;
argv++; argc--;
next:;
}
if (argc > 1) {