int len, i = 0, ch;
int x1 = 0, y1 = 0;
int xb = x, yb = y;
+ int yd = 0;
font_t *font;
fontkey_t fontkey;
char *next;
}
#endif
+ i = 0;
while (*next) {
ch = *next;
}
/* newlines */
if (ch == '\n') {
+ if (!*(++next)) break;
/* 2.0.13: reset penf.x. Christopher J. Grayce */
penf.x = 0;
penf.y -= (long)(face->size->metrics.height * linespace);
y1 = (int)(- penf.y * cos_a + 32) / 64;
xb = x + x1;
yb = y + y1;
+ yd = 0;
pen.x = pen.y = 0;
previous = 0; /* clear kerning flag */
- next++;
continue;
}
glyph_bbox.xMax += slot->metrics.horiAdvance;
}
if (!i) { /* if first character, init BB corner values */
+ yd = slot->metrics.height - slot->metrics.horiBearingY;
bbox.xMin = glyph_bbox.xMin;
bbox.yMin = glyph_bbox.yMin;
bbox.xMax = glyph_bbox.xMax;
bbox.yMax = glyph_bbox.yMax;
} else {
+ FT_Pos desc;
+
+ if ( (desc = (slot->metrics.height - slot->metrics.horiBearingY)) > yd) {
+ yd = desc;
+ }
if (bbox.xMin > glyph_bbox.xMin) {
bbox.xMin = glyph_bbox.xMin;
}
normbox.xMax = bbox.xMax - bbox.xMin;
normbox.yMax = bbox.yMax - bbox.yMin;
+ brect[0] = brect[2] = brect[4] = brect[6] = (int) (yd * sin_a);
+ brect[1] = brect[3] = brect[5] = brect[7] = (int)(- yd * cos_a);
+
/* rotate bounding rectangle */
- brect[0] = (int) (normbox.xMin * cos_a - normbox.yMin * sin_a);
- brect[1] = (int) (normbox.xMin * sin_a + normbox.yMin * cos_a);
- brect[2] = (int) (normbox.xMax * cos_a - normbox.yMin * sin_a);
- brect[3] = (int) (normbox.xMax * sin_a + normbox.yMin * cos_a);
- brect[4] = (int) (normbox.xMax * cos_a - normbox.yMax * sin_a);
- brect[5] = (int) (normbox.xMax * sin_a + normbox.yMax * cos_a);
- brect[6] = (int) (normbox.xMin * cos_a - normbox.yMax * sin_a);
- brect[7] = (int) (normbox.xMin * sin_a + normbox.yMax * cos_a);
+ brect[0] += (int) (normbox.xMin * cos_a - normbox.yMin * sin_a);
+ brect[1] += (int) (normbox.xMin * sin_a + normbox.yMin * cos_a);
+ brect[2] += (int) (normbox.xMax * cos_a - normbox.yMin * sin_a);
+ brect[3] += (int) (normbox.xMax * sin_a + normbox.yMin * cos_a);
+ brect[4] += (int) (normbox.xMax * cos_a - normbox.yMax * sin_a);
+ brect[5] += (int) (normbox.xMax * sin_a + normbox.yMax * cos_a);
+ brect[6] += (int) (normbox.xMin * cos_a - normbox.yMax * sin_a);
+ brect[7] += (int) (normbox.xMin * sin_a + normbox.yMax * cos_a);
/* scale, round and offset brect */
brect[0] = xb + gdroundupdown(brect[0], d2 > 0);
--- /dev/null
+--TEST--
+Bug #48732 (TTF Bounding box wrong for letters below baseline)
+--SKIPIF--
+<?php
+ if(!extension_loaded('gd')){ die('skip gd extension not available'); }
+ if(!function_exists('imagefttext')) die('skip imagefttext() not available');
+?>
+--FILE--
+<?php
+$cwd = dirname(__FILE__);
+$font = "$cwd/Tuffy.ttf";
+$g = imagecreate(100, 50);
+$bgnd = imagecolorallocate($g, 255, 255, 255);
+$black = imagecolorallocate($g, 0, 0, 0);
+$bbox = imagettftext($g, 12, 0, 0, 20, $black, $font, "ABCEDFGHIJKLMN\nopqrstu\n");
+imagepng($g, "$cwd/bug48732.png");
+echo 'Left Bottom: (' . $bbox[0] . ', ' . $bbox[1] . ')';
+?>
+--EXPECTF--
+Left Bottom: (0, 47)
\ No newline at end of file
--- /dev/null
+--TEST--
+Bug #48801 (Problem with imagettfbbox)
+--SKIPIF--
+<?php
+ if(!extension_loaded('gd')){ die('skip gd extension not available'); }
+ if(!function_exists('imageftbbox')) die('skip imageftbbox() not available');
+?>
+--FILE--
+<?php
+$cwd = dirname(__FILE__);
+$font = "$cwd/Tuffy.ttf";
+$bbox = imageftbbox(50, 0, $font, "image");
+echo '(' . $bbox[0] . ', ' . $bbox[1] . ")\n";
+echo '(' . $bbox[2] . ', ' . $bbox[3] . ")\n";
+echo '(' . $bbox[4] . ', ' . $bbox[5] . ")\n";
+echo '(' . $bbox[6] . ', ' . $bbox[7] . ")\n";
+?>
+--EXPECTF--
+(-1, 15)
+(155, 15)
+(155, -48)
+(-1, -48)