diff --git a/tools/convbdf.c b/tools/convbdf.c old mode 100644 new mode 100755 index aae5b43..f09ec07 --- a/tools/convbdf.c +++ b/tools/convbdf.c @@ -443,6 +443,9 @@ int bdf_read_header(FILE *fp, struct font* pf) /* use the font boundingbox to get initial maxwidth*/ /*maxwidth = pf->fbbw - pf->fbbx;*/ maxwidth = pf->fbbw; + if (pf->fbbx < 0) + maxwidth -= pf->fbbx; + pf->maxwidth = maxwidth; /* initially use font maxwidth * height for bits allocation*/ pf->bits_size = nchars * BITMAP_WORDS(maxwidth) * pf->height; @@ -535,12 +538,19 @@ int bdf_read_bitmaps(FILE *fp, struct font* pf) /* calc char width*/ if (bbx < 0) { width -= bbx; - /*if (width > maxwidth) - width = maxwidth;*/ + /*if (width > maxwidth) + width = maxwidth;*/ bbx = 0; } if (width > maxwidth) maxwidth = width; + if (maxwidth > pf->maxwidth) + { + fprintf(stderr, + "Error: %s character %d protrudes from bounding box\n", + pf->facename, encoding); + return 0; + } pf->width[encoding-pf->firstchar] = width; /* clear bitmap*/