|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2004-02-27 02:44 UTC] sniper@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Tue Nov 25 15:00:01 2025 UTC |
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