php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #46293 imagettftext() function doesn't handle UTF-8 encoded strings
Submitted: 2008-10-14 16:16 UTC Modified: 2017-01-29 04:22 UTC
Votes:5
Avg. Score:4.4 ± 0.8
Reproduced:4 of 5 (80.0%)
Same Version:2 (50.0%)
Same OS:2 (50.0%)
From: php at ibeni dot net Assigned: cmb (profile)
Status: No Feedback Package: GD related
PHP Version: 5.2.6 OS: FreeBSD c1 6.3-RELEASE
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: php at ibeni dot net
New email:
PHP Version: OS:

 

 [2008-10-14 16:16 UTC] 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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-10-14 16:19 UTC] 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.
 [2009-10-22 18:17 UTC] coa at trash2009 dot com
Make sure your font supports the characters
 [2011-01-23 21:28 UTC] jani@php.net
-Package: Feature/Change Request +Package: GD related
 [2017-01-18 17:05 UTC] cmb@php.net
-Status: Open +Status: Feedback -Assigned To: +Assigned To: cmb
 [2017-01-18 17:05 UTC] cmb@php.net
Does this issue still persist with current PHP/GD versions?
 [2017-01-29 04:22 UTC] php-bugs at lists dot php dot net
No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Wed Apr 24 11:01:30 2024 UTC