diff options
Diffstat (limited to 'tools/convbdf.c')
-rw-r--r-- | tools/convbdf.c | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c index 9b181a4f82..9f6152ebc1 100644 --- a/tools/convbdf.c +++ b/tools/convbdf.c | |||
@@ -72,6 +72,9 @@ struct font { | |||
72 | 72 | ||
73 | /* The number of clipped ascents/descents/total */ | 73 | /* The number of clipped ascents/descents/total */ |
74 | int num_clipped_ascent, num_clipped_descent, num_clipped; | 74 | int num_clipped_ascent, num_clipped_descent, num_clipped; |
75 | |||
76 | /* default width in pixels (can be overwritten at char level) */ | ||
77 | int default_width; | ||
75 | }; | 78 | }; |
76 | /* END font.h*/ | 79 | /* END font.h*/ |
77 | 80 | ||
@@ -567,11 +570,13 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
567 | char buf[256]; | 570 | char buf[256]; |
568 | char facename[256]; | 571 | char facename[256]; |
569 | char copyright[256]; | 572 | char copyright[256]; |
573 | int is_header = 1; | ||
570 | 574 | ||
571 | /* set certain values to errors for later error checking */ | 575 | /* set certain values to errors for later error checking */ |
572 | pf->defaultchar = -1; | 576 | pf->defaultchar = -1; |
573 | pf->ascent = -1; | 577 | pf->ascent = -1; |
574 | pf->descent = -1; | 578 | pf->descent = -1; |
579 | pf->default_width = -1; | ||
575 | 580 | ||
576 | for (;;) { | 581 | for (;;) { |
577 | if (!bdf_getline(fp, buf, sizeof(buf))) { | 582 | if (!bdf_getline(fp, buf, sizeof(buf))) { |
@@ -631,6 +636,19 @@ int bdf_read_header(FILE *fp, struct font* pf) | |||
631 | } | 636 | } |
632 | continue; | 637 | continue; |
633 | } | 638 | } |
639 | if (isprefix(buf, "ENDPROPERTIES") || isprefix(buf, "STARTCHAR")) { | ||
640 | is_header = 0; | ||
641 | continue; | ||
642 | } | ||
643 | |||
644 | /* for BDF version 2.2 */ | ||
645 | if (is_header && isprefix(buf, "DWIDTH ")) { | ||
646 | if (sscanf(buf, "DWIDTH %d", &pf->default_width) != 1) { | ||
647 | print_error("bad 'DWIDTH' at font level\n"); | ||
648 | return 0; | ||
649 | } | ||
650 | continue; | ||
651 | } | ||
634 | 652 | ||
635 | /* | 653 | /* |
636 | * Reading ENCODING is necessary to get firstchar/lastchar | 654 | * Reading ENCODING is necessary to get firstchar/lastchar |
@@ -751,6 +769,9 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) | |||
751 | if (encoding < 0) | 769 | if (encoding < 0) |
752 | continue; | 770 | continue; |
753 | 771 | ||
772 | if (width < 0 && pf->default_width > 0) | ||
773 | width = pf->default_width; | ||
774 | |||
754 | /* set bits offset in encode map*/ | 775 | /* set bits offset in encode map*/ |
755 | if (pf->offset[encoding-pf->firstchar] != -1) { | 776 | if (pf->offset[encoding-pf->firstchar] != -1) { |
756 | print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n", | 777 | print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n", |
@@ -992,6 +1013,11 @@ int bdf_analyze_font(FILE *fp, struct font* pf) { | |||
992 | } | 1013 | } |
993 | ignore_char = (encoding < start_char || encoding > limit_char); | 1014 | ignore_char = (encoding < start_char || encoding > limit_char); |
994 | if (!ignore_char) { | 1015 | if (!ignore_char) { |
1016 | if (!read_width && pf->default_width > 0) | ||
1017 | { | ||
1018 | width = pf->default_width; | ||
1019 | read_width = 1; | ||
1020 | } | ||
995 | if (!read_width || !read_bbx) { | 1021 | if (!read_width || !read_bbx) { |
996 | print_error("WIDTH or BBX is not specified for character %d\n", | 1022 | print_error("WIDTH or BBX is not specified for character %d\n", |
997 | encoding); | 1023 | encoding); |