summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/convbdf.c74
1 files changed, 37 insertions, 37 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c
index b8f7b1955f..c9c43848ed 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -15,7 +15,7 @@
15 15
16#define ROTATE /* define this for the new, rotated format */ 16#define ROTATE /* define this for the new, rotated format */
17 17
18/* BEGIN font.h*/ 18/* BEGIN font.h */
19/* loadable font magic and version number */ 19/* loadable font magic and version number */
20#ifdef ROTATE 20#ifdef ROTATE
21#define VERSION "RB12" /* newer version */ 21#define VERSION "RB12" /* newer version */
@@ -76,7 +76,7 @@ struct font {
76 /* default width in pixels (can be overwritten at char level) */ 76 /* default width in pixels (can be overwritten at char level) */
77 int default_width; 77 int default_width;
78}; 78};
79/* END font.h*/ 79/* END font.h */
80 80
81/* Description of how the ascent/descent is allowed to grow */ 81/* Description of how the ascent/descent is allowed to grow */
82struct stretch { 82struct stretch {
@@ -201,7 +201,7 @@ void parse_ascent_opt(char *val, struct stretch *opt) {
201 opt->value = atoi(buf); 201 opt->value = atoi(buf);
202} 202}
203 203
204/* parse command line options*/ 204/* parse command line options */
205void getopts(int *pac, char ***pav) 205void getopts(int *pac, char ***pav)
206{ 206{
207 char *p; 207 char *p;
@@ -676,7 +676,7 @@ int bdf_read_header(FILE *fp, struct font* pf)
676 break; 676 break;
677 } 677 }
678 678
679 /* calc font height*/ 679 /* calc font height */
680 if (pf->ascent < 0 || pf->descent < 0 || firstchar < 0) { 680 if (pf->ascent < 0 || pf->descent < 0 || firstchar < 0) {
681 print_error("Invalid BDF file, requires FONT_ASCENT/FONT_DESCENT/ENCODING\n"); 681 print_error("Invalid BDF file, requires FONT_ASCENT/FONT_DESCENT/ENCODING\n");
682 return 0; 682 return 0;
@@ -712,7 +712,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
712 int bbw, bbh, bbx, bby; 712 int bbw, bbh, bbx, bby;
713 int proportional = 0; 713 int proportional = 0;
714 int encodetable = 0; 714 int encodetable = 0;
715 int l; 715 int offset;
716 char buf[256]; 716 char buf[256];
717 bitmap_t *ch_bitmap; 717 bitmap_t *ch_bitmap;
718 int ch_words; 718 int ch_words;
@@ -773,7 +773,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
773 if (width < 0 && pf->default_width > 0) 773 if (width < 0 && pf->default_width > 0)
774 width = pf->default_width; 774 width = pf->default_width;
775 775
776 /* set bits offset in encode map*/ 776 /* set bits offset in encode map */
777 if (pf->offset[encoding-pf->firstchar] != -1) { 777 if (pf->offset[encoding-pf->firstchar] != -1) {
778 print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n", 778 print_error("duplicate encoding for character %d (0x%02x), ignoring duplicate\n",
779 encoding, encoding); 779 encoding, encoding);
@@ -888,22 +888,22 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
888 888
889 /* determine whether font doesn't require encode table */ 889 /* determine whether font doesn't require encode table */
890#ifdef ROTATE 890#ifdef ROTATE
891 l = 0; 891 offset = 0;
892 for (i=0; i<pf->size; ++i) { 892 for (i=0; i<pf->size; ++i) {
893 if ((int)pf->offrot[i] != l) { 893 if ((int)pf->offrot[i] != offset) {
894 encodetable = 1; 894 encodetable = 1;
895 break; 895 break;
896 } 896 }
897 l += pf->maxwidth * ((pf->height + 7) / 8); 897 offset += pf->maxwidth * ((pf->height + 7) / 8);
898 } 898 }
899#else 899#else
900 l = 0; 900 offset = 0;
901 for (i=0; i<pf->size; ++i) { 901 for (i=0; i<pf->size; ++i) {
902 if (pf->offset[i] != l) { 902 if (pf->offset[i] != offset) {
903 encodetable = 1; 903 encodetable = 1;
904 break; 904 break;
905 } 905 }
906 l += BITMAP_WORDS(pf->width[i]) * pf->height; 906 offset += BITMAP_WORDS(pf->width[i]) * pf->height;
907 } 907 }
908#endif 908#endif
909 if (!encodetable) { 909 if (!encodetable) {
@@ -1092,7 +1092,7 @@ int adjust_ascent(int ascent, int overflow, struct stretch *stretch) {
1092} 1092}
1093 1093
1094 1094
1095/* return hex value of portion of buffer*/ 1095/* return hex value of portion of buffer */
1096bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2) 1096bitmap_t bdf_hexval(unsigned char *buf, int ndx1, int ndx2)
1097{ 1097{
1098 bitmap_t val = 0; 1098 bitmap_t val = 0;
@@ -1151,20 +1151,20 @@ int rotleft(unsigned char *dst, /* output buffer */
1151 return -1; 1151 return -1;
1152 } 1152 }
1153 1153
1154 /* calc words of input image*/ 1154 /* calc words of input image */
1155 src_words = BITMAP_WORDS(width) * height; 1155 src_words = BITMAP_WORDS(width) * height;
1156 1156
1157 /* clear background*/ 1157 /* clear background */
1158 memset(dst, 0, needed_size); 1158 memset(dst, 0, needed_size);
1159 1159
1160 dst_mask = 1; 1160 dst_mask = 1;
1161 1161
1162 for (i=0; i < src_words; i++) { 1162 for (i=0; i < src_words; i++) {
1163 1163
1164 /* calc src input bit*/ 1164 /* calc src input bit */
1165 src_mask = 1 << (sizeof (bitmap_t) * 8 - 1); 1165 src_mask = 1 << (sizeof (bitmap_t) * 8 - 1);
1166 1166
1167 /* for each input column...*/ 1167 /* for each input column... */
1168 for(j=0; j < width; j++) { 1168 for(j=0; j < width; j++) {
1169 1169
1170 if (src_mask == 0) /* input word done? */ 1170 if (src_mask == 0) /* input word done? */
@@ -1193,7 +1193,7 @@ int rotleft(unsigned char *dst, /* output buffer */
1193#endif /* ROTATE */ 1193#endif /* ROTATE */
1194 1194
1195 1195
1196/* generate C source from in-core font*/ 1196/* generate C source from in-core font */
1197int gen_c_source(struct font* pf, char *path) 1197int gen_c_source(struct font* pf, char *path)
1198{ 1198{
1199 FILE *ofp; 1199 FILE *ofp;
@@ -1251,7 +1251,7 @@ int gen_c_source(struct font* pf, char *path)
1251 pf->width? "yes": "no", 1251 pf->width? "yes": "no",
1252 pf->copyright? pf->copyright: ""); 1252 pf->copyright? pf->copyright: "");
1253 1253
1254 /* generate bitmaps*/ 1254 /* generate bitmaps */
1255 for (i=0; i<pf->size; ++i) { 1255 for (i=0; i<pf->size; ++i) {
1256 int x; 1256 int x;
1257 int bitcount = 0; 1257 int bitcount = 0;
@@ -1341,7 +1341,7 @@ int gen_c_source(struct font* pf, char *path)
1341 fprintf(ofp, "};\n\n"); 1341 fprintf(ofp, "};\n\n");
1342 1342
1343 if (pf->offset) { 1343 if (pf->offset) {
1344 /* output offset table*/ 1344 /* output offset table */
1345 fprintf(ofp, "/* Character->glyph mapping. */\n" 1345 fprintf(ofp, "/* Character->glyph mapping. */\n"
1346 "static const unsigned short _sysfont_offset[] = {\n"); 1346 "static const unsigned short _sysfont_offset[] = {\n");
1347 1347
@@ -1362,7 +1362,7 @@ int gen_c_source(struct font* pf, char *path)
1362 fprintf(ofp, "};\n\n"); 1362 fprintf(ofp, "};\n\n");
1363 } 1363 }
1364 1364
1365 /* output width table for proportional fonts*/ 1365 /* output width table for proportional fonts */
1366 if (pf->width) { 1366 if (pf->width) {
1367 fprintf(ofp, "/* Character width data. */\n" 1367 fprintf(ofp, "/* Character width data. */\n"
1368 "static const unsigned char _sysfont_width[] = {\n"); 1368 "static const unsigned char _sysfont_width[] = {\n");
@@ -1373,7 +1373,7 @@ int gen_c_source(struct font* pf, char *path)
1373 fprintf(ofp, "};\n\n"); 1373 fprintf(ofp, "};\n\n");
1374 } 1374 }
1375 1375
1376 /* output struct font struct*/ 1376 /* output struct font struct */
1377 if (pf->offset) 1377 if (pf->offset)
1378 sprintf(obuf, "_sysfont_offset,"); 1378 sprintf(obuf, "_sysfont_offset,");
1379 else 1379 else
@@ -1419,7 +1419,7 @@ int gen_c_source(struct font* pf, char *path)
1419 return 0; 1419 return 0;
1420} 1420}
1421 1421
1422/* generate C header from in-core font*/ 1422/* generate C header from in-core font */
1423int gen_h_header(struct font* pf, char *path) 1423int gen_h_header(struct font* pf, char *path)
1424{ 1424{
1425 FILE *ofp; 1425 FILE *ofp;
@@ -1429,7 +1429,7 @@ int gen_h_header(struct font* pf, char *path)
1429 "/* Generated by convbdf on %s. */\n" 1429 "/* Generated by convbdf on %s. */\n"
1430 "#ifdef HAVE_LCD_BITMAP\n" 1430 "#ifdef HAVE_LCD_BITMAP\n"
1431 "\n" 1431 "\n"
1432 "/* Font information*/\n" 1432 "/* Font information */\n"
1433 "#define SYSFONT_NAME %s\n" 1433 "#define SYSFONT_NAME %s\n"
1434 "#define SYSFONT_FACENAME %s\n" 1434 "#define SYSFONT_FACENAME %s\n"
1435 "#define SYSFONT_WIDTH %d\n" 1435 "#define SYSFONT_WIDTH %d\n"
@@ -1517,7 +1517,7 @@ static int writestrpad(FILE *fp, char *str, int totlen)
1517} 1517}
1518#endif 1518#endif
1519 1519
1520/* generate .fnt format file from in-core font*/ 1520/* generate .fnt format file from in-core font */
1521int gen_fnt_file(struct font* pf, char *path) 1521int gen_fnt_file(struct font* pf, char *path)
1522{ 1522{
1523 FILE *ofp; 1523 FILE *ofp;
@@ -1532,16 +1532,16 @@ int gen_fnt_file(struct font* pf, char *path)
1532 return 1; 1532 return 1;
1533 } 1533 }
1534 1534
1535 /* write magic and version #*/ 1535 /* write magic and version number */
1536 writestr(ofp, VERSION, 4); 1536 writestr(ofp, VERSION, 4);
1537#ifndef ROTATE 1537#ifndef ROTATE
1538 /* internal font name*/ 1538 /* internal font name */
1539 writestrpad(ofp, pf->name, 64); 1539 writestrpad(ofp, pf->name, 64);
1540 1540
1541 /* copyright*/ 1541 /* copyright */
1542 writestrpad(ofp, pf->copyright, 256); 1542 writestrpad(ofp, pf->copyright, 256);
1543#endif 1543#endif
1544 /* font info*/ 1544 /* font info */
1545 writeshort(ofp, pf->maxwidth); 1545 writeshort(ofp, pf->maxwidth);
1546 writeshort(ofp, pf->height); 1546 writeshort(ofp, pf->height);
1547 writeshort(ofp, pf->ascent); 1547 writeshort(ofp, pf->ascent);
@@ -1550,11 +1550,11 @@ int gen_fnt_file(struct font* pf, char *path)
1550 writeint(ofp, pf->defaultchar); 1550 writeint(ofp, pf->defaultchar);
1551 writeint(ofp, pf->size); 1551 writeint(ofp, pf->size);
1552 1552
1553 /* variable font data sizes*/ 1553 /* variable font data sizes */
1554 writeint(ofp, pf->bits_size); /* # words of bitmap_t*/ 1554 writeint(ofp, pf->bits_size); /* # words of bitmap_t */
1555 writeint(ofp, pf->offset? pf->size: 0); /* # ints of offset*/ 1555 writeint(ofp, pf->offset? pf->size: 0); /* # ints of offset */
1556 writeint(ofp, pf->width? pf->size: 0); /* # bytes of width*/ 1556 writeint(ofp, pf->width? pf->size: 0); /* # bytes of width */
1557 /* variable font data*/ 1557 /* variable font data */
1558#ifdef ROTATE 1558#ifdef ROTATE
1559 for (i=0; i<pf->size; ++i) 1559 for (i=0; i<pf->size; ++i)
1560 { 1560 {
@@ -1585,13 +1585,13 @@ int gen_fnt_file(struct font* pf, char *path)
1585 { 1585 {
1586 /* bitmap offset is small enough, use unsigned short for offset */ 1586 /* bitmap offset is small enough, use unsigned short for offset */
1587 if (ftell(ofp) & 1) 1587 if (ftell(ofp) & 1)
1588 writebyte(ofp, 0); /* pad to 16-bit boundary*/ 1588 writebyte(ofp, 0); /* pad to 16-bit boundary */
1589 } 1589 }
1590 else 1590 else
1591 { 1591 {
1592 /* bitmap offset is large then 64K, use unsigned int for offset */ 1592 /* bitmap offset is large then 64K, use unsigned int for offset */
1593 while (ftell(ofp) & 3) 1593 while (ftell(ofp) & 3)
1594 writebyte(ofp, 0); /* pad to 32-bit boundary*/ 1594 writebyte(ofp, 0); /* pad to 32-bit boundary */
1595 } 1595 }
1596 1596
1597 if (pf->offset) 1597 if (pf->offset)
@@ -1616,7 +1616,7 @@ int gen_fnt_file(struct font* pf, char *path)
1616 for (i=0; i<pf->bits_size; ++i) 1616 for (i=0; i<pf->bits_size; ++i)
1617 writeshort(ofp, pf->bits[i]); 1617 writeshort(ofp, pf->bits[i]);
1618 if (ftell(ofp) & 2) 1618 if (ftell(ofp) & 2)
1619 writeshort(ofp, 0); /* pad to 32-bit boundary*/ 1619 writeshort(ofp, 0); /* pad to 32-bit boundary */
1620 1620
1621 if (pf->offset) 1621 if (pf->offset)
1622 for (i=0; i<pf->size; ++i) { 1622 for (i=0; i<pf->size; ++i) {