Re: [AD] Allegro font grabber bug

[ Thread Index | Date Index | More lists.liballeg.org/allegro-developers Archives ]


Peter Hull <Peter.Hull@xxxxxxxxxx> writes:
> I have found that the grabber can crash when you try to grab a font 
> from a bitmap, if the character cell heights are not all the same.

Nice one!

> The font plug-in accesses bitmap data directly and this can step 
> outside the bounds of the bitmap. If you replace the direct access with 
> a call to 'getpixel' it doesn't crash.

I think it's better to manually limit the height, rather than using 
getpixel(). If you read off the edge of the bitmap, getpixel() returns 
-1, which would result in a solid pixel being set in the font, when you 
really want this extra area to remain blank.

The attached patch should fix this problem: let me know if you still have 
any trouble.

> I can send you a diff for this, if you tell me what format you want.

Too late, I beat you to it :-)

Any sort of diff is fine, I like unified format (-u) best if I need to 
apply them manually, but context (-c) also works well.


-- 
Shawn Hargreaves - shawn@xxxxxxxxxx - http://www.talula.demon.co.uk/
"A binary is barely software: it's more like hardware on a floppy disk."
--- /e/allegro/tools/plugins/datfont.c	Sun Jan 30 20:46:58 2000
+++ tools/plugins/datfont.c	Tue Feb  1 21:47:24 2000
@@ -519,8 +519,8 @@
 
 	    memset(g->dat, 0, stride*h);
 
-	    for (y=0; y<h; y++) {
-	       for (x=0; x<w; x++) {
+	    for (y=0; y<bmp->h; y++) {
+	       for (x=0; x<bmp->w; x++) {
 		  if (bmp[d]->line[y][x])
 		     g->dat[y*stride + x/8] |= (0x80 >> (x&7));
 	       }


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/