diff options
-rw-r--r-- | tools/convbdf.c | 150 |
1 files changed, 89 insertions, 61 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c index 9e684512a7..8b6ef143a2 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c | |||
@@ -10,6 +10,7 @@ | |||
10 | #include <stdio.h> | 10 | #include <stdio.h> |
11 | #include <stdlib.h> | 11 | #include <stdlib.h> |
12 | #include <string.h> | 12 | #include <string.h> |
13 | #include <stdarg.h> | ||
13 | #include <time.h> | 14 | #include <time.h> |
14 | 15 | ||
15 | #define ROTATE /* define this for the new, rotated format */ | 16 | #define ROTATE /* define this for the new, rotated format */ |
@@ -76,8 +77,15 @@ struct font { | |||
76 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) | 77 | #define MIN(a,b) ((a) < (b) ? (a) : (b)) |
77 | 78 | ||
78 | /* Depending on the verbosity level some warnings are printed or not */ | 79 | /* Depending on the verbosity level some warnings are printed or not */ |
79 | int verbose = 0; | 80 | int verbosity_level = 0; |
80 | #define VERBOSE_CLIP 1 /* Only print clip related warnings if verb >= this */ | 81 | |
82 | /* Prints a warning of the specified verbosity level. It will only be | ||
83 | really printed if the level is >= the level set in the settings */ | ||
84 | void print_warning(int level, const char *fmt, ...); | ||
85 | void print_error(const char *fmt, ...); | ||
86 | void print_info(const char *fmt, ...); | ||
87 | #define VL_CLIP 1 /* Verbosity level for clip related warnings */ | ||
88 | #define VL_MIS 1 /* Verbosity level for other warnings */ | ||
81 | 89 | ||
82 | int gen_c = 0; | 90 | int gen_c = 0; |
83 | int gen_h = 0; | 91 | int gen_h = 0; |
@@ -117,10 +125,10 @@ usage(void) | |||
117 | " -s N Start output at character encodings >= N\n" | 125 | " -s N Start output at character encodings >= N\n" |
118 | " -l N Limit output to character encodings <= N\n" | 126 | " -l N Limit output to character encodings <= N\n" |
119 | " -n Don't generate bitmaps as comments in .c file\n" | 127 | " -n Don't generate bitmaps as comments in .c file\n" |
120 | " -v N Verbosity level: 0=quite quiet, 1=more verbose\n" | 128 | " -v N Verbosity level: 0=quite quiet, 1=more verbose, 2=even more, etc.\n" |
121 | }; | 129 | }; |
122 | 130 | ||
123 | fprintf(stderr, "%s", help); | 131 | print_info("%s", help); |
124 | } | 132 | } |
125 | 133 | ||
126 | /* parse command line options*/ | 134 | /* parse command line options*/ |
@@ -136,25 +144,25 @@ void getopts(int *pac, char ***pav) | |||
136 | p = &av[0][1]; | 144 | p = &av[0][1]; |
137 | while( *p) | 145 | while( *p) |
138 | switch(*p++) { | 146 | switch(*p++) { |
139 | case ' ': /* multiple -args on av[]*/ | 147 | case ' ': /* multiple -args on av[] */ |
140 | while( *p && *p == ' ') | 148 | while( *p && *p == ' ') |
141 | p++; | 149 | p++; |
142 | if( *p++ != '-') /* next option must have dash*/ | 150 | if( *p++ != '-') /* next option must have dash */ |
143 | p = ""; | 151 | p = ""; |
144 | break; /* proceed to next option*/ | 152 | break; /* proceed to next option */ |
145 | case 'c': /* generate .c output*/ | 153 | case 'c': /* generate .c output */ |
146 | gen_c = 1; | 154 | gen_c = 1; |
147 | break; | 155 | break; |
148 | case 'h': /* generate .h output*/ | 156 | case 'h': /* generate .h output */ |
149 | gen_h = 1; | 157 | gen_h = 1; |
150 | break; | 158 | break; |
151 | case 'f': /* generate .fnt output*/ | 159 | case 'f': /* generate .fnt output */ |
152 | gen_fnt = 1; | 160 | gen_fnt = 1; |
153 | break; | 161 | break; |
154 | case 'n': /* don't gen bitmap comments*/ | 162 | case 'n': /* don't gen bitmap comments */ |
155 | gen_map = 0; | 163 | gen_map = 0; |
156 | break; | 164 | break; |
157 | case 'o': /* set output file*/ | 165 | case 'o': /* set output file */ |
158 | oflag = 1; | 166 | oflag = 1; |
159 | if (*p) { | 167 | if (*p) { |
160 | strcpy(outfile, p); | 168 | strcpy(outfile, p); |
@@ -167,7 +175,7 @@ void getopts(int *pac, char ***pav) | |||
167 | strcpy(outfile, av[0]); | 175 | strcpy(outfile, av[0]); |
168 | } | 176 | } |
169 | break; | 177 | break; |
170 | case 'l': /* set encoding limit*/ | 178 | case 'l': /* set encoding limit */ |
171 | if (*p) { | 179 | if (*p) { |
172 | limit_char = atoi(p); | 180 | limit_char = atoi(p); |
173 | while (*p && *p != ' ') | 181 | while (*p && *p != ' ') |
@@ -179,7 +187,7 @@ void getopts(int *pac, char ***pav) | |||
179 | limit_char = atoi(av[0]); | 187 | limit_char = atoi(av[0]); |
180 | } | 188 | } |
181 | break; | 189 | break; |
182 | case 's': /* set encoding start*/ | 190 | case 's': /* set encoding start */ |
183 | if (*p) { | 191 | if (*p) { |
184 | start_char = atoi(p); | 192 | start_char = atoi(p); |
185 | while (*p && *p != ' ') | 193 | while (*p && *p != ' ') |
@@ -193,18 +201,18 @@ void getopts(int *pac, char ***pav) | |||
193 | break; | 201 | break; |
194 | case 'v': /* verbosity */ | 202 | case 'v': /* verbosity */ |
195 | if (*p) { | 203 | if (*p) { |
196 | verbose = atoi(p); | 204 | verbosity_level = atoi(p); |
197 | while (*p && *p != ' ') | 205 | while (*p && *p != ' ') |
198 | p++; | 206 | p++; |
199 | } | 207 | } |
200 | else { | 208 | else { |
201 | av++; ac--; | 209 | av++; ac--; |
202 | if (ac > 0) | 210 | if (ac > 0) |
203 | verbose = atoi(av[0]); | 211 | verbosity_level = atoi(av[0]); |
204 | } | 212 | } |
205 | break; | 213 | break; |
206 | default: | 214 | default: |
207 | fprintf(stderr, "Unknown option ignored: %c\r\n", *(p-1)); | 215 | print_info("Unknown option ignored: %c\n", *(p-1)); |
208 | } | 216 | } |
209 | ++av; --ac; | 217 | ++av; --ac; |
210 | } | 218 | } |
@@ -212,6 +220,32 @@ void getopts(int *pac, char ***pav) | |||
212 | *pav = av; | 220 | *pav = av; |
213 | } | 221 | } |
214 | 222 | ||
223 | void print_warning(int level, const char *fmt, ...) { | ||
224 | if (verbosity_level >= level) { | ||
225 | va_list ap; | ||
226 | va_start(ap, fmt); | ||
227 | fprintf(stderr, " WARN: "); | ||
228 | vfprintf(stderr, fmt, ap); | ||
229 | va_end(ap); | ||
230 | } | ||
231 | } | ||
232 | |||
233 | void print_error(const char *fmt, ...) { | ||
234 | va_list ap; | ||
235 | va_start(ap, fmt); | ||
236 | fprintf(stderr, "ERROR: "); | ||
237 | vfprintf(stderr, fmt, ap); | ||
238 | va_end(ap); | ||
239 | } | ||
240 | |||
241 | void print_info(const char *fmt, ...) { | ||
242 | va_list ap; | ||
243 | va_start(ap, fmt); | ||
244 | fprintf(stderr, " INFO: "); | ||
245 | vfprintf(stderr, fmt, ap); | ||
246 | va_end(ap); | ||
247 | } | ||
248 | |||
215 | /* remove directory prefix and file suffix from full path */ | 249 | /* remove directory prefix and file suffix from full path */ |
216 | char *basename(char *path) | 250 | char *basename(char *path) |
217 | { | 251 | { |
@@ -325,7 +359,7 @@ struct font* bdf_read_font(char *path) | |||
325 | 359 | ||
326 | fp = fopen(path, "rb"); | 360 | fp = fopen(path, "rb"); |
327 | if (!fp) { | 361 | if (!fp) { |
328 | fprintf(stderr, "Error opening file: %s\n", path); | 362 | print_error("Error opening file: %s\n", path); |
329 | return NULL; | 363 | return NULL; |
330 | } | 364 | } |
331 | 365 | ||
@@ -337,7 +371,7 @@ struct font* bdf_read_font(char *path) | |||
337 | pf->name = strdup(basename(path)); | 371 | pf->name = strdup(basename(path)); |
338 | 372 | ||
339 | if (!bdf_read_header(fp, pf)) { | 373 | if (!bdf_read_header(fp, pf)) { |
340 | fprintf(stderr, "Error reading font header\n"); | 374 | print_error("Error reading font header\n"); |
341 | goto errout; | 375 | goto errout; |
342 | } | 376 | } |
343 | 377 | ||
@@ -345,19 +379,17 @@ struct font* bdf_read_font(char *path) | |||
345 | pf->num_clipped_ascent = pf->num_clipped_descent = pf->num_clipped = 0; | 379 | pf->num_clipped_ascent = pf->num_clipped_descent = pf->num_clipped = 0; |
346 | 380 | ||
347 | if (!bdf_read_bitmaps(fp, pf)) { | 381 | if (!bdf_read_bitmaps(fp, pf)) { |
348 | fprintf(stderr, "Error reading font bitmaps\n"); | 382 | print_error("Error reading font bitmaps\n"); |
349 | goto errout; | 383 | goto errout; |
350 | } | 384 | } |
351 | 385 | ||
352 | if (verbose >= VERBOSE_CLIP) { | 386 | if (pf->num_clipped > 0) { |
353 | if (pf->num_clipped > 0) { | 387 | print_warning(VL_CLIP, "%d character(s) out of %d were clipped " |
354 | fprintf(stderr, "Warning: %d characters out of %d were clipped " | 388 | "(%d at ascent, %d at descent)\n", |
355 | "(%d at ascent, %d at descent)\n", | 389 | pf->num_clipped, pf->nchars, |
356 | pf->num_clipped, pf->nchars, | 390 | pf->num_clipped_ascent, pf->num_clipped_descent); |
357 | pf->num_clipped_ascent, pf->num_clipped_descent); | 391 | print_warning(VL_CLIP, "max overflows: %d pixel(s) at ascent, %d pixel(s) at descent\n", |
358 | fprintf(stderr, " max overflows: ascent: %d, descent: %d\n", | 392 | pf->max_over_ascent, pf->max_over_descent); |
359 | pf->max_over_ascent, pf->max_over_descent); | ||
360 | } | ||
361 | } | 393 | } |
362 | 394 | ||
363 | fclose(fp); | 395 | fclose(fp); |
@@ -386,12 +418,12 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
386 | 418 | ||
387 | for (;;) { | 419 | for (;;) { |
388 | if (!bdf_getline(fp, buf, sizeof(buf))) { | 420 | if (!bdf_getline(fp, buf, sizeof(buf))) { |
389 | fprintf(stderr, "Error: EOF on file\n"); | 421 | print_error("EOF on file\n"); |
390 | return 0; | 422 | return 0; |
391 | } | 423 | } |
392 | if (isprefix(buf, "FONT ")) { /* not required */ | 424 | if (isprefix(buf, "FONT ")) { /* not required */ |
393 | if (sscanf(buf, "FONT %[^\n]", facename) != 1) { | 425 | if (sscanf(buf, "FONT %[^\n]", facename) != 1) { |
394 | fprintf(stderr, "Error: bad 'FONT'\n"); | 426 | print_error("bad 'FONT'\n"); |
395 | return 0; | 427 | return 0; |
396 | } | 428 | } |
397 | pf->facename = strdup(facename); | 429 | pf->facename = strdup(facename); |
@@ -399,7 +431,7 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
399 | } | 431 | } |
400 | if (isprefix(buf, "COPYRIGHT ")) { /* not required */ | 432 | if (isprefix(buf, "COPYRIGHT ")) { /* not required */ |
401 | if (sscanf(buf, "COPYRIGHT \"%[^\"]", copyright) != 1) { | 433 | if (sscanf(buf, "COPYRIGHT \"%[^\"]", copyright) != 1) { |
402 | fprintf(stderr, "Error: bad 'COPYRIGHT'\n"); | 434 | print_error("bad 'COPYRIGHT'\n"); |
403 | return 0; | 435 | return 0; |
404 | } | 436 | } |
405 | pf->copyright = strdup(copyright); | 437 | pf->copyright = strdup(copyright); |
@@ -407,20 +439,20 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
407 | } | 439 | } |
408 | if (isprefix(buf, "DEFAULT_CHAR ")) { /* not required */ | 440 | if (isprefix(buf, "DEFAULT_CHAR ")) { /* not required */ |
409 | if (sscanf(buf, "DEFAULT_CHAR %d", &pf->defaultchar) != 1) { | 441 | if (sscanf(buf, "DEFAULT_CHAR %d", &pf->defaultchar) != 1) { |
410 | fprintf(stderr, "Error: bad 'DEFAULT_CHAR'\n"); | 442 | print_error("bad 'DEFAULT_CHAR'\n"); |
411 | return 0; | 443 | return 0; |
412 | } | 444 | } |
413 | } | 445 | } |
414 | if (isprefix(buf, "FONT_DESCENT ")) { | 446 | if (isprefix(buf, "FONT_DESCENT ")) { |
415 | if (sscanf(buf, "FONT_DESCENT %d", &pf->descent) != 1) { | 447 | if (sscanf(buf, "FONT_DESCENT %d", &pf->descent) != 1) { |
416 | fprintf(stderr, "Error: bad 'FONT_DESCENT'\n"); | 448 | print_error("bad 'FONT_DESCENT'\n"); |
417 | return 0; | 449 | return 0; |
418 | } | 450 | } |
419 | continue; | 451 | continue; |
420 | } | 452 | } |
421 | if (isprefix(buf, "FONT_ASCENT ")) { | 453 | if (isprefix(buf, "FONT_ASCENT ")) { |
422 | if (sscanf(buf, "FONT_ASCENT %d", &pf->ascent) != 1) { | 454 | if (sscanf(buf, "FONT_ASCENT %d", &pf->ascent) != 1) { |
423 | fprintf(stderr, "Error: bad 'FONT_ASCENT'\n"); | 455 | print_error("bad 'FONT_ASCENT'\n"); |
424 | return 0; | 456 | return 0; |
425 | } | 457 | } |
426 | continue; | 458 | continue; |
@@ -428,14 +460,14 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
428 | if (isprefix(buf, "FONTBOUNDINGBOX ")) { | 460 | if (isprefix(buf, "FONTBOUNDINGBOX ")) { |
429 | if (sscanf(buf, "FONTBOUNDINGBOX %d %d %d %d", | 461 | if (sscanf(buf, "FONTBOUNDINGBOX %d %d %d %d", |
430 | &pf->fbbw, &pf->fbbh, &pf->fbbx, &pf->fbby) != 4) { | 462 | &pf->fbbw, &pf->fbbh, &pf->fbbx, &pf->fbby) != 4) { |
431 | fprintf(stderr, "Error: bad 'FONTBOUNDINGBOX'\n"); | 463 | print_error("bad 'FONTBOUNDINGBOX'\n"); |
432 | return 0; | 464 | return 0; |
433 | } | 465 | } |
434 | continue; | 466 | continue; |
435 | } | 467 | } |
436 | if (isprefix(buf, "CHARS ")) { | 468 | if (isprefix(buf, "CHARS ")) { |
437 | if (sscanf(buf, "CHARS %d", &pf->nchars) != 1) { | 469 | if (sscanf(buf, "CHARS %d", &pf->nchars) != 1) { |
438 | fprintf(stderr, "Error: bad 'CHARS'\n"); | 470 | print_error("bad 'CHARS'\n"); |
439 | return 0; | 471 | return 0; |
440 | } | 472 | } |
441 | continue; | 473 | continue; |
@@ -448,7 +480,7 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
448 | */ | 480 | */ |
449 | if (isprefix(buf, "ENCODING ")) { | 481 | if (isprefix(buf, "ENCODING ")) { |
450 | if (sscanf(buf, "ENCODING %d", &encoding) != 1) { | 482 | if (sscanf(buf, "ENCODING %d", &encoding) != 1) { |
451 | fprintf(stderr, "Error: bad 'ENCODING'\n"); | 483 | print_error("bad 'ENCODING'\n"); |
452 | return 0; | 484 | return 0; |
453 | } | 485 | } |
454 | if (encoding >= 0 && | 486 | if (encoding >= 0 && |
@@ -468,7 +500,7 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
468 | 500 | ||
469 | /* calc font height*/ | 501 | /* calc font height*/ |
470 | if (pf->ascent < 0 || pf->descent < 0 || firstchar < 0) { | 502 | if (pf->ascent < 0 || pf->descent < 0 || firstchar < 0) { |
471 | fprintf(stderr, "Error: Invalid BDF file, requires FONT_ASCENT/FONT_DESCENT/ENCODING\n"); | 503 | print_error("Invalid BDF file, requires FONT_ASCENT/FONT_DESCENT/ENCODING\n"); |
472 | return 0; | 504 | return 0; |
473 | } | 505 | } |
474 | pf->height = pf->ascent + pf->descent; | 506 | pf->height = pf->ascent + pf->descent; |
@@ -494,7 +526,7 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
494 | pf->width = (unsigned char *)malloc(pf->size * sizeof(unsigned char)); | 526 | pf->width = (unsigned char *)malloc(pf->size * sizeof(unsigned char)); |
495 | 527 | ||
496 | if (!pf->bits || !pf->offset || !pf->offrot || !pf->width) { | 528 | if (!pf->bits || !pf->offset || !pf->offrot || !pf->width) { |
497 | fprintf(stderr, "Error: no memory for font load\n"); | 529 | print_error("no memory for font load\n"); |
498 | return 0; | 530 | return 0; |
499 | } | 531 | } |
500 | 532 | ||
@@ -524,7 +556,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
524 | 556 | ||
525 | for (;;) { | 557 | for (;;) { |
526 | if (!bdf_getline(fp, buf, sizeof(buf))) { | 558 | if (!bdf_getline(fp, buf, sizeof(buf))) { |
527 | fprintf(stderr, "Error: EOF on file\n"); | 559 | print_error("EOF on file\n"); |
528 | return 0; | 560 | return 0; |
529 | } | 561 | } |
530 | if (isprefix(buf, "STARTCHAR")) { | 562 | if (isprefix(buf, "STARTCHAR")) { |
@@ -537,7 +569,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
537 | } | 569 | } |
538 | if (isprefix(buf, "ENCODING ")) { | 570 | if (isprefix(buf, "ENCODING ")) { |
539 | if (sscanf(buf, "ENCODING %d", &encoding) != 1) { | 571 | if (sscanf(buf, "ENCODING %d", &encoding) != 1) { |
540 | fprintf(stderr, "Error: bad 'ENCODING'\n"); | 572 | print_error("bad 'ENCODING'\n"); |
541 | return 0; | 573 | return 0; |
542 | } | 574 | } |
543 | if (encoding < start_char || encoding > limit_char) | 575 | if (encoding < start_char || encoding > limit_char) |
@@ -546,7 +578,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
546 | } | 578 | } |
547 | if (isprefix(buf, "DWIDTH ")) { | 579 | if (isprefix(buf, "DWIDTH ")) { |
548 | if (sscanf(buf, "DWIDTH %d", &width) != 1) { | 580 | if (sscanf(buf, "DWIDTH %d", &width) != 1) { |
549 | fprintf(stderr, "Error: bad 'DWIDTH'\n"); | 581 | print_error("bad 'DWIDTH'\n"); |
550 | return 0; | 582 | return 0; |
551 | } | 583 | } |
552 | /* use font boundingbox width if DWIDTH <= 0 */ | 584 | /* use font boundingbox width if DWIDTH <= 0 */ |
@@ -556,7 +588,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
556 | } | 588 | } |
557 | if (isprefix(buf, "BBX ")) { | 589 | if (isprefix(buf, "BBX ")) { |
558 | if (sscanf(buf, "BBX %d %d %d %d", &bbw, &bbh, &bbx, &bby) != 4) { | 590 | if (sscanf(buf, "BBX %d %d %d %d", &bbw, &bbh, &bbx, &bby) != 4) { |
559 | fprintf(stderr, "Error: bad 'BBX'\n"); | 591 | print_error("bad 'BBX'\n"); |
560 | return 0; | 592 | return 0; |
561 | } | 593 | } |
562 | continue; | 594 | continue; |
@@ -570,7 +602,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
570 | 602 | ||
571 | /* set bits offset in encode map*/ | 603 | /* set bits offset in encode map*/ |
572 | if (pf->offset[encoding-pf->firstchar] != -1) { | 604 | if (pf->offset[encoding-pf->firstchar] != -1) { |
573 | fprintf(stderr, "Error: duplicate encoding for character %d (0x%02x), ignoring duplicate\n", | 605 | print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n", |
574 | encoding, encoding); | 606 | encoding, encoding); |
575 | continue; | 607 | continue; |
576 | } | 608 | } |
@@ -606,11 +638,9 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
606 | pf->max_over_ascent = overflow_asc; | 638 | pf->max_over_ascent = overflow_asc; |
607 | } | 639 | } |
608 | bbh = MAX(bbh - overflow_asc, 0); /* Clipped -> decrease the height */ | 640 | bbh = MAX(bbh - overflow_asc, 0); /* Clipped -> decrease the height */ |
609 | if (verbose >= VERBOSE_CLIP) { | 641 | print_warning(VL_CLIP, "character %d goes %d pixel(s)" |
610 | fprintf(stderr, "Warning: character %d goes %d pixel(s)" | 642 | " beyond the font's ascent, it will be clipped\n", |
611 | " beyond the font's ascent, it will be clipped\n", | 643 | encoding, overflow_asc); |
612 | encoding, overflow_asc); | ||
613 | } | ||
614 | } | 644 | } |
615 | overflow_desc = -bby - pf->descent; | 645 | overflow_desc = -bby - pf->descent; |
616 | if (overflow_desc > 0) { | 646 | if (overflow_desc > 0) { |
@@ -620,11 +650,9 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
620 | } | 650 | } |
621 | bby += overflow_desc; | 651 | bby += overflow_desc; |
622 | bbh = MAX(bbh - overflow_desc, 0); /* Clipped -> decrease the height */ | 652 | bbh = MAX(bbh - overflow_desc, 0); /* Clipped -> decrease the height */ |
623 | if (verbose >= VERBOSE_CLIP) { | 653 | print_warning(VL_CLIP, "character %d goes %d pixel(s)" |
624 | fprintf(stderr, "Warning: character %d goes %d pixel(s)" | 654 | " beyond the font's descent, it will be clipped\n", |
625 | " beyond the font's descent, it will be clipped\n", | 655 | encoding, overflow_desc); |
626 | encoding, overflow_desc); | ||
627 | } | ||
628 | } | 656 | } |
629 | if (overflow_asc > 0 || overflow_desc > 0) { | 657 | if (overflow_asc > 0 || overflow_desc > 0) { |
630 | pf->num_clipped++; | 658 | pf->num_clipped++; |
@@ -637,7 +665,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
637 | int hexnibbles; | 665 | int hexnibbles; |
638 | 666 | ||
639 | if (!bdf_getline(fp, buf, sizeof(buf))) { | 667 | if (!bdf_getline(fp, buf, sizeof(buf))) { |
640 | fprintf(stderr, "Error: EOF reading BITMAP data for character %d\n", | 668 | print_error("EOF reading BITMAP data for character %d\n", |
641 | encoding); | 669 | encoding); |
642 | return 0; | 670 | return 0; |
643 | } | 671 | } |
@@ -827,7 +855,7 @@ int rotleft(unsigned char *dst, /* output buffer */ | |||
827 | src_words = BITMAP_WORDS(width) * height; | 855 | src_words = BITMAP_WORDS(width) * height; |
828 | 856 | ||
829 | if(((height + 7) / 8) * width > dstlen) { | 857 | if(((height + 7) / 8) * width > dstlen) { |
830 | fprintf(stderr, "%s:%d %d x %d overflows %ld bytes buffer, needs %d\n", | 858 | print_error("%s:%d %d x %d overflows %ld bytes buffer, needs %d\n", |
831 | __FILE__, __LINE__, width, height, (unsigned long)dstlen, | 859 | __FILE__, __LINE__, width, height, (unsigned long)dstlen, |
832 | ((height + 7) / 8) * width ); | 860 | ((height + 7) / 8) * width ); |
833 | return 0; | 861 | return 0; |
@@ -907,7 +935,7 @@ int gen_c_source(struct font* pf, char *path) | |||
907 | 935 | ||
908 | ofp = fopen(path, "w"); | 936 | ofp = fopen(path, "w"); |
909 | if (!ofp) { | 937 | if (!ofp) { |
910 | fprintf(stderr, "Can't create %s\n", path); | 938 | print_error("Can't create %s\n", path); |
911 | return 1; | 939 | return 1; |
912 | } | 940 | } |
913 | 941 | ||
@@ -1003,7 +1031,7 @@ int gen_c_source(struct font* pf, char *path) | |||
1003 | for (x=BITMAP_WORDS(width)*pf->height; x>0; --x) { | 1031 | for (x=BITMAP_WORDS(width)*pf->height; x>0; --x) { |
1004 | fprintf(ofp, "0x%04x,\n", *bits); | 1032 | fprintf(ofp, "0x%04x,\n", *bits); |
1005 | if (!did_syncmsg && *bits++ != *ofs++) { | 1033 | if (!did_syncmsg && *bits++ != *ofs++) { |
1006 | fprintf(stderr, "Warning: found encoding values in non-sorted order (not an error).\n"); | 1034 | print_warning(VL_MISC, "found encoding values in non-sorted order (not an error).\n"); |
1007 | did_syncmsg = 1; | 1035 | did_syncmsg = 1; |
1008 | } | 1036 | } |
1009 | } | 1037 | } |
@@ -1109,7 +1137,7 @@ int gen_h_header(struct font* pf, char *path) | |||
1109 | 1137 | ||
1110 | ofp = fopen(path, "w"); | 1138 | ofp = fopen(path, "w"); |
1111 | if (!ofp) { | 1139 | if (!ofp) { |
1112 | fprintf(stderr, "Can't create %s\n", path); | 1140 | print_error("Can't create %s\n", path); |
1113 | return 1; | 1141 | return 1; |
1114 | } | 1142 | } |
1115 | 1143 | ||
@@ -1188,7 +1216,7 @@ int gen_fnt_file(struct font* pf, char *path) | |||
1188 | 1216 | ||
1189 | ofp = fopen(path, "wb"); | 1217 | ofp = fopen(path, "wb"); |
1190 | if (!ofp) { | 1218 | if (!ofp) { |
1191 | fprintf(stderr, "Can't create %s\n", path); | 1219 | print_error("Can't create %s\n", path); |
1192 | return 1; | 1220 | return 1; |
1193 | } | 1221 | } |
1194 | 1222 | ||