tabe                                     Fri, 08 Jan 2010 12:18:52 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=293268

Log:
Bug #49600 (imageTTFText text shifted right)
- fix difference of horizontal position between imagettftext() and 
imagettfbbox()

Bug: http://bugs.php.net/49600 (Assigned) imageTTFText text shifted right
      
Changed paths:
    U   php/php-src/branches/PHP_5_2/NEWS
    U   php/php-src/branches/PHP_5_2/ext/gd/libgd/gdft.c
    A   php/php-src/branches/PHP_5_2/ext/gd/tests/bug49600.phpt
    U   php/php-src/branches/PHP_5_3/NEWS
    U   php/php-src/branches/PHP_5_3/ext/gd/libgd/gdft.c
    A   php/php-src/branches/PHP_5_3/ext/gd/tests/bug49600.phpt
    U   php/php-src/trunk/ext/gd/libgd/gdft.c
    A   php/php-src/trunk/ext/gd/tests/bug49600.phpt

Modified: php/php-src/branches/PHP_5_2/NEWS
===================================================================
--- php/php-src/branches/PHP_5_2/NEWS   2010-01-08 12:07:52 UTC (rev 293267)
+++ php/php-src/branches/PHP_5_2/NEWS   2010-01-08 12:18:52 UTC (rev 293268)
@@ -135,6 +135,7 @@
 - Fixed bug #49630 (imap_listscan() function missing). (Felipe)
 - Fixed bug #49627 (error_log to specified file does not log time according to
   date.timezone). (Dmitry)
+- Fixed bug #49600 (imageTTFText text shifted right). (Takeshi Abe)
 - Fixed bug #49578 (make install-pear fails). (Hannes)
 - Fixed bug #49536 (mb_detect_encoding() returns incorrect results when
   mbstring.strict_mode is turned on). (Moriyoshi)

Modified: php/php-src/branches/PHP_5_2/ext/gd/libgd/gdft.c
===================================================================
--- php/php-src/branches/PHP_5_2/ext/gd/libgd/gdft.c    2010-01-08 12:07:52 UTC 
(rev 293267)
+++ php/php-src/branches/PHP_5_2/ext/gd/libgd/gdft.c    2010-01-08 12:18:52 UTC 
(rev 293268)
@@ -1101,7 +1101,7 @@

                        /* 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 */

Added: php/php-src/branches/PHP_5_2/ext/gd/tests/bug49600.phpt
===================================================================
--- php/php-src/branches/PHP_5_2/ext/gd/tests/bug49600.phpt                     
        (rev 0)
+++ php/php-src/branches/PHP_5_2/ext/gd/tests/bug49600.phpt     2010-01-08 
12:18:52 UTC (rev 293268)
@@ -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

Modified: php/php-src/branches/PHP_5_3/NEWS
===================================================================
--- php/php-src/branches/PHP_5_3/NEWS   2010-01-08 12:07:52 UTC (rev 293267)
+++ php/php-src/branches/PHP_5_3/NEWS   2010-01-08 12:18:52 UTC (rev 293268)
@@ -163,6 +163,7 @@
   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).

Modified: php/php-src/branches/PHP_5_3/ext/gd/libgd/gdft.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/gd/libgd/gdft.c    2010-01-08 12:07:52 UTC 
(rev 293267)
+++ php/php-src/branches/PHP_5_3/ext/gd/libgd/gdft.c    2010-01-08 12:18:52 UTC 
(rev 293268)
@@ -1101,7 +1101,7 @@

                        /* 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 */

Added: php/php-src/branches/PHP_5_3/ext/gd/tests/bug49600.phpt
===================================================================
--- php/php-src/branches/PHP_5_3/ext/gd/tests/bug49600.phpt                     
        (rev 0)
+++ php/php-src/branches/PHP_5_3/ext/gd/tests/bug49600.phpt     2010-01-08 
12:18:52 UTC (rev 293268)
@@ -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

Modified: php/php-src/trunk/ext/gd/libgd/gdft.c
===================================================================
--- php/php-src/trunk/ext/gd/libgd/gdft.c       2010-01-08 12:07:52 UTC (rev 
293267)
+++ php/php-src/trunk/ext/gd/libgd/gdft.c       2010-01-08 12:18:52 UTC (rev 
293268)
@@ -1101,7 +1101,7 @@

                        /* 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 */

Added: php/php-src/trunk/ext/gd/tests/bug49600.phpt
===================================================================
--- php/php-src/trunk/ext/gd/tests/bug49600.phpt                                
(rev 0)
+++ php/php-src/trunk/ext/gd/tests/bug49600.phpt        2010-01-08 12:18:52 UTC 
(rev 293268)
@@ -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

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to