summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTakeshi Abe <tabe@php.net>2010-01-08 12:18:52 +0000
committerTakeshi Abe <tabe@php.net>2010-01-08 12:18:52 +0000
commitc18d4364ed0c16ff784418d9f0c54af9701c9d5a (patch)
tree0031f7331a3a77a31ebd1429b96b022de8751559
parentb690cb881d839e5e2f37d53235bdc43ff4394f37 (diff)
downloadphp-git-c18d4364ed0c16ff784418d9f0c54af9701c9d5a.tar.gz
Bug #49600 (imageTTFText text shifted right)
- fix difference of horizontal position between imagettftext() and imagettfbbox()
-rw-r--r--NEWS1
-rw-r--r--ext/gd/libgd/gdft.c2
-rw-r--r--ext/gd/tests/bug49600.phpt32
3 files changed, 34 insertions, 1 deletions
diff --git a/NEWS b/NEWS
index 14f25fa018..b95311040a 100644
--- a/NEWS
+++ b/NEWS
@@ -163,6 +163,7 @@ PHP NEWS
ini variables). (Jani)
- Fixed bug #49660 (libxml 2.7.3+ limits text nodes to 10MB). (Felipe)
- Fixed bug #49647 (DOMUserData does not exist). (Rob)
+- Fixed bug #49600 (imageTTFText text shifted right). (Takeshi Abe)
- Fixed bug #49521 (PDO fetchObject sets values before calling constructor).
(Pierrick)
- Fixed bug #49472 (Constants defined in Interfaces can be overridden).
diff --git a/ext/gd/libgd/gdft.c b/ext/gd/libgd/gdft.c
index ac2bf344ff..a3ced0ab1b 100644
--- a/ext/gd/libgd/gdft.c
+++ b/ext/gd/libgd/gdft.c
@@ -1101,7 +1101,7 @@ gdImageStringFTEx (gdImage * im, int *brect, int fg, char *fontlist, double ptsi
/* now, draw to our target surface */
bm = (FT_BitmapGlyph) image;
- gdft_draw_bitmap(tc_cache, im, fg, bm->bitmap, x + x1 + ((pen.x + 31) >> 6) + bm->left, y + y1 + ((pen.y + 31) >> 6) - bm->top);
+ gdft_draw_bitmap(tc_cache, im, fg, bm->bitmap, x + x1 + ((pen.x + 31) >> 6), y + y1 + ((pen.y + 31) >> 6) - bm->top);
}
/* record current glyph index for kerning */
diff --git a/ext/gd/tests/bug49600.phpt b/ext/gd/tests/bug49600.phpt
new file mode 100644
index 0000000000..068f8f36a8
--- /dev/null
+++ b/ext/gd/tests/bug49600.phpt
@@ -0,0 +1,32 @@
+--TEST--
+Bug #49600 (imageTTFText text shifted right)
+--SKIPIF--
+<?php
+ if(!extension_loaded('gd')){ die('skip gd extension not available'); }
+ if(!function_exists('imagettftext')) die('skip imagettftext() not available');
+ if(!function_exists('imagettfbbox')) die('skip imagettfbbox() not available');
+?>
+--FILE--
+<?php
+$cwd = dirname(__FILE__);
+$font = "$cwd/Tuffy.ttf";
+$image = imagecreatetruecolor(50, 50);
+$color = imagecolorallocate($image, 255, 255, 255);
+foreach (array("E", "I", "P", "g", "i", "q") as $c)
+{
+ $x = imagettftext($image, 32, 0, 0, 0, $color, $font, $c);
+ $y = imagettfbbox(32, 0, "$cwd/Tuffy.ttf", $c);
+ if ( abs($x[0] - $y[0]) > 1
+ || abs($x[2] - $y[2]) > 1
+ || abs($x[4] - $y[4]) > 1
+ || abs($x[6] - $y[6]) > 1 ) {
+ echo "FAILED: \n";
+ var_dump($x);
+ var_dump($y);
+ exit;
+ }
+}
+echo 'OK';
+?>
+--EXPECTF--
+OK \ No newline at end of file