]> granicus.if.org Git - php/commitdiff
Bug #49600 (imageTTFText text shifted right)
authorTakeshi Abe <tabe@php.net>
Fri, 8 Jan 2010 12:18:52 +0000 (12:18 +0000)
committerTakeshi Abe <tabe@php.net>
Fri, 8 Jan 2010 12:18:52 +0000 (12:18 +0000)
- fix difference of horizontal position between imagettftext() and imagettfbbox()

NEWS
ext/gd/libgd/gdft.c
ext/gd/tests/bug49600.phpt [new file with mode: 0644]

diff --git a/NEWS b/NEWS
index 14f25fa018e25825488de33f1466b7b039c15caf..b95311040af50d4442786af3c3c6a5724d97745c 100644 (file)
--- 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).
index ac2bf344ffecf2ce5eb6e873b71c4639eef9fe1c..a3ced0ab1b02baef8ac72e134a3f5179ea666641 100644 (file)
@@ -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 (file)
index 0000000..068f8f3
--- /dev/null
@@ -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