summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexander Levin <al.le@rockbox.org>2009-04-29 21:51:04 +0000
committerAlexander Levin <al.le@rockbox.org>2009-04-29 21:51:04 +0000
commitecd4394f624b9f10b091bc90a63fd80653f85fad (patch)
treea3e6cb3507dec55492c6406b8d7e9f6b30444b35
parent19c258847109d04d65eaddc07532c250ab7df5dc (diff)
downloadrockbox-ecd4394f624b9f10b091bc90a63fd80653f85fad.tar.gz
rockbox-ecd4394f624b9f10b091bc90a63fd80653f85fad.zip
Allow to specify DWIDTH at font level making DWIDTH at char level optional (FS#10176 by Yoshihisa Uchida with minor modifications by me)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20828 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--tools/convbdf.c26
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);