ID: 46293
Comment by: coa at trash2009 dot com
Reported By: php at ibeni dot net
Status: Open
Bug Type: Feature/Change Request
Operating System: FreeBSD c1 6.3-RELEASE
PHP Version: 5.2.6
New Comment:
Make sure your font supports the characters
Previous Comments:
------------------------------------------------------------------------
[2008-10-14 16:19:57] php at ibeni dot net
I see that bug submission forum has "helpfully" encoded the Japanese
text in my code into HTML entities ('日本語'). In my
original code, the text is encoded directly in UTF-8 _not_ HTML
entities.
------------------------------------------------------------------------
[2008-10-14 16:16:21] php at ibeni dot net
Description:
------------
Passing UTF-8 encoded text with Japanese characters to imagettftext()
produces incorrect output. Works correctly on my Ubuntu 7.10 machine,
but broken on FreeBSD 6.3, web server.
Reproduce code:
---------------
mb_language('uni');
mb_internal_encoding('UTF-8');
header('Content-type: image/gif');
$text = '日本語'; //Japanese text
$font = './Cyberbit.ttf';
// Create the image
$im = imagecreatetruecolor(160, 160);
$white = imagecolorallocate($im, 255, 255, 255);
$black = imagecolorallocate($im, 0, 0, 0);
// Create some colors
imagefilledrectangle($im, 0, 0, 159, 159, $white);
// Add the text
imagettftext($im, 12, 0, 20, 20, $black, $font, $text);
imagegif($im);
imagedestroy($im);
Expected result:
----------------
Copy of correct image from my local machine:
http://www.ibeni.net/flashcards/imagetest.php.gif
Copy of phpinfo() from my local machine:
http://www.ibeni.net/flashcards/phpinfo.php.html
Actual result:
--------------
Broken Image on web server:
http://www.ibeni.net/flashcards/imagetest.php
Copy of phpinfo() from my webhost server:
http://example5.nfshost.com/phpinfo
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46293&edit=1