summaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorAlexander Levin <al.le@rockbox.org>2009-03-05 21:27:55 +0000
committerAlexander Levin <al.le@rockbox.org>2009-03-05 21:27:55 +0000
commit7c93b5cb60b21e32000bd27572da1869df86487c (patch)
treef8e6c74707c9a425dd54952daa9825302efe6f77 /tools
parent0c69a83253d0014d8eb402a6933900b0b3925ae1 (diff)
downloadrockbox-7c93b5cb60b21e32000bd27572da1869df86487c.tar.gz
rockbox-7c93b5cb60b21e32000bd27572da1869df86487c.zip
Correct the char's bby and bbh if it's clipped
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@20207 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r--tools/convbdf.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/tools/convbdf.c b/tools/convbdf.c
index e8d3f9d36c..ce74d83e44 100644
--- a/tools/convbdf.c
+++ b/tools/convbdf.c
@@ -67,6 +67,9 @@ struct font {
67#define isprefix(buf,str) (!strncmp(buf, str, strlen(str))) 67#define isprefix(buf,str) (!strncmp(buf, str, strlen(str)))
68#define strequal(s1,s2) (!strcmp(s1, s2)) 68#define strequal(s1,s2) (!strcmp(s1, s2))
69 69
70#define MAX(a,b) ((a) > (b) ? (a) : (b))
71#define MIN(a,b) ((a) < (b) ? (a) : (b))
72
70#define EXTRA 300 /* # bytes extra allocation for buggy .bdf files*/ 73#define EXTRA 300 /* # bytes extra allocation for buggy .bdf files*/
71 74
72int gen_c = 0; 75int gen_c = 0;
@@ -541,7 +544,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
541 bitmap_t *ch_bitmap = pf->bits + ofs; 544 bitmap_t *ch_bitmap = pf->bits + ofs;
542 int ch_words; 545 int ch_words;
543 int overflow_asc, overflow_desc; 546 int overflow_asc, overflow_desc;
544 int y; 547 int bbh_orig, bby_orig, y;
545 548
546 if (encoding < 0) 549 if (encoding < 0)
547 continue; 550 continue;
@@ -573,12 +576,16 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
573#define BM(row,col) (*(ch_bitmap + ((row)*ch_words) + (col))) 576#define BM(row,col) (*(ch_bitmap + ((row)*ch_words) + (col)))
574#define BITMAP_NIBBLES (BITMAP_BITSPERIMAGE/4) 577#define BITMAP_NIBBLES (BITMAP_BITSPERIMAGE/4)
575 578
579 bbh_orig = bbh;
580 bby_orig = bby;
581
576 overflow_asc = bby + bbh - pf->ascent; 582 overflow_asc = bby + bbh - pf->ascent;
577 if (overflow_asc > 0) { 583 if (overflow_asc > 0) {
578 pf->num_clipped_ascent++; 584 pf->num_clipped_ascent++;
579 if (overflow_asc > pf->max_over_ascent) { 585 if (overflow_asc > pf->max_over_ascent) {
580 pf->max_over_ascent = overflow_asc; 586 pf->max_over_ascent = overflow_asc;
581 } 587 }
588 bbh = MAX(bbh - overflow_asc, 0); /* Clipped -> decrease the height */
582 fprintf(stderr, "Warning: character %d goes %d pixel(s)" 589 fprintf(stderr, "Warning: character %d goes %d pixel(s)"
583 " beyond the font's ascent, it will be clipped\n", 590 " beyond the font's ascent, it will be clipped\n",
584 encoding, overflow_asc); 591 encoding, overflow_asc);
@@ -589,6 +596,8 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
589 if (overflow_desc > pf->max_over_descent) { 596 if (overflow_desc > pf->max_over_descent) {
590 pf->max_over_descent = overflow_desc; 597 pf->max_over_descent = overflow_desc;
591 } 598 }
599 bby += overflow_desc;
600 bbh = MAX(bbh - overflow_desc, 0); /* Clipped -> decrease the height */
592 fprintf(stderr, "Warning: character %d goes %d pixel(s)" 601 fprintf(stderr, "Warning: character %d goes %d pixel(s)"
593 " beyond the font's descent, it will be clipped\n", 602 " beyond the font's descent, it will be clipped\n",
594 encoding, overflow_desc); 603 encoding, overflow_desc);
@@ -597,7 +606,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
597 pf->num_clipped++; 606 pf->num_clipped++;
598 } 607 }
599 608
600 y = bby + bbh; /* 0-based y within the char */ 609 y = bby_orig + bbh_orig; /* 0-based y within the char */
601 610
602 /* read bitmaps*/ 611 /* read bitmaps*/
603 for (i=0; ; ++i) { 612 for (i=0; ; ++i) {
@@ -613,6 +622,7 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf)
613 y--; 622 y--;
614 if ((y >= pf->ascent) || (y < -pf->descent)) { 623 if ((y >= pf->ascent) || (y < -pf->descent)) {
615 /* We're beyond the area that Rockbox can render -> clip */ 624 /* We're beyond the area that Rockbox can render -> clip */
625 --i; /* This line doesn't count */
616 continue; 626 continue;
617 } 627 }
618 628