Commit 430dd220 authored by Robert Sprowson's avatar Robert Sprowson Committed by ROOL
Browse files

Fix for wrong text bounding box for font size > 240ish

Integer overflow would cause an odd/invalid bounding box. Be more careful during the calculation.
Tested with Homerton.Medium saying "Homerton" at 999 point.
parent 2ee46b5c
......@@ -26,6 +26,7 @@
*
*/
#include <assert.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
......@@ -928,11 +929,16 @@ BOOL draw_obj_findTextBox(draw_objptr hdrptr, draw_bboxtyp *bbox)
font_lose (fonth);
if (ok)
{ /* Calculate actual bbox in Draw units from millipoints */
bbox->x0 = (bbox->x0 << 8)/(400*MAXZOOMFACTOR) + hdrptr.textp->coord.x;
bbox->x1 = (bbox->x1 << 8)/(400*MAXZOOMFACTOR) + hdrptr.textp->coord.x;
bbox->y0 = (bbox->y0 << 8)/(400*MAXZOOMFACTOR) + hdrptr.textp->coord.y;
bbox->y1 = (bbox->y1 << 8)/(400*MAXZOOMFACTOR) + hdrptr.textp->coord.y;
{ /* Calculate actual bbox in Draw units from millipoints, */
/* take care with integer range as the bbox may be taller */
/* than MAX_FONTSIZE due to descenders. The divide always */
/* truncates (as 256 << 400 * MAXZOOMFACTOR) so massage */
/* some of the truncation into the draw unit promotion step */
assert (MAXZOOMFACTOR == 8);
bbox->x0 = (bbox->x0 << (8-3))/400 + hdrptr.textp->coord.x;
bbox->x1 = (bbox->x1 << (8-3))/400 + hdrptr.textp->coord.x;
bbox->y0 = (bbox->y0 << (8-3))/400 + hdrptr.textp->coord.y;
bbox->y1 = (bbox->y1 << (8-3))/400 + hdrptr.textp->coord.y;
return(TRUE);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment