forked from len0rd/rockbox
Only print clip warnings in verbose mode
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20222 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
2af0b60aaa
commit
031ac442c5
1 changed files with 36 additions and 13 deletions
|
|
@ -75,6 +75,10 @@ struct font {
|
||||||
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
#define MAX(a,b) ((a) > (b) ? (a) : (b))
|
||||||
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
#define MIN(a,b) ((a) < (b) ? (a) : (b))
|
||||||
|
|
||||||
|
/* Depending on the verbosity level some warnings are printed or not */
|
||||||
|
int verbose = 0;
|
||||||
|
#define VERBOSE_CLIP 1 /* Only print clip related warnings if verb >= this */
|
||||||
|
|
||||||
int gen_c = 0;
|
int gen_c = 0;
|
||||||
int gen_h = 0;
|
int gen_h = 0;
|
||||||
int gen_fnt = 0;
|
int gen_fnt = 0;
|
||||||
|
|
@ -113,6 +117,7 @@ usage(void)
|
||||||
" -s N Start output at character encodings >= N\n"
|
" -s N Start output at character encodings >= N\n"
|
||||||
" -l N Limit output to character encodings <= N\n"
|
" -l N Limit output to character encodings <= N\n"
|
||||||
" -n Don't generate bitmaps as comments in .c file\n"
|
" -n Don't generate bitmaps as comments in .c file\n"
|
||||||
|
" -v N Verbosity level: 0=quite quiet, 1=more verbose\n"
|
||||||
};
|
};
|
||||||
|
|
||||||
fprintf(stderr, "%s", help);
|
fprintf(stderr, "%s", help);
|
||||||
|
|
@ -186,6 +191,18 @@ void getopts(int *pac, char ***pav)
|
||||||
start_char = atoi(av[0]);
|
start_char = atoi(av[0]);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case 'v': /* verbosity */
|
||||||
|
if (*p) {
|
||||||
|
verbose = atoi(p);
|
||||||
|
while (*p && *p != ' ')
|
||||||
|
p++;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
av++; ac--;
|
||||||
|
if (ac > 0)
|
||||||
|
verbose = atoi(av[0]);
|
||||||
|
}
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "Unknown option ignored: %c\r\n", *(p-1));
|
fprintf(stderr, "Unknown option ignored: %c\r\n", *(p-1));
|
||||||
}
|
}
|
||||||
|
|
@ -332,13 +349,15 @@ struct font* bdf_read_font(char *path)
|
||||||
goto errout;
|
goto errout;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pf->num_clipped > 0) {
|
if (verbose >= VERBOSE_CLIP) {
|
||||||
fprintf(stderr, "Warning: %d characters out of %d were clipped "
|
if (pf->num_clipped > 0) {
|
||||||
"(%d at ascent, %d at descent)\n",
|
fprintf(stderr, "Warning: %d characters out of %d were clipped "
|
||||||
pf->num_clipped, pf->nchars,
|
"(%d at ascent, %d at descent)\n",
|
||||||
pf->num_clipped_ascent, pf->num_clipped_descent);
|
pf->num_clipped, pf->nchars,
|
||||||
fprintf(stderr, " max overflows: ascent: %d, descent: %d\n",
|
pf->num_clipped_ascent, pf->num_clipped_descent);
|
||||||
pf->max_over_ascent, pf->max_over_descent);
|
fprintf(stderr, " max overflows: ascent: %d, descent: %d\n",
|
||||||
|
pf->max_over_ascent, pf->max_over_descent);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
|
|
@ -587,9 +606,11 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
|
||||||
pf->max_over_ascent = overflow_asc;
|
pf->max_over_ascent = overflow_asc;
|
||||||
}
|
}
|
||||||
bbh = MAX(bbh - overflow_asc, 0); /* Clipped -> decrease the height */
|
bbh = MAX(bbh - overflow_asc, 0); /* Clipped -> decrease the height */
|
||||||
fprintf(stderr, "Warning: character %d goes %d pixel(s)"
|
if (verbose >= VERBOSE_CLIP) {
|
||||||
" beyond the font's ascent, it will be clipped\n",
|
fprintf(stderr, "Warning: character %d goes %d pixel(s)"
|
||||||
encoding, overflow_asc);
|
" beyond the font's ascent, it will be clipped\n",
|
||||||
|
encoding, overflow_asc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
overflow_desc = -bby - pf->descent;
|
overflow_desc = -bby - pf->descent;
|
||||||
if (overflow_desc > 0) {
|
if (overflow_desc > 0) {
|
||||||
|
|
@ -599,9 +620,11 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
|
||||||
}
|
}
|
||||||
bby += overflow_desc;
|
bby += overflow_desc;
|
||||||
bbh = MAX(bbh - overflow_desc, 0); /* Clipped -> decrease the height */
|
bbh = MAX(bbh - overflow_desc, 0); /* Clipped -> decrease the height */
|
||||||
fprintf(stderr, "Warning: character %d goes %d pixel(s)"
|
if (verbose >= VERBOSE_CLIP) {
|
||||||
" beyond the font's descent, it will be clipped\n",
|
fprintf(stderr, "Warning: character %d goes %d pixel(s)"
|
||||||
encoding, overflow_desc);
|
" beyond the font's descent, it will be clipped\n",
|
||||||
|
encoding, overflow_desc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (overflow_asc > 0 || overflow_desc > 0) {
|
if (overflow_asc > 0 || overflow_desc > 0) {
|
||||||
pf->num_clipped++;
|
pf->num_clipped++;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue