mirror of
https://github.com/Rockbox/rockbox.git
synced 2025-12-07 05:35:02 -05:00
Make the build system create a sysfont.h which includes font information for the system font. Available #defines are: SYSFONT_NAME, SYSFONT_FACENAME, SYSFONT_WIDTH, SYSFONT_HEIGHT, SYSFONT_SIZE, SYSFONT_ASCENT, SYSFONT_DESCENT, SYSFONT_FIRST_CHAR, SYSFONT_LAST_CHAR, SYSFONT_DEFAULT_CHAR, SYSFONT_PROPORTIONAL, SYSFONT_COPYRIGHT, SYSFONT_BITS_SIZE.
Also fix a small bug in the iPod bootloader printf() code and use printf() for PortalPlayer bootloaders too. git-svn-id: svn://svn.rockbox.org/rockbox/trunk@12041 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
b0d1bb891e
commit
f4709d0c7c
5 changed files with 114 additions and 40 deletions
|
|
@ -64,6 +64,7 @@ struct font {
|
|||
#define EXTRA 300 /* # bytes extra allocation for buggy .bdf files*/
|
||||
|
||||
int gen_c = 0;
|
||||
int gen_h = 0;
|
||||
int gen_fnt = 0;
|
||||
int gen_map = 1;
|
||||
int start_char = 0;
|
||||
|
|
@ -83,6 +84,7 @@ char * bdf_getline(FILE *fp, char *buf, int len);
|
|||
bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2);
|
||||
|
||||
int gen_c_source(struct font* pf, char *path);
|
||||
int gen_h_header(struct font* pf, char *path);
|
||||
int gen_fnt_file(struct font* pf, char *path);
|
||||
|
||||
void
|
||||
|
|
@ -93,6 +95,7 @@ usage(void)
|
|||
" convbdf [options] [-o output-file] [single-input-file]\n"
|
||||
"Options:\n"
|
||||
" -c Convert .bdf to .c source file\n"
|
||||
" -h Convert .bdf to .h header file (to create sysfont.h)\n"
|
||||
" -f Convert .bdf to .fnt font file\n"
|
||||
" -s N Start output at character encodings >= N\n"
|
||||
" -l N Limit output to character encodings <= N\n"
|
||||
|
|
@ -124,6 +127,9 @@ void getopts(int *pac, char ***pav)
|
|||
case 'c': /* generate .c output*/
|
||||
gen_c = 1;
|
||||
break;
|
||||
case 'h': /* generate .h output*/
|
||||
gen_h = 1;
|
||||
break;
|
||||
case 'f': /* generate .fnt output*/
|
||||
gen_fnt = 1;
|
||||
break;
|
||||
|
|
@ -214,6 +220,14 @@ int convbdf(char *path)
|
|||
}
|
||||
ret |= gen_c_source(pf, outfile);
|
||||
}
|
||||
|
||||
if (gen_h) {
|
||||
if (!oflag) {
|
||||
strcpy(outfile, basename(path));
|
||||
strcat(outfile, ".h");
|
||||
}
|
||||
ret |= gen_h_header(pf, outfile);
|
||||
}
|
||||
|
||||
if (gen_fnt) {
|
||||
if (!oflag) {
|
||||
|
|
@ -234,12 +248,12 @@ int main(int ac, char **av)
|
|||
++av; --ac; /* skip av[0]*/
|
||||
getopts(&ac, &av); /* read command line options*/
|
||||
|
||||
if (ac < 1 || (!gen_c && !gen_fnt)) {
|
||||
if (ac < 1 || (!gen_c && !gen_h && !gen_fnt)) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
if (oflag) {
|
||||
if (ac > 1 || (gen_c && gen_fnt)) {
|
||||
if (ac > 1 || (gen_c && gen_fnt) || (gen_c && gen_h) || (gen_h && gen_fnt)) {
|
||||
usage();
|
||||
exit(1);
|
||||
}
|
||||
|
|
@ -965,6 +979,58 @@ int gen_c_source(struct font* pf, char *path)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/* generate C header from in-core font*/
|
||||
int gen_h_header(struct font* pf, char *path)
|
||||
{
|
||||
FILE *ofp;
|
||||
time_t t = time(0);
|
||||
char buf[256];
|
||||
char hdr1[] = {
|
||||
"/* Generated by convbdf on %s. */\n"
|
||||
"#ifdef HAVE_LCD_BITMAP\n"
|
||||
"\n"
|
||||
"/* Font information*/\n"
|
||||
"#define SYSFONT_NAME %s\n"
|
||||
"#define SYSFONT_FACENAME %s\n"
|
||||
"#define SYSFONT_WIDTH %d\n"
|
||||
"#define SYSFONT_HEIGHT %d\n"
|
||||
"#define SYSFONT_SIZE %d\n"
|
||||
"#define SYSFONT_ASCENT %d\n"
|
||||
"#define SYSFONT_DESCENT %d\n"
|
||||
"#define SYSFONT_FIRST_CHAR %d\n"
|
||||
"#define SYSFONT_LAST_CHAR %d\n"
|
||||
"#define SYSFONT_DEFAULT_CHAR %d\n"
|
||||
"#define SYSFONT_PROPORTIONAL %s\n"
|
||||
"#define SYSFONT_COPYRIGHT %s\n"
|
||||
"#define SYSFONT_BITS_SIZE %d\n"
|
||||
"\n"
|
||||
"#endif\n"
|
||||
};
|
||||
|
||||
ofp = fopen(path, "w");
|
||||
if (!ofp) {
|
||||
fprintf(stderr, "Can't create %s\n", path);
|
||||
return 1;
|
||||
}
|
||||
|
||||
strcpy(buf, ctime(&t));
|
||||
buf[strlen(buf)-1] = 0;
|
||||
|
||||
fprintf(ofp, hdr1, buf,
|
||||
pf->name,
|
||||
pf->facename? pf->facename: "",
|
||||
pf->maxwidth, pf->height,
|
||||
pf->size,
|
||||
pf->ascent, pf->descent,
|
||||
pf->firstchar,
|
||||
pf->firstchar+pf->size-1,
|
||||
pf->defaultchar,
|
||||
pf->width? 1: 0,
|
||||
pf->copyright? pf->copyright: "");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int writebyte(FILE *fp, unsigned char c)
|
||||
{
|
||||
return putc(c, fp) != EOF;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue