diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/convbdf.c | 49 |
1 files changed, 36 insertions, 13 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c index b7790416a7..9e684512a7 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c | |||
@@ -75,6 +75,10 @@ struct font { | |||
75 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) | 75 | #define MAX(a,b) ((a) > (b) ? (a) : (b)) |
76 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) | 76 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
77 | 77 | ||
78 | /* Depending on the verbosity level some warnings are printed or not */ | ||
79 | int verbose = 0; | ||
80 | #define VERBOSE_CLIP 1 /* Only print clip related warnings if verb >= this */ | ||
81 | |||
78 | int gen_c = 0; | 82 | int gen_c = 0; |
79 | int gen_h = 0; | 83 | int gen_h = 0; |
80 | int gen_fnt = 0; | 84 | int gen_fnt = 0; |
@@ -113,6 +117,7 @@ usage(void) | |||
113 | " -s N Start output at character encodings >= N\n" | 117 | " -s N Start output at character encodings >= N\n" |
114 | " -l N Limit output to character encodings <= N\n" | 118 | " -l N Limit output to character encodings <= N\n" |
115 | " -n Don't generate bitmaps as comments in .c file\n" | 119 | " -n Don't generate bitmaps as comments in .c file\n" |
120 | " -v N Verbosity level: 0=quite quiet, 1=more verbose\n" | ||
116 | }; | 121 | }; |
117 | 122 | ||
118 | fprintf(stderr, "%s", help); | 123 | fprintf(stderr, "%s", help); |
@@ -186,6 +191,18 @@ void getopts(int *pac, char ***pav) | |||
186 | start_char = atoi(av[0]); | 191 | start_char = atoi(av[0]); |
187 | } | 192 | } |
188 | break; | 193 | break; |
194 | case 'v': /* verbosity */ | ||
195 | if (*p) { | ||
196 | verbose = atoi(p); | ||
197 | while (*p && *p != ' ') | ||
198 | p++; | ||
199 | } | ||
200 | else { | ||
201 | av++; ac--; | ||
202 | if (ac > 0) | ||
203 | verbose = atoi(av[0]); | ||
204 | } | ||
205 | break; | ||
189 | default: | 206 | default: |
190 | fprintf(stderr, "Unknown option ignored: %c\r\n", *(p-1)); | 207 | fprintf(stderr, "Unknown option ignored: %c\r\n", *(p-1)); |
191 | } | 208 | } |
@@ -332,13 +349,15 @@ struct font* bdf_read_font(char *path) | |||
332 | goto errout; | 349 | goto errout; |
333 | } | 350 | } |
334 | 351 | ||
335 | if (pf->num_clipped > 0) { | 352 | if (verbose >= VERBOSE_CLIP) { |
336 | fprintf(stderr, "Warning: %d characters out of %d were clipped " | 353 | if (pf->num_clipped > 0) { |
337 | "(%d at ascent, %d at descent)\n", | 354 | fprintf(stderr, "Warning: %d characters out of %d were clipped " |
338 | pf->num_clipped, pf->nchars, | 355 | "(%d at ascent, %d at descent)\n", |
339 | pf->num_clipped_ascent, pf->num_clipped_descent); | 356 | pf->num_clipped, pf->nchars, |
340 | fprintf(stderr, " max overflows: ascent: %d, descent: %d\n", | 357 | pf->num_clipped_ascent, pf->num_clipped_descent); |
341 | pf->max_over_ascent, pf->max_over_descent); | 358 | fprintf(stderr, " max overflows: ascent: %d, descent: %d\n", |
359 | pf->max_over_ascent, pf->max_over_descent); | ||
360 | } | ||
342 | } | 361 | } |
343 | 362 | ||
344 | fclose(fp); | 363 | fclose(fp); |
@@ -587,9 +606,11 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
587 | pf->max_over_ascent = overflow_asc; | 606 | pf->max_over_ascent = overflow_asc; |
588 | } | 607 | } |
589 | bbh = MAX(bbh - overflow_asc, 0); /* Clipped -> decrease the height */ | 608 | bbh = MAX(bbh - overflow_asc, 0); /* Clipped -> decrease the height */ |
590 | fprintf(stderr, "Warning: character %d goes %d pixel(s)" | 609 | if (verbose >= VERBOSE_CLIP) { |
591 | " beyond the font's ascent, it will be clipped\n", | 610 | fprintf(stderr, "Warning: character %d goes %d pixel(s)" |
592 | encoding, overflow_asc); | 611 | " beyond the font's ascent, it will be clipped\n", |
612 | encoding, overflow_asc); | ||
613 | } | ||
593 | } | 614 | } |
594 | overflow_desc = -bby - pf->descent; | 615 | overflow_desc = -bby - pf->descent; |
595 | if (overflow_desc > 0) { | 616 | if (overflow_desc > 0) { |
@@ -599,9 +620,11 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
599 | } | 620 | } |
600 | bby += overflow_desc; | 621 | bby += overflow_desc; |
601 | bbh = MAX(bbh - overflow_desc, 0); /* Clipped -> decrease the height */ | 622 | bbh = MAX(bbh - overflow_desc, 0); /* Clipped -> decrease the height */ |
602 | fprintf(stderr, "Warning: character %d goes %d pixel(s)" | 623 | if (verbose >= VERBOSE_CLIP) { |
603 | " beyond the font's descent, it will be clipped\n", | 624 | fprintf(stderr, "Warning: character %d goes %d pixel(s)" |
604 | encoding, overflow_desc); | 625 | " beyond the font's descent, it will be clipped\n", |
626 | encoding, overflow_desc); | ||
627 | } | ||
605 | } | 628 | } |
606 | if (overflow_asc > 0 || overflow_desc > 0) { | 629 | if (overflow_asc > 0 || overflow_desc > 0) { |
607 | pf->num_clipped++; | 630 | pf->num_clipped++; |