|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-08-06 11:42 UTC] fernando at barnatech dot com
Description: ------------ I don't know why bug #39543 is closed, as it's still alive in 5.2.4RC1. The original poster of the bug proved it with accented letters. In my case the trouble comes from the euro sign (a very big trouble, IMHO). Tipically related to non ascii encoding. By the way, there are no font bugs solved since PHP 5.0.4. Reproduce code: --------------- <?php $bounds = ImageTTFBBox(9,0, '/home/max/workspace/wwwdev/libraries/jpgraph/ttf/arial.ttf', '?????' ); ?> or <?php $bounds = ImageTTFBBox(9,0, '/home/max/workspace/wwwdev/libraries/jpgraph/ttf/arial.ttf', '?' ); ?> Expected result: ---------------- no warning Actual result: -------------- Warning: imagettfbbox() [function.imagettfbbox]: any2eucjp(): invalid code in input string in /home/max/workspace/wwwdev/web/test.php on line 5 PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Thu Oct 30 14:00:01 2025 UTC |
Simply use UTF-8 for text. Following code works. (Make sure you have Japanese font installed or use proper font/text) <?php $im = imagecreatetruecolor(300, 150); $black = imagecolorallocate($im, 0, 0, 0); $white = imagecolorallocate($im, 255, 255, 255); imagefilledrectangle($im, 0, 0, 299, 299, $white); $font = '/usr/share/fonts/mplus/mplus-2c-regular.ttf'; $bbox = imagettfbbox(10, 45, $font, 'Powered by PHP ' . phpversion()); $x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) - 25; $y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5; imagettftext($im, 10, 45, $x, $y, $black, $font, '日本語 Powered by PHP ' . phpversion()); $bbox = imagettfbbox(10, 45, $font, 'and Zend Engine ' . zend_version()); $x = $bbox[0] + (imagesx($im) / 2) - ($bbox[4] / 2) + 10; $y = $bbox[1] + (imagesy($im) / 2) - ($bbox[5] / 2) - 5; imagettftext($im, 10, 45, $x, $y, $black, $font, 'and Zend Engine ' . zend_version()); header('Content-Type: image/png'); imagepng($im); imagedestroy($im);