From:             Gregory_mucha at hotmail dot com
Operating system: Win98SE
PHP version:      4.3.4
PHP Bug Type:     *Graphics related
Bug description:  TTF Font positioning Unstable Across Fonts at Zero Degrees

Description:
------------
Application requires use of multiple truetype fonts to create a dynamic
display of characters, varying font sizes and colors.



As the same font is varied by size, the starting position of the font
appears to vary at zero degrees display.  This can be corrected with math
when a single font is utilized, but the problem quickly gets out of hand
when multiple fonts are used in the application.  The symptoms of cut-off
appear the same for a given font, but across fonts the symptoms do vary. 
Generally, two of the four sides of the bounding box appear to be too
small and the (x,y) start position incorrect.



I have gone to Boutell and asked for help, but he claims that ImageTTFBBox
and ImageTTFText are not his routines and the problem is not, therefore,
GD-related.



HAAAAAAALPPPP!!!

Reproduce code:
---------------
Header("Content-type: image/png");

$xshift = 0;   // AACHENB @ 50

$yshift = 0;   //

$xpad   = 0;   //

$ypad   = 0;   // 

$benchmark = "Mgy_|jW";

$box1 = imagettfbbox_t($s, 0, $font, "o");

$box2 = imagettfbbox_t($s, 0, $font, "gyjp");

$baseline = ($box2[1] - $box2[7]) - ($box1[1] - $box1[7]);

$box = imagettfbbox_t($s, 0, $font, $text . $benchmark);

$height = ($box[1] - $box[7]) + $ypad;

$box = imagettfbbox_t($s, 0, $font, $text);

$width  = ($box[2] - $box[0]) + $xpad;

$im = imagecreate($width, $height);

$bgc = hex2dec($bg_color);

$bg = ImageColorAllocate($im, $bgc['r'], $bgc['g'], $bgc['b']);

$mac = hex2dec($text_color);

$main = ImageColorAllocate($im, $mac['r'], $mac['g'], $mac['b']);

ImageTTFText($im, $s, 0, $xshift, ($height - $baseline) + $yshift, $main,
$font, $text);

ImagePng($im);

ImageDestroy($im);

Expected result:
----------------
http://www.geocities.com/paul475aw/Expected_Output.png

Actual result:
--------------
http://www.geocities.com/paul475aw/Actual_Output.png

-- 
Edit bug report at http://bugs.php.net/?id=27410&edit=1
-- 
Try a CVS snapshot (php4):  http://bugs.php.net/fix.php?id=27410&r=trysnapshot4
Try a CVS snapshot (php5):  http://bugs.php.net/fix.php?id=27410&r=trysnapshot5
Fixed in CVS:               http://bugs.php.net/fix.php?id=27410&r=fixedcvs
Fixed in release:           http://bugs.php.net/fix.php?id=27410&r=alreadyfixed
Need backtrace:             http://bugs.php.net/fix.php?id=27410&r=needtrace
Need Reproduce Script:      http://bugs.php.net/fix.php?id=27410&r=needscript
Try newer version:          http://bugs.php.net/fix.php?id=27410&r=oldversion
Not developer issue:        http://bugs.php.net/fix.php?id=27410&r=support
Expected behavior:          http://bugs.php.net/fix.php?id=27410&r=notwrong
Not enough info:            http://bugs.php.net/fix.php?id=27410&r=notenoughinfo
Submitted twice:            http://bugs.php.net/fix.php?id=27410&r=submittedtwice
register_globals:           http://bugs.php.net/fix.php?id=27410&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=27410&r=php3
Daylight Savings:           http://bugs.php.net/fix.php?id=27410&r=dst
IIS Stability:              http://bugs.php.net/fix.php?id=27410&r=isapi
Install GNU Sed:            http://bugs.php.net/fix.php?id=27410&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=27410&r=float

Reply via email to