summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tools/convbdf.c70
1 files changed, 33 insertions, 37 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c
index be746c6683..6dcd2d8394 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -503,7 +503,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
503 } 503 }
504 continue; 504 continue;
505 } 505 }
506 if (strequal(buf, "BITMAP")) { 506 if (strequal(buf, "BITMAP") || strequal(buf, "BITMAP ")) {
507 bitmap_t *ch_bitmap = pf->bits + ofs; 507 bitmap_t *ch_bitmap = pf->bits + ofs;
508 int ch_words; 508 int ch_words;
509 509
@@ -585,15 +585,12 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
585 /* set max width*/ 585 /* set max width*/
586 pf->maxwidth = maxwidth; 586 pf->maxwidth = maxwidth;
587 587
588 /* change unused offset/width values to default char values*/ 588 /* change unused width values to default char values*/
589 for (i=0; i<pf->size; ++i) { 589 for (i=0; i<pf->size; ++i) {
590 int defchar = pf->defaultchar - pf->firstchar; 590 int defchar = pf->defaultchar - pf->firstchar;
591 591
592 if (pf->offset[i] == (unsigned int)-1) { 592 if (pf->offset[i] == (unsigned int)-1)
593 pf->offset[i] = pf->offset[defchar];
594 pf->offrot[i] = pf->offrot[defchar];
595 pf->width[i] = pf->width[defchar]; 593 pf->width[i] = pf->width[defchar];
596 }
597 } 594 }
598 595
599 /* determine whether font doesn't require encode table*/ 596 /* determine whether font doesn't require encode table*/
@@ -767,7 +764,6 @@ int gen_c_source(struct font* pf, char *path)
767{ 764{
768 FILE *ofp; 765 FILE *ofp;
769 int i, ofr = 0; 766 int i, ofr = 0;
770 int did_defaultchar = 0;
771 int did_syncmsg = 0; 767 int did_syncmsg = 0;
772 time_t t = time(0); 768 time_t t = time(0);
773 bitmap_t *ofs = pf->bits; 769 bitmap_t *ofs = pf->bits;
@@ -823,22 +819,14 @@ int gen_c_source(struct font* pf, char *path)
823 int bitcount = 0; 819 int bitcount = 0;
824 int width = pf->width ? pf->width[i] : pf->maxwidth; 820 int width = pf->width ? pf->width[i] : pf->maxwidth;
825 int height = pf->height; 821 int height = pf->height;
826 bitmap_t *bits = pf->bits + (pf->offset? pf->offset[i]: (height * i)); 822 bitmap_t *bits;
827 bitmap_t bitvalue; 823 bitmap_t bitvalue;
828 824
829 /* 825 /* Skip missing glyphs */
830 * Generate bitmap bits only if not this index isn't 826 if (pf->offset && (pf->offset[i] == (unsigned int)-1))
831 * the default character in encode map, or the default 827 continue;
832 * character hasn't been generated yet. 828
833 */ 829 bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i));
834 if (pf->offset &&
835 (pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) {
836 if (did_defaultchar) {
837 pf->offrot[i] = pf->offrot[pf->defaultchar-pf->firstchar];
838 continue;
839 }
840 did_defaultchar = 1;
841 }
842 830
843 fprintf(ofp, "\n/* Character %d (0x%02x):\n width %d", 831 fprintf(ofp, "\n/* Character %d (0x%02x):\n width %d",
844 i+pf->firstchar, i+pf->firstchar, width); 832 i+pf->firstchar, i+pf->firstchar, width);
@@ -888,7 +876,7 @@ int gen_c_source(struct font* pf, char *path)
888 for (x=0; x<width; x++) { 876 for (x=0; x<width; x++) {
889 fprintf(ofp, "0x%02x, ", bytemap[ix]); 877 fprintf(ofp, "0x%02x, ", bytemap[ix]);
890 ix++; 878 ix++;
891 } 879 }
892 fprintf(ofp, "\n"); 880 fprintf(ofp, "\n");
893 } 881 }
894 882
@@ -904,7 +892,7 @@ int gen_c_source(struct font* pf, char *path)
904 fprintf(stderr, "Warning: found encoding values in non-sorted order (not an error).\n"); 892 fprintf(stderr, "Warning: found encoding values in non-sorted order (not an error).\n");
905 did_syncmsg = 1; 893 did_syncmsg = 1;
906 } 894 }
907 } 895 }
908#endif 896#endif
909 } 897 }
910 fprintf(ofp, "};\n\n"); 898 fprintf(ofp, "};\n\n");
@@ -914,13 +902,18 @@ int gen_c_source(struct font* pf, char *path)
914 fprintf(ofp, "/* Character->glyph mapping. */\n" 902 fprintf(ofp, "/* Character->glyph mapping. */\n"
915 "static const unsigned short _sysfont_offset[] = {\n"); 903 "static const unsigned short _sysfont_offset[] = {\n");
916 904
917 for (i=0; i<pf->size; ++i) 905 for (i=0; i<pf->size; ++i) {
906 if (pf->offset[i] == (unsigned int)-1) {
907 pf->offset[i] = pf->offset[pf->defaultchar - pf->firstchar];
908 pf->offrot[i] = pf->offrot[pf->defaultchar - pf->firstchar];
909 }
918 fprintf(ofp, " %ld,\t/* (0x%02x) */\n", 910 fprintf(ofp, " %ld,\t/* (0x%02x) */\n",
919#ifdef ROTATE 911#ifdef ROTATE
920 pf->offrot[i], i+pf->firstchar); 912 pf->offrot[i], i+pf->firstchar);
921#else 913#else
922 pf->offset[i], i+pf->firstchar); 914 pf->offset[i], i+pf->firstchar);
923#endif 915#endif
916 }
924 fprintf(ofp, "};\n\n"); 917 fprintf(ofp, "};\n\n");
925 } 918 }
926 919
@@ -999,7 +992,7 @@ static int writestr(FILE *fp, char *str, int count)
999static int writestrpad(FILE *fp, char *str, int totlen) 992static int writestrpad(FILE *fp, char *str, int totlen)
1000{ 993{
1001 int ret; 994 int ret;
1002 995
1003 while (str && *str && totlen > 0) { 996 while (str && *str && totlen > 0) {
1004 if (*str) { 997 if (*str) {
1005 ret = putc(*str++, fp); 998 ret = putc(*str++, fp);
@@ -1016,7 +1009,6 @@ int gen_fnt_file(struct font* pf, char *path)
1016{ 1009{
1017 FILE *ofp; 1010 FILE *ofp;
1018 int i; 1011 int i;
1019 int did_defaultchar = 0;
1020#ifdef ROTATE 1012#ifdef ROTATE
1021 int ofr = 0; 1013 int ofr = 0;
1022#endif 1014#endif
@@ -1053,19 +1045,16 @@ int gen_fnt_file(struct font* pf, char *path)
1053#ifdef ROTATE 1045#ifdef ROTATE
1054 for (i=0; i<pf->size; ++i) 1046 for (i=0; i<pf->size; ++i)
1055 { 1047 {
1056 bitmap_t* bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i)); 1048 bitmap_t* bits;
1057 int width = pf->width ? pf->width[i] : pf->maxwidth; 1049 int width = pf->width ? pf->width[i] : pf->maxwidth;
1058 int size; 1050 int size;
1059 unsigned char bytemap[256]; 1051 unsigned char bytemap[256];
1060 1052
1061 if (pf->offset && 1053 /* Skip missing glyphs */
1062 (pf->offset[i] == pf->offset[pf->defaultchar-pf->firstchar])) { 1054 if (pf->offset && (pf->offset[i] == (unsigned int)-1))
1063 if (did_defaultchar) { 1055 continue;
1064 pf->offrot[i] = pf->offrot[pf->defaultchar-pf->firstchar]; 1056
1065 continue; 1057 bits = pf->bits + (pf->offset? pf->offset[i]: (pf->height * i));
1066 }
1067 did_defaultchar = 1;
1068 }
1069 1058
1070 size = rotleft(bytemap, bits, width, pf->height); 1059 size = rotleft(bytemap, bits, width, pf->height);
1071 writestr(ofp, (char *)bytemap, size); 1060 writestr(ofp, (char *)bytemap, size);
@@ -1092,6 +1081,9 @@ int gen_fnt_file(struct font* pf, char *path)
1092 { 1081 {
1093 for (i=0; i<pf->size; ++i) 1082 for (i=0; i<pf->size; ++i)
1094 { 1083 {
1084 if (pf->offset[i] == (unsigned int)-1) {
1085 pf->offrot[i] = pf->offrot[pf->defaultchar - pf->firstchar];
1086 }
1095 if ( pf->bits_size < 0xFFDB ) 1087 if ( pf->bits_size < 0xFFDB )
1096 writeshort(ofp, pf->offrot[i]); 1088 writeshort(ofp, pf->offrot[i]);
1097 else 1089 else
@@ -1109,8 +1101,12 @@ int gen_fnt_file(struct font* pf, char *path)
1109 writeshort(ofp, 0); /* pad to 32-bit boundary*/ 1101 writeshort(ofp, 0); /* pad to 32-bit boundary*/
1110 1102
1111 if (pf->offset) 1103 if (pf->offset)
1112 for (i=0; i<pf->size; ++i) 1104 for (i=0; i<pf->size; ++i) {
1105 if (pf->offset[i] == (unsigned int)-1) {
1106 pf->offset[i] = pf->offset[pf->defaultchar - pf->firstchar];
1107 }
1113 writeint(ofp, pf->offset[i]); 1108 writeint(ofp, pf->offset[i]);
1109 }
1114 1110
1115 if (pf->width) 1111 if (pf->width)
1116 for (i=0; i<pf->size; ++i) 1112 for (i=0; i<pf->size; ++i)